### Question:
ExceptionBuilder { public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) { String msg = "Exception in %s.%s "; try { logger.error("Exception occurred", exception); String errorVariable = "Error%s%s"; StackTraceElement[] trace = Thread.currentThread().getStackTrace(); for (StackTraceElement traceElement : trace) { if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) { msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); String shortClassName = traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); break; } } logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { logger.error("Exception occurred", ex); } if (exception.getMessage() != null) msg = msg.concat(exception.getMessage()); buildAndThrowWorkflowException(execution, errorCode, msg); }  void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception); void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception,
            ONAPComponentsList extSystemErrorSource); void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception); void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception,
            ONAPComponentsList extSystemErrorSource); @Deprecated void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage); void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage,
            ONAPComponentsList extSystemErrorSource); void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage); void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage); void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage,
            ONAPComponentsList extSystemErrorSource); WorkflowException buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage,
            ONAPComponentsList extSystemErrorSource); void buildAndThrowWorkflowException(DelegateExecution execution, String errorCode, String errorMessage); String getProcessKey(DelegateExecution execution); void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue); void processOpenstackAdapterException(DelegateExecution execution);  }### Answer:
@Test public void buildAndThrowWorkflowExceptionTest() { try { ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(VALID_ERROR_MESSAGE)); } catch (BpmnError bpmnException) { assertEquals("MSOWorkflowException", bpmnException.getErrorCode()); } }
@Test public void buildAndThrowWorkflowExceptionInvalidMessageTest() { try { ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessage.txt"); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage)); } catch (BpmnError bpmnException) { assertEquals("MSOWorkflowException", bpmnException.getErrorCode()); } }
@Test public void buildAndThrowWorkflowExceptionInvalidMessageFlagTest() { try { ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessageFlag.txt"); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage)); } catch (BpmnError bpmnException) { assertEquals("MSOWorkflowException", bpmnException.getErrorCode()); } }
@Test public void buildAndThrowWorkflowExceptionNullMessageTest() { try { ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException()); } catch (BpmnError bpmnException) { assertEquals("MSOWorkflowException", bpmnException.getErrorCode()); } }