### Question:
ExecuteActivity implements JavaDelegate { protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg, ex); execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg); workflowActionBBFailure.updateRequestStatusToFailed(execution); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); }  @Override void execute(DelegateExecution execution);  }### Answer:
@Test public void buildAndThrowException_Test() throws Exception { doNothing().when(workflowActionBBFailure).updateRequestStatusToFailed(execution); doReturn("Process key").when(exceptionBuilder).getProcessKey(execution); thrown.expect(BpmnError.class); executeActivity.buildAndThrowException(execution, "TEST EXCEPTION MSG"); String errorMessage = (String) execution.getVariable("ExecuteActivityErrorMessage"); assertEquals(errorMessage, "TEST EXCEPTION MSG"); WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals(workflowException.getErrorMessage(), "TEST EXCEPTION MSG"); assertEquals(workflowException.getErrorCode(), 7000); }