use of io.automatiko.engine.workflow.bpmn2.core.Message in project jbpm by kiegroup.
the class MessageDescImplTest method testNotEqualsHashCode.
@Test
public void testNotEqualsHashCode() {
Message message1 = new Message("id");
Message message2 = new Message("id");
message2.setName("name");
message2.setName("type");
MessageDesc messageDesc1 = MessageDescImpl.from(message1);
MessageDesc messageDesc2 = MessageDescImpl.from(message2);
assertNotEquals(messageDesc1.hashCode(), messageDesc2.hashCode());
assertNotEquals(messageDesc1, messageDesc2);
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project jbpm by kiegroup.
the class SignalDescImplTest method testSignalIsNotMessage.
@Test
public void testSignalIsNotMessage() {
SignalDescBase signalDesc1 = SignalDescImpl.from(new Signal("id", "id"));
SignalDescBase signalDesc2 = MessageDescImpl.from(new Message("id"));
assertEquals(signalDesc1.getId(), signalDesc2.getId());
assertEquals(signalDesc1.getName(), signalDesc2.getName());
assertNotEquals(signalDesc1, signalDesc2);
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project droolsjbpm-integration by kiegroup.
the class KafkaServerRegistrationTest method testVersionedDeployment.
@Test
public void testVersionedDeployment() {
KafkaServerRegistration register = new KafkaServerRegistration();
DeployedUnitImpl du1 = new DeployedUnitImpl(new KModuleDeploymentUnit("individuo", "pepe", "1.0"));
DeployedUnitImpl du2 = new DeployedUnitImpl(new KModuleDeploymentUnit("individuo", "pepe", "2.0"));
Message message = new Message("pepe");
message.setName("pepe");
Node node = mock(Node.class);
message.addIncomingNode(node);
MessageDesc signal = MessageDescImpl.from(message);
ProcessAssetDesc processDesc = new ProcessAssetDesc();
processDesc.setMessagesDesc(Collections.singletonList(signal));
du1.addAssetLocation("pepe", processDesc);
du2.addAssetLocation("pepe", processDesc);
DeploymentEvent event1 = new DeploymentEvent(du1.getDeploymentUnit().getIdentifier(), du1);
DeploymentEvent event2 = new DeploymentEvent(du2.getDeploymentUnit().getIdentifier(), du2);
register.addRegistration(event1);
register.addRegistration(event2);
ConsumerRecord<String, byte[]> record = mock(ConsumerRecord.class);
when(record.topic()).thenReturn("pepe");
KafkaServerEventProcessor<MessageDesc> processor = mock(KafkaServerEventProcessor.class);
register.forEachMessage(record, processor);
verify(processor).accept(record, event1.getDeploymentId(), signal);
verify(processor).accept(record, event2.getDeploymentId(), signal);
reset(processor);
message.addIncomingNode(mock(StartNode.class));
register.forEachMessage(record, processor);
verify(processor, times(0)).accept(record, event1.getDeploymentId(), signal);
verify(processor).accept(record, event2.getDeploymentId(), signal);
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project kogito-runtimes by kiegroup.
the class ProcessHandler method postProcessCollaborations.
private void postProcessCollaborations(RuleFlowProcess process, ExtensibleXmlParser parser) {
// now we wire correlation process subscriptions
CorrelationManager correlationManager = process.getCorrelationManager();
for (Message message : HandlerUtil.messages(parser).values()) {
correlationManager.newMessage(message.getId(), message.getName(), message.getType());
}
// only the ones this process is member of
List<Collaboration> collaborations = HandlerUtil.collaborations(parser).values().stream().filter(c -> c.getProcessesRef().contains(process.getId())).collect(Collectors.toList());
for (Collaboration collaboration : collaborations) {
for (CorrelationKey key : collaboration.getCorrelationKeys()) {
correlationManager.newCorrelation(key.getId(), key.getName());
List<CorrelationProperty> properties = key.getPropertiesRef().stream().map(k -> HandlerUtil.correlationProperties(parser).get(k)).collect(Collectors.toList());
for (CorrelationProperty correlationProperty : properties) {
correlationProperty.getMessageRefs().forEach(messageRef -> {
// for now only MVEL expressions
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
correlationManager.addMessagePropertyExpression(key.getId(), messageRef, correlationProperty.getId(), evaluator);
});
}
}
}
// we create the correlations
for (CorrelationSubscription subscription : HandlerUtil.correlationSubscription(process).values()) {
correlationManager.subscribeTo(subscription.getCorrelationKeyRef());
for (Map.Entry<String, Expression> binding : subscription.getPropertyExpressions().entrySet()) {
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(binding.getValue().getScript());
correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(), binding.getKey(), evaluator);
}
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Message in project kogito-runtimes by kiegroup.
the class ReceiveTaskHandler method handleNode.
@SuppressWarnings("unchecked")
protected Node handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
WorkItemNode workItemNode = (WorkItemNode) node;
String messageRef = element.getAttribute("messageRef");
Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new ProcessParsingValidationException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new ProcessParsingValidationException("Could not find message " + messageRef);
}
workItemNode.getWork().setParameter("MessageId", message.getId());
workItemNode.getWork().setParameter("MessageType", message.getType());
return node;
}
Aggregations