diff options
| author | Paul-Christian Volkmer | 2023-07-12 14:52:09 +0200 |
|---|---|---|
| committer | Paul-Christian Volkmer | 2023-07-27 09:24:11 +0200 |
| commit | 27476863809d4f2a0a704afd3a2a30f3feafdde4 (patch) | |
| tree | dede3d2ff8f7f62dd89770f69a9554e5ccabc208 /src/test/java | |
| parent | 9389acdf641016eaf9d9b217ce7d28866a1e9263 (diff) | |
Issue #29: Tests für das Einfügen in ECOG Verlauf
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java b/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java new file mode 100644 index 0000000..2450f96 --- /dev/null +++ b/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java @@ -0,0 +1,95 @@ +package DNPM.analyzer; + +import DNPM.services.systemtherapie.SystemtherapieService; +import de.itc.onkostar.api.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.Date; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +class SystemtherapieAnalyzerTest { + + private IOnkostarApi onkostarApi; + + private SystemtherapieService systemtherapieService; + + private SystemtherapieAnalyzer systemtherapieAnalyzer; + + @BeforeEach + void setUp( + @Mock IOnkostarApi onkostarApi, + @Mock SystemtherapieService systemtherapieService + ) { + this.onkostarApi = onkostarApi; + this.systemtherapieService = systemtherapieService; + this.systemtherapieAnalyzer = new SystemtherapieAnalyzer(onkostarApi, systemtherapieService); + } + + @Test + void shouldInsertNewEcogStatus() throws Exception { + doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(new Date(), "0"))) + .when(systemtherapieService).ecogSatus(any(Patient.class)); + + var patient = new Patient(onkostarApi); + patient.setId(1); + + var procedure = new Procedure(onkostarApi); + procedure.setId(1000); + procedure.setStartDate(new Date()); + procedure.setEditState(ProcedureEditStateType.COMPLETED); + procedure.setPatientId(1); + procedure.setPatient(patient); + procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1)); + + doAnswer(invocationOnMock -> { + var disease = new Disease(onkostarApi); + disease.setId(42); + return List.of(disease); + }).when(this.onkostarApi).getDiseasesByPatientId(anyInt()); + + doAnswer(invocationOnMock -> List.of(procedure)).when(onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString()); + + systemtherapieAnalyzer.analyze(procedure, null); + + var idCaptor = ArgumentCaptor.forClass(Integer.class); + var formNameCaptor = ArgumentCaptor.forClass(String.class); + verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(idCaptor.capture(), formNameCaptor.capture()); + assertThat(idCaptor.getValue()).isEqualTo(42); + assertThat(formNameCaptor.getValue()).isEqualTo("DNPM Klinik/Anamnese"); + + verify(onkostarApi, times(1)).saveProcedure(any(Procedure.class), anyBoolean()); + } + + @Test + void shouldNotModifyEcogStatusIfNoCompletedSystemTherapy() throws Exception { + doAnswer(invocationOnMock -> List.of()) + .when(systemtherapieService).ecogSatus(any(Patient.class)); + + var patient = new Patient(onkostarApi); + patient.setId(1); + + var procedure = new Procedure(onkostarApi); + procedure.setId(1000); + procedure.setStartDate(new Date()); + procedure.setEditState(ProcedureEditStateType.COMPLETED); + procedure.setPatientId(1); + procedure.setPatient(patient); + procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1)); + + systemtherapieAnalyzer.analyze(procedure, null); + + verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString()); + verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); + } + +} |
