Search in sources :

Example 21 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method setupUser.

private void setupUser(String privilegeString, String intygType, boolean coherentJournaling, String... features) {
    WebCertUser user = new WebCertUser();
    user.setAuthorities(new HashMap<>());
    user.setFeatures(Stream.of(features).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setIntygstyper(Arrays.asList(intygType));
        return feature;
    })));
    user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", coherentJournaling, false, false, true));
    Privilege privilege = new Privilege();
    privilege.setIntygstyper(Arrays.asList(intygType));
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName("NORMAL");
    requestOrigin.setIntygstyper(privilege.getIntygstyper());
    privilege.setRequestOrigins(Arrays.asList(requestOrigin));
    user.getAuthorities().put(privilegeString, privilege);
    user.setOrigin("NORMAL");
    when(webcertUserService.getUser()).thenReturn(user);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege) Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 22 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class CopyUtkastServiceImplTest method testCreateCompletion.

@Test
public void testCreateCompletion() throws Exception {
    final String reference = "ref";
    WebCertUser user = new WebCertUser();
    user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", true, false, false, true));
    when(userService.getUser()).thenReturn(user);
    when(mockUtkastRepository.exists(INTYG_ID)).thenReturn(Boolean.TRUE);
    CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
    when(copyCompletionUtkastBuilder.populateCopyUtkastFromOrignalUtkast(any(CreateCompletionCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(false))).thenReturn(resp);
    CreateCompletionCopyRequest copyReq = buildCompletionRequest();
    CreateCompletionCopyResponse copyResp = copyService.createCompletion(copyReq);
    assertNotNull(copyResp);
    assertEquals(INTYG_COPY_ID, copyResp.getNewDraftIntygId());
    assertEquals(INTYG_TYPE, copyResp.getNewDraftIntygType());
    assertEquals(INTYG_ID, copyResp.getOriginalIntygId());
    verify(mockPUService).getPerson(PATIENT_SSN);
    verify(copyCompletionUtkastBuilder).populateCopyUtkastFromOrignalUtkast(any(CreateCompletionCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(false));
    verify(mockUtkastRepository).save(any(Utkast.class));
    verify(referensService).saveReferens(eq(INTYG_COPY_ID), eq(reference));
    verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
    verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) CreateCompletionCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyRequest) CreateCompletionCopyResponse(se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Person(se.inera.intyg.infra.integration.pu.model.Person) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 23 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class CopyUtkastServiceImplTest method testCreateRenewalFailsWhenReplacedBySignedIntyg.

@Test(expected = WebCertServiceException.class)
public void testCreateRenewalFailsWhenReplacedBySignedIntyg() throws Exception {
    final String reference = "ref";
    WebCertUser user = new WebCertUser();
    user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
    when(userService.getUser()).thenReturn(user);
    WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
    when(certificateRelationService.getNewestRelationOfType(INTYG_ID, RelationKod.ERSATT, Arrays.asList(UtkastStatus.SIGNED))).thenReturn(Optional.of(ersattRelation));
    CreateRenewalCopyRequest copyReq = buildRenewalRequest();
    try {
        copyService.createRenewalCopy(copyReq);
        fail("An exception should have been thrown.");
    } catch (Exception e) {
        verifyZeroInteractions(mockUtkastRepository);
        verifyZeroInteractions(mockNotificationService);
        verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
        // Assert no pdl logging
        verifyZeroInteractions(logService);
        throw e;
    }
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) CreateRenewalCopyRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 24 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class UtkastServiceImplTest method createUser.

private WebCertUser createUser() {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    user.setHsaId("hsaId");
    user.setNamn("namn");
    List<String> tmp = new ArrayList<>();
    tmp.add("Ortoped");
    user.setSpecialiseringar(tmp);
    user.setTitel("Befattning");
    Vardgivare vardgivare = new Vardgivare();
    vardgivare.setId("vardgivarid");
    vardgivare.setNamn("vardgivarnamn");
    user.setValdVardgivare(vardgivare);
    Vardenhet vardenhet = new Vardenhet();
    vardenhet.setId(UTKAST_ENHETS_ID);
    vardenhet.setNamn("enhetnamn");
    user.setValdVardenhet(vardenhet);
    vardgivare.setVardenheter(Arrays.asList(vardenhet));
    user.setVardgivare(Arrays.asList(vardgivare));
    user.setParameters(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 25 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.

the class IntygIntegrationServiceImplTest method verifyMonitoringWhenSammanhallenSjukforingAndOtherVardenhet.

@Test
public void verifyMonitoringWhenSammanhallenSjukforingAndOtherVardenhet() {
    // given
    when(utkastRepository.findOne(anyString())).thenReturn(createUtkast());
    when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
    IntegrationParameters parameters = new IntegrationParameters(null, null, ALTERNATE_SSN, "Nollan", null, "Nollansson", "Nollgatan", "000000", "Nollby", true, false, false, false);
    WebCertUser user = createDefaultUser();
    user.setParameters(parameters);
    user.setValdVardgivare(createVardenhet());
    // when
    testee.prepareRedirectToIntyg(INTYGSTYP, INTYGSID, user);
    // then
    verify(monitoringLog).logIntegratedOtherCaregiver(anyString(), anyString(), anyString(), anyString());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)36 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)32 Test (org.junit.Test)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)9 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)9 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 Response (javax.ws.rs.core.Response)7 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)7 Personnummer (se.inera.intyg.schemas.contract.Personnummer)6 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)6 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)5 Person (se.inera.intyg.infra.integration.pu.model.Person)4 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)4 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)4 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)4 Patient (se.inera.intyg.common.support.model.common.internal.Patient)3 Privilege (se.inera.intyg.infra.security.common.model.Privilege)3 Role (se.inera.intyg.infra.security.common.model.Role)3