use of org.apache.archiva.model.ProjectReference in project archiva by apache.
the class MetadataToolsTest method assertUpdatedProjectMetadata.
private void assertUpdatedProjectMetadata(String artifactId, String[] expectedVersions, String latestVersion, String releaseVersion) throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
prepTestRepo(testRepo, reference);
tools.updateMetadata(testRepo, reference);
StringBuilder buf = new StringBuilder();
buf.append("<metadata>\n");
buf.append(" <groupId>").append(reference.getGroupId()).append("</groupId>\n");
buf.append(" <artifactId>").append(reference.getArtifactId()).append("</artifactId>\n");
if (expectedVersions != null) {
buf.append(" <versioning>\n");
if (latestVersion != null) {
buf.append(" <latest>").append(latestVersion).append("</latest>\n");
}
if (releaseVersion != null) {
buf.append(" <release>").append(releaseVersion).append("</release>\n");
}
buf.append(" <versions>\n");
for (int i = 0; i < expectedVersions.length; i++) {
buf.append(" <version>").append(expectedVersions[i]).append("</version>\n");
}
buf.append(" </versions>\n");
buf.append(" </versioning>\n");
}
buf.append("</metadata>");
assertMetadata(buf.toString(), testRepo, reference);
}
use of org.apache.archiva.model.ProjectReference in project archiva by apache.
the class MetadataToolsTest method prepTestRepo.
private void prepTestRepo(ManagedRepositoryContent repo, VersionedReference reference) throws IOException {
ProjectReference projectRef = new ProjectReference();
projectRef.setGroupId(reference.getGroupId());
projectRef.setArtifactId(reference.getArtifactId());
prepTestRepo(repo, projectRef);
}
use of org.apache.archiva.model.ProjectReference in project archiva by apache.
the class MetadataToolsTest method testUpdateProjectNonExistingVersion.
// TODO: replace with group tests
// public void testUpdateProjectBadArtifact()
// throws Exception
// {
// try
// {
// assertUpdatedProjectMetadata( "bad_artifact", null );
// fail( "Should have thrown an IOException on a bad artifact." );
// }
// catch ( IOException e )
// {
// // Expected path
// }
// }
@Test
public void testUpdateProjectNonExistingVersion() throws Exception {
ManagedRepositoryContent testRepo = createTestRepoContent();
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId("missing_artifact");
prepTestRepo(testRepo, reference);
// check metadata prior to update -- should contain the non-existing artifact version
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
tools.updateMetadata(testRepo, reference);
// metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
assertProjectMetadata(testRepo, reference, "missing_artifact", new String[] { "1.0-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null);
}
use of org.apache.archiva.model.ProjectReference in project archiva by apache.
the class MetadataToolsTest method assertProjectReference.
private void assertProjectReference(String groupId, String artifactId, String path) throws RepositoryMetadataException {
ProjectReference reference = tools.toProjectReference(path);
assertNotNull("Reference should not be null.", reference);
assertEquals("ProjectReference.groupId", groupId, reference.getGroupId());
assertEquals("ProjectReference.artifactId", artifactId, reference.getArtifactId());
}
use of org.apache.archiva.model.ProjectReference in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method assertGetVersions.
private void assertGetVersions(String artifactId, List<String> expectedVersions) throws Exception {
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
// Use the test metadata-repository, which is already setup for
// These kind of version tests.
Path repoDir = Paths.get("src/test/repositories/metadata-repository");
((EditableManagedRepository) repoContent.getRepository()).setLocation(repoDir.toAbsolutePath().toUri());
// Request the versions.
Set<String> testedVersionSet = repoContent.getVersions(reference);
// Sort the list (for asserts)
List<String> testedVersions = new ArrayList<>();
testedVersions.addAll(testedVersionSet);
Collections.sort(testedVersions, new VersionComparator());
// Test the expected array of versions, to the actual tested versions
assertEquals("available versions", expectedVersions, testedVersions);
}
Aggregations