2 * ============LICENSE_START=======================================================
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
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.be.model;
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;
29 import java.util.HashMap;
30 import java.util.HashSet;
33 import org.junit.jupiter.api.Test;
34 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
37 class InterfaceDefinitionTest {
40 void testCtor() throws Exception {
41 new InterfaceDefinition(new InterfaceDataDefinition());
42 new InterfaceDefinition("mock", "mock", new HashMap<>());
46 void testIsDefinition() {
47 final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
48 assertFalse(interfaceDefinition.isDefinition());
52 void testGetOperationsMap() {
53 final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
54 assertNotNull(interfaceDefinition.getOperationsMap());
55 assertTrue(interfaceDefinition.getOperationsMap().isEmpty());
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);
69 operationSet.forEach(operation -> assertThat(String.format("Should contain operation: %s", operation),
70 interfaceDefinition.hasOperation(operation), is(true)));