RootServiceResponseFactory extends
    AbstractRootServiceResponseFactory { @Override public Set<RootServiceResponse> getRootServices(RootServiceRequest request) throws ObjectNotFoundException { Set<RootServiceResponse> response; String serviceName = null; if (request != null) serviceName = request.getServiceName(); if (serviceName != null) { Services service; try { service = Services.valueOf(serviceName); } catch (IllegalArgumentException ex) { throw new ObjectNotFoundException("Root service name: " + serviceName); } response = Collections.singleton(new RootServiceResponse(service.toString())); } else { response = new HashSet<RootServiceResponse>(); for (Services service: Services.values()) response.add(new RootServiceResponse(service.toString())); } return response; }  @Override Set<RootServiceResponse> getRootServices(RootServiceRequest request); @Override Set<RootServiceComponentResponse> getRootServiceComponents(
      RootServiceComponentRequest request); @Override Set<RootServiceHostComponentResponse> getRootServiceHostComponent(RootServiceHostComponentRequest request, Set<HostResponse> hosts); static final String NOT_APPLICABLE; }
@Test public void testGetRootServices() throws Exception { RootServiceRequest request = new RootServiceRequest(null); Set<RootServiceResponse> rootServices = responseFactory.getRootServices(request); assertEquals(RootServiceResponseFactory.Services.values().length, rootServices.size()); request = null; rootServices = responseFactory.getRootServices(request); assertEquals(RootServiceResponseFactory.Services.values().length, rootServices.size()); try { request = new RootServiceRequest("XXX"); rootServices = responseFactory.getRootServices(request); } catch (Exception e) { assertTrue(e instanceof ObjectNotFoundException); } request = new RootServiceRequest( RootServiceResponseFactory.Services.AMBARI.name()); rootServices = responseFactory.getRootServices(request); assertEquals(1, rootServices.size()); assertTrue(rootServices.contains(new RootServiceResponse( RootServiceResponseFactory.Services.AMBARI.name()))); }