From 425e8067b60024256437a5ee4180efdd9d134022 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 6 Apr 2023 09:38:58 +0200 Subject: Issue #22: Verwende Angabe des Systemtherapie-Formulars in den Einstellungen Standardwert, wenn die Einstellung nicht vorhanden ist, ist "OS.Systemische Therapie". closes #22 --- .../DefaultSystemtherapieServiceTest.java | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/test/java/DNPM/services/systemtherapie/DefaultSystemtherapieServiceTest.java') 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> 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 formnameSetting() { + return List.of("OS.Systemische Therapie", "OS.Systemische Therapie.VarianteUKW"); } @ParameterizedTest - @MethodSource("expectedFormnameMappings") - void testShouldMapSidToFormName(Map.Entry 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"); -- cgit v1.2.3