2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.client.exception;
23 import static org.junit.Assert.assertEquals;
25 import org.camunda.bpm.engine.delegate.BpmnError;
26 import org.junit.Test;
27 import org.onap.so.BaseTest;
28 import org.onap.so.bpmn.mock.FileUtil;
30 public class ExceptionBuilderTest extends BaseTest {
32 private static final String RESOURCE_PATH = "__files/";
33 private static final String VALID_ERROR_MESSAGE = "{test error message}";
36 public void buildAndThrowWorkflowExceptionTest() {
38 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
39 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(VALID_ERROR_MESSAGE));
40 } catch (BpmnError bpmnException){
41 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
46 public void buildAndThrowWorkflowExceptionInvalidMessageTest() {
48 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
49 String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessage.txt");
50 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage));
51 } catch (BpmnError bpmnException){
52 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
57 public void buildAndThrowWorkflowExceptionInvalidMessageFlagTest() {
59 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
60 String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessageFlag.txt");
61 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage));
62 } catch (BpmnError bpmnException){
63 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
68 public void buildAndThrowWorkflowExceptionNullMessageTest() {
70 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
71 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException());
72 } catch (BpmnError bpmnException){
73 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());