use of com.artipie.asto.ext.PublisherAs in project artipie by artipie.
the class StorageYamlConfigTest method returnsSubStorageWithCorrectPrefix.
@Test
void returnsSubStorageWithCorrectPrefix() throws IOException {
final Key prefix = new Key.From("prefix");
final Key path = new Key.From("some/path");
final Key full = new Key.From(prefix, path);
final byte[] data = "content".getBytes();
this.config().subStorage(prefix).save(path, new Content.From(data)).join();
MatcherAssert.assertThat(new PublisherAs(new FileStorage(this.tmp).value(full).join()).bytes().toCompletableFuture().join(), new IsEqual<>(data));
}
use of com.artipie.asto.ext.PublisherAs in project artipie by artipie.
the class ConfigFileTest method valueFromStorageReturnsYamlWhenBothExist.
@Test
void valueFromStorageReturnsYamlWhenBothExist() {
final Storage storage = new InMemoryStorage();
final String yaml = String.join("", Arrays.toString(ConfigFileTest.CONTENT), "some");
this.saveByKey(storage, ".yml");
this.saveByKey(storage, ".yaml", yaml.getBytes());
MatcherAssert.assertThat(new PublisherAs(new ConfigFile(new Key.From(ConfigFileTest.NAME)).valueFrom(storage).toCompletableFuture().join()).asciiString().toCompletableFuture().join(), new IsEqual<>(yaml));
}
use of com.artipie.asto.ext.PublisherAs in project maven-adapter by artipie.
the class MavenITCase method deploysSnapshotAfterRelease.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void deploysSnapshotAfterRelease(final boolean anonymous) throws Exception {
this.init(anonymous);
this.copyHellowordSourceToContainer();
MatcherAssert.assertThat("Failed to deploy version 1.0", this.exec("mvn", "-s", "/home/settings.xml", "-f", "/home/helloworld-src/pom.xml", "deploy"), new StringContains("BUILD SUCCESS"));
this.clean();
this.verifyArtifactsAdded("1.0");
MatcherAssert.assertThat("Failed to set version 2.0-SNAPSHOT", this.exec("mvn", "-s", "/home/settings.xml", "-f", "/home/helloworld-src/pom.xml", "versions:set", "-DnewVersion=2.0-SNAPSHOT"), new StringContains("BUILD SUCCESS"));
MatcherAssert.assertThat("Failed to deploy version 2.0", this.exec("mvn", "-s", "/home/settings.xml", "-f", "/home/helloworld-src/pom.xml", "deploy"), new StringContains("BUILD SUCCESS"));
this.clean();
this.verifySnapshotAdded("2.0-SNAPSHOT");
MatcherAssert.assertThat("Maven metadata xml is not correct", new XMLDocument(this.storage.value(new Key.From("com/artipie/helloworld/maven-metadata.xml")).thenCompose(content -> new PublisherAs(content).string(StandardCharsets.UTF_8)).join()), new AllOf<>(new ListOf<Matcher<? super XML>>(XhtmlMatchers.hasXPath("/metadata/versioning/latest[text() = '2.0-SNAPSHOT']"), XhtmlMatchers.hasXPath("/metadata/versioning/release[text() = '1.0']"))));
}
use of com.artipie.asto.ext.PublisherAs in project maven-adapter by artipie.
the class AstoMavenTest method generatesMetadataForFirstArtifact.
@Test
void generatesMetadataForFirstArtifact() {
final String version = "1.0";
new TestResource("maven-metadata.xml.example").saveTo(this.storage, new Key.From(AstoMavenTest.LGR_UPLOAD, version, PutMetadataSlice.SUB_META, "maven-metadata.xml"));
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() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/release[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions[count(//version) = 1]"), 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 maven-adapter by artipie.
the class AstoMavenTest method generatesWithSnapshotMetadata.
@Test
void generatesWithSnapshotMetadata() throws Exception {
final String snapshot = "1.0-SNAPSHOT";
final Predicate<String> cond = item -> !item.contains(snapshot);
this.addFilesToStorage(cond, AstoMavenTest.ASTO);
this.addFilesToStorage(cond.negate(), AstoMavenTest.ASTO_UPLOAD);
this.metadataAndVersions(snapshot, "0.20.2");
new AstoMaven(this.storage).update(new Key.From(AstoMavenTest.ASTO_UPLOAD, snapshot), AstoMavenTest.ASTO).toCompletableFuture().get();
MatcherAssert.assertThat(new XMLDocument(this.storage.value(new Key.From(AstoMavenTest.ASTO, "maven-metadata.xml")).thenCompose(content -> new PublisherAs(content).string(StandardCharsets.UTF_8)).join()), new AllOf<>(new ListOf<Matcher<? super XML>>(// @checkstyle LineLengthCheck (20 lines)
XhtmlMatchers.hasXPath("/metadata/groupId[text() = 'com.artipie']"), XhtmlMatchers.hasXPath("/metadata/artifactId[text() = 'asto']"), XhtmlMatchers.hasXPath("/metadata/versioning/latest[text() = '1.0-SNAPSHOT']"), XhtmlMatchers.hasXPath("/metadata/versioning/release[text() = '0.20.2']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '0.15']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '0.11.1']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '0.20.1']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '0.20.2']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '0.18']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '1.0-SNAPSHOT']"), XhtmlMatchers.hasXPath("metadata/versioning/versions[count(//version) = 6]"), XhtmlMatchers.hasXPath("/metadata/versioning/lastUpdated"))));
MatcherAssert.assertThat("Artifacts were not moved to the correct location", this.storage.list(new Key.From(AstoMavenTest.ASTO, snapshot)).join().size(), new IsEqual<>(12));
MatcherAssert.assertThat("Upload directory was not cleaned up", this.storage.list(new Key.From(AstoMavenTest.ASTO_UPLOAD, snapshot)).join().size(), new IsEqual<>(0));
}
Aggregations