diff options
| author | Paul-Christian Volkmer | 2026-09-04 08:14:28 +0200 |
|---|---|---|
| committer | GitHub | 2026-09-04 08:14:28 +0200 |
| commit | cdcdb21eca393b17ac5d075c5a002d30ccf038c5 (patch) | |
| tree | 5d7ed46e6febfe9fd1c4150f702841b40986cbbd /src/test/java | |
| parent | fb91356b7777dfa5b6088bcc3a48b43924c1c0fd (diff) | |
refactor: remove deprecated ConsentManagerService (#294)
Diffstat (limited to 'src/test/java')
5 files changed, 0 insertions, 386 deletions
diff --git a/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java b/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java deleted file mode 100644 index 80e7298..0000000 --- a/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of onkostar-plugin-dnpm - * - * Copyright (C) 2023-2026 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package dev.dnpm.oshelper; - -import static org.mockito.Mockito.*; - -import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Procedure; -import dev.dnpm.oshelper.analyzer.ConsentManager; -import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory; -import dev.dnpm.oshelper.services.consent.MrConsentManagerService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class ConsentManagerTest { - - private IOnkostarApi onkostarApi; - - private ConsentManagerServiceFactory consentManagerServiceFactory; - - private ConsentManager consentManager; - - @BeforeEach - void setup( - @Mock IOnkostarApi onkostarApi, - @Mock ConsentManagerServiceFactory consentManagerServiceFactory) { - this.onkostarApi = onkostarApi; - this.consentManagerServiceFactory = consentManagerServiceFactory; - this.consentManager = new ConsentManager(onkostarApi, consentManagerServiceFactory); - } - - @Test - void shouldRunServiceMethodsOnAnalyzeCalled() { - var consentManagerServiceMock = mock(MrConsentManagerService.class); - - when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(true); - - when(this.consentManagerServiceFactory.currentUsableInstance()) - .thenReturn(consentManagerServiceMock); - - this.consentManager.analyze(new Procedure(onkostarApi), null); - - verify(consentManagerServiceMock, times(1)).applyConsent(any(Procedure.class)); - } - - @Test - void shouldNotRunServiceMethodsIfProcedureCannotBeAppliesForForm() { - var consentManagerServiceMock = mock(MrConsentManagerService.class); - - when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(false); - - when(this.consentManagerServiceFactory.currentUsableInstance()) - .thenReturn(consentManagerServiceMock); - - this.consentManager.analyze(new Procedure(onkostarApi), null); - - verify(consentManagerServiceMock, times(0)).applyConsent(any(Procedure.class)); - } -} diff --git a/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java b/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java index 42583ca..bb483f1 100644 --- a/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java +++ b/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java @@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat; import de.itc.onkostar.api.IOnkostarApi; import dev.dnpm.oshelper.services.FormService; import dev.dnpm.oshelper.services.SettingsService; -import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory; import dev.dnpm.oshelper.services.therapieplan.TherapieplanServiceFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -49,12 +48,6 @@ class PluginConfigurationTest { } @Test - void testShouldReturnConsentManagerServiceFactory() { - var actual = this.configuration.consentManagerServiceFactory(onkostarApi); - assertThat(actual).isInstanceOf(ConsentManagerServiceFactory.class); - } - - @Test void testShouldReturnTherapieplanServiceFactory() { var actual = this.configuration.therapieplanServiceFactory(onkostarApi, settingsService, formService); diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java deleted file mode 100644 index 7d086de..0000000 --- a/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file is part of onkostar-plugin-dnpm - * - * Copyright (C) 2023-2026 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package dev.dnpm.oshelper.services.consent; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; - -import de.itc.onkostar.api.IOnkostarApi; -import java.util.Map; -import java.util.Set; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class ConsentManagerServiceFactoryTest { - - private IOnkostarApi onkostarApi; - - private ConsentManagerServiceFactory consentManagerServiceFactory; - - @BeforeEach - void setup(@Mock IOnkostarApi onkostarApi) { - this.onkostarApi = onkostarApi; - this.consentManagerServiceFactory = new ConsentManagerServiceFactory(onkostarApi); - } - - private static Set<Map.Entry<String, Class<? extends ConsentManagerService>>> expectedMappings() { - return Map.ofEntries( - Map.entry("MR.Consent", MrConsentManagerService.class), - Map.entry("Excel-Formular", UkwConsentManagerService.class)) - .entrySet(); - } - - @ParameterizedTest - @MethodSource("expectedMappings") - void testShouldMapFormNameToService(Map.Entry<String, Class<?>> expectedMapping) { - when(onkostarApi.getGlobalSetting(anyString())).thenReturn(expectedMapping.getKey()); - - var actual = consentManagerServiceFactory.currentUsableInstance(); - - assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue()); - } -} diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java deleted file mode 100644 index b747987..0000000 --- a/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of onkostar-plugin-dnpm - * - * Copyright (C) 2023-2026 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package dev.dnpm.oshelper.services.consent; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Procedure; -import org.hibernate.SQLQuery; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.type.Type; -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; - -@ExtendWith(MockitoExtension.class) -class MrConsentManagerServiceTest { - - private IOnkostarApi onkostarApi; - - private MrConsentManagerService service; - - @BeforeEach - void setup(@Mock IOnkostarApi onkostarApi) { - this.onkostarApi = onkostarApi; - this.service = new MrConsentManagerService(onkostarApi); - } - - @Test - void testShouldCreateSqlQueriesWithRelatedEntityIds() { - var sessionFactory = mock(SessionFactory.class); - var session = mock(Session.class); - var query = mock(SQLQuery.class); - - when(onkostarApi.getSessionFactory()).thenReturn(sessionFactory); - when(sessionFactory.getCurrentSession()).thenReturn(session); - when(session.createSQLQuery(anyString())).thenReturn(query); - when(query.addScalar(anyString(), any(Type.class))).thenReturn(query); - when(query.uniqueResult()).thenReturn(""); - - var dummyProzedur = new Procedure(this.onkostarApi); - dummyProzedur.setId(111); - dummyProzedur.setPatientId(123); - - this.service.applyConsent(dummyProzedur); - - var argumentCaptor = ArgumentCaptor.forClass(String.class); - verify(session, times(2)).createSQLQuery(argumentCaptor.capture()); - assertThat(argumentCaptor.getAllValues()).hasSize(2); - assertThat(argumentCaptor.getAllValues().get(0)).contains("where entity_id = '111'"); - assertThat(argumentCaptor.getAllValues().get(1)) - .contains("WHERE patient_id = 123 AND geloescht = 0"); - } -} diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java deleted file mode 100644 index e28dd64..0000000 --- a/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This file is part of onkostar-plugin-dnpm - * - * Copyright (C) 2023-2026 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package dev.dnpm.oshelper.services.consent; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Item; -import de.itc.onkostar.api.Procedure; -import java.sql.Date; -import java.time.Instant; -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; - -@ExtendWith(MockitoExtension.class) -class UkwConsentManagerServiceTest { - - private IOnkostarApi onkostarApi; - - private UkwConsentManagerService service; - - @BeforeEach - void setup(@Mock IOnkostarApi onkostarApi) { - this.onkostarApi = onkostarApi; - this.service = new UkwConsentManagerService(onkostarApi); - } - - @Test - void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentAvailable() throws Exception { - - var excelForm = new Procedure(this.onkostarApi); - excelForm.setId(111); - excelForm.setPatientId(123); - excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); - - var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); - dnpmKlinikAnamneseForm.setId(2); - dnpmKlinikAnamneseForm.setPatientId(123); - - when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); - - this.service.applyConsent(excelForm); - - verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); - } - - @Test - void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentDateAvailable() - throws Exception { - - var consentSubForm = new Procedure(this.onkostarApi); - consentSubForm.setId(1); - consentSubForm.setPatientId(123); - consentSubForm.setValue("status", new Item("status", "accepted")); - - var excelForm = new Procedure(this.onkostarApi); - excelForm.setId(111); - excelForm.setPatientId(123); - excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); - excelForm.addSubProcedure("ufdnpmconsent", consentSubForm); - - var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); - dnpmKlinikAnamneseForm.setId(2); - dnpmKlinikAnamneseForm.setPatientId(123); - - when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); - - this.service.applyConsent(excelForm); - - verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); - } - - @Test - void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentValueAvailable() - throws Exception { - - var consentSubForm = new Procedure(this.onkostarApi); - consentSubForm.setId(1); - consentSubForm.setPatientId(123); - consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z"))); - consentSubForm.setValue( - "datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z")))); - - var excelForm = new Procedure(this.onkostarApi); - excelForm.setId(111); - excelForm.setPatientId(123); - excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); - excelForm.addSubProcedure("ufdnpmconsent", consentSubForm); - - var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); - dnpmKlinikAnamneseForm.setId(2); - dnpmKlinikAnamneseForm.setPatientId(123); - - when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); - - this.service.applyConsent(excelForm); - - verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); - } - - @Test - void testShouldUpdateRelatedDnpmKlinikAnamneseFormOnFormSave() throws Exception { - - var consentSubForm = new Procedure(this.onkostarApi); - consentSubForm.setId(1); - consentSubForm.setPatientId(123); - consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z"))); - consentSubForm.setValue( - "datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z")))); - consentSubForm.setValue("status", new Item("status", "accepted")); - - var excelForm = new Procedure(this.onkostarApi); - excelForm.setId(111); - excelForm.setPatientId(123); - excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); - excelForm.addSubProcedure("ufdnpmconsent", consentSubForm); - - var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); - dnpmKlinikAnamneseForm.setId(2); - dnpmKlinikAnamneseForm.setPatientId(123); - - when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); - - this.service.applyConsent(excelForm); - - var argumentCaptor = ArgumentCaptor.forClass(Procedure.class); - verify(onkostarApi, times(1)).saveProcedure(argumentCaptor.capture(), anyBoolean()); - - var savedForm = argumentCaptor.getValue(); - assertThat(savedForm).isExactlyInstanceOf(Procedure.class); - assertThat(savedForm.getValue("ConsentStatusEinwilligungDNPM").getString()) - .isEqualTo("accepted"); - assertThat(savedForm.getValue("ConsentDatumEinwilligungDNPM").getDate()) - .isEqualTo("2023-04-03T12:00:00Z"); - } -} |
