Search in sources :

Example 6 with PersonalInfo

use of org.mule.test.heisenberg.extension.model.PersonalInfo in project mule by mulesoft.

the class ExtensionNotificationsTestCase method sourceFiresNotificationsOnError.

@Test
public void sourceFiresNotificationsOnError() throws Exception {
    CountDownLatch latch = new CountDownLatch(4);
    setUpListener(notification -> latch.countDown());
    Flow flow = (Flow) getFlowConstruct("sourceNotificationsError");
    flow.start();
    latch.await(4000, MILLISECONDS);
    assertThat(listener.getNotifications(), hasSize(4));
    ExtensionNotification notification1 = listener.getNotifications().get(0);
    verifyNewBatch(notification1, 1);
    String correlationId = notification1.getEvent().getCorrelationId();
    ExtensionNotification notification2 = listener.getNotifications().get(1);
    verifyNextBatch(notification2, 100000L);
    assertThat(notification2.getEvent().getCorrelationId(), is(correlationId));
    ExtensionNotification notification3 = listener.getNotifications().get(2);
    assertThat(notification3.getAction().getNamespace(), is(HEISENBERG));
    assertThat(notification3.getAction().getIdentifier(), is("BATCH_DELIVERY_FAILED"));
    assertThat(notification3.getData().getValue(), instanceOf(PersonalInfo.class));
    assertThat(((PersonalInfo) notification3.getData().getValue()).getAge(), is(27));
    assertThat(notification3.getEvent().getCorrelationId(), is(correlationId));
    ExtensionNotification notification4 = listener.getNotifications().get(3);
    verifyBatchTerminated(notification4, 1);
    assertThat(notification4.getEvent().getCorrelationId(), is(correlationId));
}
Also used : ExtensionNotification(org.mule.runtime.api.notification.ExtensionNotification) PersonalInfo(org.mule.test.heisenberg.extension.model.PersonalInfo) CountDownLatch(java.util.concurrent.CountDownLatch) Flow(org.mule.runtime.core.api.construct.Flow) Test(org.junit.Test)

Aggregations

PersonalInfo (org.mule.test.heisenberg.extension.model.PersonalInfo)6 Test (org.junit.Test)5 SmallTest (org.mule.tck.size.SmallTest)3 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1 JavaTypeLoader (org.mule.metadata.java.api.JavaTypeLoader)1 Message (org.mule.runtime.api.message.Message)1 ExtensionNotification (org.mule.runtime.api.notification.ExtensionNotification)1 Flow (org.mule.runtime.core.api.construct.Flow)1 ParameterGroupDescriptor (org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor)1 TypeWrapper (org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper)1