1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-03 01:32:55 +00:00

Testcode aufgeräumt

This commit is contained in:
2023-04-01 21:28:07 +02:00
parent 82ab2234e8
commit 3627a9e898
16 changed files with 56 additions and 64 deletions

View File

@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
public class AtcCodeTest { class AtcCodeTest {
@Test @Test
void testShouldDetectAtcCodeScheme() { void testShouldDetectAtcCodeScheme() {

View File

@ -128,7 +128,7 @@ class DNPMHelperTest {
@Test @Test
void testShouldReturnEmptyStringOnParamCheckIfNoDataFormParamGiven() { void testShouldReturnEmptyStringOnParamCheckIfNoDataFormParamGiven() {
var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("DiagnoseId", 1, "PatientId", 2)); var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("DiagnoseId", 1, "PatientId", 2));
assertThat(actual).isEqualTo(""); assertThat(actual).isExactlyInstanceOf(String.class).isEmpty();
verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt()); verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt());
} }
@ -136,7 +136,7 @@ class DNPMHelperTest {
@Test @Test
void testShouldReturnEmptyStringOnParamCheckIfNoDiagnoseIdParamGiven() { void testShouldReturnEmptyStringOnParamCheckIfNoDiagnoseIdParamGiven() {
var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("dataForm", "OS.Example", "PatientId", 2)); var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("dataForm", "OS.Example", "PatientId", 2));
assertThat(actual).isEqualTo(""); assertThat(actual).isExactlyInstanceOf(String.class).isEmpty();
verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt()); verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt());
} }
@ -144,7 +144,7 @@ class DNPMHelperTest {
@Test @Test
void testShouldReturnEmptyStringOnParamCheckIfNoPatientIdParamGiven() { void testShouldReturnEmptyStringOnParamCheckIfNoPatientIdParamGiven() {
var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("dataForm", "OS.Example", "DiagnoseId", 1)); var actual = dnpmHelper.getProzedurenFromDiagnose(Map.of("dataForm", "OS.Example", "DiagnoseId", 1));
assertThat(actual).isEqualTo(""); assertThat(actual).isExactlyInstanceOf(String.class).isEmpty();
verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt()); verify(onkostarApi, times(0)).getProceduresByPatientId(anyInt());
} }

View File

