InstanceResource { @GET @Path("/{instanceId}/serviceStatusInfo") @Produces(MediaType.APPLICATION_JSON) public ServiceStatusInfo getServiceStatus( @PathParam("instanceId") String instanceId, @QueryParam("clusterId") String clusterIdString, @QueryParam("serviceType") String serviceTypeString, @QueryParam("configId") String configIdString) { ApplicationInstanceReference reference = parseInstanceId(instanceId); ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference); if (clusterIdString == null) { throwBadRequest("Missing clusterId query parameter"); } if (serviceTypeString == null) { throwBadRequest("Missing serviceType query parameter"); } if (configIdString == null) { throwBadRequest("Missing configId query parameter"); } ClusterId clusterId = new ClusterId(clusterIdString); ServiceType serviceType = new ServiceType(serviceTypeString); ConfigId configId = new ConfigId(configIdString); return rootManager.getStatus(applicationId, clusterId, serviceType, configId); } @Inject  InstanceResource(@Component ServiceMonitor serviceMonitor,
                            @Component StatusService statusService,
                            @Component SlobrokApi slobrokApi,
                            @Component UnionMonitorManager rootManager); @GET @Produces(MediaType.APPLICATION_JSON) List<ApplicationInstanceReference> getAllInstances(); @GET @Path("/{instanceId}") @Produces(MediaType.APPLICATION_JSON) InstanceStatusResponse getInstance(@PathParam("instanceId") String instanceIdString); @GET @Path("/{instanceId}/slobrok") @Produces(MediaType.APPLICATION_JSON) List<SlobrokEntryResponse> getSlobrokEntries(
            @PathParam("instanceId") String instanceId,
            @QueryParam("pattern") String pattern); @GET @Path("/{instanceId}/serviceStatusInfo") @Produces(MediaType.APPLICATION_JSON) ServiceStatusInfo getServiceStatus(
            @PathParam("instanceId") String instanceId,
            @QueryParam("clusterId") String clusterIdString,
            @QueryParam("serviceType") String serviceTypeString,
            @QueryParam("configId") String configIdString); static final String DEFAULT_SLOBROK_PATTERN; }
@Test public void testGetServiceStatusInfo() { ServiceType serviceType = new ServiceType("serviceType"); ConfigId configId = new ConfigId("configId"); ServiceStatus serviceStatus = ServiceStatus.UP; when(rootManager.getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId)) .thenReturn(new ServiceStatusInfo(serviceStatus)); ServiceStatus actualServiceStatus = resource.getServiceStatus( APPLICATION_INSTANCE_REFERENCE, CLUSTER_ID.s(), serviceType.s(), configId.s()).serviceStatus(); verify(rootManager).getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId); assertEquals(serviceStatus, actualServiceStatus); }
@Test(expected = WebApplicationException.class) public void testBadRequest() { resource.getServiceStatus(APPLICATION_INSTANCE_REFERENCE, CLUSTER_ID.s(), null, null); }