|
7 | 7 | import java.io.PrintStream;
|
8 | 8 | import java.util.Arrays;
|
9 | 9 | import java.util.List;
|
10 |
| - |
11 | 10 | import org.junit.jupiter.api.Test;
|
12 | 11 |
|
13 | 12 | public class MultistageGraphTest {
|
14 | 13 |
|
15 |
| -@Test |
16 |
| -public void testAddEdge_invalidFromStage() { |
17 |
| - MultistageGraph graph = new MultistageGraph(3); |
| 14 | + @Test |
| 15 | + public void testAddEdge_invalidFromStage() { |
| 16 | + MultistageGraph graph = new MultistageGraph(3); |
18 | 17 |
|
19 |
| - assertThrows(IllegalArgumentException.class, () -> graph.addEdge(0, 2)); |
20 |
| -} |
| 18 | + assertThrows(IllegalArgumentException.class, () -> graph.addEdge(0, 2)); |
| 19 | + } |
21 | 20 |
|
22 |
| -@Test |
23 |
| -public void testAddEdge_invalidToStage() { |
24 |
| - MultistageGraph graph = new MultistageGraph(3); |
| 21 | + @Test |
| 22 | + public void testAddEdge_invalidToStage() { |
| 23 | + MultistageGraph graph = new MultistageGraph(3); |
25 | 24 |
|
26 |
| - assertThrows(IllegalArgumentException.class, () -> graph.addEdge(1, 4)); |
27 |
| -} |
| 25 | + assertThrows(IllegalArgumentException.class, () -> graph.addEdge(1, 4)); |
| 26 | + } |
28 | 27 |
|
29 |
| -@Test |
30 |
| -public void testAddEdge_edgeAlreadyExists() { |
31 |
| - MultistageGraph graph = new MultistageGraph(3); |
| 28 | + @Test |
| 29 | + public void testAddEdge_edgeAlreadyExists() { |
| 30 | + MultistageGraph graph = new MultistageGraph(3); |
32 | 31 |
|
33 |
| - graph.addEdge(1, 2); |
34 |
| - graph.addEdge(1, 2); // Attempt to add the same edge again |
| 32 | + graph.addEdge(1, 2); |
| 33 | + graph.addEdge(1, 2); // Attempt to add the same edge again |
35 | 34 |
|
36 |
| - List<Integer> expectedAdjacentStages = Arrays.asList(2); |
37 |
| - assertEquals(expectedAdjacentStages, graph.adjacencyList.get(0)); |
38 |
| -} |
| 35 | + List<Integer> expectedAdjacentStages = Arrays.asList(2); |
| 36 | + assertEquals(expectedAdjacentStages, graph.adjacencyList.get(0)); |
| 37 | + } |
39 | 38 |
|
40 |
| -@Test |
41 |
| -public void testAddEdge_printsSuccessMessage() { |
42 |
| - MultistageGraph graph = new MultistageGraph(3); |
| 39 | + @Test |
| 40 | + public void testAddEdge_printsSuccessMessage() { |
| 41 | + MultistageGraph graph = new MultistageGraph(3); |
43 | 42 |
|
44 |
| - // Capture the standard output stream |
45 |
| - ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); |
46 |
| - System.setOut(new PrintStream(outputStreamCaptor)); |
| 43 | + // Capture the standard output stream |
| 44 | + ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); |
| 45 | + System.setOut(new PrintStream(outputStreamCaptor)); |
47 | 46 |
|
48 |
| - graph.addEdge(1, 2); |
| 47 | + graph.addEdge(1, 2); |
49 | 48 |
|
50 |
| - String expectedOutput = "Added edge between stage 1 and stage 2\r\n"; |
51 |
| - assertEquals(expectedOutput, outputStreamCaptor.toString()); |
52 |
| -} |
| 49 | + String expectedOutput = "Added edge between stage 1 and stage 2\r\n"; |
| 50 | + assertEquals(expectedOutput, outputStreamCaptor.toString()); |
| 51 | + } |
53 | 52 | }
|
0 commit comments