use of org.apache.camel.impl.DefaultMessage in project webcert by sklintyg.
the class RouteTest method testRoutesToAggregatorForLuaeFsAndrat.
@Test
public void testRoutesToAggregatorForLuaeFsAndrat() throws InterruptedException, ModuleException {
// This is just a hack in order to not fail subsequent tests due to camel unit tests leaking context between
// tests. This one just makes sure the notficationAggregator doesn't cause the subsequent "split(body())"
// to throw some exception caught by later tests.
notificationAggregator.whenAnyExchangeReceived(exchange -> {
Message msg = new DefaultMessage();
exchange.setOut(msg);
});
// Given
notificationWSClient.expectedMessageCount(0);
notificationAggregator.expectedMessageCount(1);
permanentErrorHandlerEndpoint.expectedMessageCount(0);
temporaryErrorHandlerEndpoint.expectedMessageCount(0);
signatWireTap.expectedMessageCount(1);
// When
Map<String, Object> headers = new HashMap<>();
headers.put(NotificationRouteHeaders.INTYGS_TYP, "luae_fs");
headers.put(NotificationRouteHeaders.HANDELSE, HandelsekodEnum.ANDRAT.value());
producerTemplate.sendBodyAndHeaders(createNotificationMessage(SchemaVersion.VERSION_3, "luae_fs"), headers);
// Then
assertIsSatisfied(notificationWSClient);
assertIsSatisfied(notificationAggregator);
assertIsSatisfied(permanentErrorHandlerEndpoint);
assertIsSatisfied(temporaryErrorHandlerEndpoint);
assertIsSatisfied(signatWireTap);
}
use of org.apache.camel.impl.DefaultMessage 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);
}
use of org.apache.camel.impl.DefaultMessage 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 org.apache.camel.impl.DefaultMessage in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method createSwiftContainer.
@Test
public void createSwiftContainer() throws Exception {
CamelContext camelContext = Mockito.mock(CamelContext.class);
when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
Message msg = new DefaultMessage(camelContext);
Exchange exchange = Mockito.mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
when(containerService.create(anyString(), nullable(CreateUpdateContainerOptions.class))).thenReturn(actionResponse);
when(actionResponse.isSuccess()).thenReturn(true);
SwiftEndpoint endpoint = Mockito.mock(SwiftEndpoint.class);
Producer producer = new ContainerProducer(endpoint, client);
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
producer.process(exchange);
ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
assertNull(optionsCaptor.getValue());
assertFalse(msg.isFault());
}
use of org.apache.camel.impl.DefaultMessage in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method createNeutronNetwork.
@Test
public void createNeutronNetwork() throws Exception {
CamelContext camelContext = Mockito.mock(CamelContext.class);
when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
Message msg = new DefaultMessage(camelContext);
Exchange exchange = Mockito.mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(OpenstackConstants.NAME, dummyNetwork.getName());
msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());
NeutronEndpoint endpoint = Mockito.mock(NeutronEndpoint.class);
Producer producer = new NetworkProducer(endpoint, client);
producer.process(exchange);
ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
verify(networkService).create(captor.capture());
assertEqualsNetwork(dummyNetwork, captor.getValue());
assertNotNull(msg.getBody(Network.class).getId());
}
Aggregations