Skip to content

Commit

Permalink
o yesss! now we cooking :-)
Browse files Browse the repository at this point in the history
o  updated test data and fixed unit tests.

git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/branches/key-based-refactor@493273 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Rahul Thakur committed Jan 6, 2007
1 parent 0c50afa commit d7fcfe8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import org.apache.maven.continuum.key.GroupProjectKey;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
import org.apache.maven.continuum.store.ContinuumStoreException;
Expand Down Expand Up @@ -73,13 +72,14 @@ public Project lookupProject( GroupProjectKey key )
{
tx.begin();

Extent extent = pm.getExtent( BuildResult.class, true );
Extent extent = pm.getExtent( Project.class, true );

Query query = pm.newQuery( extent );

query.declareParameters( "String groupKey, String projectKey" );

query.setFilter( "this.project.groupKey == groupKey && this.project.key == projectKey" );
// XXX: Why do we have a 'groupKey' column set up in Project table?
query.setFilter( "this.projectGroup.key == groupKey && this.key == projectKey" );

List result = (List) query.execute( key.getGroupKey(), key.getProjectKey() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void testLookupProjectGroup() throws Exception
GroupProjectKey key = new GroupProjectKey( "Default", null );
ProjectGroup group = store.lookupProjectGroup( key );
assertNotNull( group );
assertEquals( 1L, group.getId() );
assertEquals( "Default Group", group.getDescription() );
assertEquals( 100L, group.getId() );
assertEquals( "Default Group Desc.", group.getDescription() );
assertEquals( "default", group.getGroupId() );
assertEquals( "Default", group.getKey() );
assertEquals( "Default Group", group.getName() );
Expand Down Expand Up @@ -88,6 +88,7 @@ public void testSaveNewProjectGroup() throws Exception

group = store.saveProjectGroup( group );
assertNotNull( group );
assertTrue( group.getId() > 0 );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ public void testLookupProject() throws Exception
assertNotNull( group );

// verify group properties
assertEquals( 1L, group.getId() );
assertEquals( "Default Group", group.getDescription() );
assertEquals( 100L, group.getId() );
assertEquals( "Default Group Desc.", group.getDescription() );
assertEquals( "default", group.getGroupId() );
assertEquals( "Default", group.getKey() );
assertEquals( "Default Group", group.getName() );

// verify project properties
assertEquals( 1L, project.getId() );
assertEquals( "Test Project 1", group.getDescription() );
assertEquals( "org.test.projects", group.getGroupId() );
assertEquals( "project1", group.getKey() );
assertEquals( "Project 1", group.getName() );
assertEquals( "Test Project 1", project.getDescription() );
assertEquals( "org.test.projects", project.getGroupId() );
assertEquals( "project1", project.getKey() );
assertEquals( "Project 1", project.getName() );
}

public void testDeleteProject() throws Exception
{
ProjectStore store = (ProjectStore) lookup( ProjectStore.ROLE, "jdo" );
GroupProjectKey key = new GroupProjectKey( "DeleteableGroup", "deleteableProject" );
GroupProjectKey key = new GroupProjectKey( "Continuum", "deleteableProject" );
Project project = store.lookupProject( key );
assertNotNull( project );

Expand Down
2 changes: 1 addition & 1 deletion continuum-store/src/test/resources/db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CREATE TABLE CHANGEFILE

CREATE TABLE CHANGESET
(
CHANGESET_ID BIGINT NOT NULL,
CHANGESET_ID BIGINT NOT NULL ,
AUTHOR VARCHAR(256) NULL,
COMMENT VARCHAR(8192) NULL,
"DATE" BIGINT NOT NULL,
Expand Down
14 changes: 7 additions & 7 deletions continuum-store/src/test/resources/db/testData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Set up Project Groups
insert into PROJECTGROUP (ID, DESCRIPTION, GROUP_ID, GROUPKEY, NAME)
values (1, 'Default Group' , 'default', 'Default' , 'Default Group');
values (100, 'Default Group Desc.' , 'default', 'Default' , 'Default Group');
insert into PROJECTGROUP (ID, DESCRIPTION, GROUP_ID, GROUPKEY, NAME)
values (2, 'Group 1' , 'org.apache.maven.continuum', 'Continuum' , 'Continuum Group');
values (200, 'Group 1' , 'org.apache.maven.continuum', 'Continuum' , 'Continuum Group');
insert into PROJECTGROUP (ID, DESCRIPTION, GROUP_ID, GROUPKEY, NAME)
values (999, 'Deleteable Group' , 'org.group.deleteable', 'DeleteableGroup' , 'Deleteable Group');

Expand All @@ -14,19 +14,19 @@ insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY,
PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE,
PROJECT_GROUP_ID_OID, "STATE")
values (1, 'Test Project 1', 'project-1', 'org.test.projects', 'Default',
'project1', 'Project 1', 0, 0, 0, 1, 0);
'project1', 'Project 1', 0, 0, 0, 100, 0);
insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY,
PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID,
OLD_STATE, PROJECT_GROUP_ID_OID, "STATE")
values (2, 'Test Project 2', 'project-2', 'org.test.projects', 'Group 1',
'project2', 'Project 2', 0, 0, 0, 2, 0);
'project2', 'Project 2', 0, 0, 0, 200, 0);
insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY,
PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE,
PROJECT_GROUP_ID_OID, "STATE")
values (3, 'Test Project 3', 'project-3', 'org.test.projects', 'Group 1',
'project3', 'Project 3', 0, 0, 0, 2, 0);
'project3', 'Project 3', 0, 0, 0, 200, 0);
insert into PROJECT (ID, DESCRIPTION, ARTIFACT_ID, GROUP_ID, GROUP_KEY,
PROJECTKEY, NAME, BUILD_NUMBER, LATEST_BUILD_ID, OLD_STATE,
PROJECT_GROUP_ID_OID, "STATE")
values (999, 'Deleteable Project', 'deleteable-project', 'org.test.projects', 'DeleteableGroup',
'deleteableProject', 'Deleteable Project', 0, 0, 0, 2, 0);
values (999, 'Deleteable Project', 'deleteable-project', 'org.test.projects', 'Continuum',
'deleteableProject', 'Deleteable Project', 0, 0, 0, 200, 0);
15 changes: 15 additions & 0 deletions continuum-store/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
<appender-ref ref="default"/>
</category>

<category name="JPOX.JDO.QUERY">
<priority value="DEBUG"/>
<appender-ref ref="default"/>
</category>

<category name="JPOX.RDBMS.DDL">
<priority value="ERROR"/>
<appender-ref ref="default"/>
</category>

<category name="JPOX.RDBMS.SQL">
<priority value="DEBUG"/>
<appender-ref ref="default"/>
</category>

<root>
<priority value="INFO"/>
<appender-ref ref="default"/>
Expand Down

0 comments on commit d7fcfe8

Please sign in to comment.