38d8aba3ece675f2d07cf35256bf91daec64bb79
[sdc.git] / openecomp-be / lib / openecomp-tosca-lib / src / test / java / org / openecomp / sdc / tosca / datatypes / model / RequirementDefinitionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.tosca.datatypes.model;
22
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.openecomp.core.utilities.yaml.YamlUtil;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 /**
33  * @author shiria
34  * @since September 07, 2016.
35  */
36 public class RequirementDefinitionTest {
37
38   @Test
39   public void cloneTest() {
40     RequirementDefinition reqDef1 = new RequirementDefinition();
41     reqDef1.setNode("node1");
42     reqDef1.setRelationship("my Relationship");
43     reqDef1.setCapability("capabilities");
44     reqDef1.setOccurrences(new Object[]{1, 1});
45
46     RequirementDefinition reqDef2 = reqDef1.clone();
47     NodeType nodeType = new NodeType();
48
49     List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
50     Map<String, RequirementDefinition> reqMap1 = new HashMap<>();
51     reqMap1.put("req1", reqDef1);
52     requirements.add(reqMap1);
53     Map<String, RequirementDefinition> reqMap2 = new HashMap<>();
54     reqMap2.put("req2", reqDef2);
55     requirements.add(reqMap2);
56     nodeType.setRequirements(requirements);
57
58     String yamlString = new YamlUtil().objectToYaml(nodeType);
59     Boolean passResult = !yamlString.contains("&") && !yamlString.contains("*");
60     Assert.assertEquals(true, passResult);
61   }
62
63
64 }