use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByChecksumMultipleResult.
@Test
public void testGetArtifactsByChecksumMultipleResult() throws Exception {
ArtifactMetadata artifact1 = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
String newProjectId = "another-project";
ArtifactMetadata artifact2 = createArtifact();
artifact2.setProject(newProjectId);
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, newProjectId, TEST_PROJECT_VERSION, artifact2);
repository.save();
tryAssert(() -> {
List<ArtifactMetadata> artifacts = new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_SHA1));
Collections.sort(artifacts, new ArtifactMetadataComparator());
assertEquals(Arrays.asList(artifact2, artifact1), artifacts);
});
tryAssert(() -> {
ArrayList<ArtifactMetadata> artifacts = new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_MD5));
Collections.sort(artifacts, new ArtifactMetadataComparator());
assertEquals(Arrays.asList(artifact2, artifact1), artifacts);
});
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByChecksumSingleResultSha1.
@Test
public void testGetArtifactsByChecksumSingleResultSha1() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.save();
assertEquals(Collections.singletonList(artifact), new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_SHA1)));
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByPropertySingleResult.
@Test
public void testGetArtifactsByPropertySingleResult() throws Exception {
createArtifactWithData();
// only works on JCR implementation
// Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID );
Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty("url", TEST_URL, TEST_REPO_ID);
assertThat(artifactsByProperty).hasSize(1);
ArtifactMetadata artifactMetadata = artifactsByProperty.iterator().next();
assertThat(artifactMetadata.getId()).isEqualTo("projectId-1.0.jar");
assertThat(artifactMetadata.getSha1()).isEqualTo(TEST_SHA1);
assertThat(artifactMetadata.getRepositoryId()).isEqualTo(TEST_REPO_ID);
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByChecksumMultipleCopies.
@Test
public void testGetArtifactsByChecksumMultipleCopies() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
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), new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_SHA1)));
assertEquals(Collections.singletonList(secondArtifact), new ArrayList<>(repository.getArtifactsByChecksum(OTHER_REPO_ID, TEST_SHA1)));
assertEquals(Collections.singletonList(artifact), new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_MD5)));
assertEquals(Collections.singletonList(secondArtifact), new ArrayList<>(repository.getArtifactsByChecksum(OTHER_REPO_ID, TEST_MD5)));
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByDateRangeMultipleCopies.
@Test
public void testGetArtifactsByDateRangeMultipleCopies() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
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, null));
assertEquals(Collections.singletonList(secondArtifact), repository.getArtifactsByDateRange(OTHER_REPO_ID, null, null));
}
Aggregations