ArtifactMetadata artifactMetadata = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifactMetadata );
+ repository.save();
Collection<ArtifactMetadata> artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
TEST_PROJECT_VERSION );
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, null,
null ) );
ArtifactMetadata artifact = createArtifact();
artifact.setNamespace( namespace );
repository.updateArtifact( TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, null,
null ) );
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
Date date = new Date( artifact.getWhenGathered().getTime() - 10000 );
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, date,
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
Date lower = new Date( artifact.getWhenGathered().getTime() - 10000 );
Date upper = new Date( artifact.getWhenGathered().getTime() + 10000 );
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
Date upper = new Date( artifact.getWhenGathered().getTime() + 10000 );
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, null,
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
Date upper = new Date( artifact.getWhenGathered().getTime() - 10000 );
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ).isEmpty() );
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
+
assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) );
}
ArtifactMetadata secondArtifact = createArtifact();
secondArtifact.setRepositoryId( OTHER_REPO_ID );
repository.updateArtifact( OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ repository.save();
// test it restricts to the appropriate repository
assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) );
ArtifactMetadata secondArtifact = createArtifact();
secondArtifact.setRepositoryId( OTHER_REPO_ID );
repository.updateArtifact( OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ repository.save();
// test it restricts to the appropriate repository
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByDateRange( TEST_REPO_ID, null,
ArtifactMetadata secondArtifact = createArtifact();
secondArtifact.setRepositoryId( OTHER_REPO_ID );
repository.updateArtifact( OTHER_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, secondArtifact );
+ repository.save();
// test it restricts to the appropriate repository
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID,
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID,
TEST_MD5 ) );
{
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID,
TEST_SHA1 ) );
String namespace = "multi.level.ns";
artifact.setNamespace( namespace );
repository.updateArtifact( TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ repository.save();
assertEquals( Collections.singletonList( artifact ), repository.getArtifactsByChecksum( TEST_REPO_ID,
TEST_SHA1 ) );
ArtifactMetadata artifact2 = createArtifact();
artifact2.setProject( newProjectId );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, newProjectId, TEST_PROJECT_VERSION, artifact2 );
+ repository.save();
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( repository.getArtifactsByChecksum(
TEST_REPO_ID, TEST_SHA1 ) );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
- assertEquals( Collections.<ArtifactMetadata>emptyList(), repository.getArtifactsByChecksum( TEST_REPO_ID,
- "not checksum" ) );
+ List<ArtifactMetadata> artifactsByChecksum = repository.getArtifactsByChecksum( TEST_REPO_ID, "not checksum" );
+ assertEquals( Collections.<ArtifactMetadata>emptyList(), artifactsByChecksum );
}
public void testDeleteArtifact()
ArtifactMetadata artifact2 = createArtifact();
artifact2.setProject( "project2" );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, "project2", TEST_PROJECT_VERSION, artifact2 );
+ repository.save();
List<ArtifactMetadata> expected = Arrays.asList( artifact1, artifact2 );
Collections.sort( expected, new ArtifactMetadataComparator() );