ApplicationSlaManagementResource implements ApplicationSlaManagementEndpoint { @GET @Override public List<ApplicationSlaRepresentation> getApplicationSLAs(@QueryParam("extended") boolean extended, @QueryParam("schedulerName") String schedulerName) { List<ApplicationSlaRepresentation> result = new ArrayList<>(); String cellId = extended ? configuration.getCellName() : null; Map<String, ReservationUsage> usageMap = extended ? reservationUsageCalculator.buildUsage() : Collections.emptyMap(); Collection<ApplicationSLA> applicationSLAs; if (Strings.isNullOrEmpty(schedulerName)) { applicationSLAs = applicationSlaManagementService.getApplicationSLAs(); } else { applicationSLAs = applicationSlaManagementService.getApplicationSLAsForScheduler(schedulerName); } applicationSLAs.forEach(a -> result.add(asRepresentation(a, cellId, usageMap.get(a.getAppName())))); return result; } @Inject  ApplicationSlaManagementResource(MasterConfiguration configuration,
                                            ApplicationSlaManagementService applicationSlaManagementService,
                                            ReservationUsageCalculator reservationUsageCalculator); @GET @Override List<ApplicationSlaRepresentation> getApplicationSLAs(@QueryParam("extended") boolean extended, @QueryParam("schedulerName") String schedulerName); @GET @Path("/{applicationName}") @Override ApplicationSlaRepresentation getApplicationSLA(@PathParam("applicationName") String applicationName,
                                                          @QueryParam("extended") boolean extended); @POST @Override Response addApplicationSLA(ApplicationSlaRepresentation applicationSLA); @PUT @Path("/{applicationName}") @Override Response updateApplicationSLA(@PathParam("applicationName") String applicationName,
                                         ApplicationSlaRepresentation applicationSLA); @DELETE @Path("/{applicationName}") @Override Response removeApplicationSLA(@PathParam("applicationName") String applicationName);  }
@Test public void getAllApplications() { when(capacityManagementService.getApplicationSLAs()).thenReturn(Arrays.asList( ApplicationSlaSample.CriticalSmall.build(), ApplicationSlaSample.CriticalLarge.build() )); testClient.get().exchange() .expectStatus().isOk() .expectBody(APPLICATION_SLA_REP_LIST_TR).value(result -> assertThat(result).hasSize(2)); verify(capacityManagementService, times(1)).getApplicationSLAs(); }