Replace FileSelectedEvent with OpenFileEvent
This commit is contained in:
@@ -38,7 +38,7 @@ import app.service.FileOperations;
|
||||
import app.service.LanguageOperations;
|
||||
import app.events.CopyEvent;
|
||||
import app.events.CutEvent;
|
||||
import app.events.FileSelectedEvent;
|
||||
import app.events.OpenFileEvent;
|
||||
import app.events.LanguageChangedEvent;
|
||||
import app.events.PasteEvent;
|
||||
import app.events.RedoEvent;
|
||||
@@ -80,8 +80,8 @@ public class EditorControllerTest extends FxTestTemplate {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test handling of FileSelectedEvent with a real file")
|
||||
public void testFileSelectedEventWithRealFile() throws IOException {
|
||||
@DisplayName("Test handling of OpenFileEvent with a real file")
|
||||
public void testOpenFileEventWithRealFile() throws IOException {
|
||||
|
||||
String resourcePath = "/testfile.txt";
|
||||
String filePath = getClass().getResource(resourcePath).getPath();
|
||||
@@ -91,18 +91,18 @@ public class EditorControllerTest extends FxTestTemplate {
|
||||
mocked.when(() -> FileOperations.readFile(any()))
|
||||
.thenReturn("");
|
||||
|
||||
eventBus.post(new FileSelectedEvent(Optional.of(file.toPath())));
|
||||
eventBus.post(new OpenFileEvent(Optional.of(file.toPath())));
|
||||
|
||||
mocked.verify(() -> FileOperations.readFile(any()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test handling of FileSelectedEvent with a file that doesn't exist")
|
||||
public void testFileSelectedEventWithUnrealFile() throws IOException {
|
||||
@DisplayName("Test handling of OpenFileEvent with a file that doesn't exist")
|
||||
public void testOpenFileEventWithUnrealFile() throws IOException {
|
||||
|
||||
String brokenFilePath = "/doesNotExist.txt";
|
||||
eventBus.post(new FileSelectedEvent(Optional.ofNullable(new File(brokenFilePath).toPath())));
|
||||
eventBus.post(new OpenFileEvent(Optional.ofNullable(new File(brokenFilePath).toPath())));
|
||||
|
||||
verify(editor, never()).clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user