2 * ============LICENSE_START=======================================================
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
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 java.io.IOException;
24 import java.nio.file.Files;
25 import java.nio.file.Paths;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collections;
29 import java.util.List;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.InjectMocks;
33 import org.mockito.Mock;
34 import org.mockito.Spy;
35 import org.mockito.junit.MockitoJUnitRunner;
36 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
37 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
38 import org.onap.so.client.exception.ExceptionBuilder;
39 import org.onap.so.client.orchestration.AAIConfigurationResources;
40 import org.onap.so.db.catalog.beans.ConfigurationResource;
41 import org.onap.so.db.catalog.beans.CvnfcCustomization;
42 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
43 import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
44 import org.onap.so.db.catalog.client.CatalogDbClient;
46 @RunWith(MockitoJUnitRunner.class)
47 public class WorkflowActionUnitTest {
49 private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
52 private CatalogDbClient catalogDbClient;
54 private BBInputSetup bbInputSetup;
56 private BBInputSetupUtils bbInputSetupUtils;
58 private ExceptionBuilder exceptionBuilder;
60 private AAIConfigurationResources aaiConfigurationResources;
64 private WorkflowAction workflowAction;
67 public void traverseCatalogDbForConfigurationTest() {
69 CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
70 CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
71 ConfigurationResource configuration = new ConfigurationResource();
72 configuration.setToscaNodeType("FabricConfiguration");
73 configuration.setModelUUID("my-uuid");
74 vfModuleCustomization.setConfigurationResource(configuration);
75 cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singletonList(vfModuleCustomization));
76 List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization);
77 // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class),
78 // any(String.class)))
79 // .thenReturn(cvnfcCustomizations);
81 // List<CvnfcConfigurationCustomization> results =
82 // workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
84 // assertThat(results, is(Arrays.asList(vfModuleCustomization)));
88 private String getJson(String filename) throws IOException {
89 return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
92 private List<OrchestrationFlow> createFlowList(String... myList) {
94 List<OrchestrationFlow> result = new ArrayList<>();
95 for (String name : myList) {
96 OrchestrationFlow flow = new OrchestrationFlow();
97 flow.setFlowName(name);