@Test public void calculateWeightedPenaltyFailure() { String expectedMessage = "Task priority %s is out of range. " + "A valid priority value must be between 0 (inclusive) " + " and 10 (inclusive)"; Stream.of(-2, -1, 11, 12).forEach(priority -> { Assertions.assertThatThrownBy(() -> { PriorityHelper.calculateWeightedPenalty(priority, 1234); }).hasMessage(String.format(expectedMessage, priority)); }); }
public static int calculateWeightedPenalty(int priority, int endTime) { assertValue(priority); return -(11 - priority) * endTime; }
PriorityHelper { public static int calculateWeightedPenalty(int priority, int endTime) { assertValue(priority); return -(11 - priority) * endTime; } }
PriorityHelper { public static int calculateWeightedPenalty(int priority, int endTime) { assertValue(priority); return -(11 - priority) * endTime; } private  PriorityHelper(); }
PriorityHelper { public static int calculateWeightedPenalty(int priority, int endTime) { assertValue(priority); return -(11 - priority) * endTime; } private  PriorityHelper(); static boolean isHighLevel(int priority); static boolean isMediumLevel(int priority); static boolean isLowLevel(int priority); static int calculateWeightedPenalty(int priority, int endTime); }
PriorityHelper { public static int calculateWeightedPenalty(int priority, int endTime) { assertValue(priority); return -(11 - priority) * endTime; } private  PriorityHelper(); static boolean isHighLevel(int priority); static boolean isMediumLevel(int priority); static boolean isLowLevel(int priority); static int calculateWeightedPenalty(int priority, int endTime);  }