From 2a8caf8efd508a82e721888b1328ea7401dfb9ef Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 13 May 2022 23:45:49 +0200 Subject: [PATCH 1/2] FactoryDecoratorTest --- .../FactoryDecoratorTest.java | 38 +++++++++++++++++++ .../turnierverwaltung/FactoryTest.java | 27 ------------- 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryDecoratorTest.java delete mode 100644 app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryTest.java diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryDecoratorTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryDecoratorTest.java new file mode 100644 index 0000000..000d4ba --- /dev/null +++ b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryDecoratorTest.java @@ -0,0 +1,38 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; +import org.junit.jupiter.api.Test; +import org.mockito.InOrder; +import org.mockito.Mockito; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.inOrder; + +public class FactoryDecoratorTest { + + private FactoryDecorator factoryDecorator; + + @Test + void test() { + FileIO io = Mockito.mock(FileIO.class); + Factory fc = Mockito.mock(Factory.class); + Pane pn = Mockito.mock(BorderPane.class); + FileIO.TournamentFile tf = Mockito.mock(FileIO.TournamentFile.class); + + factoryDecorator = new FactoryDecorator(io,fc,pn); + factoryDecorator.openTournament(tf); + + InOrder order = inOrder(io,fc,pn); + + try { + order.verify(fc).setTournament(io.loadTournament(tf)); + order.verify(fc).showGameScheduler((BorderPane) pn); + + } catch (IOException | ClassNotFoundException e) { + e.printStackTrace(); + fail(); + } + } +} diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryTest.java deleted file mode 100644 index 8da1478..0000000 --- a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FactoryTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package ch.zhaw.projekt2.turnierverwaltung; - -import javafx.scene.layout.BorderPane; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.InOrder; -import org.mockito.Mockito; - -import static org.mockito.Mockito.inOrder; - -public class FactoryTest { - private Factory factory; - - @Test - @DisplayName("Test method calls") - void checkMethodCalls() { - FileIO fileIO = Mockito.mock(FileIO.class); - TournamentDecorator td = Mockito.mock(TournamentDecorator.class); - LanguageConfigurator lc = Mockito.mock(LanguageConfigurator.class); - BorderPane pane = Mockito.mock(BorderPane.class); - factory = new Factory(fileIO,td,lc); - InOrder order = inOrder(fileIO,td,lc); - - //factory.showTournamentList(pane); - - } -} -- 2.40.1 From ec256d40c63c4c684cc91332326c23c9d90c49aa Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 13 May 2022 23:47:06 +0200 Subject: [PATCH 2/2] FactoryDecoratorTest --- .../ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java index 0078957..45c3f38 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java @@ -1,7 +1,6 @@ package ch.zhaw.projekt2.turnierverwaltung; import javafx.application.Platform; - import java.io.IOException; import java.util.ArrayList; import java.util.Date; -- 2.40.1