use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeWhenOneTransferIsInvalidXml.
@Test
public void mergeWhenOneTransferIsInvalidXml() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "invalid.xml");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
assertThat(versioning.getRelease(), equalTo("1.0"));
assertThat(versioning.getLatest(), equalTo("1.0"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class PackageMetadataMergerTest method mergeWhenOneTransferIsInvalidXml.
@Test
public void mergeWhenOneTransferIsInvalidXml() throws Exception {
String path = "jquery/package.json";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "package-1.json");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "invalid.json");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new PackageMetadataMerger(Collections.emptyList()).merge(sources, g, path);
IndyObjectMapper mapper = new IndyObjectMapper(true);
PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
// normal object fields merging verification
assertThat(merged.getName(), equalTo("jquery"));
assertThat(merged.getAuthor().getName(), equalTo("JS Foundation and other contributors"));
assertThat(merged.getRepository().getType(), equalTo("git"));
assertThat(merged.getRepository().getUrl(), equalTo("git+https://github.com/jquery1/jquery1.git"));
assertThat(merged.getReadmeFilename(), equalTo("README1.md"));
assertThat(merged.getHomepage(), equalTo("https://jquery1.com"));
assertThat(merged.getBugs().getUrl(), equalTo("https://github.com/jquery1/jquery1/issues"));
assertThat(merged.getLicense(), equalTo("MIT1"));
// dist-tags object merging verification
assertThat(merged.getDistTags().getBeta(), equalTo("2.2.1"));
assertThat(merged.getDistTags().getLatest(), equalTo("2.2.1"));
// error, versions map merging verification
Map<String, VersionMetadata> versions = merged.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(1));
assertThat(versions.get("1.5.1").getVersion(), equalTo("1.5.1"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class PackageMetadataMergerTest method mergeOneTransferWithProviderContent.
@Test
public void mergeOneTransferWithProviderContent() throws Exception {
String path = "jquery/package.json";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "package-1.json");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "package-2.json");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
PackageMetadata provided = new PackageMetadata("jquery");
provided.setDescription("provider description test");
provided.setRepository(new Repository("svn", "svn+https://svn.host/jquery"));
provided.setBugs(new Bugs("https://github.com/jquery2/jquery2/issues", "jquery2@bug.com"));
List<UserInfo> added = new ArrayList<UserInfo>();
added.add(new UserInfo("testa", "testa@test.com"));
provided.setMaintainers(added);
TestPackageMetadataProvider testProvider = new TestPackageMetadataProvider(provided);
byte[] output = new PackageMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
IndyObjectMapper mapper = new IndyObjectMapper(true);
PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
// normal object fields merging verification
assertThat(merged.getName(), equalTo("jquery"));
assertThat(merged.getDescription(), equalTo("provider description test"));
assertThat(merged.getRepository().getType(), equalTo("svn"));
assertThat(merged.getRepository().getUrl(), equalTo("svn+https://svn.host/jquery"));
assertThat(merged.getBugs().getUrl(), equalTo("https://github.com/jquery2/jquery2/issues"));
assertThat(merged.getBugs().getEmail(), equalTo("jquery2@bug.com"));
// maintainers list merging verification
List<UserInfo> maintainers = merged.getMaintainers();
assertThat(maintainers, notNullValue());
assertThat(maintainers.size(), equalTo(4));
assertThat(maintainers.get(0).getName(), equalTo("dmethvin"));
assertThat(maintainers.get(1).getName(), equalTo("mgol"));
assertThat(maintainers.get(2).getName(), equalTo("scott.gonzalez"));
assertThat(maintainers.get(3).getName(), equalTo("testa"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class PackageMetadataMergerTest method mergeProviderWithSameVersionMetadata.
@Test
public void mergeProviderWithSameVersionMetadata() throws Exception {
String path = "jquery/package.json";
HostedRepository h1 = new HostedRepository("test-hosted-1");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "package-1.json");
Group g = new Group("test-group", h1.getKey());
List<Transfer> sources = Arrays.asList(t1);
PackageMetadata provided = new PackageMetadata("jquery");
VersionMetadata versionMetadata = new VersionMetadata("jquery", "1.5.1");
versionMetadata.setUrl("jquery.new.com");
TestPackageMetadataProvider testProvider = new TestPackageMetadataProvider(provided);
byte[] output = new PackageMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
IndyObjectMapper mapper = new IndyObjectMapper(true);
PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
assertThat(merged.getVersions().get("1.5.1"), notNullValue());
assertThat(merged.getVersions().get("1.5.1").getUrl(), equalTo("jquery.com"));
}
use of org.commonjava.maven.galley.model.Transfer in project indy by Commonjava.
the class PackageMetadataMergerTest method mergeProviderWithDistTagVersionSorted.
@Test
public void mergeProviderWithDistTagVersionSorted() throws Exception {
String path = "jquery/package.json";
HostedRepository h1 = new HostedRepository("test-hosted-1");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "package-dist-tag-version.json");
Group g = new Group("test-group", h1.getKey());
List<Transfer> sources = Arrays.asList(t1);
PackageMetadata provided = new PackageMetadata("jquery");
DistTag distTag = new DistTag();
distTag.putTag(DistTag.LATEST, "3.2.3-rc.3");
distTag.putTag(DistTag.STABLE, "2.0");
distTag.putTag(DistTag.BETA, "3.2.1-beta.2");
distTag.putTag(DistTag.DEV, "3.2.3-alpha");
provided.setDistTags(distTag);
TestPackageMetadataProvider testProvider = new TestPackageMetadataProvider(provided);
byte[] output = new PackageMetadataMerger(Collections.singletonList(testProvider)).merge(sources, g, path);
IndyObjectMapper mapper = new IndyObjectMapper(true);
PackageMetadata merged = mapper.readValue(IOUtils.toString(new ByteArrayInputStream(output)), PackageMetadata.class);
assertThat(merged.getDistTags().getLatest(), equalTo("3.2.3-rc.3"));
assertThat(merged.getDistTags().getStable(), equalTo("3.2.1"));
assertThat(merged.getDistTags().getBeta(), equalTo("3.2.1-beta.2"));
assertThat(merged.getDistTags().getDev(), equalTo("3.2.3-alpha"));
}
Aggregations