This commit is contained in:
2021-04-26 16:52:12 +02:00
parent de8d1e9756
commit 909e241c5b
5 changed files with 204 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package app.controllers;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Optional;
import org.fxmisc.richtext.CodeArea;
@@ -100,11 +101,15 @@ public class EditorControllerTest extends FxTestTemplate {
@Test
@DisplayName("Test handling of OpenFileEvent with a file that doesn't exist")
public void testOpenFileEventWithUnrealFile() throws IOException {
try (MockedStatic<FileOperations> mocked = mockStatic(FileOperations.class)) {
mocked.when(() -> FileOperations.readFile(any()))
.thenReturn(null);
String brokenFilePath = "/doesNotExist.txt";
eventBus.post(new OpenFileEvent(Optional.ofNullable(new File(brokenFilePath).toPath())));
String brokenFilePath = "/doesNotExist.txt";
eventBus.post(new OpenFileEvent(Optional.ofNullable(Paths.get(brokenFilePath))));
verify(editor, never()).clear();
verify(editor, never()).clear();
}
}
@Test