@Test(expected = IllegalArgumentException.class) public void whenGenerateTooManyEmployees_thenThrowException() { employeeGeneratorService.resetEmployees(TEST_MAX_GENERATED_EMPLOYEES); }
@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; }