ResourceService extends Service { @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") }) public List<ResourceDto> getAvailableResources(@PathParam("accountId") String accountId) throws NotFoundException, ServerException { return resourceManager .getAvailableResources(accountId) .stream() .map(DtoConverter::asDto) .collect(Collectors.toList()); } @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 shouldReturnAvailableResourcesForGivenAccount() throws Exception { doReturn(singletonList(resource)).when(resourceManager).getAvailableResources(any()); final Response response = given() .auth() .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD) .contentType("application/json") .when() .get(SECURE_PATH + "/resource/account123/available"); assertEquals(response.statusCode(), 200); verify(resourceManager).getAvailableResources(eq("account123")); final List<ResourceDto> resources = unwrapDtoList(response, ResourceDto.class); assertEquals(resources.size(), 1); final ResourceDto fetchedResource = resources.get(0); assertEquals(fetchedResource.getType(), RESOURCE_TYPE); assertEquals(new Long(fetchedResource.getAmount()), RESOURCE_AMOUNT); assertEquals(fetchedResource.getUnit(), RESOURCE_UNIT); }