d4496d3a5597c12b86c23d16986db4039fee58f0
[so.git] / bpmn / so-bpmn-building-blocks / src / test / java / org / onap / so / bpmn / buildingblock / SniroHomingV2BBTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.bpmn.buildingblock;
22
23 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
24 import static org.mockito.Matchers.any;
25 import static org.mockito.Mockito.doThrow;
26
27 import org.camunda.bpm.engine.delegate.BpmnError;
28 import org.camunda.bpm.engine.runtime.ProcessInstance;
29 import org.junit.Ignore;
30 import org.junit.Test;
31 import org.onap.so.bpmn.buildingblock.SniroHomingV2;
32 import org.onap.so.bpmn.common.BuildingBlockExecution;
33 import org.onap.so.BaseTest;
34 import org.springframework.boot.test.mock.mockito.MockBean;
35
36
37 @Ignore //these test run locally but fail when ran in conjunction with others in jenkins
38 public class SniroHomingV2BBTest extends BaseTest{
39
40         @MockBean
41         protected SniroHomingV2 sniroHoming;
42
43         @Test
44         public void testHomingV2_success(){
45                 mockSubprocess("ReceiveWorkflowMessage", "Mock ReceiveWorkflowMessage", "GenericStub");
46                 ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables);
47                 assertThat(pi).isNotNull();
48                 assertThat(pi).isStarted().hasPassedInOrder("start", "callSniro", "callReceiveAsync", "processSolution", "end");
49                 assertThat(pi).isEnded();
50         }
51
52         @Test
53         public void testHomingV2_error_bpmnError(){
54                 doThrow(new BpmnError("MSOWorkflowException")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class));
55                 ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables);
56                 assertThat(pi).isNotNull();
57                 assertThat(pi).isStarted()
58                                 .hasPassedInOrder("start", "catchBpmnError", "processBpmnError", "endBpmnError")
59                                 .hasNotPassed("callReceiveAsync");
60                 assertThat(pi).isEnded();
61         }
62
63         @Test
64         public void testHomingV2_error_javaException(){
65                 doThrow(new RuntimeException("Test")).when(sniroHoming).callSniro(any(BuildingBlockExecution.class));
66                 ProcessInstance pi = runtimeService.startProcessInstanceByKey("HomingV2", variables);
67                 assertThat(pi).isNotNull();
68                 assertThat(pi).isStarted()
69                                 .hasPassedInOrder("start", "catchJavaException", "processJavaException", "endJavaException")
70                                 .hasNotPassed("callReceiveAsync");
71                 assertThat(pi).isEnded();
72         }
73
74 }