03b39f57e5ba3197b6c82f8da97d787ddccdac7b
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / workflow / tasks / OrchestrationStatusValidatorUnitTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.infrastructure.workflow.tasks;
22
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.junit.Assert.assertThat;
25 import static org.mockito.Mockito.when;
26
27 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.InjectMocks;
31 import org.mockito.Mock;
32 import org.mockito.runners.MockitoJUnitRunner;
33 import org.onap.so.bpmn.common.BuildingBlockExecution;
34 import org.onap.so.bpmn.common.DelegateExecutionImpl;
35 import org.onap.so.db.catalog.beans.BuildingBlockDetail;
36 import org.onap.so.db.catalog.beans.OrchestrationAction;
37 import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
38 import org.onap.so.db.catalog.beans.ResourceType;
39 import org.onap.so.db.catalog.client.CatalogDbClient;
40
41 @RunWith(MockitoJUnitRunner.class)
42 public class OrchestrationStatusValidatorUnitTest {
43
44         @Mock
45         private CatalogDbClient catalogDbClient;
46         
47         @InjectMocks
48         private OrchestrationStatusValidator validator;
49         @Test
50         public void skipValidationTest() {
51                 BuildingBlockDetail bbDetail = new BuildingBlockDetail();
52                 bbDetail.setBuildingBlockName("customBB");
53                 bbDetail.setResourceType(ResourceType.NO_VALIDATE);
54                 bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
55                 when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
56                 BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
57                 execution.setVariable("flowToBeCalled", "customBB");
58                 execution.setVariable("aLaCarte", false);
59                 validator.validateOrchestrationStatus(execution);
60                 
61                 
62                 assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
63         }
64         
65 }