mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-04 10:02:55 +00:00
Issue #11: Backend-Service-Methode zum Abrufen des Protokollauszugs hinzugefügt
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
package DNPM.analyzer;
|
||||
|
||||
import DNPM.services.MultipleMtbTherapieplanService;
|
||||
import DNPM.services.StudienService;
|
||||
import DNPM.services.TherapieplanServiceFactory;
|
||||
import DNPM.services.*;
|
||||
import DNPM.services.mtb.MtbService;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -13,6 +13,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -24,22 +25,32 @@ public class TherapieplanAnalyzerTest {
|
||||
@Mock
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
@Mock
|
||||
private FormService formService;
|
||||
|
||||
@Mock
|
||||
private StudienService studienService;
|
||||
|
||||
@Mock
|
||||
private TherapieplanServiceFactory therapieplanServiceFactory;
|
||||
|
||||
@Mock
|
||||
private TherapieplanService therapieplanService;
|
||||
|
||||
@Mock
|
||||
private MtbService mtbService;
|
||||
|
||||
private TherapieplanAnalyzer therapieplanAnalyzer;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.therapieplanAnalyzer = new TherapieplanAnalyzer(studienService, therapieplanServiceFactory);
|
||||
this.therapieplanAnalyzer = new TherapieplanAnalyzer(studienService, therapieplanServiceFactory, mtbService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRunServiceMethodsOnAnalyzeCalled() {
|
||||
when(this.therapieplanServiceFactory.currentUsableInstance()).thenReturn(new MultipleMtbTherapieplanService());
|
||||
when(this.therapieplanServiceFactory.currentUsableInstance())
|
||||
.thenReturn(new MultipleMtbTherapieplanService(onkostarApi, formService));
|
||||
|
||||
this.therapieplanAnalyzer.analyze(new Procedure(onkostarApi), null);
|
||||
|
||||
@ -72,4 +83,23 @@ public class TherapieplanAnalyzerTest {
|
||||
assertThat(captor.getValue()).isEqualTo("NCT-123");
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ public class TherapieplanServiceFactoryTest {
|
||||
@Test
|
||||
void testShouldReturnDefaultTherapieplanServiceIfSettingIsFalse() {
|
||||
when(settingsService.multipleMtbsInMtbEpisode()).thenReturn(false);
|
||||
var actual = this.therapieplanServiceFactory.currentUsableInstance();
|
||||
|
||||
var actual = this.therapieplanServiceFactory.currentUsableInstance();
|
||||
|
||||
|
Reference in New Issue
Block a user