summaryrefslogtreecommitdiff
path: root/src/test/java/DNPM/analyzer/EinzelempfehlungAnalyzerTest.java
blob: 337ffdb1d2a5814848b234294e74ef2ae54af3f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package DNPM.analyzer;

import DNPM.security.DelegatingDataBasedPermissionEvaluator;
import DNPM.services.molekulargenetik.MolekulargenetikFormService;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Procedure;
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;

import java.util.Map;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
class EinzelempfehlungAnalyzerTest {

    private IOnkostarApi onkostarApi;

    private MolekulargenetikFormService molekulargenetikFormService;

    private EinzelempfehlungAnalyzer analyzer;

    @BeforeEach
    void setup(
            @Mock IOnkostarApi onkostarApi,
            @Mock MolekulargenetikFormService molekulargenetikFormService,
            @Mock DelegatingDataBasedPermissionEvaluator permissionEvaluator
    ) {
        this.onkostarApi = onkostarApi;
        this.molekulargenetikFormService = molekulargenetikFormService;
        this.analyzer = new EinzelempfehlungAnalyzer(onkostarApi, molekulargenetikFormService, permissionEvaluator);
    }

    @Test
    void testShouldRequestVariantsFromMolekulargenetikFormService() {
        doAnswer(invocationOnMock -> new Procedure(this.onkostarApi)).when(onkostarApi).getProcedure(anyInt());

        analyzer.getVariants(Map.of("id", 123));
        verify(molekulargenetikFormService, times(1)).getVariants(any(Procedure.class));
    }

}