@Test public void updateTest() throws Exception { when(habitStatisticService.update(anyLong(), any(UpdateHabitStatisticDto.class))) .thenReturn(new UpdateHabitStatisticDto()); mockMvc.perform(patch(habitStatisticLink + "/{habitStatisticId}", 1) .content("{\n" + " \"amountOfItems\": 0,\n" + " \"habitRate\": \"DEFAULT\",\n" + " \"id\": 0\n" + "}") .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); verify(habitStatisticService, times(1)).update(anyLong(), any(UpdateHabitStatisticDto.class)); }
@ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") public ResponseEntity<UpdateHabitStatisticDto> update( @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto) { return ResponseEntity.status(HttpStatus.OK).body(habitStatisticService .update(habitStatisticId, habitStatisticForUpdateDto)); }
HabitStatisticController { @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") public ResponseEntity<UpdateHabitStatisticDto> update( @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto) { return ResponseEntity.status(HttpStatus.OK).body(habitStatisticService .update(habitStatisticId, habitStatisticForUpdateDto)); } }
HabitStatisticController { @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") public ResponseEntity<UpdateHabitStatisticDto> update( @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto) { return ResponseEntity.status(HttpStatus.OK).body(habitStatisticService .update(habitStatisticId, habitStatisticForUpdateDto)); }  }
HabitStatisticController { @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") public ResponseEntity<UpdateHabitStatisticDto> update( @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto) { return ResponseEntity.status(HttpStatus.OK).body(habitStatisticService .update(habitStatisticId, habitStatisticForUpdateDto)); }  @ApiOperation(value = "Add habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = AddHabitStatisticDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/statistic/") ResponseEntity<Object> save(@Valid @RequestBody AddHabitStatisticDto addHabitStatisticDto); @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") ResponseEntity<UpdateHabitStatisticDto> update(
        @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto); @ApiOperation(value = "Find statistic by habit id.") @GetMapping("/statistic/{habitId}") ResponseEntity<List<HabitStatisticDto>> findAllByHabitId(
        @PathVariable Long habitId); @ApiOperation(value = "Get today's statistic for all habit items") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = List.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/statistic/todayStatisticsForAllHabitItems") ResponseEntity<List<HabitItemsAmountStatisticDto>> getTodayStatisticsForAllHabitItems(
        @ApiParam(value = "Requested language code")
        @RequestParam(defaultValue = "en") String language
    ); }
HabitStatisticController { @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") public ResponseEntity<UpdateHabitStatisticDto> update( @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto) { return ResponseEntity.status(HttpStatus.OK).body(habitStatisticService .update(habitStatisticId, habitStatisticForUpdateDto)); }  @ApiOperation(value = "Add habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = AddHabitStatisticDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/statistic/") ResponseEntity<Object> save(@Valid @RequestBody AddHabitStatisticDto addHabitStatisticDto); @ApiOperation(value = "Update habit statistic.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/statistic/{habitStatisticId}") ResponseEntity<UpdateHabitStatisticDto> update(
        @PathVariable Long habitStatisticId, @Valid @RequestBody UpdateHabitStatisticDto habitStatisticForUpdateDto); @ApiOperation(value = "Find statistic by habit id.") @GetMapping("/statistic/{habitId}") ResponseEntity<List<HabitStatisticDto>> findAllByHabitId(
        @PathVariable Long habitId); @ApiOperation(value = "Get today's statistic for all habit items") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = List.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/statistic/todayStatisticsForAllHabitItems") ResponseEntity<List<HabitItemsAmountStatisticDto>> getTodayStatisticsForAllHabitItems(
        @ApiParam(value = "Requested language code")
        @RequestParam(defaultValue = "en") String language
    );  }