Search in sources :

Example 1 with SimpleKnockeableDoor

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

the class HeisenbergOperations method knock.

@MediaType(TEXT_PLAIN)
@Fires(KnockNotificationProvider.class)
public String knock(KnockeableDoor knockedDoor, NotificationEmitter notificationEmitter) {
    TypedValue<SimpleKnockeableDoor> door = of(new SimpleKnockeableDoor(knockedDoor));
    notificationEmitter.fire(KNOCKING_DOOR, door);
    String knock = knockedDoor.knock();
    notificationEmitter.fire(KNOCKED_DOOR, door);
    return knock;
}
Also used : SimpleKnockeableDoor(org.mule.test.heisenberg.extension.model.SimpleKnockeableDoor) Fires(org.mule.runtime.extension.api.annotation.notification.Fires) MediaType(org.mule.runtime.extension.api.annotation.param.MediaType)

Example 2 with SimpleKnockeableDoor

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

the class ExtensionNotificationsTestCase method operationFiresNotificationsWithCustomData.

@Test
public void operationFiresNotificationsWithCustomData() throws Exception {
    CountDownLatch latch = new CountDownLatch(2);
    setUpListener(notification -> latch.countDown());
    String correlationId = flowRunner("operationNotification").run().getCorrelationId();
    latch.await(2000, MILLISECONDS);
    assertThat(listener.getNotifications(), hasSize(2));
    ExtensionNotification notification1 = listener.getNotifications().get(0);
    assertThat(notification1.getAction().getNamespace(), is(HEISENBERG));
    assertThat(notification1.getAction().getIdentifier(), is("KNOCKING_DOOR"));
    assertThat(notification1.getData().getValue(), instanceOf(SimpleKnockeableDoor.class));
    assertThat(((SimpleKnockeableDoor) notification1.getData().getValue()).getSimpleName(), is("Top Level Skyler @ 308 Negra Arroyo Lane"));
    assertThat(notification1.getEvent().getCorrelationId(), is(correlationId));
    ExtensionNotification notification2 = listener.getNotifications().get(1);
    assertThat(notification2.getAction().getNamespace(), is(HEISENBERG));
    assertThat(notification2.getAction().getIdentifier(), is("KNOCKED_DOOR"));
    assertThat(notification2.getData().getValue(), instanceOf(SimpleKnockeableDoor.class));
    assertThat(((SimpleKnockeableDoor) notification2.getData().getValue()).getSimpleName(), is("Top Level Skyler @ 308 Negra Arroyo Lane"));
    assertThat(notification2.getEvent().getCorrelationId(), is(correlationId));
}
Also used : ExtensionNotification(org.mule.runtime.api.notification.ExtensionNotification) CountDownLatch(java.util.concurrent.CountDownLatch) SimpleKnockeableDoor(org.mule.test.heisenberg.extension.model.SimpleKnockeableDoor) Test(org.junit.Test)

Aggregations

SimpleKnockeableDoor (org.mule.test.heisenberg.extension.model.SimpleKnockeableDoor)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1 ExtensionNotification (org.mule.runtime.api.notification.ExtensionNotification)1 Fires (org.mule.runtime.extension.api.annotation.notification.Fires)1 MediaType (org.mule.runtime.extension.api.annotation.param.MediaType)1