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());
}
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());
}
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;
}
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);
}
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);
}
Aggregations