Alguém sabe fazer um teste unitário chamando uma external task no camunda.
O problema é que ele não entra no método handler do ExternalTaskClient
@Test
@Deployment(resources = “SAC0002-Sincronizacao-de-arvore-de-classificacao.bpmn”)
public void externalTask2() {
RuntimeService runtimeService = processEngine.getRuntimeService();//
ProcessInstance proccessInstance = runtimeService.startProcessInstanceByKey(“SAC0002SincronizacaoDeArvoreDeClassificacaoProcess”);
assertThat(proccessInstance).isWaitingAt(“AtualizarArvoreDeClassificacaoTask”).externalTask().hasTopicName(“AtualizarArvoreDeClassificacaoTask”);
Map<String, Object> mapa = new HashMap<String, Object>();
mapa.put("enterprise", "1");
mapa.put("origin", "1");
mapa.put("type", "1");
complete(externalTask(), mapa);
new AtualizarArvoreDeClassificacaoTask();
}
Classe com external task
public AtualizarArvoreDeClassificacaoTask() {
log.info(“AtualizarArvoreDeClassificacaoTask() - start”);
ExternalTaskClient client = ExternalTaskClient.create().baseUrl(CamundaRestApi.url())
.asyncResponseTimeout(10000).build();
client.subscribe("AtualizarArvoreDeClassificacaoTask").handler((externalTask, externalTaskService) -> {
log.info("AtualizarArvoreDeClassificacaoTask() - start handler");
Map<String, Object> variables = externalTask.getAllVariables();
Enterprise enterprise = (Enterprise) variables.get("enterprise");
String origin = (String) variables.get("origin");
ManifestationType type = (ManifestationType) variables.get("type");
ClassificationTree tree = new ClassificationTree(enterprise, origin, type);
ClassificationTree existentTree = repository.findByCompositeCode(enterprise, origin, type);
if (existentTree != null) {
tree.setId(existentTree.getId());
if (!tree.equals(existentTree)) {
tree = repository.save(tree);
}
} else {
tree = repository.save(tree);
}
variables.put("tree", tree);
externalTaskService.complete(externalTask, variables);
log.info("AtualizarArvoreDeClassificacaoTask() - end handler");
}).open();
log.info("AtualizarArvoreDeClassificacaoTask() - end");
}
Atenciosamente,