From 9afb438eeae0f5a5d6cf63afdaf4b5df8b06a895 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Tue, 7 Apr 2026 10:15:30 +0200 Subject: refactor: remove deprecated MtbService (#260) --- .../analyzer/TherapieplanAnalyzerTest.java | 61 ++-------------------- 1 file changed, 5 insertions(+), 56 deletions(-) (limited to 'src/test/java/dev/dnpm/oshelper/analyzer/TherapieplanAnalyzerTest.java') diff --git a/src/test/java/dev/dnpm/oshelper/analyzer/TherapieplanAnalyzerTest.java b/src/test/java/dev/dnpm/oshelper/analyzer/TherapieplanAnalyzerTest.java index d822f89..0ee1ef8 100644 --- a/src/test/java/dev/dnpm/oshelper/analyzer/TherapieplanAnalyzerTest.java +++ b/src/test/java/dev/dnpm/oshelper/analyzer/TherapieplanAnalyzerTest.java @@ -19,27 +19,17 @@ package dev.dnpm.oshelper.analyzer; -import dev.dnpm.oshelper.security.DelegatingDataBasedPermissionEvaluator; -import dev.dnpm.oshelper.security.PermissionType; -import dev.dnpm.oshelper.services.FormService; -import dev.dnpm.oshelper.services.mtb.MtbService; -import dev.dnpm.oshelper.services.therapieplan.MultipleMtbTherapieplanService; -import dev.dnpm.oshelper.services.therapieplan.TherapieplanService; -import dev.dnpm.oshelper.services.therapieplan.TherapieplanServiceFactory; import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Item; import de.itc.onkostar.api.Procedure; +import dev.dnpm.oshelper.services.FormService; +import dev.dnpm.oshelper.services.therapieplan.DefaultTherapieplanService; +import dev.dnpm.oshelper.services.therapieplan.TherapieplanServiceFactory; 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.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) @@ -54,62 +44,21 @@ class TherapieplanAnalyzerTest { @Mock private TherapieplanServiceFactory therapieplanServiceFactory; - @Mock - private TherapieplanService therapieplanService; - - @Mock - private MtbService mtbService; - - @Mock - private DelegatingDataBasedPermissionEvaluator permissionEvaluator; - private TherapieplanAnalyzer therapieplanAnalyzer; @BeforeEach void setUp() { - this.therapieplanAnalyzer = new TherapieplanAnalyzer(therapieplanServiceFactory, mtbService, permissionEvaluator); + this.therapieplanAnalyzer = new TherapieplanAnalyzer(therapieplanServiceFactory); } @Test void shouldRunServiceMethodsOnAnalyzeCalled() { when(this.therapieplanServiceFactory.currentUsableInstance()) - .thenReturn(new MultipleMtbTherapieplanService(onkostarApi, formService)); + .thenReturn(new DefaultTherapieplanService(onkostarApi, formService)); this.therapieplanAnalyzer.analyze(new Procedure(onkostarApi), null); verify(this.therapieplanServiceFactory, times(1)).currentUsableInstance(); } - @Test - void shouldRequestProtokollauszug() { - doAnswer(invocationOnMock -> { - var procedure = new Procedure(onkostarApi); - procedure.setValue("referstemtb", new Item("referstemtb", 2345)); - return List.of(procedure); - }).when(this.therapieplanService).findReferencedMtbs(anyInt()); - - when(this.therapieplanServiceFactory.currentUsableInstance()) - .thenReturn(therapieplanService); - - when(this.permissionEvaluator.hasPermission(any(), anyInt(), anyString(), any(PermissionType.class))).thenReturn(true); - - var input = Map.of("id", (Object) 1234); - this.therapieplanAnalyzer.getProtokollauszug(input); - - var captor = ArgumentCaptor.forClass(List.class); - verify(mtbService, times(1)).getProtocol(captor.capture()); - assertThat(captor.getValue()).hasSize(1); - } - - @Test - void shouldNotRequestProtokollauszugDueToNoPermission() { - when(this.permissionEvaluator.hasPermission(any(), anyInt(), anyString(), any(PermissionType.class))) - .thenReturn(false); - - var input = Map.of("id", (Object) 1234); - this.therapieplanAnalyzer.getProtokollauszug(input); - - verify(mtbService, times(0)).getProtocol(anyList()); - } - } -- cgit v1.2.3