Search in sources :

Example 26 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project artipie by artipie.

the class VersionSliceTest method returnVersionOfApplication.

@Test
void returnVersionOfApplication() {
    final ArtipieProperties proprts = new ArtipieProperties();
    MatcherAssert.assertThat(new VersionSlice(proprts), new SliceHasResponse(Matchers.allOf(new RsHasStatus(RsStatus.OK), new RsHasBody(new IsJson(new JsonContains(new JsonHas("version", new JsonValueIs(proprts.version())))))), new RequestLine(RqMethod.GET, "/.version")));
}
Also used : RequestLine(com.artipie.http.rq.RequestLine) SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) RsHasBody(com.artipie.http.hm.RsHasBody) ArtipieProperties(com.artipie.misc.ArtipieProperties) JsonContains(wtf.g4s8.hamcrest.json.JsonContains) IsJson(com.artipie.IsJson) JsonHas(wtf.g4s8.hamcrest.json.JsonHas) JsonValueIs(wtf.g4s8.hamcrest.json.JsonValueIs) Test(org.junit.jupiter.api.Test)

Example 27 with RsHasStatus

use of com.artipie.http.hm.RsHasStatus in project artipie by artipie.

the class MetricSliceTest method shouldReturnMetricsInJsonArray.

@Test
void shouldReturnMetricsInJsonArray() {
    final String keyone = "one";
    final String keytwo = "two";
    final String json = "[{\"key\":\"%s\",\"value\":%s},{\"key\":\"%s\",\"value\":%s}]";
    final long valone = 1;
    final long valtwo = 2;
    final String dirorder = String.format(json, keyone, valone, keytwo, valtwo);
    final String revorder = String.format(json, keytwo, valtwo, keyone, valone);
    final Storage storage = new InMemoryStorage();
    storage.save(new Key.From(keyone), this.getContent(valone));
    storage.save(new Key.From(keytwo), this.getContent(valtwo));
    MatcherAssert.assertThat(new MetricSlice(storage), new SliceHasResponse(new AllOf<>(Arrays.asList(new RsHasStatus(RsStatus.OK), new AnyOf<>(Arrays.asList(new RsHasBody(dirorder, StandardCharsets.UTF_8), new RsHasBody(revorder, StandardCharsets.UTF_8))))), new RequestLine(RqMethod.GET, "/api/repositories/")));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) AnyOf(org.hamcrest.core.AnyOf) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) RequestLine(com.artipie.http.rq.RequestLine) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) RsHasBody(com.artipie.http.hm.RsHasBody) Key(com.artipie.asto.Key) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test)

Aggregations

RsHasStatus (com.artipie.http.hm.RsHasStatus)27 Test (org.junit.jupiter.api.Test)23 RequestLine (com.artipie.http.rq.RequestLine)20 SliceHasResponse (com.artipie.http.hm.SliceHasResponse)15 RsWithStatus (com.artipie.http.rs.RsWithStatus)10 Content (com.artipie.asto.Content)9 Key (com.artipie.asto.Key)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 RsStatus (com.artipie.http.rs.RsStatus)8 SliceSimple (com.artipie.http.slice.SliceSimple)7 Storage (com.artipie.asto.Storage)6 ContentIs (com.artipie.asto.test.ContentIs)6 MetadataXml (com.artipie.maven.MetadataXml)6 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)5 RsHasBody (com.artipie.http.hm.RsHasBody)5 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)4 Slice (com.artipie.http.Slice)4 BasicAuthSlice (com.artipie.http.auth.BasicAuthSlice)4 Permission (com.artipie.http.auth.Permission)4 Authorization (com.artipie.http.headers.Authorization)4