1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-09-14 00:12:52 +00:00

feat: add initial support for recommendations

This commit is contained in:
2025-06-22 19:11:24 +02:00
parent a24855ec7a
commit 1ab33de3f8
15 changed files with 306 additions and 30 deletions

View File

@@ -0,0 +1,62 @@
package dev.pcvolkmer.onco.datamapper.datacatalogues;
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 org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
import java.util.Map;
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.verify;
@ExtendWith(MockitoExtension.class)
class EinzelempfehlungCatalogueTest {
JdbcTemplate jdbcTemplate;
EinzelempfehlungCatalogue catalogue;
@BeforeEach
void setUp(@Mock JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
this.catalogue = EinzelempfehlungCatalogue.create(jdbcTemplate);
}
@Test
void shouldUseCorrectQuery(@Mock Map<String, Object> resultSet) {
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getById(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT * FROM dk_dnpm_uf_einzelempfehlung JOIN prozedur ON (prozedur.id = dk_dnpm_uf_einzelempfehlung.id) WHERE geloescht = 0 AND prozedur.id = ?");
}
@Test
void shouldUseCorrectSubformQuery(@Mock Map<String, Object> resultSet) {
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getAllByParentId(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT * FROM dk_dnpm_uf_einzelempfehlung JOIN prozedur ON (prozedur.id = dk_dnpm_uf_einzelempfehlung.id) WHERE geloescht = 0 AND hauptprozedur_id = ?");
}
}

View File

@@ -55,7 +55,7 @@ class KpaEcogDataMapperTest {
return testData.get(columnName);
}).when(resultSet).getDate(anyString());
when(resultSet.getProcedureId()).thenReturn(1);
when(resultSet.getId()).thenReturn(1);
doAnswer(invocationOnMock -> List.of(resultSet))
.when(catalogue)

View File

@@ -69,8 +69,8 @@ class KpaProzedurDataMapperTest {
return testData.get(columnName);
}).when(resultSet).getDate(anyString());
when(resultSet.getDiseaseId()).thenReturn(1);
when(resultSet.getProcedureId()).thenReturn(1);
when(resultSet.getInteger(anyString())).thenReturn(1);
when(resultSet.getId()).thenReturn(1);
doAnswer(invocationOnMock -> List.of(resultSet))
.when(catalogue)

View File

@@ -68,8 +68,8 @@ class KpaTherapielinieDataMapperTest {
return testData.get(columnName);
}).when(resultSet).getDate(anyString());
when(resultSet.getDiseaseId()).thenReturn(1);
when(resultSet.getProcedureId()).thenReturn(1);
when(resultSet.getInteger(anyString())).thenReturn(1);
when(resultSet.getId()).thenReturn(1);
doAnswer(invocationOnMock -> List.of(resultSet))
.when(catalogue)

View File

@@ -4,6 +4,7 @@ import dev.pcvolkmer.mv64e.mtb.MtbCarePlan;
import dev.pcvolkmer.mv64e.mtb.Reference;
import dev.pcvolkmer.onco.datamapper.PropertyCatalogue;
import dev.pcvolkmer.onco.datamapper.ResultSet;
import dev.pcvolkmer.onco.datamapper.datacatalogues.EinzelempfehlungCatalogue;
import dev.pcvolkmer.onco.datamapper.datacatalogues.TherapieplanCatalogue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -22,6 +23,7 @@ import static org.mockito.Mockito.doAnswer;
class TherapieplanDataMapperTest {
TherapieplanCatalogue therapieplanCatalogue;
EinzelempfehlungCatalogue einzelempfehlungCatalogue;
PropertyCatalogue propertyCatalogue;
TherapieplanDataMapper dataMapper;
@@ -29,11 +31,13 @@ class TherapieplanDataMapperTest {
@BeforeEach
void setUp(
@Mock TherapieplanCatalogue therapieplanCatalogue,
@Mock EinzelempfehlungCatalogue einzelempfehlungCatalogue,
@Mock PropertyCatalogue propertyCatalogue
) {
this.therapieplanCatalogue = therapieplanCatalogue;
this.einzelempfehlungCatalogue = einzelempfehlungCatalogue;
this.propertyCatalogue = propertyCatalogue;
this.dataMapper = new TherapieplanDataMapper(therapieplanCatalogue, propertyCatalogue);
this.dataMapper = new TherapieplanDataMapper(therapieplanCatalogue, einzelempfehlungCatalogue, propertyCatalogue);
}
@Test