Search in sources :

Example 1 with NotificationMessage

use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.

the class RouteIT method ensureWiretapWorks.

@Test
public void ensureWiretapWorks() throws Exception {
    LocalDateTime first = LocalDateTime.now().minusSeconds(15);
    LocalDateTime second = LocalDateTime.now().minusSeconds(10);
    NotificationMessage notificationMessage2 = createNotificationMessage("intyg1", first, HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage notificationMessage3 = createNotificationMessage("intyg1", second, HandelsekodEnum.SIGNAT, "luae_fs", SchemaVersion.VERSION_3);
    sendMessage(notificationMessage2);
    sendMessage(notificationMessage3);
    await().atMost(SECONDS_TO_WAIT, TimeUnit.SECONDS).until(() -> {
        int numberOfReceivedMessages = certificateStatusUpdateForCareResponderV3.getNumberOfReceivedMessages();
        if (numberOfReceivedMessages == 1) {
            List<NotificationStubEntry> notificationMessages = certificateStatusUpdateForCareResponderV3.getNotificationMessages();
            for (NotificationStubEntry nse : notificationMessages) {
                if (nse.handelseTyp.equals(HandelsekodEnum.SIGNAT.value())) {
                    assertEquals(second, nse.handelseTid);
                }
            }
        }
        return (numberOfReceivedMessages == 1);
    });
}
Also used : LocalDateTime(java.time.LocalDateTime) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) NotificationStubEntry(se.inera.intyg.webcert.notification_sender.mocks.NotificationStubEntry) Test(org.junit.Test)

Example 2 with NotificationMessage

use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.

the class RouteIT method ensureMessagesAreResentAndDoNotBlockEachOther.

@Test
public void ensureMessagesAreResentAndDoNotBlockEachOther() throws Exception {
    final String intygsId1 = FALLERAT_MEDDELANDE + "2";
    final String intygsId2 = "korrekt-meddelande-1";
    NotificationMessage notificationMessage1 = createNotificationMessage(intygsId1, "fk7263", HandelsekodEnum.SKAPAT);
    NotificationMessage notificationMessage2 = createNotificationMessage(intygsId2, "fk7263", HandelsekodEnum.ANDRAT);
    sendMessage(notificationMessage1);
    sendMessage(notificationMessage2);
    await().atMost(SECONDS_TO_WAIT, TimeUnit.SECONDS).until(() -> {
        int numberOfSuccessfulMessages = certificateStatusUpdateForCareResponderStub.getNumberOfSentMessages();
        if (numberOfSuccessfulMessages == 2) {
            List<String> utlatandeIds = certificateStatusUpdateForCareResponderStub.getIntygsIdsInOrder();
            System.err.println(utlatandeIds);
            return (utlatandeIds.size() == 2 && utlatandeIds.get(0).equals(intygsId2) && utlatandeIds.get(1).equals(intygsId1));
        }
        return false;
    });
}
Also used : NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with NotificationMessage

use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.

the class RouteIT method ensureAggregatorFiltersOutOldestAndratMessages.

@Test
public void ensureAggregatorFiltersOutOldestAndratMessages() throws Exception {
    LocalDateTime first = LocalDateTime.now().minusSeconds(15);
    LocalDateTime second = LocalDateTime.now().minusSeconds(10);
    LocalDateTime third = LocalDateTime.now().minusSeconds(5);
    NotificationMessage notificationMessage1 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.SKAPAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage notificationMessage2 = createNotificationMessage("intyg1", first, HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage notificationMessage3 = createNotificationMessage("intyg1", second, HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage notificationMessage4 = createNotificationMessage("intyg1", third, HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    sendMessage(notificationMessage1);
    sendMessage(notificationMessage2);
    sendMessage(notificationMessage3);
    sendMessage(notificationMessage4);
    await().atMost(SECONDS_TO_WAIT, TimeUnit.SECONDS).until(() -> {
        int numberOfReceivedMessages = certificateStatusUpdateForCareResponderV3.getNumberOfReceivedMessages();
        if (numberOfReceivedMessages == 2) {
            List<NotificationStubEntry> notificationMessages = certificateStatusUpdateForCareResponderV3.getNotificationMessages();
            for (NotificationStubEntry nse : notificationMessages) {
                if (nse.handelseTyp.equals(HandelsekodEnum.ANDRAT.value())) {
                    assertEquals(third, nse.handelseTid);
                }
            }
        }
        return (numberOfReceivedMessages == 2);
    });
}
Also used : LocalDateTime(java.time.LocalDateTime) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) NotificationStubEntry(se.inera.intyg.webcert.notification_sender.mocks.NotificationStubEntry) Test(org.junit.Test)

Example 4 with NotificationMessage

use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.

the class RouteIT method ensureRouting.

@Test
public void ensureRouting() throws Exception {
    // 2 messages
    NotificationMessage luaefs1 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.SKAPAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage luaefs2 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage luaefs3 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
    // 3 messages
    NotificationMessage fk1 = createNotificationMessage("intyg2", "fk7263", HandelsekodEnum.SKAPAT);
    NotificationMessage fk2 = createNotificationMessage("intyg2", "fk7263", HandelsekodEnum.ANDRAT);
    NotificationMessage fk3 = createNotificationMessage("intyg2", "fk7263", HandelsekodEnum.SIGNAT);
    // 2 messages
    NotificationMessage luaefs4 = createNotificationMessage("intyg3", LocalDateTime.now(), HandelsekodEnum.MAKULE, "luae_fs", SchemaVersion.VERSION_3);
    NotificationMessage luaefs5 = createNotificationMessage("intyg4", LocalDateTime.now(), HandelsekodEnum.SKICKA, "luae_fs", SchemaVersion.VERSION_3);
    sendMessage(luaefs1);
    sendMessage(fk1);
    sendMessage(luaefs2);
    sendMessage(luaefs3);
    sendMessage(fk2);
    sendMessage(luaefs4);
    sendMessage(fk3);
    sendMessage(luaefs5);
    await().atMost(SECONDS_TO_WAIT, TimeUnit.SECONDS).until(() -> {
        int numberOfReceivedMessagesV1 = certificateStatusUpdateForCareResponderStub.getNumberOfReceivedMessages();
        int numberOfReceivedMessagesV3 = certificateStatusUpdateForCareResponderV3.getNumberOfReceivedMessages();
        return (numberOfReceivedMessagesV1 == 3 && numberOfReceivedMessagesV3 == 4);
    });
}
Also used : NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Test(org.junit.Test)

Example 5 with NotificationMessage

use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.

the class RouteIT method setupConverter.

private void setupConverter() throws ModuleException {
    when(mockFk7263Transform.createCertificateStatusUpdateForCareType(any(NotificationMessage.class))).thenAnswer(invocation -> {
        NotificationMessage msg = (NotificationMessage) invocation.getArguments()[0];
        if (msg == null) {
            return null;
        }
        CertificateStatusUpdateForCareType request = new CertificateStatusUpdateForCareType();
        UtlatandeType utlatande = new UtlatandeType();
        UtlatandeId id = new UtlatandeId();
        id.setExtension(msg.getIntygsId());
        utlatande.setUtlatandeId(id);
        request.setUtlatande(utlatande);
        return request;
    });
}
Also used : NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) UtlatandeId(se.riv.clinicalprocess.healthcond.certificate.types.v1.UtlatandeId) UtlatandeType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.UtlatandeType) CertificateStatusUpdateForCareType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v1.CertificateStatusUpdateForCareType)

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