Improve test coverage
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / InterfaceDefinitionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.be.model;
22
23 import static org.hamcrest.MatcherAssert.assertThat;
24 import static org.hamcrest.Matchers.is;
25 import static org.junit.jupiter.api.Assertions.assertFalse;
26 import static org.junit.jupiter.api.Assertions.assertNotNull;
27 import static org.junit.jupiter.api.Assertions.assertTrue;
28
29 import java.util.HashMap;
30 import java.util.HashSet;
31 import java.util.Map;
32 import java.util.Set;
33 import org.junit.jupiter.api.Test;
34 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
35
36
37 class InterfaceDefinitionTest {
38
39         @Test
40         void testCtor() throws Exception {
41                 new InterfaceDefinition(new InterfaceDataDefinition());
42                 new InterfaceDefinition("mock", "mock", new HashMap<>());
43         }
44         
45         @Test
46         void testIsDefinition() {
47                 final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
48                 assertFalse(interfaceDefinition.isDefinition());
49         }
50
51         @Test
52         void testGetOperationsMap() {
53                 final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
54                 assertNotNull(interfaceDefinition.getOperationsMap());
55                 assertTrue(interfaceDefinition.getOperationsMap().isEmpty());
56         }
57
58         @Test
59         void testHasOperation() {
60                 final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
61                 final Map<String, Operation> operationMap = new HashMap<>();
62                 final Set<String> operationSet = new HashSet<>();
63                 operationSet.add("operation1");
64                 operationSet.add("operation2");
65                 operationSet.add("operation3");
66                 operationSet.forEach(operation -> operationMap.put(operation, new Operation()));
67                 interfaceDefinition.setOperationsMap(operationMap);
68
69                 operationSet.forEach(operation -> assertThat(String.format("Should contain operation: %s", operation),
70                         interfaceDefinition.hasOperation(operation), is(true)));
71         }
72 }