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.config.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.config.model.data.ArtifactDefinition;
\r
25 import org.onap.ccsdk.config.model.data.CapabilityAssignment;
\r
26 import org.onap.ccsdk.config.model.data.NodeTemplate;
\r
28 public class ServiceTemplateUtilsTest {
\r
30 ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils();
\r
33 public void testPopulateVnfNodeProperties() {
\r
34 NodeTemplate nodeTemplate = createNodeTemplate();
\r
36 String nodeTemplateKey = "nodeTemplateKey";
\r
37 Map<String, String> context = new HashMap<String, String>();
\r
39 Map<String, String> result =
\r
40 serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null);
\r
42 Assert.assertTrue(result.size() > 0);
\r
46 public void testPopulateNodeTemplateArtifacts() {
\r
47 String nodeTemplateKey = "nodeTemplateKey";
\r
48 NodeTemplate nodeTemplate = createNodeTemplate();
\r
49 Map<String, String> context = new HashMap<String, String>();
\r
51 Map<String, String> result =
\r
52 serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context);
\r
54 Assert.assertTrue(result.size() > 0);
\r
57 private NodeTemplate createNodeTemplate() {
\r
58 NodeTemplate nodeTemplate = new NodeTemplate();
\r
59 Map<String, Object> properties = new HashMap<String, Object>();
\r
60 properties.put("prop1", "value");
\r
61 CapabilityAssignment capabilityAssignment = new CapabilityAssignment();
\r
62 capabilityAssignment.setProperties(properties);
\r
63 Map<String, CapabilityAssignment> capabilities = new HashMap<String, CapabilityAssignment>();
\r
64 capabilities.put("key", capabilityAssignment);
\r
65 nodeTemplate.setCapabilities(capabilities);
\r
67 ArtifactDefinition artifactDefinition = new ArtifactDefinition();
\r
68 artifactDefinition.setFile("file");
\r
69 artifactDefinition.setDeployPath("deployPath");
\r
70 artifactDefinition.setContent("content");
\r
71 Map<String, ArtifactDefinition> artifacts = new HashMap<String, ArtifactDefinition>();
\r
72 artifacts.put("artifactName1", artifactDefinition);
\r
73 nodeTemplate.setArtifacts(artifacts);
\r
75 return nodeTemplate;
\r