use of de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.access.ElementReadEventMessage in project FAAAST-Service by FraunhoferIOSB.
the class RequestHandler method publishElementReadEventMessage.
/**
* Publish a ElementReadEventMessage to the message bus
*
* @param reference of the element
* @param referable the instance
*/
public void publishElementReadEventMessage(Reference reference, Referable referable) {
ElementReadEventMessage eventMessage = new ElementReadEventMessage();
eventMessage.setElement(reference);
eventMessage.setValue(referable);
try {
this.messageBus.publish(eventMessage);
} catch (Exception e) {
e.printStackTrace();
}
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.access.ElementReadEventMessage in project FAAAST-Service by FraunhoferIOSB.
the class Util method setUpEventCheck.
public static void setUpEventCheck(Referable expected, Class<? extends EventMessage> clazz, Supplier<?> call) {
AtomicBoolean fired = new AtomicBoolean(false);
SubscriptionId subscriptionId = IntegrationTestHttpEndpoint.messageBus.subscribe(SubscriptionInfo.create(clazz, x -> {
if (ElementReadEventMessage.class.isAssignableFrom(x.getClass())) {
Assert.assertEquals(expected, ((ElementReadEventMessage) x).getValue());
fired.set(true);
}
if (ElementCreateEventMessage.class.isAssignableFrom(x.getClass())) {
Assert.assertEquals(expected, ((ElementCreateEventMessage) x).getValue());
fired.set(true);
}
if (ElementUpdateEventMessage.class.isAssignableFrom(x.getClass())) {
Assert.assertEquals(expected, ((ElementUpdateEventMessage) x).getValue());
fired.set(true);
}
if (ElementDeleteEventMessage.class.isAssignableFrom(x.getClass())) {
Assert.assertEquals(expected, ((ElementDeleteEventMessage) x).getValue());
fired.set(true);
}
}));
call.get();
Assert.assertTrue(fired.get());
IntegrationTestHttpEndpoint.messageBus.unsubscribe(subscriptionId);
}
Aggregations