Search in sources :

Example 31 with NotificationMessage

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);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Message(org.apache.camel.Message) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) DefaultMessage(org.apache.camel.impl.DefaultMessage) Test(org.junit.Test)

Example 32 with NotificationMessage

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());
}
Also used : NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Amneskod(se.riv.clinicalprocess.healthcond.certificate.types.v3.Amneskod)

Aggregations

NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)32 Test (org.junit.Test)21 LocalDateTime (java.time.LocalDateTime)8 Message (org.apache.camel.Message)8 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 DefaultMessage (org.apache.camel.impl.DefaultMessage)5 ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)5 Intyg (se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)5 TextMessage (javax.jms.TextMessage)3 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 MessageCreator (org.springframework.jms.core.MessageCreator)3 HandelsekodEnum (se.inera.intyg.common.support.common.enumerations.HandelsekodEnum)3 FragorOchSvar (se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar)3 NotificationStubEntry (se.inera.intyg.webcert.notification_sender.mocks.NotificationStubEntry)3 CertificateStatusUpdateForCareType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType)3 Session (javax.jms.Session)2 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)2 Handelse (se.inera.intyg.webcert.persistence.handelse.model.Handelse)2 CertificateStatusUpdateForCareType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareType)2