diff options
| author | Paul-Christian Volkmer | 2023-04-06 09:38:58 +0200 |
|---|---|---|
| committer | Paul-Christian Volkmer | 2023-04-06 09:38:58 +0200 |
| commit | 425e8067b60024256437a5ee4180efdd9d134022 (patch) | |
| tree | 660f4d8cc61149e9d465bb88b7f1f27583daf4bd /src/test/java/DNPM/services | |
| parent | 367f46ccead37f145d88130497be34dafd57f2b8 (diff) | |
Issue #22: Verwende Angabe des Systemtherapie-Formulars in den Einstellungen
Standardwert, wenn die Einstellung nicht vorhanden ist, ist "OS.Systemische Therapie".
closes #22
Diffstat (limited to 'src/test/java/DNPM/services')
| -rw-r--r-- | src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java b/src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java index 3e63fa6..40ce315 100644 --- a/src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java +++ b/src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -16,8 +17,7 @@ import java.util.*; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) class DefaultSystemtherapieServiceTest { @@ -50,21 +50,37 @@ class DefaultSystemtherapieServiceTest { assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue()); } - private static Set<Map.Entry<String, String>> expectedFormnameMappings() { - return Map.ofEntries(Map.entry("2011", "OS.Systemische Therapie.VarianteUKW"), Map.entry("20119", "OS.Systemische Therapie.VarianteUKW"), Map.entry("Defaultwert", "OS.Systemische Therapie")).entrySet(); + private static List<String> formnameSetting() { + return List.of("OS.Systemische Therapie", "OS.Systemische Therapie.VarianteUKW"); } @ParameterizedTest - @MethodSource("expectedFormnameMappings") - void testShouldMapSidToFormName(Map.Entry<String, String> expectedMapping) { - var actual = service.selectFormNameBySID(expectedMapping.getKey()); - assertThat(actual).isEqualTo(expectedMapping.getValue()); + @MethodSource("formnameSetting") + void testShouldRequestProceduresWithExpectedFormName(String expectedFormName) { + when(this.settingsService.getSetting(anyString())).thenReturn(Optional.of(expectedFormName)); + when(this.onkostarApi.getProceduresForDiseaseByForm(anyInt(), anyString())).thenReturn(List.of()); + + service.getSystemischeTherapienFromDiagnose(123); + + var argumentCaptor = ArgumentCaptor.forClass(String.class); + verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(anyInt(), argumentCaptor.capture()); + assertThat(argumentCaptor.getValue()).isEqualTo(expectedFormName); } @Test - void testShouldReturnSystemischeTherapienFromDiagnose() { - when(settingsService.getSID()).thenReturn(Optional.of("12345")); + void testShouldRequestProceduresWithDefaultFormName() { + when(this.settingsService.getSetting(anyString())).thenReturn(Optional.empty()); + when(this.onkostarApi.getProceduresForDiseaseByForm(anyInt(), anyString())).thenReturn(List.of()); + + service.getSystemischeTherapienFromDiagnose(123); + var argumentCaptor = ArgumentCaptor.forClass(String.class); + verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(anyInt(), argumentCaptor.capture()); + assertThat(argumentCaptor.getValue()).isEqualTo("OS.Systemische Therapie"); + } + + @Test + void testShouldReturnSystemischeTherapienFromDiagnose() { doAnswer(invocationOnMock -> { var procedure = new Procedure(onkostarApi); procedure.setFormName("OS.Systemische Therapie"); |
