Skip to content

Commit dee1d84

Browse files
committed
refactor: fix checkstyle
1 parent 9252fe6 commit dee1d84

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/main/java/com/thealgorithms/scheduling/SJFScheduling.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public void scheduleProcesses() {
5959
* processes
6060
*/
6161
private ProcessDetails findShortestJob(List<ProcessDetails> readyProcesses) {
62-
return readyProcesses.stream()
63-
.min(Comparator.comparingInt(ProcessDetails::getBurstTime))
64-
.orElse(null);
62+
return readyProcesses.stream().min(Comparator.comparingInt(ProcessDetails::getBurstTime)).orElse(null);
6563
}
6664

6765
/**

src/test/java/com/thealgorithms/scheduling/SJFSchedulingTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ class SJFSchedulingTest {
1515

1616
private static Stream<Arguments> schedulingTestData() {
1717
return Stream.of(Arguments.of(List.of(new ProcessDetails("1", 0, 6), new ProcessDetails("2", 1, 2)), List.of("1", "2")),
18-
Arguments.of(List.of(new ProcessDetails("1", 0, 6), new ProcessDetails("2", 1, 2), new ProcessDetails("3", 4, 3), new ProcessDetails("4", 3, 1), new ProcessDetails("5", 6, 4), new ProcessDetails("6", 5, 5)), List.of("1", "4", "2", "3", "5", "6")),
19-
Arguments.of(List.of(new ProcessDetails("1", 0, 3), new ProcessDetails("2", 1, 2), new ProcessDetails("3", 2, 1)), List.of("1", "3", "2")),
20-
Arguments.of(List.of(new ProcessDetails("1", 0, 3), new ProcessDetails("2", 5, 2), new ProcessDetails("3", 9, 1)), List.of("1", "2", "3")),
21-
Arguments.of(Collections.emptyList(), List.of()));
18+
Arguments.of(List.of(new ProcessDetails("1", 0, 6), new ProcessDetails("2", 1, 2), new ProcessDetails("3", 4, 3), new ProcessDetails("4", 3, 1), new ProcessDetails("5", 6, 4), new ProcessDetails("6", 5, 5)), List.of("1", "4", "2", "3", "5", "6")),
19+
Arguments.of(List.of(new ProcessDetails("1", 0, 3), new ProcessDetails("2", 1, 2), new ProcessDetails("3", 2, 1)), List.of("1", "3", "2")), Arguments.of(List.of(new ProcessDetails("1", 0, 3), new ProcessDetails("2", 5, 2), new ProcessDetails("3", 9, 1)), List.of("1", "2", "3")),
20+
Arguments.of(Collections.emptyList(), List.of()));
2221
}
2322

2423
@ParameterizedTest(name = "Test SJF schedule: {index}")
@@ -31,11 +30,10 @@ void testSJFScheduling(List<ProcessDetails> inputProcesses, List<String> expecte
3130

3231
@Test
3332
@DisplayName("Test sorting by arrival order")
34-
void testProcessArrivalOrderIsSorted() {List<ProcessDetails> processes = List.of(new ProcessDetails("1", 0, 6), new ProcessDetails("2", 1, 2), new ProcessDetails("4", 3, 1), new ProcessDetails("3", 4, 3), new ProcessDetails("6", 5, 5), new ProcessDetails("5", 6, 4));
33+
void testProcessArrivalOrderIsSorted() {
34+
List<ProcessDetails> processes = List.of(new ProcessDetails("1", 0, 6), new ProcessDetails("2", 1, 2), new ProcessDetails("4", 3, 1), new ProcessDetails("3", 4, 3), new ProcessDetails("6", 5, 5), new ProcessDetails("5", 6, 4));
3535
SJFScheduling scheduler = new SJFScheduling(processes);
36-
List<String> actualOrder = scheduler.getProcesses().stream()
37-
.map(ProcessDetails::getProcessId)
38-
.toList();
36+
List<String> actualOrder = scheduler.getProcesses().stream().map(ProcessDetails::getProcessId).toList();
3937

4038
assertEquals(List.of("1", "2", "4", "3", "6", "5"), actualOrder);
4139
}

0 commit comments

Comments
 (0)