@ -10,7 +10,7 @@ import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class AnalyzerUtilsTest { class AnalyzerUtilsTest {
private final Map<String, Object> input = Map.of("value1", 1, "valueA", "A", "valueTrue", true); private final Map<String, Object> input = Map.of("value1", 1, "valueA", "A", "valueTrue", true);

View File

@ -15,7 +15,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class FollowUpAnalyzerTest { class FollowUpAnalyzerTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TherapieplanAnalyzerTest { class TherapieplanAnalyzerTest {
@Mock @Mock
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -13,7 +13,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class PluginConfigurationTest { class PluginConfigurationTest {
@Mock @Mock
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TherapieplanServiceFactoryTest { class TherapieplanServiceFactoryTest {
@Mock @Mock
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -20,7 +20,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class DefaultTherapieplanServiceTest { class DefaultTherapieplanServiceTest {
@Mock @Mock
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -13,7 +13,7 @@ import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class SettingsServiceTest { class SettingsServiceTest {
@Mock @Mock
private SettingsRepository settingsRepository; private SettingsRepository settingsRepository;
@ -36,8 +36,9 @@ public class SettingsServiceTest {
}).when(settingsRepository).findByName(anyString()); }).when(settingsRepository).findByName(anyString());
var actual = service.getSID(); var actual = service.getSID();
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("12345"); .isPresent()
.contains("12345");
} }
@Test @Test
@ -51,8 +52,9 @@ public class SettingsServiceTest {
}).when(settingsRepository).findByName(anyString()); }).when(settingsRepository).findByName(anyString());
var actual = service.getSetting("SID"); var actual = service.getSetting("SID");
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("12345"); .isPresent()
.contains("12345");
} }
} }

View File

@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class StudieTest { class StudieTest {
@Test @Test
void shouldDetectStudieWithNctNumber() { void shouldDetectStudieWithNctNumber() {

View File

@ -17,7 +17,7 @@ import java.util.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class DefaultMtbServiceTest { class DefaultMtbServiceTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;

View File

@ -16,7 +16,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class MrMtbAnmeldungToProtocolMapperTest { class MrMtbAnmeldungToProtocolMapperTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;
@ -76,12 +76,13 @@ public class MrMtbAnmeldungToProtocolMapperTest {
var actual = this.mapper.apply(anmeldung); var actual = this.mapper.apply(anmeldung);
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo( .isPresent()
"Fragestellung:\nFrage?\n\n" + .contains(
"Empfehlung:\nEmpfehlung1\n\n" + "Fragestellung:\nFrage?\n\n"
"Empfehlung:\nEmpfehlung2" + "Empfehlung:\nEmpfehlung1\n\n"
); + "Empfehlung:\nEmpfehlung2"
);
} }
@Test @Test
@ -106,8 +107,9 @@ public class MrMtbAnmeldungToProtocolMapperTest {
var actual = this.mapper.apply(anmeldung); var actual = this.mapper.apply(anmeldung);
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("Fragestellung:\nFrage?"); .isPresent()
.contains("Fragestellung:\nFrage?");
} }
@Test @Test
@ -119,8 +121,9 @@ public class MrMtbAnmeldungToProtocolMapperTest {
var actual = this.mapper.apply(anmeldung); var actual = this.mapper.apply(anmeldung);
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("Fragestellung:\nFrage?"); .isPresent()
.contains("Fragestellung:\nFrage?");
} }
@Test @Test

View File

@ -15,7 +15,7 @@ import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class OsTumorkonferenzToProtocolMapperTest { class OsTumorkonferenzToProtocolMapperTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;
@ -39,8 +39,9 @@ public class OsTumorkonferenzToProtocolMapperTest {
var actual = mapper.apply(procedure); var actual = mapper.apply(procedure);
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!"); .isPresent()
.contains("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!");
} }
} }

View File

@ -15,7 +15,7 @@ import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class OsTumorkonferenzVarianteUkwToProtocolMapperTest { class OsTumorkonferenzVarianteUkwToProtocolMapperTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;
@ -39,8 +39,9 @@ public class OsTumorkonferenzVarianteUkwToProtocolMapperTest {
var actual = mapper.apply(procedure); var actual = mapper.apply(procedure);
assertThat(actual).isPresent(); assertThat(actual)
assertThat(actual.get()).isEqualTo("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!"); .isPresent()
.contains("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!");
} }
} }

View File

