continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r600213 - in /maven/continuum/branches/continuum-jpa/continuum-model-jpa/src: main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
Date Sat, 01 Dec 2007 23:22:35 GMT
Author: rinku
Date: Sat Dec  1 15:22:33 2007
New Revision: 600213

URL: http://svn.apache.org/viewvc?rev=600213&view=rev
Log:
o  added more unit tests for ProjectGroupStore and fixes.

Modified:
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java?rev=600213&r1=600212&r2=600213&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStore.java
Sat Dec  1 15:22:33 2007
@@ -115,7 +115,7 @@
         }
         if ( query.hasName() )
         {
-            where.put( "name", query.getModelEncoding() );
+            where.put( "name", query.getName() );
             if ( sb.length() > 0 )
                 sb.append( "and" );
             sb.append( " projectGroup.name =:name " );

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java?rev=600213&r1=600212&r2=600213&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
Sat Dec  1 15:22:33 2007
@@ -9,9 +9,8 @@
 
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
+import org.apache.maven.continuum.store.api.EntityNotFoundException;
 import org.apache.maven.continuum.store.api.ProjectGroupQuery;
-import org.apache.maven.continuum.store.api.Query;
-import org.apache.maven.continuum.store.api.QueryFactory;
 import org.apache.maven.continuum.store.api.Store;
 import org.apache.maven.continuum.store.api.StoreException;
 import org.apache.openjpa.persistence.OpenJPAQuery;
@@ -80,11 +79,45 @@
     }
 
     @Test
-    public void testExecuteProjectGroupQuery() throws Exception
+    public void testLookupProjectGroup() throws EntityNotFoundException, StoreException
     {
-        Query<ProjectGroup> qry = QueryFactory.createQuery( ProjectGroupQuery.class
);
-        Assert.assertNotNull( qry );
-        // TODO: Implement!
+        ProjectGroup projectGroup = getProjectGroupStore().lookup( 1000L );
+        Assert.assertNotNull( projectGroup );
+        Assert.assertEquals( 1000L, projectGroup.getId().longValue() );
+        Assert.assertEquals( "Continuum Projects", projectGroup.getName() );
+        Assert.assertEquals( "org.apache.continuum", projectGroup.getGroupId() );
+    }
+
+    @Test
+    public void testLookupInvalidProjectGroup() throws StoreException
+    {
+        try
+        {
+            ProjectGroup projectGroup = getProjectGroupStore().lookup( 99999L );
+            Assert.fail( "Expected " + EntityNotFoundException.class.getSimpleName()
+                            + " on account of an invalid ProjectGroup Id." );
+        }
+        catch ( EntityNotFoundException e )
+        {
+            // Expected!
+        }
+    }
+
+    @Test
+    public void testQueryProjectGroup() throws Exception
+    {
+        ProjectGroupQuery qry = new ProjectGroupQuery();
+        qry.setName( "Continuum Projects" );
+        List<ProjectGroup> results = getProjectGroupStore().query( qry );
+        Assert.assertNotNull( results );
+        Assert.assertEquals( "Expected 1 matching Project Group.", 1, results.size() );
+
+        // with an invalid ProjectGroup Id
+        qry = new ProjectGroupQuery();
+        qry.setName( "invalid Project" );
+        results = getProjectGroupStore().query( qry );
+        Assert.assertNotNull( results );
+        Assert.assertEquals( "Expected 0 matching Project Group.", 0, results.size() );
     }
 
     @Override



Mime
View raw message