use of com.artipie.asto.ext.PublisherAs in project maven-adapter by artipie.
the class AstoMavenTest method updatesCorrectlyWhenVersionIsDowngraded.
@Test
void updatesCorrectlyWhenVersionIsDowngraded() {
final String version = "1.0";
new MetadataXml("com.test", "logger").addXmlToStorage(this.storage, new Key.From(AstoMavenTest.LGR, "maven-metadata.xml"), new MetadataXml.VersionTags("2.0", "2.0", new ListOf<>("2.0")));
this.storage.save(new Key.From(AstoMavenTest.LGR, "2.0", "logger-2.0.jar"), Content.EMPTY).join();
new MetadataXml("com.test", "logger").addXmlToStorage(this.storage, new Key.From(AstoMavenTest.LGR_UPLOAD, version, PutMetadataSlice.SUB_META, "maven-metadata.xml"), new MetadataXml.VersionTags("2.0", "1.0", new ListOf<>("2.0", "1.0")));
new AstoMaven(this.storage).update(new Key.From(AstoMavenTest.LGR_UPLOAD, version), AstoMavenTest.LGR).toCompletableFuture().join();
MatcherAssert.assertThat("Maven metadata xml is not correct", new XMLDocument(this.storage.value(new Key.From(AstoMavenTest.LGR, "maven-metadata.xml")).thenCompose(content -> new PublisherAs(content).string(StandardCharsets.UTF_8)).join()), new AllOf<>(new ListOf<Matcher<? super XML>>(XhtmlMatchers.hasXPath("/metadata/groupId[text() = 'com.test']"), XhtmlMatchers.hasXPath("/metadata/artifactId[text() = 'logger']"), XhtmlMatchers.hasXPath("/metadata/versioning/latest[text() = '2.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/release[text() = '2.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '2.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions[count(//version) = 2]"), XhtmlMatchers.hasXPath("/metadata/versioning/lastUpdated"))));
MatcherAssert.assertThat("Upload directory was not cleaned up", this.storage.list(new Key.From(AstoMavenTest.LGR_UPLOAD, version)).join().size(), new IsEqual<>(0));
}
use of com.artipie.asto.ext.PublisherAs in project artipie by artipie.
the class ConfigFileTest method valueFromStorageReturnsContentWhenYamlExist.
@ParameterizedTest
@ValueSource(strings = { ".yaml", ".yml", "" })
void valueFromStorageReturnsContentWhenYamlExist(final String extension) {
final Storage storage = new InMemoryStorage();
this.saveByKey(storage, ".yml");
MatcherAssert.assertThat(new PublisherAs(new ConfigFile(new Key.From(ConfigFileTest.NAME + extension)).valueFrom(storage).toCompletableFuture().join()).bytes().toCompletableFuture().join(), new IsEqual<>(ConfigFileTest.CONTENT));
}
Aggregations