Search in sources :

Example 6 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class MailNotificationServiceImplTest method testSendMailForIncomingAnswerMailIsSentToPrivatePractitioner.

@Test
public void testSendMailForIncomingAnswerMailIsSentToPrivatePractitioner() throws Exception {
    // Given
    HoSPersonType hoSPersonType = new HoSPersonType();
    EnhetType enhet = new EnhetType();
    String epost = "test@test.se";
    enhet.setEpost(epost);
    enhet.setEnhetsnamn("TestEnhet");
    hoSPersonType.setEnhet(enhet);
    doReturn(hoSPersonType).when(ppService).getPrivatePractitioner(anyString(), isNull(), isNull());
    MailNotification mailNotification = mailNotification("intygsId", MailNotificationServiceImpl.PRIVATE_PRACTITIONER_HSAID_PREFIX + "1234");
    // When
    mailNotificationService.sendMailForIncomingAnswer(mailNotification);
    // Then
    verify(mailSender, times(1)).send(mimeCaptor.capture());
    MimeMessage mimeMessage = mimeCaptor.getValue();
    Address[] allRecipients = mimeMessage.getAllRecipients();
    assertEquals(1, allRecipients.length);
    assertEquals(epost, allRecipients[0].toString());
}
Also used : Address(javax.mail.Address) MimeMessage(javax.mail.internet.MimeMessage) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) EnhetType(se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class MailNotificationServiceImplTest method testSendMailForIncomingQuestionHsaIsNotCalledIfPrivatePractitioner.

@Test
public void testSendMailForIncomingQuestionHsaIsNotCalledIfPrivatePractitioner() throws Exception {
    // Given
    HoSPersonType hoSPersonType = new HoSPersonType();
    EnhetType enhet = new EnhetType();
    enhet.setEpost("test@test.se");
    enhet.setEnhetsnamn("TestEnhet");
    hoSPersonType.setEnhet(enhet);
    doReturn(hoSPersonType).when(ppService).getPrivatePractitioner(anyString(), isNull(), isNull());
    MailNotification mailNotification = mailNotification("intygsId", MailNotificationServiceImpl.PRIVATE_PRACTITIONER_HSAID_PREFIX + "1234");
    // When
    mailNotificationService.sendMailForIncomingQuestion(mailNotification);
    // Then
    verify(hsaOrganizationUnitService, times(0)).getVardenhet(anyString());
}
Also used : HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) EnhetType(se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType) Test(org.junit.Test)

Example 8 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class MailNotificationServiceImpl method getPrivatePractitionerEnhet.

private MailNotificationEnhet getPrivatePractitionerEnhet(String hsaId) {
    try {
        HoSPersonType privatePractitioner = ppService.getPrivatePractitioner(ppLogicalAddress, hsaId, null);
        if (privatePractitioner != null) {
            EnhetType enhet = privatePractitioner.getEnhet();
            if (enhet != null) {
                return new MailNotificationEnhet(hsaId, enhet.getEnhetsnamn(), enhet.getEpost());
            }
        }
        LOG.error("Failed to lookup privatepractitioner with HSA Id '" + hsaId + "'");
    } catch (Exception e) {
        LOG.error("Failed to contact ppService to get HSA Id '" + hsaId + "'", e);
    }
    return null;
}
Also used : HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType) EnhetType(se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType) MessagingException(javax.mail.MessagingException) MailSendException(org.springframework.mail.MailSendException) WebServiceException(javax.xml.ws.WebServiceException) HsaServiceCallException(se.inera.intyg.infra.integration.hsa.exception.HsaServiceCallException)

Example 9 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class ElegWebCertUserDetailsService method createUser.

// - - - - - Default scope - - - - -
protected WebCertUser createUser(SAMLCredential samlCredential) {
    String personId = elegAuthenticationAttributeHelper.getAttribute(samlCredential, CgiElegAssertion.PERSON_ID_ATTRIBUTE);
    assertHosPersonIsAuthorized(personId);
    HoSPersonType hosPerson = getHosPerson(personId);
    if (hosPerson == null) {
        throw new IllegalArgumentException("No HSAPerson found for personId specified in SAML ticket");
    }
    // Lookup user's role
    Role role = lookupUserRole();
    return createWebCertUser(hosPerson, role, samlCredential);
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) HoSPersonType(se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)

Example 10 with HoSPersonType

use of se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType in project webcert by sklintyg.

the class ElegWebCertUserDetailsService method decorateWebCertUserWithLegitimeradeYrkesgrupper.

private void decorateWebCertUserWithLegitimeradeYrkesgrupper(HoSPersonType hosPerson, WebCertUser webCertUser) {
    List<String> legitimeradeYrkesgrupper = new ArrayList<>();
    for (LegitimeradYrkesgruppType ly : hosPerson.getLegitimeradYrkesgrupp()) {
        legitimeradeYrkesgrupper.add(ly.getNamn());
    }
    webCertUser.setLegitimeradeYrkesgrupper(legitimeradeYrkesgrupper);
}
Also used : LegitimeradYrkesgruppType(se.riv.infrastructure.directory.privatepractitioner.v1.LegitimeradYrkesgruppType) ArrayList(java.util.ArrayList)

Aggregations

HoSPersonType (se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)16 Test (org.junit.Test)9 EnhetType (se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType)6 ArrayList (java.util.ArrayList)3 GetPrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerResponseType)3 Address (javax.mail.Address)2 MimeMessage (javax.mail.internet.MimeMessage)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 ObjectCreator (se.inera.intyg.webcert.integration.pp.util.ObjectCreator)2 ValidatePrivatePractitionerResponseType (se.riv.infrastructure.directory.privatepractitioner.validateprivatepractitionerresponder.v1.ValidatePrivatePractitionerResponseType)2 MessagingException (javax.mail.MessagingException)1 WebServiceException (javax.xml.ws.WebServiceException)1 MailSendException (org.springframework.mail.MailSendException)1 HsaServiceCallException (se.inera.intyg.infra.integration.hsa.exception.HsaServiceCallException)1 Role (se.inera.intyg.infra.security.common.model.Role)1 GetPrivatePractitionerType (se.riv.infrastructure.directory.privatepractitioner.getprivatepractitionerresponder.v1.GetPrivatePractitionerType)1 HsaId (se.riv.infrastructure.directory.privatepractitioner.types.v1.HsaId)1 PersonId (se.riv.infrastructure.directory.privatepractitioner.types.v1.PersonId)1