1 package org.openecomp.sdc.tosca.services;
3 import org.openecomp.sdc.common.errors.CoreException;
6 import org.junit.rules.ExpectedException;
7 import org.junit.runner.RunWith;
8 import org.mockito.runners.MockitoJUnitRunner;
9 import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
10 import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
11 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
12 import org.openecomp.sdc.tosca.datatypes.model.PolicyDefinition;
13 import org.openecomp.sdc.tosca.datatypes.model.RelationshipTemplate;
14 import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
15 import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
17 import java.util.ArrayList;
19 @RunWith(MockitoJUnitRunner.class)
20 public class DataModelUtilTest {
23 public ExpectedException thrown = ExpectedException.none();
26 public void testAddSubstitutionMapping() throws Exception {
27 thrown.expect(CoreException.class);
29 "Invalid action, can't add 'Substitution Mapping' to 'Service Template', 'Service Template' entity is NULL.");
30 DataModelUtil.addSubstitutionMapping(null, new SubstitutionMapping());
34 public void testAddSubstitutionMappingReq() throws Exception {
35 thrown.expect(CoreException.class);
37 "Invalid action, can't add 'Substitution Mapping Requirements' to 'Service Template', 'Service Template' entity is NULL.");
38 DataModelUtil.addSubstitutionMappingReq(null, "123", new ArrayList<>());
42 public void testAddNodeTemplate() throws Exception {
43 thrown.expect(CoreException.class);
45 "Invalid action, can't add 'Node Template' to 'Service Template', 'Service Template' entity is NULL.");
46 DataModelUtil.addNodeTemplate(null, "123", new NodeTemplate());
50 public void testAddPolicyDefinition() throws Exception {
51 thrown.expect(CoreException.class);
53 "Invalid action, can't add 'Policy Definition' to 'Service Template', 'Service Template' entity is NULL.");
54 DataModelUtil.addPolicyDefinition(null, "123", new PolicyDefinition());
58 public void testAddNodeType() throws Exception {
59 thrown.expect(CoreException.class);
61 "Invalid action, can't add 'Node Type' to 'Service Template', 'Service Template' entity is NULL.");
62 DataModelUtil.addNodeType(null, "123", new NodeType());
66 public void testAddRelationshipTemplate() throws Exception {
67 thrown.expect(CoreException.class);
69 "Invalid action, can't add 'Relationship Template' to 'Service Template', 'Service Template' entity is NULL.");
70 DataModelUtil.addRelationshipTemplate(null, "123", new RelationshipTemplate());
74 public void testAddRequirementAssignment() throws Exception {
75 thrown.expect(CoreException.class);
77 "Invalid action, can't add 'Requirement Assignment' to 'Node Template', 'Node Template' entity is NULL.");
78 DataModelUtil.addRequirementAssignment(null, "123", new RequirementAssignment());
82 public void testGetNodeTemplate() throws Exception {
83 thrown.expect(CoreException.class);
85 "Invalid action, can't add 'Node Template' to 'Service Template', 'Service Template' entity is NULL.");
86 DataModelUtil.addNodeTemplate(null, "123", new NodeTemplate());
90 public void testGetNodeType() throws Exception {
91 thrown.expect(CoreException.class);
93 "Invalid action, can't add 'Node Type' to 'Service Template', 'Service Template' entity is NULL.");
94 DataModelUtil.addNodeType(null, "123", new NodeType());
98 public void testAddGroupToTopologyTemplate() throws Exception {
99 thrown.expect(CoreException.class);
100 thrown.expectMessage(
101 "Invalid action, can't add 'Group Definition' to 'Service Template', 'Service Template' entity is NULL.");
102 DataModelUtil.addGroupDefinitionToTopologyTemplate(null, "123", new GroupDefinition());