Tosca for Workflow operations
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / tosca / utils / OperationArtifactUtilTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.openecomp.sdc.be.tosca.utils;
17
18 import static org.junit.Assert.assertEquals;
19
20 import java.io.File;
21 import java.util.HashMap;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
24 import org.openecomp.sdc.be.DummyConfigurationManager;
25 import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
26 import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
27 import org.openecomp.sdc.be.model.Component;
28 import org.openecomp.sdc.be.model.InterfaceDefinition;
29 import org.openecomp.sdc.be.model.Resource;
30
31 public class OperationArtifactUtilTest {
32
33     @BeforeClass
34     public static void setUp() throws Exception {
35         new DummyConfigurationManager();
36     }
37
38     @Test
39     public void testCorrectPathForOperationArtifacts() {
40         Component component =   new Resource();
41         component.setNormalizedName("normalizedComponentName");
42         final InterfaceDefinition addedInterface = new InterfaceDefinition();
43         final OperationDataDefinition op = new OperationDataDefinition();
44         final ArtifactDataDefinition implementation = new ArtifactDataDefinition();
45         implementation.setArtifactName("createBPMN.bpmn");
46         op.setImplementation(implementation);
47         addedInterface.setOperations(new HashMap<>());
48         addedInterface.getOperations().put("create", op);
49         final String interfaceType = "normalizedComponentName-interface";
50         ((Resource) component).setInterfaces(new HashMap<>());
51         ((Resource) component).getInterfaces().put(interfaceType, addedInterface);
52         final String actualArtifactPath = OperationArtifactUtil.createOperationArtifactPath(component.getNormalizedName(), interfaceType, op);
53         String expectedArtifactPath ="Artifacts"+ File.separator+"normalizedComponentName"+File.separator
54                                              +"normalizedComponentName-interface"+File.separator+"Deployment"
55                                              +File.separator+"Workflows"+File.separator+"BPMN"
56                                              +File.separator+"createBPMN.bpmn";
57
58
59         assertEquals(expectedArtifactPath,actualArtifactPath);
60     }
61 }