2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.tosca.datatypes.model;
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.onap.sdc.tosca.datatypes.model.NodeType;
26 import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
27 import org.onap.sdc.tosca.services.YamlUtil;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
36 * @since September 07, 2016.
38 public class RequirementDefinitionTest {
41 public void cloneTest() {
42 RequirementDefinition reqDef1 = new RequirementDefinition();
43 reqDef1.setNode("node1");
44 reqDef1.setRelationship("my Relationship");
45 reqDef1.setCapability("capabilities");
46 reqDef1.setOccurrences(new Object[]{1, 1});
48 RequirementDefinition reqDef2 = reqDef1.clone();
49 NodeType nodeType = new NodeType();
51 List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
52 Map<String, RequirementDefinition> reqMap1 = new HashMap<>();
53 reqMap1.put("req1", reqDef1);
54 requirements.add(reqMap1);
55 Map<String, RequirementDefinition> reqMap2 = new HashMap<>();
56 reqMap2.put("req2", reqDef2);
57 requirements.add(reqMap2);
58 nodeType.setRequirements(requirements);
60 String yamlString = new YamlUtil().objectToYaml(nodeType);
61 Boolean passResult = !yamlString.contains("&") && !yamlString.contains("*");
62 Assert.assertEquals(true, passResult);