Map<String, Object> metadata = eventNodeInstance.getNode().getMetaData();
ProcessInstance pi = eventNodeInstance.getProcessInstance();
Node node = eventNodeInstance.getNode();
String bpmn2NodeId = (String) metadata.get("UniqueId");
SimulationDataProvider provider = context.getDataProvider();
TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node));
long duration = timeGenerator.generateTime();
context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS);
// set end time for processinstance end time
context.setMaxEndTime(context.getClock().getCurrentTime());
String type = (String) provider.getProcessDataForNode(node).get("node.type");
return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration,
startTime, context.getClock().getCurrentTime(), type);
}