use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformer method process.
public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException {
LOG.debug("Receiving message: {}", message.getMessageId());
NotificationMessage notificationMessage = message.getBody(NotificationMessage.class);
message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress());
message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId());
// Note that this header have been set already by the original sender to accommodate header-based routing
// in the aggreagatorRoute. It is 100% safe to overwrite it at this point.
message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value());
if (notificationMessage.getVersion() != null) {
message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name());
} else {
message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_1.name());
}
if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) {
ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp());
Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast());
Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande);
notificationPatientEnricher.enrichWithPatient(intyg);
message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg));
} else if (Fk7263EntryPoint.MODULE_ID.equals(notificationMessage.getIntygsTyp())) {
message.setBody(fk7263Transform.createCertificateStatusUpdateForCareType(notificationMessage));
} else {
throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'");
}
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class RouteIT method ensureAggregatorFiltersOutAndratMessagesWhenSigned.
@Test
public void ensureAggregatorFiltersOutAndratMessagesWhenSigned() throws Exception {
NotificationMessage notificationMessage1 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.SKAPAT, "luae_fs", SchemaVersion.VERSION_3);
NotificationMessage notificationMessage2 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
NotificationMessage notificationMessage3 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.ANDRAT, "luae_fs", SchemaVersion.VERSION_3);
NotificationMessage notificationMessage4 = createNotificationMessage("intyg1", LocalDateTime.now(), HandelsekodEnum.SIGNAT, "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())) {
fail("No ANDRAT messages are allowed when intyg has been signed");
}
}
}
return (numberOfReceivedMessages == 2);
});
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class RouteIT method ensureStubReceivedAllMessages.
@Test
public void ensureStubReceivedAllMessages() throws Exception {
NotificationMessage notificationMessage1 = createNotificationMessage("intyg1", "fk7263", HandelsekodEnum.SKAPAT);
NotificationMessage notificationMessage2 = createNotificationMessage("intyg2", "fk7263", HandelsekodEnum.ANDRAT);
NotificationMessage notificationMessage3 = createNotificationMessage("intyg3", "fk7263", HandelsekodEnum.SIGNAT);
sendMessage(notificationMessage1);
sendMessage(notificationMessage2);
sendMessage(notificationMessage3);
await().atMost(SECONDS_TO_WAIT, TimeUnit.SECONDS).until(() -> {
int numberOfReceivedMessages = certificateStatusUpdateForCareResponderStub.getNumberOfReceivedMessages();
return (numberOfReceivedMessages == 3);
});
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationAggregatorTest method buildMessage.
private Message buildMessage(String intygsId, HandelsekodEnum ht, LocalDateTime tid) throws JsonProcessingException {
Message message = mock(Message.class);
NotificationMessage nf = new NotificationMessage();
nf.setIntygsId(intygsId);
nf.setHandelse(ht);
nf.setHandelseTid(tid);
when(message.getBody()).thenReturn(objectMapper.writeValueAsString(nf));
return message;
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformerTest method testSendBackwardsCompatibility.
@Test
public void testSendBackwardsCompatibility() throws Exception {
// Given
NotificationMessage notificationMessage = new NotificationMessage(INTYGS_ID, FK7263, LocalDateTime.now(), HandelsekodEnum.SKAPAT, LOGISK_ADRESS, "{ }", FragorOchSvar.getEmpty(), null, null, null, "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);
}
Aggregations