Search in sources :

Example 6 with StyxObjectRecord

use of com.hotels.styx.StyxObjectRecord in project styx by ExpediaGroup.

the class ServiceProviderHandlerTest method returnsNoContentStatusWhenNoProvidersAvailable.

@Test
public void returnsNoContentStatusWhenNoProvidersAvailable() {
    StyxObjectStore<StyxObjectRecord<StyxService>> empty = new StyxObjectStore<>();
    ServiceProviderHandler handler = new ServiceProviderHandler(empty);
    HttpRequest request = HttpRequest.get("/admin/service/providers").build();
    HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
    assertThat(response.status(), equalTo(NO_CONTENT));
    assertFalse(response.contentLength().isPresent());
}
Also used : StyxObjectRecord(com.hotels.styx.StyxObjectRecord) HttpRequest(com.hotels.styx.api.HttpRequest) StyxObjectStore(com.hotels.styx.routing.db.StyxObjectStore) HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 7 with StyxObjectRecord

use of com.hotels.styx.StyxObjectRecord in project styx by ExpediaGroup.

the class ServiceProviderHandlerTest method returnsNamedProvider.

@Test
public void returnsNamedProvider() throws IOException {
    StyxObjectStore<StyxObjectRecord<StyxService>> store = createTestStore();
    ServiceProviderHandler handler = new ServiceProviderHandler(store);
    HttpRequest request = HttpRequest.get("/admin/service/provider/object2").build();
    HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
    assertThat(response.status(), equalTo(OK));
    StyxObjectDefinition actualProvider = deserialiseProvider(response.bodyAs(UTF_8));
    assertThat(actualProvider, notNullValue());
    assertThat(actualProvider.name(), equalTo("object2"));
    validateProvider(actualProvider, store.get("object2").get());
}
Also used : StyxObjectRecord(com.hotels.styx.StyxObjectRecord) HttpRequest(com.hotels.styx.api.HttpRequest) HttpResponse(com.hotels.styx.api.HttpResponse) StyxObjectDefinition(com.hotels.styx.routing.config.StyxObjectDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

StyxObjectRecord (com.hotels.styx.StyxObjectRecord)7 HttpResponse (com.hotels.styx.api.HttpResponse)6 Test (org.junit.jupiter.api.Test)6 HttpRequest (com.hotels.styx.api.HttpRequest)5 StyxObjectStore (com.hotels.styx.routing.db.StyxObjectStore)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 StyxObjectDefinition (com.hotels.styx.routing.config.StyxObjectDefinition)2 StyxService (com.hotels.styx.api.extension.service.spi.StyxService)1 HashSet (java.util.HashSet)1