-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSecondaryControllerTest.java
More file actions
32 lines (26 loc) · 1.06 KB
/
SecondaryControllerTest.java
File metadata and controls
32 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ratemate;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
public class SecondaryControllerTest {
@Test
public void testSwitchToPrimary() {
try (MockedStatic<App> appMock = Mockito.mockStatic(App.class)) {
appMock.when(() -> App.setRoot("primary")).thenReturn(null);
SecondaryController controller = new SecondaryController();
assertDoesNotThrow(controller::switchToPrimary);
}
}
@Test
public void testSwitchToPrimaryIOException() {
try (MockedStatic<App> appMock = Mockito.mockStatic(App.class)) {
appMock.when(() -> App.setRoot("primary"))
.thenThrow(new IOException("File not found"));
SecondaryController controller = new SecondaryController();
IOException ex = assertThrows(IOException.class, controller::switchToPrimary);
assertEquals("File not found", ex.getMessage());
}
}
}