@Test public void givenValidTaxTo_whenSubmitTaxForm_ThenALogLineIsCreatedWithStatusOk() throws JsonProcessingException { taxController.submitTaxForm(taxTo); verify(taxLogger, times(1)).log(employeeId, amount, "OK"); }
@RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode) throws JsonProcessingException { if(isNotValid(jsonNode)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (specialEmployeesService.isEmployeeBlacklisted(getEmployeeId(jsonNode))) { taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_FAIL); return new ResponseEntity<>(createResponse(RESPONSE_BODY_FAIL), HttpStatus.INTERNAL_SERVER_ERROR); } else { specialEmployeesService.sleepIfNecessary(getEmployeeId(jsonNode)); taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_SUCCESS); return new ResponseEntity<>(createResponse(RESPONSE_BODY_SUCCESS), HttpStatus.OK); } }
TaxController { @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode) throws JsonProcessingException { if(isNotValid(jsonNode)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (specialEmployeesService.isEmployeeBlacklisted(getEmployeeId(jsonNode))) { taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_FAIL); return new ResponseEntity<>(createResponse(RESPONSE_BODY_FAIL), HttpStatus.INTERNAL_SERVER_ERROR); } else { specialEmployeesService.sleepIfNecessary(getEmployeeId(jsonNode)); taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_SUCCESS); return new ResponseEntity<>(createResponse(RESPONSE_BODY_SUCCESS), HttpStatus.OK); } } }
TaxController { @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode) throws JsonProcessingException { if(isNotValid(jsonNode)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (specialEmployeesService.isEmployeeBlacklisted(getEmployeeId(jsonNode))) { taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_FAIL); return new ResponseEntity<>(createResponse(RESPONSE_BODY_FAIL), HttpStatus.INTERNAL_SERVER_ERROR); } else { specialEmployeesService.sleepIfNecessary(getEmployeeId(jsonNode)); taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_SUCCESS); return new ResponseEntity<>(createResponse(RESPONSE_BODY_SUCCESS), HttpStatus.OK); } }  }
TaxController { @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode) throws JsonProcessingException { if(isNotValid(jsonNode)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (specialEmployeesService.isEmployeeBlacklisted(getEmployeeId(jsonNode))) { taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_FAIL); return new ResponseEntity<>(createResponse(RESPONSE_BODY_FAIL), HttpStatus.INTERNAL_SERVER_ERROR); } else { specialEmployeesService.sleepIfNecessary(getEmployeeId(jsonNode)); taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_SUCCESS); return new ResponseEntity<>(createResponse(RESPONSE_BODY_SUCCESS), HttpStatus.OK); } }  @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode); @RequestMapping(value = "/taxservice", method = GET) @ResponseBody String getWebServiceLog(HttpServletResponse response); @RequestMapping(value = "/reset", method = POST) ResponseEntity resetSpecialEmployeesService(); }
TaxController { @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode) throws JsonProcessingException { if(isNotValid(jsonNode)) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } if (specialEmployeesService.isEmployeeBlacklisted(getEmployeeId(jsonNode))) { taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_FAIL); return new ResponseEntity<>(createResponse(RESPONSE_BODY_FAIL), HttpStatus.INTERNAL_SERVER_ERROR); } else { specialEmployeesService.sleepIfNecessary(getEmployeeId(jsonNode)); taxLogger.log(getEmployeeId(jsonNode), getTaxAmount(jsonNode), RESPONSE_BODY_SUCCESS); return new ResponseEntity<>(createResponse(RESPONSE_BODY_SUCCESS), HttpStatus.OK); } }  @RequestMapping(value = "/taxservice", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody ResponseEntity<JsonNode> submitTaxForm(@RequestBody JsonNode jsonNode); @RequestMapping(value = "/taxservice", method = GET) @ResponseBody String getWebServiceLog(HttpServletResponse response); @RequestMapping(value = "/reset", method = POST) ResponseEntity resetSpecialEmployeesService(); static final String RESPONSE_BODY_SUCCESS; static final String RESPONSE_BODY_FAIL; static final String EMPLOYEE_ID; static final String AMOUNT; }