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;
24 import static org.junit.Assert.assertTrue;
25 import org.camunda.bpm.engine.delegate.BpmnError;
26 import org.junit.Test;
27 import org.onap.so.bpmn.mock.FileUtil;
28 import org.onap.so.BaseTest;
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}";
37 public void buildAndThrowWorkflowExceptionTest() {
39 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
40 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
41 new NullPointerException(VALID_ERROR_MESSAGE));
42 } catch (BpmnError bpmnException) {
43 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
48 public void buildAndThrowWorkflowExceptionInvalidMessageTest() {
50 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
51 String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessage.txt");
52 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
53 new NullPointerException(invalidErrorMessage));
54 } catch (BpmnError bpmnException) {
55 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
60 public void buildAndThrowWorkflowExceptionInvalidMessageFlagTest() {
62 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
63 String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessageFlag.txt");
64 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
65 new NullPointerException(invalidErrorMessage));
66 } catch (BpmnError bpmnException) {
67 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
72 public void buildAndThrowWorkflowExceptionNullMessageTest() {
74 ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
75 exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException());
76 } catch (BpmnError bpmnException) {
77 assertEquals("MSOWorkflowException", bpmnException.getErrorCode());