ResourceService extends Service { @GET @Path("{accountId}/details") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get detailed information about resources for given account", response = ResourcesDetailsDto.class) @ApiResponses({ @ApiResponse(code = 200, message = "The resources details successfully fetched"), @ApiResponse(code = 404, message = "Account with specified id was not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public ResourcesDetailsDto getResourceDetails( @ApiParam("Account id") @PathParam("accountId") String accountId) throws NotFoundException, ServerException { return asDto(resourceManager.getResourceDetails(accountId)); } @Inject  ResourceService(ResourceManager resourceManager); @GET @Path("/{accountId}") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get list of resources which are available for given account", response = ResourceDto.class, responseContainer = "List") @ApiResponses({ @ApiResponse(code = 200, message = "The total resources are successfully fetched"), @ApiResponse(code = 404, message = "Account with specified id was not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) List<ResourceDto> getTotalResources(
      @ApiParam("Account id") @PathParam("accountId") String accountId); @GET @Path("/{accountId}/available") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get list of resources which are available for usage by given account", response = ResourceDto.class, responseContainer = "List") @ApiResponses({ @ApiResponse(code = 200, message = "The available resources are successfully fetched"), @ApiResponse(code = 404, message = "Account with specified id was not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) List<ResourceDto> getAvailableResources(@PathParam("accountId") String accountId); @GET @Path("/{accountId}/used") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get list of resources which are used by given account", response = ResourceDto.class, responseContainer = "List") @ApiResponses({ @ApiResponse(code = 200, message = "The used resources are successfully fetched"), @ApiResponse(code = 404, message = "Account with specified id was not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) List<ResourceDto> getUsedResources(@PathParam("accountId") String accountId); @GET @Path("{accountId}/details") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get detailed information about resources for given account", response = ResourcesDetailsDto.class) @ApiResponses({ @ApiResponse(code = 200, message = "The resources details successfully fetched"), @ApiResponse(code = 404, message = "Account with specified id was not found"), @ApiResponse(code = 500, message = "Internal server error occurred") }) ResourcesDetailsDto getResourceDetails(
      @ApiParam("Account id") @PathParam("accountId") String accountId);  }
@Test public void testGetsResourceDetails() throws Exception { final ResourceDto testResource = DtoFactory.newDto(ResourceDto.class).withType("test").withAmount(1234).withUnit("mb"); final ResourcesDetailsDto toFetch = DtoFactory.newDto(ResourcesDetailsDto.class) .withAccountId("account123") .withProvidedResources( singletonList( DtoFactory.newDto(ProvidedResourcesDto.class) .withId("resource123") .withProviderId("provider") .withOwner("account123") .withStartTime(123L) .withEndTime(321L) .withResources(singletonList(testResource)))) .withTotalResources(singletonList(testResource)); when(resourceManager.getResourceDetails(eq("account123"))) .thenReturn(new ResourcesDetailsImpl(toFetch)); final Response response = given() .auth() .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD) .contentType("application/json") .when() .expect() .statusCode(200) .get(SECURE_PATH + "/resource/account123/details"); final ResourcesDetailsDto resourceDetailsDto = DtoFactory.getInstance() .createDtoFromJson(response.body().print(), ResourcesDetailsDto.class); assertEquals(resourceDetailsDto, toFetch); verify(resourceManager).getResourceDetails("account123"); }