@Test public void whenGenerateEmployees_thenEmployeesGetSaved() { employeeGeneratorService.resetEmployees(3L); verify(employeeGeneratorCleaner).deleteAll(); verify(employeeRepositoryMock, times(3)).save(any(Employee.class)); }
@Transactional public void resetEmployees(Long numberOfEmployees) { if (numberOfEmployees < 1 || numberOfEmployees > MAX_GENERATED_EMPLOYEES) { throw new IllegalArgumentException("The number of generated employees must be between 1 and " + MAX_GENERATED_EMPLOYEES); } deleteEmployeesAndEverythingRelated(); generateNewEmployees(numberOfEmployees); }
EmployeeGeneratorService { @Transactional public void resetEmployees(Long numberOfEmployees) { if (numberOfEmployees < 1 || numberOfEmployees > MAX_GENERATED_EMPLOYEES) { throw new IllegalArgumentException("The number of generated employees must be between 1 and " + MAX_GENERATED_EMPLOYEES); } deleteEmployeesAndEverythingRelated(); generateNewEmployees(numberOfEmployees); } }
EmployeeGeneratorService { @Transactional public void resetEmployees(Long numberOfEmployees) { if (numberOfEmployees < 1 || numberOfEmployees > MAX_GENERATED_EMPLOYEES) { throw new IllegalArgumentException("The number of generated employees must be between 1 and " + MAX_GENERATED_EMPLOYEES); } deleteEmployeesAndEverythingRelated(); generateNewEmployees(numberOfEmployees); }  }
EmployeeGeneratorService { @Transactional public void resetEmployees(Long numberOfEmployees) { if (numberOfEmployees < 1 || numberOfEmployees > MAX_GENERATED_EMPLOYEES) { throw new IllegalArgumentException("The number of generated employees must be between 1 and " + MAX_GENERATED_EMPLOYEES); } deleteEmployeesAndEverythingRelated(); generateNewEmployees(numberOfEmployees); }  @Transactional void resetEmployees(Long numberOfEmployees); }
EmployeeGeneratorService { @Transactional public void resetEmployees(Long numberOfEmployees) { if (numberOfEmployees < 1 || numberOfEmployees > MAX_GENERATED_EMPLOYEES) { throw new IllegalArgumentException("The number of generated employees must be between 1 and " + MAX_GENERATED_EMPLOYEES); } deleteEmployeesAndEverythingRelated(); generateNewEmployees(numberOfEmployees); }  @Transactional void resetEmployees(Long numberOfEmployees); static final Long MAX_GENERATED_EMPLOYEES; }