@Test public void getThreeLastEcoNewsTest() throws Exception { mockMvc.perform(get(ecoNewsLink + "/newest")) .andExpect(status().isOk()); verify(ecoNewsService).getThreeLastEcoNews(); }
@ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") public ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews() { return ResponseEntity.status(HttpStatus.OK).body(ecoNewsService.getThreeLastEcoNews()); }
EcoNewsController { @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") public ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews() { return ResponseEntity.status(HttpStatus.OK).body(ecoNewsService.getThreeLastEcoNews()); } }
EcoNewsController { @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") public ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews() { return ResponseEntity.status(HttpStatus.OK).body(ecoNewsService.getThreeLastEcoNews()); }  }
EcoNewsController { @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") public ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews() { return ResponseEntity.status(HttpStatus.OK).body(ecoNewsService.getThreeLastEcoNews()); }  @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews(); @ApiOperation(value = "Add new eco news.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = AddEcoNewsDtoResponse.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping(consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<AddEcoNewsDtoResponse> save(
            @ApiParam(value = "Add Eco News Request", required = true)
            @RequestPart @ValidEcoNewsDtoRequest AddEcoNewsDtoRequest addEcoNewsDtoRequest,
            @ApiParam(value = "Image of eco news")
            @ImageValidation
            @RequestPart(required = false) MultipartFile image,
            @ApiIgnore Principal principal); @ApiOperation(value = "Get eco news by id.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/{id}") ResponseEntity<EcoNewsDto> getEcoNewsById(@PathVariable Long id); @ApiOperation(value = "Find all eco news by page.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("") @ApiPageable ResponseEntity<PageableDto<EcoNewsDto>> findAll(@ApiIgnore Pageable page); @ApiOperation(value = "Delete eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @DeleteMapping("/{econewsId}") ResponseEntity<Object> delete(@PathVariable Long econewsId); @ApiOperation(value = "Get eco news by tags") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/tags") @ApiPageable ResponseEntity<PageableDto<EcoNewsDto>> getEcoNews(
            @ApiIgnore Pageable page,
            @ApiParam(value = "Tags to filter (if do not input tags get all)")
            @RequestParam(required = false) List<String> tags
    ); @ApiOperation(value = "Get three recommended eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/recommended") ResponseEntity<List<EcoNewsDto>> getThreeRecommendedEcoNews(
            @RequestParam(required = true) Long openedEcoNewsId

    ); @ApiOperation(value = "Find all eco news tags") @GetMapping("/tags/all") ResponseEntity<List<String>> findAllEcoNewsTags(); }
EcoNewsController { @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") public ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews() { return ResponseEntity.status(HttpStatus.OK).body(ecoNewsService.getThreeLastEcoNews()); }  @ApiOperation(value = "Get three last eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/newest") ResponseEntity<List<EcoNewsDto>> getThreeLastEcoNews(); @ApiOperation(value = "Add new eco news.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = AddEcoNewsDtoResponse.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping(consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<AddEcoNewsDtoResponse> save(
            @ApiParam(value = "Add Eco News Request", required = true)
            @RequestPart @ValidEcoNewsDtoRequest AddEcoNewsDtoRequest addEcoNewsDtoRequest,
            @ApiParam(value = "Image of eco news")
            @ImageValidation
            @RequestPart(required = false) MultipartFile image,
            @ApiIgnore Principal principal); @ApiOperation(value = "Get eco news by id.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/{id}") ResponseEntity<EcoNewsDto> getEcoNewsById(@PathVariable Long id); @ApiOperation(value = "Find all eco news by page.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("") @ApiPageable ResponseEntity<PageableDto<EcoNewsDto>> findAll(@ApiIgnore Pageable page); @ApiOperation(value = "Delete eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @DeleteMapping("/{econewsId}") ResponseEntity<Object> delete(@PathVariable Long econewsId); @ApiOperation(value = "Get eco news by tags") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/tags") @ApiPageable ResponseEntity<PageableDto<EcoNewsDto>> getEcoNews(
            @ApiIgnore Pageable page,
            @ApiParam(value = "Tags to filter (if do not input tags get all)")
            @RequestParam(required = false) List<String> tags
    ); @ApiOperation(value = "Get three recommended eco news.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/recommended") ResponseEntity<List<EcoNewsDto>> getThreeRecommendedEcoNews(
            @RequestParam(required = true) Long openedEcoNewsId

    ); @ApiOperation(value = "Find all eco news tags") @GetMapping("/tags/all") ResponseEntity<List<String>> findAllEcoNewsTags();  }