use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.
the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadata.
@Test
void returnsCreatedAndSavesSnapshotMetadata() {
final byte[] xml = new MetadataXml("com.example", "abc").get(new MetadataXml.VersionTags("0.1-SNAPSHOT", "0.2-SNAPSHOT")).getBytes(StandardCharsets.UTF_8);
this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/abc/0.2-SNAPSHOT/abc.jar"), Content.EMPTY).join();
MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/abc/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/abc/0.2-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.
the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent.
@Test
void returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent() {
final byte[] xml = new MetadataXml("com.example", "any").get(new MetadataXml.VersionTags(Optional.empty(), Optional.of("0.2"), new ListOf<String>("0.1", "0.2", "0.3-SNAPSHOT"))).getBytes(StandardCharsets.UTF_8);
this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/any/0.3-SNAPSHOT/any.jar"), Content.EMPTY).join();
MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/any/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/any/0.3-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.
the class AstoValidUploadTest method returnsFalseWhenMetadataIsNotValid.
@Test
void returnsFalseWhenMetadataIsNotValid() throws InterruptedException {
final Key upload = new Key.From(".upload/com/test/logger");
final Key artifact = new Key.From("com/test/logger");
final Key jar = new Key.From("com/test/logger/1.0/my-package.jar");
final byte[] bytes = "artifact".getBytes();
this.bsto.save(jar, bytes);
new MetadataXml("com.test", "jogger").addXmlToStorage(this.storage, new Key.From(upload, PutMetadataSlice.SUB_META, "maven-metadata.xml"), new MetadataXml.VersionTags("1.0", "1.0", "1.0"));
this.addMetadata(artifact);
this.bsto.save(jar, bytes);
new RepositoryChecksums(this.storage).generate(jar).toCompletableFuture().join();
MatcherAssert.assertThat(this.validupload.validate(upload, artifact).toCompletableFuture().join(), new IsEqual<>(false));
}
Aggregations