EventTests
This commit is contained in:
parent
92fa16891c
commit
2e397fd971
@ -103,7 +103,7 @@ public class MenubarController implements Initializable, Controller {
|
|||||||
try {
|
try {
|
||||||
File dir = FileOperations.openFolderWithDialog(stage);
|
File dir = FileOperations.openFolderWithDialog(stage);
|
||||||
|
|
||||||
this.eventBus.post(new OpenProjectEvent(dir.toPath()));
|
this.eventBus.post(new OpenProjectEvent(Optional.of(dir.toPath())));
|
||||||
} catch (FileNotFoundException e) {}
|
} catch (FileNotFoundException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,21 +10,21 @@ import app.model.Model;
|
|||||||
*/
|
*/
|
||||||
public class OpenProjectEvent extends Event {
|
public class OpenProjectEvent extends Event {
|
||||||
|
|
||||||
private Path path;
|
private Optional<Path> path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event signalizing that a folder is supposed to be opened in the filetree.
|
* Event signalizing that a folder is supposed to be opened in the filetree.
|
||||||
* @param path The path of the folder to be opened
|
* @param path The path of the folder to be opened
|
||||||
*/
|
*/
|
||||||
public OpenProjectEvent(Path path) {
|
public OpenProjectEvent(Optional<Path> path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
Model.setProjectPath(Optional.of(path));
|
Model.setProjectPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The path of the folder to be opened
|
* @return The path of the folder to be opened
|
||||||
*/
|
*/
|
||||||
public Path getPath() {
|
public Optional<Path> getPath() {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
src/test/java/app/events/LanguageChangedEventTest.java
Normal file
19
src/test/java/app/events/LanguageChangedEventTest.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package app.events;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import app.model.Model;
|
||||||
|
import app.model.languages.Java;
|
||||||
|
import app.testing.EventTestTemplate;
|
||||||
|
|
||||||
|
public class LanguageChangedEventTest extends EventTestTemplate {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check that model gets changed on constructor")
|
||||||
|
private void checkModel() {
|
||||||
|
new LanguageChangedEvent("Java");
|
||||||
|
this.mockModel.verify(() -> Model.setLanguage(new Java()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
src/test/java/app/events/OpenFileEventTest.java
Normal file
20
src/test/java/app/events/OpenFileEventTest.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package app.events;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import app.model.Model;
|
||||||
|
import app.testing.EventTestTemplate;
|
||||||
|
|
||||||
|
public class OpenFileEventTest extends EventTestTemplate {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check that model gets changed on constructor")
|
||||||
|
private void checkModel() {
|
||||||
|
new OpenFileEvent(Optional.empty());
|
||||||
|
this.mockModel.verify(() -> Model.setActiveFilePath(Optional.empty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/test/java/app/events/OpenProjectEventTest.java
Normal file
21
src/test/java/app/events/OpenProjectEventTest.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package app.events;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import app.model.Model;
|
||||||
|
import app.testing.EventTestTemplate;
|
||||||
|
|
||||||
|
public class OpenProjectEventTest extends EventTestTemplate {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check that model gets changed on constructor")
|
||||||
|
private void checkModel() {
|
||||||
|
new OpenProjectEvent(Optional.empty());
|
||||||
|
this.mockModel.verify(() -> Model.setProjectPath(Optional.empty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
18
src/test/java/app/events/ThemeChangedEventTest.java
Normal file
18
src/test/java/app/events/ThemeChangedEventTest.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package app.events;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import app.model.Model;
|
||||||
|
import app.testing.EventTestTemplate;
|
||||||
|
|
||||||
|
public class ThemeChangedEventTest extends EventTestTemplate {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Check that model gets changed on constructor")
|
||||||
|
private void checkModel() {
|
||||||
|
new ThemeChangedEvent("Monokai");
|
||||||
|
this.mockModel.verify(() -> Model.setTheme("Monokai"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
|
|
||||||
|
call mvn package -Dmaven.test.skip=true
|
||||||
|
|
||||||
java -jar --enable-preview target/banana-editor-1.0.0.jar
|
java -jar --enable-preview target/banana-editor-1.0.0.jar
|
Loading…
Reference in New Issue
Block a user