@ -20,7 +20,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class DefaultSystemtherapieServiceTest { class DefaultSystemtherapieServiceTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;
@ -29,20 +29,14 @@ public class DefaultSystemtherapieServiceTest {
private DefaultSystemtherapieService service; private DefaultSystemtherapieService service;
@BeforeEach @BeforeEach
void setup( void setup(@Mock IOnkostarApi onkostarApi, @Mock SettingsService settingsService) {
@Mock IOnkostarApi onkostarApi,
@Mock SettingsService settingsService
) {
this.onkostarApi = onkostarApi; this.onkostarApi = onkostarApi;
this.settingsService = settingsService; this.settingsService = settingsService;
this.service = new DefaultSystemtherapieService(onkostarApi, settingsService); this.service = new DefaultSystemtherapieService(onkostarApi, settingsService);
} }
private static Set<Map.Entry<String, Class<OsSystemischeTherapieToProzedurwerteMapper>>> expectedMapperMappings() { private static Set<Map.Entry<String, Class<OsSystemischeTherapieToProzedurwerteMapper>>> expectedMapperMappings() {
return Map.ofEntries( return Map.ofEntries(Map.entry("OS.Systemische Therapie", OsSystemischeTherapieToProzedurwerteMapper.class), Map.entry("OS.Systemische Therapie.VarianteUKW", OsSystemischeTherapieToProzedurwerteMapper.class)).entrySet();
Map.entry("OS.Systemische Therapie", OsSystemischeTherapieToProzedurwerteMapper.class),
Map.entry("OS.Systemische Therapie.VarianteUKW", OsSystemischeTherapieToProzedurwerteMapper.class)
).entrySet();
} }
@ParameterizedTest @ParameterizedTest
@ -57,11 +51,7 @@ public class DefaultSystemtherapieServiceTest {
} }
private static Set<Map.Entry<String, String>> expectedFormnameMappings() { private static Set<Map.Entry<String, String>> expectedFormnameMappings() {
return Map.ofEntries( return Map.ofEntries(Map.entry("2011", "OS.Systemische Therapie.VarianteUKW"), Map.entry("20119", "OS.Systemische Therapie.VarianteUKW"), Map.entry("Defaultwert", "OS.Systemische Therapie")).entrySet();
Map.entry("2011", "OS.Systemische Therapie.VarianteUKW"),
Map.entry("20119", "OS.Systemische Therapie.VarianteUKW"),
Map.entry("Defaultwert", "OS.Systemische Therapie")
).entrySet();
} }
@ParameterizedTest @ParameterizedTest
@ -83,8 +73,9 @@ public class DefaultSystemtherapieServiceTest {
var actual = service.getSystemischeTherapienFromDiagnose(1); var actual = service.getSystemischeTherapienFromDiagnose(1);
assertThat(actual).isNotNull(); assertThat(actual)
assertThat(actual).isExactlyInstanceOf(ArrayList.class); .isNotNull()
assertThat(actual).hasSize(1); .isExactlyInstanceOf(ArrayList.class)
.hasSize(1);
} }
} }

View File

@ -17,7 +17,7 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class ProzedurToProzedurwerteMapperTest { class ProzedurToProzedurwerteMapperTest {
private IOnkostarApi onkostarApi; private IOnkostarApi onkostarApi;
@ -55,18 +55,12 @@ public class ProzedurToProzedurwerteMapperTest {
assertThat(actual).isPresent(); assertThat(actual).isPresent();
assertThat(actual.get().get("Beginn")) assertThat(actual.get()).containsEntry("Beginn", Date.from(Instant.parse("2023-01-01T00:00:00Z")).toString());
.isEqualTo(Date.from(Instant.parse("2023-01-01T00:00:00Z")).toString()); assertThat(actual.get()).containsEntry("Ende", Date.from(Instant.parse("2023-01-31T00:00:00Z")).toString());
assertThat(actual.get().get("Ende")) assertThat(actual.get()).containsEntry("Beendigung", "E");
.isEqualTo(Date.from(Instant.parse("2023-01-31T00:00:00Z")).toString()); assertThat(actual.get()).containsEntry("Ergebnis", "T");
assertThat(actual.get().get("Beendigung")) assertThat(actual.get()).containsEntry("Wirkstoffe", "Testsubstanz, cyclophosphamide");
.isEqualTo("E"); assertThat(actual.get()).containsEntry("WirkstoffCodes",
assertThat(actual.get().get("Ergebnis"))
.isEqualTo("T");
assertThat(actual.get().get("Wirkstoffe"))
.isEqualTo("Testsubstanz, cyclophosphamide");
assertThat(actual.get().get("WirkstoffCodes"))
.isEqualTo(
"[" + "[" +
"{\"system\":\"other\",\"code\":\"Testsubstanz\",\"substance\":\"Testsubstanz\"}," + "{\"system\":\"other\",\"code\":\"Testsubstanz\",\"substance\":\"Testsubstanz\"}," +
"{\"system\":\"ATC\",\"code\":\"L01AA01\",\"substance\":\"cyclophosphamide\"}" + "{\"system\":\"ATC\",\"code\":\"L01AA01\",\"substance\":\"cyclophosphamide\"}" +