2 * ============LICENSE_START=======================================================
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
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.bpmn.infrastructure.workflow.tasks;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.junit.Assert.assertThat;
25 import static org.mockito.Mockito.when;
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;
41 @RunWith(MockitoJUnitRunner.class)
42 public class OrchestrationStatusValidatorUnitTest {
45 private CatalogDbClient catalogDbClient;
48 private OrchestrationStatusValidator validator;
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);
62 assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));