### Question:
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) { RootService service; try { service = RootService.valueOf(serviceName); } catch (IllegalArgumentException ex) { throw new ObjectNotFoundException("Root service name: " + serviceName); } response = Collections.singleton(new RootServiceResponse(service.toString())); } else { response = new HashSet<>(); for (RootService service: RootService.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; }### Answer:
@Test public void getReturnsAllServicesForNullServiceName() throws Exception { RootServiceRequest request = new RootServiceRequest(null); Set<RootServiceResponse> rootServices = responseFactory.getRootServices(request); assertEquals(RootService.values().length, rootServices.size()); }
@Test public void getReturnsAllServicesForNullRequest() throws Exception { Set<RootServiceResponse> rootServices = responseFactory.getRootServices(null); assertEquals(RootService.values().length, rootServices.size()); }
@Test(expected = ObjectNotFoundException.class) public void getThrowsForNonExistentService() throws Exception { RootServiceRequest request = new RootServiceRequest("XXX"); responseFactory.getRootServices(request); }
@Test public void getReturnsSingleServiceForValidServiceName() throws Exception { RootServiceRequest request = new RootServiceRequest(AMBARI.name()); Set<RootServiceResponse> rootServices = responseFactory.getRootServices(request); assertEquals(Collections.singleton(new RootServiceResponse(AMBARI.name())), rootServices); }