re base code
[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 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;
26
27 import java.io.File;
28 import java.util.HashMap;
29
30 import static org.junit.Assert.assertEquals;
31
32 public class OperationArtifactUtilTest {
33
34     @BeforeClass
35     public static void setUp() throws Exception {
36         new DummyConfigurationManager();
37     }
38
39     @Test
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";
58
59
60         assertEquals(expectedArtifactPath,actualArtifactPath);
61     }
62 }