From ef5c91a352788a2ad84afa18fa0c7cdadec70ed8 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 20 Mar 2023 14:07:00 +0100 Subject: Issue #11: Service und Spring Data JPA Repository für Systemeinstellungen --- .../java/DNPM/config/PluginConfigurationTest.java | 6 +++- .../config/TherapieplanServiceFactoryTest.java | 36 +++++----------------- 2 files changed, 12 insertions(+), 30 deletions(-) (limited to 'src/test/java/DNPM/config') diff --git a/src/test/java/DNPM/config/PluginConfigurationTest.java b/src/test/java/DNPM/config/PluginConfigurationTest.java index 77c95e7..d94b3c7 100644 --- a/src/test/java/DNPM/config/PluginConfigurationTest.java +++ b/src/test/java/DNPM/config/PluginConfigurationTest.java @@ -1,6 +1,7 @@ package DNPM.config; import DNPM.services.FormService; +import DNPM.services.SettingsService; import DNPM.services.TherapieplanServiceFactory; import de.itc.onkostar.api.IOnkostarApi; import org.junit.jupiter.api.BeforeEach; @@ -17,6 +18,9 @@ public class PluginConfigurationTest { @Mock private IOnkostarApi onkostarApi; + @Mock + private SettingsService settingsService; + @Mock private FormService formService; @@ -29,7 +33,7 @@ public class PluginConfigurationTest { @Test void testShouldReturnTherapieplanServiceFactory() { - var actual = this.configuration.therapieplanServiceFactory(onkostarApi, formService); + var actual = this.configuration.therapieplanServiceFactory(onkostarApi, settingsService, formService); assertThat(actual).isInstanceOf(TherapieplanServiceFactory.class); } } diff --git a/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java b/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java index f974dcf..2f0022d 100644 --- a/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java +++ b/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java @@ -1,9 +1,6 @@ package DNPM.config; -import DNPM.services.DefaultTherapieplanService; -import DNPM.services.FormService; -import DNPM.services.MultipleMtbTherapieplanService; -import DNPM.services.TherapieplanServiceFactory; +import DNPM.services.*; import de.itc.onkostar.api.IOnkostarApi; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -12,8 +9,6 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @@ -25,32 +20,21 @@ public class TherapieplanServiceFactoryTest { @Mock private FormService formService; + @Mock + private SettingsService settingsService; + private TherapieplanServiceFactory therapieplanServiceFactory; @BeforeEach void setup() { - this.therapieplanServiceFactory = new TherapieplanServiceFactory(onkostarApi, formService); + this.therapieplanServiceFactory = new TherapieplanServiceFactory(onkostarApi, settingsService, formService); } @Test void testShouldReturnDefaultTherapieplanServiceIfSettingIsFalse() { - doAnswer(invocationOnMock -> { - var settingName = invocationOnMock.getArgument(0, String.class); - if (settingName.equals("mehrere_mtb_in_mtbepisode")) { - return "false"; - } - return null; - }).when(onkostarApi).getGlobalSetting(anyString()); - + when(settingsService.multipleMtbsInMtbEpisode()).thenReturn(false); var actual = this.therapieplanServiceFactory.currentUsableInstance(); - assertThat(actual).isInstanceOf(DefaultTherapieplanService.class); - } - - @Test - void testShouldReturnDefaultTherapieplanServiceIfNoSetting() { - when(onkostarApi.getGlobalSetting(anyString())).thenReturn(null); - var actual = this.therapieplanServiceFactory.currentUsableInstance(); assertThat(actual).isInstanceOf(DefaultTherapieplanService.class); @@ -58,13 +42,7 @@ public class TherapieplanServiceFactoryTest { @Test void testShouldReturnMultipleMtbTherapieplanServiceIfSettingIsTrue() { - doAnswer(invocationOnMock -> { - var settingName = invocationOnMock.getArgument(0, String.class); - if (settingName.equals("mehrere_mtb_in_mtbepisode")) { - return "true"; - } - return null; - }).when(onkostarApi).getGlobalSetting(anyString()); + when(settingsService.multipleMtbsInMtbEpisode()).thenReturn(true); var actual = this.therapieplanServiceFactory.currentUsableInstance(); -- cgit v1.2.3 From aad777b5e36238ef437210bd9ad3ea51c3274a45 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 20 Mar 2023 22:19:20 +0100 Subject: Issue #11: Backend-Service-Methode zum Abrufen des Protokollauszugs hinzugefügt --- src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/test/java/DNPM/config') diff --git a/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java b/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java index 2f0022d..ea9ff42 100644 --- a/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java +++ b/src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java @@ -33,7 +33,6 @@ public class TherapieplanServiceFactoryTest { @Test void testShouldReturnDefaultTherapieplanServiceIfSettingIsFalse() { when(settingsService.multipleMtbsInMtbEpisode()).thenReturn(false); - var actual = this.therapieplanServiceFactory.currentUsableInstance(); var actual = this.therapieplanServiceFactory.currentUsableInstance(); -- cgit v1.2.3