rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1087796 [18/37] - in /incubator/rave/donations/mitre-osec: ./ conf/ db/ db/data/ db/sequences/ db/tables/ lib/ lib/apache-commons/ lib/apache-taglibs/ lib/build/ lib/build/cobertura/ lib/eclipselink/ lib/freemarker/ lib/google-collections/...
Date Fri, 01 Apr 2011 16:42:42 GMT
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,409 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.Container;
+import org.mitre.portal.model.Page;
+import org.mitre.portal.model.PageLayout;
+import org.mitre.portal.model.Region;
+import org.mitre.portal.model.RegionGadget;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.orm.jpa.JpaSystemException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class PageRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private PageRepository pageRepository;
+
+    // test data
+    private final Long VALID_ID = 1L;
+    private final Long VALID_CONTAINER_ID = 1L;
+    private final String VALID_NAME = "Home";
+    private final String VALID_USER_ID = "100";
+    private final long VALID_RENDER_SEQ = 1L;
+    private final Long VALID_PAGE_LAYOUT_ID = 2L;
+    private final Long INVALID_ID = -1L;
+    private Container validContainer;
+    private Container invalidContainer;
+    private PageLayout validPageLayout;
+    private PageLayout invalidPageLayout;
+    private final Long VALID_TO_PAGE_ID= 2L;
+
+    private final Long INVALID_CONTAINER_ID = -1L;
+    private final String INVALID_NAME = "QQQQQQQQZXZX";
+    private final String INVALID_USER_ID = "00000";
+    private final Long INVALID_PAGE_LAYOUT_ID = -1L;
+
+
+    @Before
+    public void setup() {
+       validContainer = new Container(VALID_CONTAINER_ID);
+       invalidContainer = new Container(INVALID_CONTAINER_ID);
+       validPageLayout = new PageLayout(VALID_PAGE_LAYOUT_ID);
+       invalidPageLayout = new PageLayout(INVALID_PAGE_LAYOUT_ID);
+    }
+
+    @Test
+    public void get_validId_validPage() {
+        Page result = pageRepository.get(VALID_ID);
+        assertNotNull(result);
+        assertEquals(VALID_ID, result.getPageId());
+        assertEquals(validContainer, result.getContainer());
+        assertEquals(VALID_NAME, result.getName());
+        assertEquals(VALID_USER_ID, result.getUserId());
+        assertEquals(VALID_RENDER_SEQ, result.getRenderSeq());
+        assertEquals(VALID_PAGE_LAYOUT_ID, result.getPageLayout().getPageLayoutId());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception() {
+        Page result = pageRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        Page result = pageRepository.get(null);
+    }
+
+    @Test
+    public void find_validContainer_validPageName_validUserId_validPage() {
+        Page page = pageRepository.find(validContainer, VALID_NAME, VALID_USER_ID);
+        assertNotNull(page);
+        assertEquals(validContainer, page.getContainer());
+        assertEquals(VALID_NAME, page.getName());
+        assertEquals(VALID_USER_ID, page.getUserId());
+        assertEquals(VALID_ID, page.getPageId());
+    }
+
+    @Test
+    public void find_invalidContainer_validPageName_validUserId_nullPage() {
+        Page page = pageRepository.find(invalidContainer, VALID_NAME, VALID_USER_ID);
+        assertNull(page);
+    }
+
+    @Test
+    public void find_nullContainer_validPageName_validUserId_nullPage() {
+        Page page = pageRepository.find(null, VALID_NAME, VALID_USER_ID);
+        assertNull(page);
+    }
+
+    @Test
+    public void find_validContainer_invalidPageName_validUserId_nullPage() {
+        Page page = pageRepository.find(validContainer, INVALID_NAME, VALID_USER_ID);
+        assertNull(page);
+    }
+
+    @Test
+    public void find_validContainer_nullPageName_validUserId_nullPage() {
+        Page page = pageRepository.find(validContainer, null, VALID_USER_ID);
+        assertNull(page);
+    }
+
+    @Test
+    public void find_validContainer_validPageName_invalidUserId_nullPage() {
+        Page page = pageRepository.find(validContainer, VALID_NAME, INVALID_USER_ID);
+        assertNull(page);
+    }
+
+    @Test
+    public void find_validContainer_validPageName_nullUserId_nullPage() {
+        Page page = pageRepository.find(validContainer, VALID_NAME, null);
+        assertNull(page);
+    }    
+
+    @Test
+    public void find_validContainer_validUserId_validPageList() {
+        List<Page> list = pageRepository.find(validContainer, VALID_USER_ID);
+        assertNotNull(list);
+        assertFalse(list.isEmpty());
+        for (Page p : list) {
+            assertEquals(VALID_USER_ID, p.getUserId());
+            assertEquals(validContainer, p.getContainer());
+        }
+    }
+
+    @Test
+    public void find_invalidContainer_validUserId_emptyPageList() {
+        List<Page> list = pageRepository.find(invalidContainer, VALID_USER_ID);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void find_nullContainer_validUserId_emptyPageList() {
+        List<Page> list = pageRepository.find(null, VALID_USER_ID);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void find_validContainer_invalidUserId_emptyPageList() {
+        List<Page> list = pageRepository.find(validContainer, INVALID_USER_ID);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void find_validContainer_nullUserId_emptyPageList() {
+        List<Page> list = pageRepository.find(validContainer, null);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void findDefault_validContainer_validUserId_validPage() {
+        Page p = pageRepository.findDefault(validContainer, VALID_USER_ID);
+        assertNotNull(p);
+        assertEquals(VALID_USER_ID, p.getUserId());
+        assertEquals(validContainer, p.getContainer());
+        assertEquals(VALID_RENDER_SEQ, p.getRenderSeq());
+    }
+
+    @Test
+    public void findDefault_invalidContainer_validUserId_nullPage() {
+        Page p = pageRepository.findDefault(invalidContainer, VALID_USER_ID);
+        assertNull(p);
+    }
+
+    @Test
+    public void findDefault_nullContainer_validUserId_nullPage() {
+        Page p = pageRepository.findDefault(null, VALID_USER_ID);
+        assertNull(p);
+    }
+
+    @Test
+    public void findDefault_validContainer_invalidUserId_nullPage() {
+        Page p = pageRepository.findDefault(validContainer, INVALID_USER_ID);
+        assertNull(p);
+    }
+    
+    @Test
+    public void findDefault_validContainer_nullUserId_nullPage() {
+        Page p = pageRepository.findDefault(validContainer, null);
+        assertNull(p);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validPageNullId() {        
+        String newPageName = "A NEW PAGE";
+        int newRenderSeq = 4;
+
+        Page p = new Page();
+        p.setContainer(validContainer);
+        p.setName(newPageName);
+        p.setPageLayout(validPageLayout);
+        p.setRenderSeq(newRenderSeq);
+        p.setUserId(VALID_USER_ID);
+
+        List<Region> regionList = new ArrayList<Region>();
+        for (int i = 1; i <= 2; i++) {
+            Region r = new Region();
+            r.setPage(p);
+            r.setName("region_" + i);
+            regionList.add(r);        
+        }
+        p.setRegionList(regionList);
+        
+        assertNull(p.getPageId());
+        pageRepository.save(p);
+        assertNotNull(p.getPageId());
+        assertTrue("new pageId > 0", p.getPageId() > 0);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validPageNullIdFirstPage() {
+        String newPageName = "A NEW PAGE";
+
+        Page p = new Page();
+        p.setContainer(validContainer);
+        p.setName(newPageName);
+        p.setPageLayout(validPageLayout);
+        p.setUserId("dummy");
+
+        List<Region> regionList = new ArrayList<Region>();
+        for (int i = 1; i <= 2; i++) {
+            Region r = new Region();
+            r.setPage(p);
+            r.setName("region_" + i);
+            regionList.add(r);
+        }
+        p.setRegionList(regionList);
+
+        assertNull(p.getPageId());
+        pageRepository.save(p);
+        assertNotNull(p.getPageId());
+        assertTrue("new pageId > 0", p.getPageId() > 0);
+        assertEquals(1, p.getRenderSeq());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validPageExistingId() {
+        final String NEW_PAGE_NAME = "New Page Name";
+        
+        Page p = pageRepository.get(VALID_ID);
+        p.setName(NEW_PAGE_NAME);
+        pageRepository.save(p);
+
+        Page p2 = pageRepository.get(VALID_ID);
+        assertEquals(NEW_PAGE_NAME, p2.getName());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_nullPage_exception() {
+        pageRepository.save(null);
+    }
+
+    @Test (expected = JpaSystemException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_duplicatePageName_exception() {
+        final String DUPLICATE_PAGE_NAME = "acarlucci Custom Page";
+
+        Page p = pageRepository.get(VALID_ID);       
+        p.setName(DUPLICATE_PAGE_NAME);
+        pageRepository.save(p);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_validPage() {
+        Page p = pageRepository.get(VALID_ID);
+        pageRepository.delete(p);
+
+        boolean gotExpectedException = false;
+        try {
+            Page p2 = pageRepository.get(VALID_ID);
+        }
+        catch (IncorrectResultSizeDataAccessException e) {
+            gotExpectedException = true;
+        }
+
+        if (!gotExpectedException)
+            fail("page delete did not work - get method found id after delete!");
+
+        // make sure sequence numbers are updated
+        List<Page> list = pageRepository.find(validContainer, VALID_USER_ID);
+        for (int i = 0; i < list.size(); i++) {
+            assertEquals(i+1, list.get(i).getRenderSeq());
+        }
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_invalidPage() {
+        Page p = new Page(INVALID_ID);
+        pageRepository.delete(p);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_nullPage() {
+        pageRepository.delete(null);
+    }
+
+    // TODO - this can't be tested until h2 supports deferrable constraints
+    @Test
+    @Ignore
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void updatePageRenderSequences_validPageList() {
+        List<Page> list = pageRepository.find(validContainer, VALID_USER_ID);
+        
+        // swap the first and second pages
+        Page firstPage = list.get(0);
+        Page secondPage = list.remove(1);
+        list.add(0, secondPage);
+        pageRepository.updatePageRenderSequences(list);
+
+        // verify render sequences have been updated
+        List<Page> list2 = pageRepository.find(validContainer, VALID_USER_ID);
+        assertEquals(secondPage.getPageId(), list2.get(0).getPageId());
+        assertEquals(1, list2.get(0).getRenderSeq());
+        assertEquals(firstPage.getPageId(), list2.get(1).getPageId());
+        assertEquals(2, list2.get(1).getRenderSeq());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void updatePageRenderSequences_emptyPageList() {
+        pageRepository.updatePageRenderSequences(new ArrayList<Page>());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void updatePageRenderSequences_nullPageList() {
+        pageRepository.updatePageRenderSequences(null);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_validRegionGadget_validRegionId_validRenderSequence() {
+        final int TO_REGION_SEQUENCE = 2;
+
+        Page p = pageRepository.get(VALID_ID);
+        Region fromRegion = p.getRegionList().get(2);
+        int beforeFromGadgetCount = fromRegion.getRegionGadgetList().size();
+        Region toRegion = p.getRegionList().get(0);
+        int beforeToGadgetCount = toRegion.getRegionGadgetList().size();
+
+        RegionGadget rg = fromRegion.getRegionGadgetList().get(1);
+        pageRepository.move(rg, toRegion.getRegionId(), TO_REGION_SEQUENCE);
+
+        Page p2 = pageRepository.get(VALID_ID);
+        Region fromRegion2 = p.getRegionList().get(2);
+        Region toRegion2 = p.getRegionList().get(0);
+        assertEquals(beforeFromGadgetCount - 1, fromRegion2.getRegionGadgetList().size());
+        assertEquals(beforeToGadgetCount + 1, toRegion2.getRegionGadgetList().size());
+        assertEquals(rg.getRegionGadgetId(), toRegion.getRegionGadgetList().get(1).getRegionGadgetId());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateOwnerTypeRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateOwnerTypeRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateOwnerTypeRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateOwnerTypeRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,75 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.PageTemplateOwnerType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class PageTemplateOwnerTypeRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private PageTemplateOwnerTypeRepository pageTemplateOwnerTypeRepository;
+
+    // test data
+    private final String VALID_CODE = "ORG";
+    private final String VALID_NAME = "Organization";
+    private final String INVALID_CODE = "ZZZQQQ";
+
+    @Test
+    public void get_validCode_validPageTemplateOwnerType() {
+        PageTemplateOwnerType result = pageTemplateOwnerTypeRepository.get(VALID_CODE);
+        assertNotNull(result);
+        assertEquals(VALID_CODE, result.getCode());
+        assertEquals(VALID_NAME, result.getName());                
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidCode_exception() {
+        PageTemplateOwnerType result = pageTemplateOwnerTypeRepository.get(INVALID_CODE);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        PageTemplateOwnerType result = pageTemplateOwnerTypeRepository.get(null);
+    }
+
+    @Test
+    public void findAll_validList()
+    {
+        List<PageTemplateOwnerType> list = pageTemplateOwnerTypeRepository.findAll();
+        assertNotNull(list);
+        assertFalse("list is not empty", list.isEmpty());        
+    }
+    
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateOwnerTypeRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,190 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.Container;
+import org.mitre.portal.model.PageLayout;
+import org.mitre.portal.model.PageTemplate;
+import org.mitre.portal.model.PageTemplateOwnerType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class PageTemplateRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private PageTemplateRepository pageTemplateRepository;
+
+    // test data
+    private final Long VALID_ID = 1L;
+    private final Long VALID_CONTAINER_ID = 1L;
+    private final Long VALID_PAGE_LAYOUT_ID = 1L;
+    private final String VALID_PAGE_TEMPLATE_OWNER_TYPE_CODE = "ORG";
+    private final String VALID_PAGE_NAME = "Empty";
+    private final String VALID_DESC = "Blank empty page.";
+    private Container validContainer;
+    private Container invalidContainer;
+    private PageLayout validPageLayout;
+    private PageLayout invalidPageLayout;
+    private PageTemplateOwnerType validPageTemplateOwnerType;
+    private PageTemplateOwnerType invalidPageTemplateOwnerType;
+
+    private final Long INVALID_ID = -1L;
+    private final Long INVALID_CONTAINER_ID = -1L;
+    private final Long INVALID_PAGE_LAYOUT_ID = -1L;
+    private final String INVALID_PAGE_TEMPLATE_OWNER_TYPE_CODE = "QQQ123";
+    private final String INVALID_PAGE_NAME = "OEWOWEO";
+
+    @Before
+    public void setup() {
+       validContainer = new Container(VALID_CONTAINER_ID);
+       invalidContainer = new Container(INVALID_CONTAINER_ID);
+       validPageLayout = new PageLayout(VALID_PAGE_LAYOUT_ID);
+       invalidPageLayout = new PageLayout(INVALID_PAGE_LAYOUT_ID);
+       validPageTemplateOwnerType = new PageTemplateOwnerType(VALID_PAGE_TEMPLATE_OWNER_TYPE_CODE);
+       invalidPageTemplateOwnerType = new PageTemplateOwnerType(INVALID_PAGE_TEMPLATE_OWNER_TYPE_CODE);
+    }
+
+    @Test
+    public void get_validId_validPageTemplate() {
+        PageTemplate result = pageTemplateRepository.get(VALID_ID);
+        assertNotNull(result);
+        assertEquals(VALID_ID, result.getPageTemplateId());
+        assertEquals(validContainer, result.getContainer());
+        assertEquals(VALID_PAGE_LAYOUT_ID, result.getPageLayout().getPageLayoutId());
+        assertEquals(VALID_PAGE_NAME, result.getName());
+        assertEquals(VALID_PAGE_TEMPLATE_OWNER_TYPE_CODE, result.getPageTemplateOwnerType().getCode());
+        assertEquals(VALID_DESC, result.getDescription());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception() {
+        PageTemplate result = pageTemplateRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        PageTemplate result = pageTemplateRepository.get(null);
+    }
+
+    @Test
+    public void getDefault_validPageTemplate() {
+        PageTemplate result = pageTemplateRepository.getDefault();
+        assertNotNull(result);
+        assertTrue(result.getPageTemplateId() > 0);
+        assertTrue(result.isDefaultTemplate());
+    }
+        
+    @Test
+    public void find_validContainer_validPageName_validPageTemplate() {
+        PageTemplate pageTemplate = pageTemplateRepository.find(validContainer, VALID_PAGE_NAME);
+        assertNotNull(pageTemplate);
+        assertEquals(VALID_ID, pageTemplate.getPageTemplateId());
+        assertEquals(validContainer.getContainerId(), pageTemplate.getContainer().getContainerId());
+        assertEquals(VALID_PAGE_LAYOUT_ID, pageTemplate.getPageLayout().getPageLayoutId());
+        assertEquals(VALID_PAGE_NAME, pageTemplate.getName());
+        assertEquals(VALID_PAGE_TEMPLATE_OWNER_TYPE_CODE, pageTemplate.getPageTemplateOwnerType().getCode());
+    }
+
+    @Test
+    public void find_invalidContainer_validPageName_nullPageTemplate() {
+        PageTemplate pageTemplate = pageTemplateRepository.find(invalidContainer, VALID_PAGE_NAME);
+        assertNull(pageTemplate);
+    }
+
+    @Test
+    public void find_nullContainer_validPageName_nullPageTemplate() {
+        PageTemplate pageTemplate = pageTemplateRepository.find(null, VALID_PAGE_NAME);
+        assertNull(pageTemplate);
+    }   
+
+    @Test
+    public void find_validContainer_invalidPageName_nullPageTemplate() {
+        PageTemplate pageTemplate = pageTemplateRepository.find(validContainer, INVALID_PAGE_NAME);
+        assertNull(pageTemplate);
+    }
+
+    @Test
+    public void find_validContainer_nullPageName_nullPageTemplate() {
+        String nullPageName = null;
+        PageTemplate pageTemplate = pageTemplateRepository.find(validContainer, nullPageName);
+        assertNull(pageTemplate);
+    }
+
+    @Test
+    public void find_validContainer_validPageTemplateOwnerType_validList() {
+        List<PageTemplate> list = pageTemplateRepository.find(validContainer, validPageTemplateOwnerType);
+        assertNotNull(list);
+        assertFalse("list is not empty", list.isEmpty());
+        for (PageTemplate pt : list) {
+            assertEquals(validContainer.getContainerId(), pt.getContainer().getContainerId());
+            assertEquals(validPageTemplateOwnerType.getCode(), pt.getPageTemplateOwnerType().getCode());
+        }
+    }    
+
+    @Test
+    public void find_invalidContainer_validPageTemplateOwnerType_emptyList() {
+        List<PageTemplate> list = pageTemplateRepository.find(invalidContainer, validPageTemplateOwnerType);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());       
+    }     
+ 
+    @Test
+    public void find_nullContainer_validPageTemplateOwnerType_emptyList() {
+        List<PageTemplate> list = pageTemplateRepository.find(null, validPageTemplateOwnerType);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());       
+    }
+
+    @Test
+    public void find_validContainer_invalidPageTemplateOwnerType_emptyList() {
+        List<PageTemplate> list = pageTemplateRepository.find(validContainer, invalidPageTemplateOwnerType);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_validContainer_nullPageTemplateOwnerType_emptyList() {
+        PageTemplateOwnerType ptot = null;
+        List<PageTemplate> list = pageTemplateRepository.find(validContainer,  ptot);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void findAll_validList() {
+        List<PageTemplate> list = pageTemplateRepository.findAll();
+        assertNotNull(list);
+        assertFalse(list.isEmpty());
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PageTemplateRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonGadgetRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonGadgetRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonGadgetRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonGadgetRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,188 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import org.mitre.portal.repository.PersonGadgetRepository;
+import java.util.List;
+import org.junit.Test;
+import org.mitre.portal.model.Gadget;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.PersonGadget;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class PersonGadgetRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private PersonGadgetRepository personGadgetRepository;
+
+    // test data
+    private final Long VALID_ID = 1L;
+    private final Long VALID_GADGET_ID = 1L;
+    private final String VALID_USER_ID = "100";
+    private final Long INVALID_ID = -1L;
+    private final String INVALID_USER_ID = "00000";
+    private final Long INVALID_GADGET_ID = -1L;
+
+    @Test
+    public void get_validId_validPageTemplate() {
+        PersonGadget result = personGadgetRepository.get(VALID_ID);
+        assertNotNull(result);
+        assertEquals(VALID_ID, result.getPersonGadgetId());
+        assertEquals(VALID_GADGET_ID, result.getGadget().getGadgetId());
+        assertEquals(VALID_USER_ID, result.getUserId());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception() {
+        PersonGadget result = personGadgetRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        PersonGadget result = personGadgetRepository.get(null);
+    }
+
+    @Test
+    public void find_validUserId_validList() {
+        List<PersonGadget> list = personGadgetRepository.find(VALID_USER_ID);
+        assertNotNull(list);
+        assertFalse("list is not empty", list.isEmpty());
+        for (PersonGadget pg : list) {
+            assertEquals(VALID_USER_ID, pg.getUserId());
+        }
+    }
+
+    @Test
+    public void find_invalidUserId_emptyList() {
+        List<PersonGadget> list = personGadgetRepository.find(INVALID_USER_ID);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_nullUserId_emptyList() {
+        String s = null;
+        List<PersonGadget> list = personGadgetRepository.find(s);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_validGadget_validList() {
+        Gadget gadget = new Gadget(VALID_GADGET_ID);
+        List<PersonGadget> list = personGadgetRepository.find(gadget);
+        assertNotNull(list);
+        assertFalse("list is not empty", list.isEmpty());
+        for (PersonGadget pg : list) {
+            assertEquals(VALID_GADGET_ID, pg.getGadget().getGadgetId());
+        }
+    }
+
+    @Test
+    public void find_invalidGadget_emptyList() {
+        Gadget gadget = new Gadget(INVALID_GADGET_ID);
+        List<PersonGadget> list = personGadgetRepository.find(gadget);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_nullGadget_emptyList() {
+        Gadget g = null;
+        List<PersonGadget> list = personGadgetRepository.find(g);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_validPersonGadget() {
+        PersonGadget pg = personGadgetRepository.get(VALID_ID);
+        personGadgetRepository.delete(pg);
+
+        PersonGadget pg2 = personGadgetRepository.get(VALID_ID);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_invalidPersonGadget() {
+        PersonGadget pg = new PersonGadget(INVALID_ID);
+        personGadgetRepository.delete(pg);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_nullPersonGadget() {
+        personGadgetRepository.delete(null);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validPersonGadgetNullId() {
+        final Long newGadgetId = 1L;
+
+        PersonGadget newPersonGadget = new PersonGadget();
+        newPersonGadget.setGadget(new Gadget(newGadgetId));
+        newPersonGadget.setUserId(VALID_USER_ID);
+
+        assertNull(newPersonGadget.getPersonGadgetId());
+        personGadgetRepository.save(newPersonGadget);
+        assertNotNull(newPersonGadget.getPersonGadgetId());
+        assertTrue("new personGadgetId > 0", newPersonGadget.getPersonGadgetId() > 0);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validPersonGadgetExistingId() {
+        final String NEW_USER_ID = "99999";
+
+        PersonGadget pg = personGadgetRepository.get(VALID_ID);
+        assertNotNull(pg);
+        pg.setUserId(NEW_USER_ID);
+        personGadgetRepository.save(pg);
+
+        PersonGadget pg2 = personGadgetRepository.get(VALID_ID);
+        assertEquals(NEW_USER_ID, pg2.getUserId());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_nullPersoGadget_exception() {
+        personGadgetRepository.save(null);
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonGadgetRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import org.junit.Test;
+import org.mitre.portal.model.Person;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations = {"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly = true)
+public class PersonRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private PersonRepository personRepository;
+
+    // test data
+    private final String VALID_USERNAME = "acarlucci";
+    private final String VALID_USER_ID = "100";
+    private final String INVALID_USERNAME = "qqq";
+    private final String INVALID_USER_ID = "-1";
+
+    @Test
+    public void getPersonByUsername_validUsername() {
+        Person person = personRepository.getPersonByUsername(VALID_USERNAME);
+        assertNotNull(person);
+        assertEquals(VALID_USERNAME, person.getUsername());
+        assertEquals(VALID_USER_ID, person.getUserId());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void getPersonByUsername_invalidUsername() {
+        personRepository.getPersonByUsername(INVALID_USERNAME);
+    }
+
+    @Test
+    public void getPersonByUserId_validUserId() {
+        Person person = personRepository.getPersonByUserId(VALID_USER_ID);
+        assertNotNull(person);
+        assertEquals(VALID_USERNAME, person.getUsername());
+        assertEquals(VALID_USER_ID, person.getUserId());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void getPersonByUserId_invalidUserId() {
+        personRepository.getPersonByUserId(INVALID_USER_ID);
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/PersonRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionGadgetRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionGadgetRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionGadgetRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionGadgetRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,228 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import org.mitre.portal.repository.RegionGadgetRepository;
+import java.util.List;
+import java.util.ArrayList;
+import org.junit.Test;
+import org.mitre.portal.model.Gadget;
+import org.mitre.portal.model.PersonGadget;
+import org.mitre.portal.model.Region;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.RegionGadget;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class RegionGadgetRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private RegionGadgetRepository regionGadgetRepository;
+
+    // test data
+    private final Long VALID_ID = 4L;
+    private final Long VALID_REGION_ID = 3L;
+    private final Long VALID_PERSON_GADGET_ID = 4L;
+    private final long VALID_RENDER_SEQ = 2L;
+    private final boolean VALID_COLLAPSED = false;
+    private final String VALID_USER_ID = "100";
+    private final Long VALID_GADGET_ID = 1L;
+    private final Long VALID_TO_REGION_ID = 1L;
+
+    private final Long INVALID_ID = -1L;
+    private final Long INVALID_REGION_ID = -1L;
+    private final Long INVALID_GADGET_ID = -1L;
+
+
+    @Test
+    public void get_validId_validRegionGadget() {
+        RegionGadget result = regionGadgetRepository.get(VALID_ID);
+        assertNotNull(result);
+        assertEquals(VALID_ID, result.getRegionGadgetId());
+        assertEquals(VALID_PERSON_GADGET_ID, result.getPersonGadget().getPersonGadgetId());
+        assertEquals(VALID_REGION_ID, result.getRegion().getRegionId());
+        assertEquals(VALID_RENDER_SEQ, result.getRenderSeq());
+        assertEquals(VALID_COLLAPSED, result.isCollapsed());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception() {
+        RegionGadget result = regionGadgetRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        RegionGadget result = regionGadgetRepository.get(null);
+    }
+
+    @Test
+    public void find_validRegion_validList() {
+        Region region = new Region(VALID_REGION_ID);
+        List<RegionGadget> list = regionGadgetRepository.find(region);
+        assertNotNull(list);
+        assertFalse("list is empty", list.isEmpty());
+        long prevRenderSeq = 0;
+        for (RegionGadget rg : list) {
+            assertEquals(VALID_REGION_ID, rg.getRegion().getRegionId());
+            assertTrue("prev render sequence is less than current", prevRenderSeq < rg.getRenderSeq());
+            prevRenderSeq = rg.getRenderSeq();
+        }
+    }
+
+    @Test
+    public void find_invalidRegion_emptyList() {
+        Region region = new Region(INVALID_REGION_ID);
+        List<RegionGadget> list = regionGadgetRepository.find(region);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_nullRegion_emptyList() {
+        Region r = null;
+        List<RegionGadget> list = regionGadgetRepository.find(r);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_validGadget_validList() {
+        Gadget gadget = new Gadget(VALID_GADGET_ID);
+        List<RegionGadget> list = regionGadgetRepository.find(gadget);
+        assertNotNull(list);
+        assertFalse("list is empty", list.isEmpty());
+        for (RegionGadget rg : list) {
+            assertEquals(VALID_GADGET_ID, rg.getPersonGadget().getGadget().getGadgetId());           
+        }
+    }
+
+    @Test
+    public void find_invalidGadget_emptyList() {
+        Gadget gadget = new Gadget(INVALID_GADGET_ID);
+        List<RegionGadget> list = regionGadgetRepository.find(gadget);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_nullGadget_emptyList() {
+        Gadget r = null;
+        List<RegionGadget> list = regionGadgetRepository.find(r);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validRegionGadgetNullId() {
+        final Long newRegionId = 3L;
+        final long newRenderSeq = 5;
+        final boolean newCollapsed = false;
+        final Long newGadgetId = 1L;
+
+        PersonGadget newPersonGadget = new PersonGadget();
+        newPersonGadget.setGadget(new Gadget(newGadgetId));
+        newPersonGadget.setUserId(VALID_USER_ID);
+
+        Region newRegion = new Region(newRegionId);
+
+        RegionGadget rg = new RegionGadget();
+        rg.setCollapsed(newCollapsed);
+        rg.setPersonGadget(newPersonGadget);
+        rg.setRegion(newRegion);
+        rg.setRenderSeq(newRenderSeq);
+
+        assertNull(rg.getRegionGadgetId());
+        regionGadgetRepository.save(rg);
+        assertNotNull(rg.getRegionGadgetId());
+        assertTrue("new regionGadgetId > 0", rg.getRegionGadgetId() > 0);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validRegionGadgetExistingId() {
+        final boolean NEW_COLLAPSED = true;
+
+        RegionGadget rg = regionGadgetRepository.get(VALID_ID);
+        assertTrue(rg.isCollapsed() == !NEW_COLLAPSED);
+        rg.setCollapsed(NEW_COLLAPSED);
+        regionGadgetRepository.save(rg);
+
+        RegionGadget rg2 = regionGadgetRepository.get(VALID_ID);
+        assertEquals(NEW_COLLAPSED, rg2.isCollapsed());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_nullRegionGadget_exception() {
+        regionGadgetRepository.save(null);
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_validRegionGadget() {
+        RegionGadget rg = regionGadgetRepository.get(VALID_ID);
+        regionGadgetRepository.delete(rg);
+
+        RegionGadget rg2 = regionGadgetRepository.get(VALID_ID);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_invalidRegionGadget() {
+        RegionGadget rg = new RegionGadget(INVALID_ID);
+        regionGadgetRepository.delete(rg);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_nullRegionGadget() {
+        regionGadgetRepository.delete(null);
+    }
+    
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_validRegionGadget() {
+    	RegionGadget regionGadget = regionGadgetRepository.get(VALID_ID);
+    	Region toRegion = new Region(VALID_TO_REGION_ID);
+    	toRegion.setRegionGadgetList(new ArrayList<RegionGadget>());
+    	int toRenderSequence = 0;
+    	
+    	regionGadgetRepository.move(regionGadget, toRegion, toRenderSequence);
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionGadgetRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,358 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import org.mitre.portal.repository.RegionRepository;
+import org.mitre.portal.repository.GadgetRepository;
+import java.util.List;
+import org.junit.Test;
+import org.mitre.portal.model.Gadget;
+import org.mitre.portal.model.Page;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.PersonGadget;
+import org.mitre.portal.model.PersonGadgetUserPref;
+import org.mitre.portal.model.PersonGadgetUserPrefListType;
+import org.mitre.portal.model.Region;
+import org.mitre.portal.model.RegionGadget;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class RegionRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests {
+    @Autowired
+    private RegionRepository regionRepository;
+    @Autowired
+    private GadgetRepository gadgetRepository;
+
+    // test data
+    private final Long VALID_ID = 1L;
+    private final String VALID_REGION_NAME = "region_1";
+    private final Long VALID_PAGE_ID = 1L;
+    private final String VALID_USER_ID = "acarlucci";
+    private final Long VALID_GADGET_ID = 6L;
+
+    private final Long INVALID_ID = -1L;
+    private final String INVALID_REGION_NAME = "QQZZSSS";
+    private final Long INVALID_PAGE_ID = -1L;
+    private final Long INVALID_REGION_GADGET_ID = -1L;
+    private final Long INVALID_GADGET_ID = -1L;
+
+    @Test
+    public void get_validId_validRegion() {
+        Region result = regionRepository.get(VALID_ID);
+        assertNotNull(result);
+        assertEquals(VALID_ID, result.getRegionId());
+        assertEquals(VALID_REGION_NAME, result.getName());
+        assertEquals(VALID_PAGE_ID, result.getPage().getPageId());
+        for (RegionGadget rg : result.getRegionGadgetList()) {
+            assertEquals(VALID_ID, rg.getRegion().getRegionId());
+        }
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception() {
+        Region result = regionRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception() {
+        Region result = regionRepository.get(null);
+    }
+
+    @Test
+    public void find_validRegionName_validPage_validRegion() {
+        Page p = new Page(VALID_PAGE_ID);
+        Region r = regionRepository.find(VALID_REGION_NAME, p);
+        assertNotNull(r);
+        assertEquals(VALID_PAGE_ID, r.getPage().getPageId());
+        assertEquals(VALID_REGION_NAME, r.getName());
+        assertEquals(VALID_ID, r.getRegionId());
+    }
+
+    @Test
+    public void find_invalidRegionName_validPage_nullRegion() {
+        Page p = new Page(VALID_PAGE_ID);
+        Region r = regionRepository.find(INVALID_REGION_NAME, p);
+        assertNull(r);
+    }
+
+    @Test
+    public void find_nullRegionName_validPage_nullRegion() {
+        Page p = new Page(VALID_PAGE_ID);
+        Region r = regionRepository.find(null, p);
+        assertNull(r);
+    }
+
+    @Test
+    public void find_validRegionName_invalidPage_nullRegion() {
+        Page p = new Page(INVALID_PAGE_ID);
+        Region r = regionRepository.find(VALID_REGION_NAME, p);
+        assertNull(r);
+    }
+
+    @Test
+    public void find_validRegionName_nullPage_nullRegion() {
+        Region r = regionRepository.find(VALID_REGION_NAME, null);
+        assertNull(r);
+    }
+
+    @Test
+    public void find_validPage_validList() {
+        Page p = new Page(VALID_PAGE_ID);
+        List<Region> list = regionRepository.find(p);
+        assertNotNull(list);
+        assertFalse("list is not empty", list.isEmpty());
+        for (Region r : list) {
+            assertEquals(VALID_PAGE_ID, r.getPage().getPageId());
+        }
+    }
+
+    @Test
+    public void find_invalidPage_emptyList() {
+        Page p = new Page(INVALID_PAGE_ID);
+        List<Region> list = regionRepository.find(p);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    public void find_nullPage_emptyList() {
+        List<Region> list = regionRepository.find(null);
+        assertNotNull(list);
+        assertTrue("list is empty", list.isEmpty());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validRegionNullId() {
+        Page p = new Page(VALID_PAGE_ID);
+        final String NEW_REGION_NAME = "NEW_REGION_NAME";
+
+        Region r = new Region();
+        r.setName(NEW_REGION_NAME);
+        r.setPage(p);
+
+        assertNull(r.getRegionId());
+        regionRepository.save(r);
+        assertNotNull(r.getRegionId());
+        assertTrue("new region id > 0", r.getRegionId() > 0);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validRegionExistingId() {
+        final String UPDATED_REGION_NAME = "UPDATED_REGION_NAME";
+
+        Region r = regionRepository.get(VALID_ID);
+        r.setName(UPDATED_REGION_NAME);
+        assertNotNull(r.getRegionId());
+        regionRepository.save(r);
+
+        Region r2 = regionRepository.get(VALID_ID);
+        assertEquals(UPDATED_REGION_NAME, r2.getName());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_nullRegion_exception() {
+        regionRepository.save(null);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_validRegionGadget() {
+        Region r = regionRepository.get(VALID_ID);
+
+        List<RegionGadget> regionGadgetList = r.getRegionGadgetList();
+        int beforeSize = regionGadgetList.size();
+        RegionGadget delRegionGadget = regionGadgetList.get(0);
+        Long delRegionGadgetId = delRegionGadget.getRegionGadgetId();
+
+        regionRepository.delete(delRegionGadget);
+        
+        Region r2 = regionRepository.get(VALID_ID);
+        assertEquals(beforeSize - 1, r2.getRegionGadgetList().size());
+        for (RegionGadget rg : r2.getRegionGadgetList()) {
+            assertTrue(delRegionGadgetId != rg.getRegionGadgetId());
+        }
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_invalidRegionGadget() {
+        RegionGadget delRegionGadget = new RegionGadget();
+        delRegionGadget.setRegionGadgetId(INVALID_REGION_GADGET_ID);
+        regionRepository.delete(delRegionGadget);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_nullRegionGadget() {
+        regionRepository.delete(null);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_validRegionGadget_validNewRenderSequence() {
+        final Long VALID_REGION_ID_MULTI_GADGETS = 3L;
+        final int NEW_RENDER_SEQUENCE = 1;
+
+        Region r = regionRepository.get(VALID_REGION_ID_MULTI_GADGETS);
+        RegionGadget rgToMove = r.getRegionGadgetList().get(2);
+        Long rgToMoveId = rgToMove.getRegionGadgetId();
+        regionRepository.move(rgToMove, NEW_RENDER_SEQUENCE);
+
+        Region r2 = regionRepository.get(VALID_REGION_ID_MULTI_GADGETS);
+        for (RegionGadget rg : r2.getRegionGadgetList()) {
+            if (rg.getRegionGadgetId() == rgToMoveId) {
+                assertEquals(NEW_RENDER_SEQUENCE, rg.getRenderSeq());
+                return;
+            }
+        }
+
+        fail("moved RegionGadget not found in list after move");
+    }
+
+    @Test(expected = NullPointerException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_invalidRegionGadget_validNewRenderSequence() {
+        final int NEW_RENDER_SEQUENCE = 1;
+
+        RegionGadget rg = new RegionGadget();
+        regionRepository.move(rg, NEW_RENDER_SEQUENCE);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_nullRegionGadget_validNewRenderSequence() {
+        final int NEW_RENDER_SEQUENCE = 1;
+        regionRepository.move(null, NEW_RENDER_SEQUENCE);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void move_validRegionGadget_invalidNewRenderSequence() {
+        final int INVALID_NEW_RENDER_SEQUENCE = 0;
+        final Long VALID_REGION_ID_MULTI_GADGETS = 3L;
+
+        Region r = regionRepository.get(VALID_REGION_ID_MULTI_GADGETS);
+        RegionGadget rg = r.getRegionGadgetList().get(2);        
+        regionRepository.move(rg, INVALID_NEW_RENDER_SEQUENCE);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_validRegion_validGadget_validBeginningLocation() {
+        Region r = regionRepository.get(VALID_ID);
+        Gadget g = gadgetRepository.get(VALID_GADGET_ID);
+
+        for (RegionGadget rg : r.getRegionGadgetList()) {
+            assertTrue(VALID_GADGET_ID != rg.getPersonGadget().getGadget().getGadgetId());
+        }
+
+        regionRepository.addGadget(r, g, Region.Location.BEGINNING);
+        Region r2 = regionRepository.get(VALID_ID);
+
+        // verify new gadget is added to beginning of region
+        RegionGadget newRegionGadget = r2.getRegionGadgetList().get(0);
+        PersonGadget newPersonGadget = newRegionGadget.getPersonGadget();
+        assertEquals(VALID_GADGET_ID, newPersonGadget.getGadget().getGadgetId());       
+        
+        // verify that list type user prefs were assigned
+        List<PersonGadgetUserPrefListType> pguplList = newRegionGadget.getPersonGadget().getPersonGadgetUserPrefListTypeList();
+        assertNotNull(pguplList);
+        assertFalse(pguplList.isEmpty());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_validRegion_validGadget_validEndLocation() {
+        Region r = regionRepository.get(VALID_ID);
+        Gadget g = gadgetRepository.get(VALID_GADGET_ID);
+
+        for (RegionGadget rg : r.getRegionGadgetList()) {
+            assertTrue(VALID_GADGET_ID != rg.getPersonGadget().getGadget().getGadgetId());
+        }
+
+        regionRepository.addGadget(r, g, Region.Location.END);
+        Region r2 = regionRepository.get(VALID_ID);
+
+        // verify new gadget is added to end of region
+        RegionGadget newRegionGadget = r2.getRegionGadgetList().get(r2.getRegionGadgetList().size()-1);
+        assertEquals(VALID_GADGET_ID, newRegionGadget.getPersonGadget().getGadget().getGadgetId());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_invalidRegion_validGadget_validLocation() {
+        Region r = new Region();
+        Gadget g = gadgetRepository.get(VALID_GADGET_ID);
+        regionRepository.addGadget(r, g, Region.Location.BEGINNING);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_nullRegion_validGadget_validLocation() {
+        Gadget g = gadgetRepository.get(VALID_GADGET_ID);
+        regionRepository.addGadget(null, g, Region.Location.BEGINNING);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_validRegion_invalidGadget_validLocation() {
+        Region r = regionRepository.get(VALID_ID);
+        Gadget g = new Gadget();
+        regionRepository.addGadget(r, g, Region.Location.BEGINNING);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void addGadget_validRegion_nullGadget_validLocation() {
+        Region r = regionRepository.get(VALID_ID);
+        regionRepository.addGadget(r, null, Region.Location.BEGINNING);
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/RegionRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/SecurityUserRoleRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/SecurityUserRoleRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/SecurityUserRoleRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/SecurityUserRoleRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+
+import org.mitre.portal.repository.SecurityUserRoleRepository;
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.SecurityUserRole;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ *
+ * A system test that verifies the components of the ContainerRepository work together.
+ * Uses Spring to bootstrap the application for use in a test environment.
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class SecurityUserRoleRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests
+{
+    @Autowired
+    private SecurityUserRoleRepository securityUserRoleRepository;
+
+    // test data
+    private final String VALID_USER_ID = "100";
+    private final String INVALID_USER_ID = "00000";
+
+    @Test
+    public void find_validUserId_validList()
+    {
+        List<SecurityUserRole> result = securityUserRoleRepository.find(VALID_USER_ID);
+        assertNotNull(result);
+        assertTrue("list size > 0", result.size() > 0);
+        for (SecurityUserRole sur : result) {
+            assertEquals(VALID_USER_ID, sur.getUserId());
+        }
+    }
+
+    @Test
+    public void find_invalidSui_emptyList()
+    {
+        List<SecurityUserRole> result = securityUserRoleRepository.find(INVALID_USER_ID);
+        assertTrue(result.isEmpty());
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/SecurityUserRoleRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/StatisticsRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/StatisticsRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/StatisticsRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/StatisticsRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mitre.portal.model.Container;
+import org.mitre.portal.model.ContainerRegistry;
+import org.mitre.portal.model.Gadget;
+import org.mitre.portal.model.GadgetRating;
+import org.mitre.portal.model.PersonGadget;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.util.GadgetStatistics;
+import org.mitre.portal.repository.impl.JdbcStatisticsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author Sean Cooper
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class StatisticsRepositoryTest  extends AbstractTransactionalJUnit4SpringContextTests {
+
+    @Autowired
+    private StatisticsRepository statisticsRepository;
+    @Autowired
+    private ContainerRepository containerRepository;
+    @Autowired
+    private ContainerRegistryRepository containerRegistryRepository;
+
+    private Map<Long, GadgetStatistics> calculatedStatistics;
+    
+    private final String VALID_USER_ID = "28063";
+    private final Long VALID_GADGET_ID = 1L;
+    private final Long RATING_LIKE = 5L;
+    private final Long RATING_DISLIKE= 0L;
+
+    private Container container;
+    private List<ContainerRegistry> containerRegistryList;
+
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+        container = containerRepository.find("default");
+        containerRegistryList = containerRegistryRepository.find(container);
+
+        calculatedStatistics = new HashMap<Long, GadgetStatistics>();
+
+        assertNotNull(containerRepository);
+        for (Container container : containerRepository.findAll())
+        {
+            assertNotNull(container);
+            for (ContainerRegistry containerRegistry : container.getContainerRegistryList())
+            {
+                Gadget gadget = containerRegistry.getGadget();
+                GadgetStatistics curStats = new GadgetStatistics(gadget.getGadgetId());
+
+                //Determine the number of unique users who have the gadget deployed
+                Set<String> userIds = new TreeSet<String>();
+                for (PersonGadget personGadget : gadget.getPersonGadgetList())
+                    userIds.add(personGadget.getUserId());
+                curStats.setUserCount(userIds.size());
+
+                //Determine the like and dislike ratings
+                for (GadgetRating gadgetRating : gadget.getGadgetRatingList())
+                {
+                    if (gadgetRating.getRating().equals(RATING_DISLIKE))
+                        curStats.setUserDislike(curStats.getUserDislike()+1);
+                    else if (gadgetRating.getRating().equals(RATING_LIKE))
+                        curStats.setUserLike(curStats.getUserLike()+1);
+
+                    if (gadgetRating.getUserId().equals(VALID_USER_ID))
+                        curStats.setUserRating(gadgetRating.getRating().intValue());
+                }
+
+                calculatedStatistics.put(gadget.getGadgetId(), curStats);
+            }
+        }
+
+        System.err.println("Size: "+calculatedStatistics.size());
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of getAllGadgetStatistics method, of class JdbcStatisticsRepository.
+     */
+    @Test
+    public void testGetAllGadgetStatistics() {
+        System.out.println("getAllGadgetStatistics");
+
+        // reset the like count to default for non-user based query
+        calculatedStatistics.get(VALID_GADGET_ID).setUserRating(0);
+
+        Map<String,GadgetStatistics> result = statisticsRepository.getAllGadgetStatistics(containerRegistryList);
+        for (GadgetStatistics gadgetStatistics : result.values())
+            assertEquals(calculatedStatistics.get(gadgetStatistics.getGadgetId()), gadgetStatistics);
+    }
+
+    @Test
+    public void getAllGadgetStatistics_validUserId_validContainerRegistryList() {
+        Map<String,GadgetStatistics> result = statisticsRepository.getAllGadgetStatistics(VALID_USER_ID, containerRegistryList);
+        assertNotNull(result);
+        assertFalse(result.isEmpty());        
+    }
+
+    /**
+     * Test of getGadgetStatistics method, of class JdbcStatisticsRepository.
+     */
+    @Test
+    public void testGetGadgetStatistics_Long() {
+        System.out.println("getGadgetStatistics");
+
+        // reset the like count to default non-user based query
+        calculatedStatistics.get(VALID_GADGET_ID).setUserRating(0);
+
+        GadgetStatistics result = statisticsRepository.getGadgetStatistics(VALID_GADGET_ID);
+        assertEquals(calculatedStatistics.get(VALID_GADGET_ID), result);
+    }
+
+    @Test
+    public void getGadgetStatistics_validGadgetId_validUserId() {
+        GadgetStatistics result = statisticsRepository.getGadgetStatistics(VALID_GADGET_ID, VALID_USER_ID);
+        assertEquals(RATING_LIKE.intValue(), result.getUserRating());
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/StatisticsRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/UserWizardCompletedRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/UserWizardCompletedRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/UserWizardCompletedRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/UserWizardCompletedRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.UserWizardCompleted;
+import org.mitre.portal.model.Wizard;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ *
+ * A system test that verifies the components of the UserWizardCompletedRepository work together.
+ * Uses Spring to bootstrap the application for use in a test environment.
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class UserWizardCompletedRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests
+{
+    @Autowired
+    private UserWizardCompletedRepository userWizardCompletedRepository;
+
+    // test data
+    private final Long VALID_ID = new Long(1);
+    private final Long VALID_WIZARD_ID = 1L;
+    private final String VALID_USER_ID = "100";
+    
+    private final Long INVALID_ID = new Long(-1);
+    private final String INVALID_USER_ID = "-99999";
+
+
+    @Test
+    public void get_validId_validUserWizardCompleted()
+    {
+        UserWizardCompleted userWizardCompleted = userWizardCompletedRepository.get(VALID_ID);
+        assertNotNull(userWizardCompleted);
+        assertEquals(VALID_ID, userWizardCompleted.getUserWizardCompletedId());
+        assertEquals(VALID_WIZARD_ID, userWizardCompleted.getWizard().getWizardId());
+        assertEquals(VALID_USER_ID, userWizardCompleted.getUserId());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception()
+    {
+        userWizardCompletedRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception()
+    {
+        userWizardCompletedRepository.get(null);
+    }
+
+    @Test
+    public void find_validUserId_validList()
+    {
+        List<UserWizardCompleted> list = userWizardCompletedRepository.find(VALID_USER_ID);
+        assertNotNull(list);
+        assertFalse(list.isEmpty());
+        for (UserWizardCompleted uwc : list) {
+            assertEquals(VALID_USER_ID, uwc.getUserId());
+        }
+    }
+
+    @Test
+    public void find_invalidUserId_emptyList()
+    {
+        List<UserWizardCompleted> list  = userWizardCompletedRepository.find(INVALID_USER_ID);
+        assertNotNull(list);
+        assertTrue(list.isEmpty());
+    }
+
+    @Test
+    public void findAll_validList()
+    {
+        List<UserWizardCompleted> list = userWizardCompletedRepository.findAll();
+        assertNotNull(list);
+        assertEquals(3, list.size());
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validUserWizardCompletedNullId() {
+        final String newUserId = "12345";
+        Wizard wizard = new Wizard(VALID_WIZARD_ID);
+
+        UserWizardCompleted uwc = new UserWizardCompleted();
+        uwc.setUserId(newUserId);
+        uwc.setWizard(wizard);
+
+        assertNull(uwc.getUserWizardCompletedId());
+        userWizardCompletedRepository.save(uwc);
+        assertNotNull(uwc.getUserWizardCompletedId());
+        assertTrue("new userWizardCompletedId > 0", uwc.getUserWizardCompletedId() > 0);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_validUserWizardCompletedExistingId_exception() {
+
+        UserWizardCompleted rg = userWizardCompletedRepository.get(VALID_ID);
+        userWizardCompletedRepository.save(rg);
+    }
+
+    @Test(expected = NullPointerException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void save_nullUserWizardCompleted_exception() {
+        userWizardCompletedRepository.save(null);
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_validUserWizardCompleted() {
+        UserWizardCompleted uwc = userWizardCompletedRepository.get(VALID_ID);
+        userWizardCompletedRepository.delete(uwc);
+        // second get should throw error
+        userWizardCompletedRepository.get(VALID_ID);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_invalidUserWizardCompleted() {
+        UserWizardCompleted uwc = new UserWizardCompleted(INVALID_ID);
+        userWizardCompletedRepository.delete(uwc);
+    }
+
+    @Test
+    @Transactional(readOnly=false)
+    @Rollback(true)
+    public void delete_nullUserWizardCompleted() {
+        userWizardCompletedRepository.delete(null);
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/UserWizardCompletedRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/WizardRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/WizardRepositoryTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/WizardRepositoryTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/WizardRepositoryTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.repository;
+
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.model.Wizard;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.IncorrectResultSizeDataAccessException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author ACARLUCCI
+ *
+ * A system test that verifies the components of the WizardRepository work together.
+ * Uses Spring to bootstrap the application for use in a test environment.
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+@Transactional(readOnly=true)
+public class WizardRepositoryTest extends AbstractTransactionalJUnit4SpringContextTests
+{
+    @Autowired
+    private WizardRepository wizardRepository;
+
+    // test data
+    private final Long VALID_ID = new Long(1);
+    private final String VALID_NAME = "new_user";
+    private final String VALID_DISPLAY_NAME = "New User Wizard";
+    private final String VALID_USER_TARGET = "all";
+    private final String VALID_URL = "http://dummy.example.com/new_user.html";
+    private final Long INVALID_ID = new Long(-1);
+    private final String INVALID_NAME = "ZZZ";
+
+    @Test
+    public void get_validId_validWizard()
+    {
+        Wizard wizard = wizardRepository.get(VALID_ID);
+        assertNotNull(wizard);
+        assertEquals(VALID_ID, wizard.getWizardId());
+        assertEquals(VALID_NAME, wizard.getName());
+        assertEquals(VALID_DISPLAY_NAME, wizard.getDisplayName());
+        assertEquals(VALID_USER_TARGET, wizard.getUserTarget());
+        assertEquals(VALID_URL, wizard.getUrl().toString());
+    }
+
+    @Test(expected = IncorrectResultSizeDataAccessException.class)
+    public void get_invalidId_exception()
+    {
+        wizardRepository.get(INVALID_ID);
+    }
+
+    @Test(expected = InvalidDataAccessApiUsageException.class)
+    public void get_nullId_exception()
+    {
+        wizardRepository.get(null);
+    }
+
+    @Test
+    public void find_validName_validWizard()
+    {
+        Wizard wizard = wizardRepository.find(VALID_NAME);
+        assertNotNull(wizard);
+        assertEquals(VALID_ID, wizard.getWizardId());
+        assertEquals(VALID_NAME, wizard.getName());
+    }
+
+    @Test
+    public void find_invalidName_nullWizard()
+    {
+        Wizard wizard = wizardRepository.find(INVALID_NAME);
+        assertNull(wizard);
+    }
+
+    @Test
+    public void find_nullName_nullWizard()
+    {
+        Wizard wizard = wizardRepository.find(null);
+        assertNull(wizard);
+    }
+
+    @Test
+    public void findAll_validList()
+    {
+        List<Wizard> list= wizardRepository.findAll();
+        assertNotNull(list);
+        assertEquals(2, list.size());
+    }
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/WizardRepositoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/util/JpaConstantsTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/util/JpaConstantsTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/util/JpaConstantsTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/util/JpaConstantsTest.java Fri Apr  1 16:42:22 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.mitre.portal.repository.util;
+
+import org.junit.Test;
+import org.mitre.portal.repository.util.JpaConstants.Constraint;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Sean Cooper
+ */
+public class JpaConstantsTest {
+
+    @Test
+    public void simpleVerification() {
+        new JpaConstants();
+
+        assertTrue(JpaConstants.Constraint.UNIQUE_GADGET_URL instanceof String);
+        assertTrue(JpaConstants.Constraint.UNIQUE_PAGE_NAME instanceof String);
+
+    }
+
+}
\ No newline at end of file

Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/repository/util/JpaConstantsTest.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message