use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.
the class KafkaServerExtensionConsumerTest method testWithDestroy.
@Test
public void testWithDestroy() {
when(processDefinition.getSignalsDesc()).thenReturn(Collections.singletonList(createSignal("MySignal2", "String")));
Message msg = new Message("MyMessage");
msg.setName("Hello2");
msg.setType("String");
msg.addIncomingNode(mock(Node.class));
extension.onDeploy(getDeploymentEvent("MyDeploy4"));
publishEvent("MySignal2", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"javierito\"}");
verify(processService, getTimeout()).signalEvent("MyDeploy4", "MySignal2", "javierito");
extension.destroy(server, registry);
mockConsumer = new MockConsumer<String, byte[]>(OffsetResetStrategy.EARLIEST);
when(processDefinition.getSignalsDesc()).thenReturn(Collections.emptyList());
when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(msg)));
extension.setKafkaConsumer(mockConsumer);
extension.init(server, registry);
extension.onDeploy(getDeploymentEvent("MyDeploy5"));
publishEvent("Hello2", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"pepe\"}");
verify(processService, getTimeout()).signalEvent("MyDeploy5", "Message-Hello2", "pepe");
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.
the class KafkaServerExtensionConsumerTest method testKafkaServerExecutorMessage.
@Test
public void testKafkaServerExecutorMessage() {
Message msg = new Message("MyMessage");
msg.setName("Hello");
msg.setType("String");
msg.addIncomingNode(mock(Node.class));
when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(msg)));
extension.onDeploy(getDeploymentEvent("MyDeploy2"));
publishEvent("Hello", "{\"id\":\"javi\",\"type\":\"one\",\"source\":\"pepe\",\"data\":\"pepe\"}");
verify(processService, getTimeout()).signalEvent("MyDeploy2", "Message-Hello", "pepe");
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.
the class KafkaServerExtensionConsumerTest method testMessageDisable.
@Test
public void testMessageDisable() {
when(processDefinition.getMessagesDesc()).thenReturn(Collections.singletonList(MessageDescImpl.from(new Message("MyMessage"))));
System.setProperty(MESSAGE_MAPPING_PROPERTY, Mapping.NONE.toString());
extension.onDeploy(getDeploymentEvent("MyDeploy4"));
verify(processDefinition, never()).getMessagesDesc();
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method handleMessageNode.
@SuppressWarnings("unchecked")
public void handleMessageNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
ActionNode actionNode = (ActionNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String inputName = ((Element) xmlNode).getAttribute("name");
dataInputs.put(id, inputName);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, actionNode, parser);
} else if ("messageEventDefinition".equals(nodeName)) {
String messageRef = ((Element) xmlNode).getAttribute("messageRef");
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new IllegalArgumentException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new IllegalArgumentException("Could not find message " + messageRef);
}
String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE_KEY);
Variable v = (Variable) ((ProcessBuildData) parser.getData()).getMetaData("Variable");
if (v != null) {
variable = (String) v.getMetaData(variable);
}
actionNode.setMetaData("MessageType", message.getType());
actionNode.setMetaData("TriggerType", "ProduceMessage");
actionNode.setMetaData("TriggerRef", message.getName());
for (Entry<String, Object> entry : message.getMetaData().entrySet()) {
actionNode.setMetaData(entry.getKey(), entry.getValue());
}
ConsequenceAction action = createJavaAction(new HandleMessageAction(message.getType(), variable, (Transformation) actionNode.getMetaData().get(TRANSFORMATION_KEY)));
actionNode.setAction(action);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project automatiko-engine by automatiko-io.
the class InMessageRefHandler method end.
@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
Element element = parser.endElementBuilder();
String messageId = element.getTextContent();
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new IllegalArgumentException("No messages found");
}
Operation operation = (Operation) parser.getParent();
Message message = messages.get(messageId);
if (message != null) {
operation.setMessage(message);
}
return parser.getCurrent();
}
Aggregations