### Question:
ExecuteActivity implements JavaDelegate { @Override public void execute(DelegateExecution execution) throws Exception { final String requestId = (String) execution.getVariable(G_REQUEST_ID); WorkflowException workflowException; String handlingCode; try { Boolean workflowSyncAckSent = (Boolean) execution.getVariable(WORKFLOW_SYNC_ACK_SENT); if (workflowSyncAckSent == null || workflowSyncAckSent == false) { workflowActionBBTasks.sendSyncAck(execution); execution.setVariable(WORKFLOW_SYNC_ACK_SENT, Boolean.TRUE); } final String implementationString = execution.getBpmnModelElementInstance().getAttributeValue(SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE); logger.debug("activity implementation String: {}", implementationString); if (!implementationString.startsWith(ACTIVITY_PREFIX)) { buildAndThrowException(execution, "Implementation attribute has a wrong format"); } String activityName = implementationString.replaceFirst(ACTIVITY_PREFIX, ""); logger.info("activityName is: {}", activityName); BuildingBlock buildingBlock = buildBuildingBlock(activityName); ExecuteBuildingBlock executeBuildingBlock = buildExecuteBuildingBlock(execution, requestId, buildingBlock); Map<String, Object> variables = new HashMap<>(); if (execution.getVariables() != null) { execution.getVariables().forEach((key, value) -> { if (value instanceof Serializable) { variables.put(key, value); } }); } variables.put(BUILDING_BLOCK, executeBuildingBlock); variables.put(G_REQUEST_ID, requestId); variables.put(RETRY_COUNT, 1); variables.put(A_LA_CARTE, true); variables.put(SUPPRESS_ROLLBACK, true); ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey(EXECUTE_BUILDING_BLOCK).setVariables(variables) .executeWithVariablesInReturn(); VariableMap variableMap = buildingBlockResult.getVariables(); workflowException = (WorkflowException) variableMap.get(WORKFLOW_EXCEPTION); if (workflowException != null) { logger.error("Workflow exception is: {}", workflowException.getErrorMessage()); } handlingCode = (String) variableMap.get(HANDLING_CODE); logger.debug("Handling code: " + handlingCode); execution.setVariable(WORKFLOW_EXCEPTION, workflowException); } catch (Exception e) { logger.error("BPMN exception on activity execution: " + e.getMessage()); workflowException = new WorkflowException(EXECUTE_BUILDING_BLOCK, 7000, e.getMessage()); handlingCode = ABORT_HANDLING_CODE; } if (workflowException != null && handlingCode != null && handlingCode.equals(ABORT_HANDLING_CODE)) { logger.debug("Aborting execution of the custom workflow"); buildAndThrowException(execution, workflowException.getErrorMessage()); } }  @Override void execute(DelegateExecution execution);  }### Answer:
@Test public void executeException_Test() throws Exception { execution.setVariable("workflowSyncAckSent", true); execution.setVariable("testProcessKey", "testProcessKeyValue"); thrown.expect(BpmnError.class); executeActivity.execute(execution); String errorMessage = (String) execution.getVariable("ExecuteActivityErrorMessage"); assertEquals(errorMessage, "not implemented"); WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals(workflowException.getErrorMessage(), "not implemented"); assertEquals(workflowException.getErrorCode(), 7000); }