Search in sources :

Example 1 with EnhetType

use of se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType in project webcert by sklintyg.

the class ConvertToFKTypesTest method testToEnhetTypeVardpersonNull.

@Test
public void testToEnhetTypeVardpersonNull() {
    EnhetType res = ConvertToFKTypes.toEnhetType(null);
    assertNull(res);
}
Also used : EnhetType(se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType) Test(org.junit.Test)

Example 2 with EnhetType

use of se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType in project webcert by sklintyg.

the class MailNotificationServiceImplTest method testSendMailForIncomingQuestionMailIsSentToPrivatePractitioner.

@Test
public void testSendMailForIncomingQuestionMailIsSentToPrivatePractitioner() 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.sendMailForIncomingQuestion(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 3 with EnhetType

use of se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType 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 4 with EnhetType

use of se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType 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 5 with EnhetType

use of se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType 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)

Aggregations

EnhetType (se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType)6 HoSPersonType (se.riv.infrastructure.directory.privatepractitioner.v1.HoSPersonType)6 Test (org.junit.Test)5 Address (javax.mail.Address)2 MimeMessage (javax.mail.internet.MimeMessage)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 EnhetType (se.inera.ifv.insuranceprocess.healthreporting.v2.EnhetType)2 MessagingException (javax.mail.MessagingException)1 WebServiceException (javax.xml.ws.WebServiceException)1 MailSendException (org.springframework.mail.MailSendException)1 VardgivareType (se.inera.ifv.insuranceprocess.healthreporting.v2.VardgivareType)1 HsaServiceCallException (se.inera.intyg.infra.integration.hsa.exception.HsaServiceCallException)1 HsaId (se.riv.infrastructure.directory.privatepractitioner.types.v1.HsaId)1 PersonId (se.riv.infrastructure.directory.privatepractitioner.types.v1.PersonId)1 VardgivareType (se.riv.infrastructure.directory.privatepractitioner.v1.VardgivareType)1