2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
3 * Modifications Copyright © 2018 IBM.
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
18 package org.onap.ccsdk.features.model.utils;
\r
20 import java.util.HashMap;
\r
21 import java.util.Map;
\r
22 import org.junit.Assert;
\r
23 import org.junit.Test;
\r
24 import org.onap.ccsdk.features.model.data.ArtifactDefinition;
\r
25 import org.onap.ccsdk.features.model.data.CapabilityAssignment;
\r
26 import org.onap.ccsdk.features.model.data.NodeTemplate;
\r
27 import org.onap.ccsdk.features.model.utils.ServiceTemplateUtils;
\r
29 public class ServiceTemplateUtilsTest {
\r
31 ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();
\r
34 public void testPopulateVnfNodeProperties() {
\r
35 NodeTemplate nodeTemplate = createNodeTemplate();
\r
37 String nodeTemplateKey = "nodeTemplateKey";
\r
38 Map<String, String> context = new HashMap<String, String>();
\r
40 Map<String, String> result =
\r
41 serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null);
\r
43 Assert.assertTrue(result.size() > 0);
\r
47 public void testPopulateNodeTemplateArtifacts() {
\r
48 String nodeTemplateKey = "nodeTemplateKey";
\r
49 NodeTemplate nodeTemplate = createNodeTemplate();
\r
50 Map<String, String> context = new HashMap<String, String>();
\r
52 Map<String, String> result =
\r
53 serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context);
\r
55 Assert.assertTrue(result.size() > 0);
\r
58 private NodeTemplate createNodeTemplate() {
\r
59 NodeTemplate nodeTemplate = new NodeTemplate();
\r
60 Map<String, Object> properties = new HashMap<String, Object>();
\r
61 properties.put("prop1", "value");
\r
62 CapabilityAssignment capabilityAssignment = new CapabilityAssignment();
\r
63 capabilityAssignment.setProperties(properties);
\r
64 Map<String, CapabilityAssignment> capabilities = new HashMap<String, CapabilityAssignment>();
\r
65 capabilities.put("key", capabilityAssignment);
\r
66 nodeTemplate.setCapabilities(capabilities);
\r
68 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
\r
69 artifactDefinition.setFile("file");
\r
70 artifactDefinition.setDeployPath("deployPath");
\r
71 artifactDefinition.setContent("content");
\r
72 Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();
\r
73 artifacts.put("artifactName1", artifactDefinition);
\r
74 nodeTemplate.setArtifacts(artifacts);
\r
76 return nodeTemplate;
\r