use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformerTest method testSend.
@Test
public void testSend() throws Exception {
// Given
NotificationMessage notificationMessage = new NotificationMessage(INTYGS_ID, FK7263, LocalDateTime.now(), HandelsekodEnum.SKAPAT, LOGISK_ADRESS, "{ }", FragorOchSvar.getEmpty(), null, null, SchemaVersion.VERSION_1, "ref");
Message message = spy(new DefaultMessage());
message.setBody(notificationMessage);
setupInternalToNotification();
// When
transformer.process(message);
// Then
assertEquals(INTYGS_ID, ((CertificateStatusUpdateForCareType) message.getBody()).getUtlatande().getUtlatandeId().getExtension());
assertEquals(HandelsekodEnum.SKAPAT.value(), message.getHeader(NotificationRouteHeaders.HANDELSE));
assertEquals(INTYGS_ID, message.getHeader(NotificationRouteHeaders.INTYGS_ID));
assertEquals(LOGISK_ADRESS, message.getHeader(NotificationRouteHeaders.LOGISK_ADRESS));
assertEquals(SchemaVersion.VERSION_1.name(), message.getHeader(NotificationRouteHeaders.VERSION));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.LOGISK_ADRESS), eq(LOGISK_ADRESS));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.INTYGS_ID), eq(INTYGS_ID));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.HANDELSE), eq(HandelsekodEnum.SKAPAT.value()));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.VERSION), eq(SchemaVersion.VERSION_1.name()));
verify(internalToNotification, times(1)).createCertificateStatusUpdateForCareType(any());
verifyZeroInteractions(notificationPatientEnricher);
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationServiceImpl method createAndSendNotification.
private void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse, ArendeAmne amne, LocalDate sistaDatumForSvar, SchemaVersion version) {
Amneskod amneskod = null;
if (amne != null) {
amneskod = AmneskodCreator.create(amne.name(), amne.getDescription());
}
String reference = referensService.getReferensForIntygsId(utkast.getIntygsId());
NotificationMessage notificationMessage = notificationMessageFactory.createNotificationMessage(utkast, handelse, version, reference, amneskod, sistaDatumForSvar);
save(notificationMessage, utkast.getEnhetsId(), utkast.getVardgivarId(), utkast.getPatientPersonnummer().getPersonnummer(), amne, sistaDatumForSvar);
send(notificationMessage, utkast.getEnhetsId());
}
Aggregations