use of co.cask.cdap.internal.app.ServiceSpecificationCodec in project cdap by caskdata.
the class ProgramLifecycleHttpHandlerTest method testServiceSpecification.
@Test
public void testServiceSpecification() throws Exception {
deploy(AppWithServices.class);
HttpResponse response = doGet("/v3/namespaces/default/apps/AppWithServices/services/NoOpService");
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
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.assertTrue(returnedEndpoints.equals(expectedEndpoints));
}
Aggregations