05fa8bb9d44be01c1c156e43732c322c8740bd38
[so.git] /
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.infrastructure.workflow.tasks;
22
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;
45
46 @RunWith(MockitoJUnitRunner.class)
47 public class WorkflowActionUnitTest {
48
49     private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
50
51     @Mock
52     private CatalogDbClient catalogDbClient;
53     @Mock
54     private BBInputSetup bbInputSetup;
55     @Mock
56     private BBInputSetupUtils bbInputSetupUtils;
57     @Mock
58     private ExceptionBuilder exceptionBuilder;
59     @Mock
60     private AAIConfigurationResources aaiConfigurationResources;
61
62     @InjectMocks
63     @Spy
64     private WorkflowAction workflowAction;
65
66     @Test
67     public void traverseCatalogDbForConfigurationTest() {
68
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);
80
81         // List<CvnfcConfigurationCustomization> results =
82         // workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
83
84         // assertThat(results, is(Arrays.asList(vfModuleCustomization)));
85
86     }
87
88     private String getJson(String filename) throws IOException {
89         return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
90     }
91
92     private List<OrchestrationFlow> createFlowList(String... myList) {
93
94         List<OrchestrationFlow> result = new ArrayList<>();
95         for (String name : myList) {
96             OrchestrationFlow flow = new OrchestrationFlow();
97             flow.setFlowName(name);
98             result.add(flow);
99         }
100
101         return result;
102
103     }
104 }