Service Consumption BE
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / utils / InterfaceOperationUtilsTest.java
index 8ceac17..43649f6 100644 (file)
@@ -1,7 +1,10 @@
 package org.openecomp.sdc.be.components.utils;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -17,6 +20,8 @@ public class InterfaceOperationUtilsTest {
     private static final String operationId = "operationId";
     private static final String operationName = "createOperation";
     private static final String interfaceId = "interfaceId";
+    private static final String operationId1 = "operationId1";
+    private static final String interfaceId1 = "interfaceId1";
     private static Resource resource;
 
     @Before
@@ -94,4 +99,28 @@ public class InterfaceOperationUtilsTest {
         Assert.assertFalse(operationEntry.isPresent());
     }
 
+    @Test
+    public void testGetInterfaceDefinitionFromOperationIdSuccess() {
+        List<InterfaceDefinition> interfaces = new ArrayList<>();
+        interfaces.add(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName));
+        interfaces.add(InterfaceOperationTestUtils.createMockInterface(interfaceId1, operationId1, operationName));
+        Assert.assertTrue(InterfaceOperationUtils.getInterfaceDefinitionFromOperationId(interfaces, operationId)
+                                  .isPresent());
+    }
+
+    @Test
+    public void testGetInterfaceDefinitionFromOperationIdFailure() {
+        List<InterfaceDefinition> interfaces = new ArrayList<>();
+        interfaces.add(InterfaceOperationTestUtils.createMockInterface(interfaceId1, operationId1, operationName));
+        Assert.assertFalse(InterfaceOperationUtils.getInterfaceDefinitionFromOperationId(interfaces, operationId)
+                                  .isPresent());
+    }
+
+    @Test
+    public void testGetInterfaceDefinitionFromOperationIdFailureInterfacesEmpty() {
+        List<InterfaceDefinition> interfaces = new ArrayList<>();
+        Assert.assertFalse(InterfaceOperationUtils.getInterfaceDefinitionFromOperationId(interfaces, operationId)
+                                   .isPresent());
+    }
+
 }
\ No newline at end of file