public void testQueryArtifactsInRepoWithWhenGathered()
throws Exception
{
Date whenGathered = Calendar.getInstance().getTime();
ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" );
artifact.getModel().setWhenGathered( whenGathered );
artifactDao.saveArtifact( artifact );
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" );
artifact.getModel().setWhenGathered( whenGathered );
artifactDao.saveArtifact( artifact );
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2" );
artifact.getModel().setWhenGathered( whenGathered );
artifactDao.saveArtifact( artifact );
artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" );
artifact.getModel().setRepositoryId( "different-repo" );
artifact.getModel().setWhenGathered( whenGathered );
artifactDao.saveArtifact( artifact );
Date olderWhenGathered = Calendar.getInstance().getTime();
olderWhenGathered.setTime( 123456789 );
artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT" );
artifact.getModel().setWhenGathered( olderWhenGathered );
artifactDao.saveArtifact( artifact );
artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1" );
artifact.getModel().setWhenGathered( whenGathered );
artifactDao.saveArtifact( artifact );
assertConstraint( "Artifacts By Repository and When Gathered", 4,
new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId" ) );
}