use of io.cdap.cdap.internal.app.ServiceSpecificationCodec in project cdap by caskdata.
the class ProgramLifecycleHttpHandlerTest method testServiceSpecification.
@Test
public void testServiceSpecification() throws Exception {
deploy(AppWithServices.class, 200);
HttpResponse response = doGet("/v3/namespaces/default/apps/AppWithServices/services/NoOpService");
Assert.assertEquals(200, response.getResponseCode());
Set<ServiceHttpEndpoint> expectedEndpoints = ImmutableSet.of(new ServiceHttpEndpoint("GET", "/ping"), new ServiceHttpEndpoint("POST", "/multi"), new ServiceHttpEndpoint("GET", "/multi"), new ServiceHttpEndpoint("GET", "/multi/ping"));
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(ServiceSpecification.class, new ServiceSpecificationCodec());
Gson gson = gsonBuilder.create();
ServiceSpecification specification = readResponse(response, ServiceSpecification.class, gson);
Set<ServiceHttpEndpoint> returnedEndpoints = new HashSet<>();
for (HttpServiceHandlerSpecification httpServiceHandlerSpecification : specification.getHandlers().values()) {
returnedEndpoints.addAll(httpServiceHandlerSpecification.getEndpoints());
}
Assert.assertEquals("NoOpService", specification.getName());
Assert.assertEquals(returnedEndpoints, expectedEndpoints);
}
Aggregations