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=========================================================
19 * Modifications copyright (c) 2019 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.tosca.datatypes.model;
25 import org.junit.Assert;
26 import org.junit.Test;
27 import org.onap.sdc.tosca.datatypes.model.NodeType;
28 import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
29 import org.onap.sdc.tosca.services.YamlUtil;
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
36 import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
37 import static org.hamcrest.MatcherAssert.assertThat;
41 * @since September 07, 2016.
43 public class RequirementDefinitionTest {
45 public void shouldHaveValidGettersAndSetters() {
46 assertThat(RequirementDefinition.class, hasValidGettersAndSetters());
50 public void cloneTest() {
51 RequirementDefinition reqDef1 = new RequirementDefinition();
52 reqDef1.setNode("node1");
53 reqDef1.setRelationship("my Relationship");
54 reqDef1.setCapability("capabilities");
55 reqDef1.setOccurrences(new Object[]{1, 1});
57 RequirementDefinition reqDef2 = reqDef1.clone();
58 NodeType nodeType = new NodeType();
60 List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
61 Map<String, RequirementDefinition> reqMap1 = new HashMap<>();
62 reqMap1.put("req1", reqDef1);
63 requirements.add(reqMap1);
64 Map<String, RequirementDefinition> reqMap2 = new HashMap<>();
65 reqMap2.put("req2", reqDef2);
66 requirements.add(reqMap2);
67 nodeType.setRequirements(requirements);
69 String yamlString = new YamlUtil().objectToYaml(nodeType);
70 Boolean passResult = !yamlString.contains("&") && !yamlString.contains("*");
71 Assert.assertEquals(true, passResult);