diff options
| author | Paul-Christian Volkmer | 2023-03-20 14:07:00 +0100 |
|---|---|---|
| committer | Paul-Christian Volkmer | 2023-03-20 22:29:19 +0100 |
| commit | ef5c91a352788a2ad84afa18fa0c7cdadec70ed8 (patch) | |
| tree | cc769f185bf6c29e02da79879cd396252eed38ad /src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java | |
| parent | a8a5e1be8a8bc8a048106b608fa4f58d80a66444 (diff) | |
Issue #11: Service und Spring Data JPA Repository für Systemeinstellungen
Diffstat (limited to 'src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java')
| -rw-r--r-- | src/test/java/DNPM/config/TherapieplanServiceFactoryTest.java | 36 |
1 files changed, 7 insertions, 29 deletions
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(); |
