use of se.riv.infrastructure.directory.privatepractitioner.v1.EnhetType in project webcert by sklintyg.
the class ConvertToFKTypesTest method testToEnhetTypeVardpersonNull.
@Test
public void testToEnhetTypeVardpersonNull() {
EnhetType res = ConvertToFKTypes.toEnhetType(null);
assertNull(res);
}
use of se.riv.infrastructure.directory.privatepractitioner.v1.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());
}
use of se.riv.infrastructure.directory.privatepractitioner.v1.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());
}
use of se.riv.infrastructure.directory.privatepractitioner.v1.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());
}
use of se.riv.infrastructure.directory.privatepractitioner.v1.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;
}
Aggregations