use of org.eclipse.che.api.core.rest.shared.dto.ServiceDescriptor in project che by eclipse.
the class RemoteServiceDescriptorTest method shouldBeAbleToReturnServiceDescriptors.
@Test
public void shouldBeAbleToReturnServiceDescriptors() throws Exception {
remoteServiceDescriptor = new RemoteServiceDescriptor(serverUrl + SERVICE_PATH, requestFactory);
final ServiceDescriptor serviceDescriptor = remoteServiceDescriptor.getServiceDescriptor();
assertNotNull(serviceDescriptor);
assertEquals(serviceDescriptor.getHref(), serverUrl + SERVICE_PATH);
assertEquals(serviceDescriptor.getDescription(), SERVICE_DESCRIPTION);
assertEquals(serviceDescriptor.getLinks().size(), 1);
}
use of org.eclipse.che.api.core.rest.shared.dto.ServiceDescriptor in project che by eclipse.
the class Service method generateServiceDescriptor.
private ServiceDescriptor generateServiceDescriptor(UriInfo uriInfo, Class<? extends Service> service) {
final List<Link> links = new ArrayList<>();
for (Method method : service.getMethods()) {
final GenerateLink generateLink = method.getAnnotation(GenerateLink.class);
if (generateLink != null) {
try {
links.add(generateLinkForMethod(uriInfo, generateLink.rel(), method));
} catch (RuntimeException ignored) {
}
}
}
final Description description = service.getAnnotation(Description.class);
final ServiceDescriptor dto = createServiceDescriptor().withHref(uriInfo.getRequestUriBuilder().replaceQuery(null).build().toString()).withLinks(links).withVersion(Constants.API_VERSION);
if (description != null) {
dto.setDescription(description.value());
}
return dto;
}
use of org.eclipse.che.api.core.rest.shared.dto.ServiceDescriptor in project che by eclipse.
the class ServiceDescriptorTest method getDescriptor.
private ServiceDescriptor getDescriptor() throws Exception {
String path = SERVICE_URI;
ContainerResponse response = launcher.service(HttpMethod.OPTIONS, path, BASE_URI, null, null, null, null);
Assert.assertEquals(response.getStatus(), 200);
return (ServiceDescriptor) response.getEntity();
}
Aggregations