BDD style
This commit is contained in:
parent
9e8f67ad03
commit
f2adeb5956
|
@ -16,7 +16,7 @@ class ShiftScheduleConstraintProviderUnitTest {
|
||||||
ShiftSchedule.class, Shift.class);
|
ShiftSchedule.class, Shift.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenTwoShiftsOnOneDay_thenPenalize() {
|
void givenTwoShiftsOnOneDay_whenApplyingAtMostOneShiftPerDayConstraint_thenPenalize() {
|
||||||
Employee ann = new Employee("Ann", null);
|
Employee ann = new Employee("Ann", null);
|
||||||
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::atMostOneShiftPerDay)
|
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::atMostOneShiftPerDay)
|
||||||
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), null, ann), new Shift(MONDAY.atTime(14, 0), MONDAY.atTime(22, 0), null, ann))
|
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), null, ann), new Shift(MONDAY.atTime(14, 0), MONDAY.atTime(22, 0), null, ann))
|
||||||
|
@ -26,7 +26,7 @@ class ShiftScheduleConstraintProviderUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenTwoShiftsOnDifferentDays_thenDoNotPenalize() {
|
void givenTwoShiftsOnDifferentDays_whenApplyingAtMostOneShiftPerDayConstraint_thenDoNotPenalize() {
|
||||||
Employee ann = new Employee("Ann", null);
|
Employee ann = new Employee("Ann", null);
|
||||||
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::atMostOneShiftPerDay)
|
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::atMostOneShiftPerDay)
|
||||||
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), null, ann), new Shift(TUESDAY.atTime(14, 0), TUESDAY.atTime(22, 0), null, ann))
|
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), null, ann), new Shift(TUESDAY.atTime(14, 0), TUESDAY.atTime(22, 0), null, ann))
|
||||||
|
@ -34,7 +34,7 @@ class ShiftScheduleConstraintProviderUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenEmployeeLacksRequiredSkill_thenPenalize() {
|
void givenEmployeeLacksRequiredSkill_whenApplyingRequiredSkillConstraint_thenPenalize() {
|
||||||
Employee ann = new Employee("Ann", Set.of("Waiter"));
|
Employee ann = new Employee("Ann", Set.of("Waiter"));
|
||||||
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::requiredSkill)
|
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::requiredSkill)
|
||||||
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), "Cook", ann))
|
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), "Cook", ann))
|
||||||
|
@ -42,7 +42,7 @@ class ShiftScheduleConstraintProviderUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenEmployeeHasRequiredSkill_thenDoNotPenalize() {
|
void givenEmployeeHasRequiredSkill_whenApplyingRequiredSkillConstraint_thenDoNotPenalize() {
|
||||||
Employee ann = new Employee("Ann", Set.of("Waiter"));
|
Employee ann = new Employee("Ann", Set.of("Waiter"));
|
||||||
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::requiredSkill)
|
constraintVerifier.verifyThat(ShiftScheduleConstraintProvider::requiredSkill)
|
||||||
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), "Waiter", ann))
|
.given(ann, new Shift(MONDAY.atTime(6, 0), MONDAY.atTime(14, 0), "Waiter", ann))
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class ShiftScheduleSolverUnitTest {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ShiftScheduleSolverUnitTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(ShiftScheduleSolverUnitTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSolve_thenScoreIsOptimalAndAllShiftsAssigned() {
|
public void given3Employees5Shifts_whenSolve_thenScoreIsOptimalAndAllShiftsAssigned() {
|
||||||
SolverFactory<ShiftSchedule> solverFactory = SolverFactory.create(new SolverConfig().withSolutionClass(ShiftSchedule.class)
|
SolverFactory<ShiftSchedule> solverFactory = SolverFactory.create(new SolverConfig().withSolutionClass(ShiftSchedule.class)
|
||||||
.withEntityClasses(Shift.class)
|
.withEntityClasses(Shift.class)
|
||||||
.withConstraintProviderClass(ShiftScheduleConstraintProvider.class)
|
.withConstraintProviderClass(ShiftScheduleConstraintProvider.class)
|
||||||
|
|
Loading…
Reference in New Issue