My Bpmn flow working Fine with all tasks with spring boot start up. Trying to local test setup with junit5 to do entire process test. Getting the below error
org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: ${delegateExpressionDelegator}. Cause: Cannot resolve identifier ‘delegateExpressionDelegator’
Thanks Jonathan for the reply. I have tried MockExpressionManager but not working. I am dynamically passing the activity id and using the same delegateExression for all the service tasks which would have required args constructor.
@Named(value = “delegateExpressionDelegator”) @Slf4j @RequiredArgsConstructor
public class DelegateExpressionDelegator implements DelegateExpressionListener {
private final ActivityBeanMapper<DelegateExpressionListener> activityBeanMapper;
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
log.info("Well done -- DelegateExpressionSplitter");
final var beanId = delegateExecution.getCurrentActivityId();
DelegateExpressionListener delegateExpressionListenerTask = activityBeanMapper.getBeanByActivityId(
beanId);
delegateExpressionListenerTask.execute(delegateExecution);
}
}
@Component @Slf4j @RequiredArgsConstructor
public class ActivityBeanMapper {
private final BeanFactory beanFactory;
public DelegateExpressionListener getBeanByActivityId(@NotBlank final String beanName) {
log.debug("Get Instance for Service Bean [{}]", beanName);
return getBeanFromFactory(beanName);
}
private DelegateExpressionListener getBeanFromFactory(final String beanName) {
try {
return beanFactory.getBean(beanName,
DelegateExpressionListener.class);
} catch (BeansException beansException) {
log.error("Exception while fetching bean for Service = [{}] is [{}]", beanName, beansException);
throw new BpmnError("No Mapping found for Service Bean".concat( beanName));
}
}
public T getBeanByActivityId(@NotBlank final String beanName, final Class<T> clazz) {
log.info("Get Instance for Service Bean [{}]", beanName);
return getBeanFromFactory(beanName, clazz);
}
private T getBeanFromFactory(@NotBlank final String beanName, final Class<T> clazz) {
try {
return beanFactory.getBean(beanName, clazz);
} catch (BeansException beansException) {
log.error("Exception while fetching bean for Service = [{}] is [{}]", beanName, beansException);
throw new BpmnError("No Mapping found for Service Bean [{}]".concat( beanName));
}
}
}
@Component(value = “serviceTaskActivityId”) @Slf4j @RequiredArgsConstructor
public class ServiceTaskListener extends DelegateExpressionListener {
log.info(“Business-Key [{}] ServiceTaskListener with Activity_ID >> [{}]”, delegateExecution.getVariable(ExecutionVariableConstants.BUSINESS_KEY),
delegateExecution.getCurrentActivityId());
}