@Test public void testGetEmployeeTaxes() throws Exception { long employeeId = 12L; int year = 2012; int month = 2; Money tax = Money.of(CurrencyUnit.EUR, 10); Employee employee = new Employee(); MonthlyTaxForEmployee taxCalculation = MonthlyTaxForEmployee.from(employee, year, month, tax, (String)null); when(employeeServiceMock.getEmployee(employeeId)).thenReturn(employee); when(employeeServiceMock.getEmployeeTaxes(employeeId)).thenReturn(asList(taxCalculation)); List<EmployeeTaxTo> employeeTaxes = employeeRestController.getEmployeeTaxes(employeeId); assertThat(employeeTaxes).hasSize(1); assertThat(employeeTaxes.get(0).getStatus()).isEqualTo("IN PROGRESS"); assertThat(employeeTaxes.get(0).getYear()).isEqualTo(year); assertThat(employeeTaxes.get(0).getMonth()).isEqualTo(month); assertThat(employeeTaxes.get(0).getTax()).isEqualTo(tax); verify(employeeServiceMock).getEmployee(employeeId); verify(employeeServiceMock).getEmployeeTaxes(employeeId); verify(monthlyTaxForEmployeeRepository).find(employee, year, month); }
@RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody public List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId) { Employee employee = employeeService.getEmployee(employeeId); List<MonthlyTaxForEmployee> employeeTaxes = employeeService.getEmployeeTaxes(employeeId); List<EmployeeTaxTo> employeeTaxTos = employeeTaxes .stream() .map(mapTaxCalculationToEmployeeTaxTo(employee)) .sorted(comparing(onMonth).reversed()) .collect(Collectors.toList()); return employeeTaxTos; }
EmployeeRestController { @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody public List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId) { Employee employee = employeeService.getEmployee(employeeId); List<MonthlyTaxForEmployee> employeeTaxes = employeeService.getEmployeeTaxes(employeeId); List<EmployeeTaxTo> employeeTaxTos = employeeTaxes .stream() .map(mapTaxCalculationToEmployeeTaxTo(employee)) .sorted(comparing(onMonth).reversed()) .collect(Collectors.toList()); return employeeTaxTos; } }
EmployeeRestController { @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody public List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId) { Employee employee = employeeService.getEmployee(employeeId); List<MonthlyTaxForEmployee> employeeTaxes = employeeService.getEmployeeTaxes(employeeId); List<EmployeeTaxTo> employeeTaxTos = employeeTaxes .stream() .map(mapTaxCalculationToEmployeeTaxTo(employee)) .sorted(comparing(onMonth).reversed()) .collect(Collectors.toList()); return employeeTaxTos; }  }
EmployeeRestController { @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody public List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId) { Employee employee = employeeService.getEmployee(employeeId); List<MonthlyTaxForEmployee> employeeTaxes = employeeService.getEmployeeTaxes(employeeId); List<EmployeeTaxTo> employeeTaxTos = employeeTaxes .stream() .map(mapTaxCalculationToEmployeeTaxTo(employee)) .sorted(comparing(onMonth).reversed()) .collect(Collectors.toList()); return employeeTaxTos; }  @RequestMapping(method = RequestMethod.GET) @ResponseBody List<EmployeeTo> getEmployees(@RequestParam int page, @RequestParam int pageSize); @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseBody long getEmployeeCount(); @RequestMapping(value = "/{employeeId}/details", method = RequestMethod.GET) @ResponseBody EmployeeTo getEmployeeDetails(@PathVariable(value = "employeeId") Long employeeId); @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId); }
EmployeeRestController { @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody public List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId) { Employee employee = employeeService.getEmployee(employeeId); List<MonthlyTaxForEmployee> employeeTaxes = employeeService.getEmployeeTaxes(employeeId); List<EmployeeTaxTo> employeeTaxTos = employeeTaxes .stream() .map(mapTaxCalculationToEmployeeTaxTo(employee)) .sorted(comparing(onMonth).reversed()) .collect(Collectors.toList()); return employeeTaxTos; }  @RequestMapping(method = RequestMethod.GET) @ResponseBody List<EmployeeTo> getEmployees(@RequestParam int page, @RequestParam int pageSize); @RequestMapping(value = "/count", method = RequestMethod.GET) @ResponseBody long getEmployeeCount(); @RequestMapping(value = "/{employeeId}/details", method = RequestMethod.GET) @ResponseBody EmployeeTo getEmployeeDetails(@PathVariable(value = "employeeId") Long employeeId); @RequestMapping(value = "/{employeeId}/taxes", method = RequestMethod.GET) @ResponseBody List<EmployeeTaxTo> getEmployeeTaxes(@PathVariable(value = "employeeId") Long employeeId);  }