use of com.uber.cadence.internal.testservice.StateMachines.State in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method processRequestCancelActivityTask.
private void processRequestCancelActivityTask(RequestContext ctx, RequestCancelActivityTaskDecisionAttributes a, long decisionTaskCompletedId) throws InternalServiceError {
String activityId = a.getActivityId();
StateMachine<?> activity = activities.get(activityId);
if (activity == null) {
RequestCancelActivityTaskFailedEventAttributes failedAttr = new RequestCancelActivityTaskFailedEventAttributes().setActivityId(activityId).setCause("ACTIVITY_ID_UNKNOWN").setDecisionTaskCompletedEventId(decisionTaskCompletedId);
HistoryEvent cancellationFailed = new HistoryEvent().setEventType(EventType.RequestCancelActivityTaskFailed).setRequestCancelActivityTaskFailedEventAttributes(failedAttr);
ctx.addEvent(cancellationFailed);
return;
}
State beforeState = activity.getState();
activity.action(StateMachines.Action.REQUEST_CANCELLATION, ctx, a, decisionTaskCompletedId);
if (beforeState == StateMachines.State.INITIATED) {
activity.action(StateMachines.Action.CANCEL, ctx, null, 0);
activities.remove(activityId);
ctx.setNeedDecision(true);
}
}
Aggregations