2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openecomp.sdc.be.tosca.utils;
18 import org.junit.BeforeClass;
19 import org.junit.Test;
20 import org.openecomp.sdc.be.DummyConfigurationManager;
21 import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
22 import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
23 import org.openecomp.sdc.be.model.Component;
24 import org.openecomp.sdc.be.model.InterfaceDefinition;
25 import org.openecomp.sdc.be.model.Resource;
28 import java.util.HashMap;
30 import static org.junit.Assert.assertEquals;
32 public class OperationArtifactUtilTest {
35 public static void setUp() throws Exception {
36 new DummyConfigurationManager();
40 public void testCorrectPathForOperationArtifacts() {
41 Component component = new Resource();
42 component.setNormalizedName("normalizedComponentName");
43 final InterfaceDefinition addedInterface = new InterfaceDefinition();
44 final OperationDataDefinition op = new OperationDataDefinition();
45 final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
46 implementation.setArtifactName("createBPMN.bpmn");
47 op.setImplementation(implementation);
48 addedInterface.setOperations(new HashMap<>());
49 addedInterface.getOperations().put("create", op);
50 final String interfaceType = "normalizedComponentName-interface";
51 ((Resource) component).setInterfaces(new HashMap<>());
52 ((Resource) component).getInterfaces().put(interfaceType, addedInterface);
53 final String actualArtifactPath = OperationArtifactUtil.createOperationArtifactPath(component.getNormalizedName(), interfaceType, op);
54 String expectedArtifactPath ="Artifacts"+ File.separator+"normalizedComponentName"+File.separator
55 +"normalizedComponentName-interface"+File.separator+"Deployment"
56 +File.separator+"Workflows"+File.separator+"BPMN"
57 +File.separator+"createBPMN.bpmn";
60 assertEquals(expectedArtifactPath,actualArtifactPath);