Services { @GET @Produces(MediaType.APPLICATION_JSON) public Response getServices() { return Response.ok() .entity(FluentIterable.from(serviceManagers) .transformAndConcat(input -> input.servicesByState().values()) .transform(SERVICE_TO_BEAN) .toList()) .build(); } @Inject  Services(
      @SchedulerActive ServiceManagerIface schedulerActiveServiceManager,
      @AppStartup ServiceManagerIface appStartupServiceManager); @GET @Produces(MediaType.APPLICATION_JSON) Response getServices();  }
@Test public void testGetServices() throws Exception { Service newService = createMock(Service.class); expect(newService.state()).andReturn(State.NEW); Service failedService = createMock(Service.class); expect(failedService.state()).andReturn(State.FAILED); Exception failureCause = new Exception(FAILURE_CAUSE_REASON); expect(failedService.failureCause()).andReturn(failureCause); Service runningService = createMock(Service.class); expect(runningService.state()).andReturn(State.RUNNING); expect(startupServiceManager.servicesByState()).andReturn( ImmutableMultimap.of( State.RUNNING, runningService, State.FAILED, failedService)); expect(activeServicesManager.servicesByState()) .andReturn(ImmutableMultimap.of(State.NEW, newService)); control.replay(); assertEquals( ImmutableList.of( ImmutableMap.of( "name", newService.getClass().getSimpleName(), "state", State.NEW), ImmutableMap.of( "name", failedService.getClass().getSimpleName(), "state", State.RUNNING), ImmutableMap.of( "name", failedService.getClass().getSimpleName(), "state", State.FAILED, "failureCause", failureCause.toString())), servicesServlet.getServices().getEntity()); }