Replaced all tabs with spaces in java and pom.xml
[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 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.mockito.InjectMocks;
30 import org.mockito.Mock;
31 import org.mockito.runners.MockitoJUnitRunner;
32 import org.onap.so.bpmn.common.BuildingBlockExecution;
33 import org.onap.so.bpmn.common.DelegateExecutionImpl;
34 import org.onap.so.db.catalog.beans.BuildingBlockDetail;
35 import org.onap.so.db.catalog.beans.OrchestrationAction;
36 import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
37 import org.onap.so.db.catalog.beans.ResourceType;
38 import org.onap.so.db.catalog.client.CatalogDbClient;
39
40 @RunWith(MockitoJUnitRunner.class)
41 public class OrchestrationStatusValidatorUnitTest {
42
43     @Mock
44     private CatalogDbClient catalogDbClient;
45
46     @InjectMocks
47     private OrchestrationStatusValidator validator;
48
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"),
63                 equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
64     }
65
66 }