Retry a Service Task based on response from API

Camunda service tasks will be retried in case of exceptions. However, how to retry for business logic.
The api I call in the service task which happens to be a parallel multi instance can respond with three states :Success, Fail, Inprogress.
I would want ALL the executions to stop and the workflow to have an incident in case of any request returning a Fails status.
In case the status of any request is Inprogress a retry should happen for that individual request unless the status is either Success or Fail.
If all requests pass, the workflow should successfully complete.

In my Java delegate I just invoke the client.
MyExpectedResponse response = client.getStatusForId(id);
switch (response.getStatus()) {
case FAIL:
throw new BpmnError(“Failed”, String.format("failed for transaction Id: %s ", id));
case PROCESSING:“transaction Id {} status is still in progress”, id);
// what to do here ??
log.error(“invalid status for transaction Id {}”, id);
throw new BpmnError(
String.format(“invalid status for transaction Id %s”, id));


Also, I would like to understand how to test with Mockito.

Will this be the right approach?