UT-InputsBusinessLogic 08/73408/3
authorSindhuri.A <arcot.sindhuri@huawei.com>
Wed, 21 Nov 2018 12:04:47 +0000 (17:34 +0530)
committerTal Gitelman <tal.gitelman@att.com>
Thu, 29 Nov 2018 11:13:10 +0000 (11:13 +0000)
UT for InputsBusinessLogic class

Issue-ID: SDC-1775

Change-Id: Ia95f73af0af5e8abef883250c3b649b53a0cb4e9
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java

index 34b0177..934a35e 100644 (file)
@@ -61,6 +61,9 @@ public class InputsBusinessLogicTest {
     @Mock
     private UserValidations userValidations;
 
+    @Mock
+    private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
+
     @InjectMocks
     private InputsBusinessLogic testInstance;
 
@@ -118,6 +121,32 @@ public class InputsBusinessLogicTest {
         assertEquals("inputId", componentInstanceInputs.left().value().get(0).getInputId());
     }
 
+    @Test
+    public void testGetInputs() {
+        String userId = "userId";
+        String componentId = "compId";
+        Component component = new Resource();
+        when(toscaOperationFacadeMock.getToscaElement(Mockito.any(String.class), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(component));
+        testInstance.getInputs(userId, componentId);
+        assertEquals(null, component.getInputs());
+    }
+
+    @Test
+    public void testGetCIPropertiesByInputId() {
+        Either<List<ComponentInstanceProperty>, ResponseFormat> result;
+        String userId = "userId";
+        String componentId = "compId";
+        Component component = new Resource();
+        List<InputDefinition> listDef = new ArrayList<>();
+        InputDefinition inputDef = new InputDefinition();
+        inputDef.setUniqueId(componentId);
+        listDef.add(inputDef);
+        component.setInputs(listDef);
+        when(toscaOperationFacadeMock.getToscaElement(Mockito.any(String.class), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(component));
+        result = testInstance.getComponentInstancePropertiesByInputId(userId, componentId, componentId, componentId);
+        assertTrue(result.isLeft());
+    }
+
     private void getComponents_emptyInputs(Service service) {
         when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), Mockito.any(ComponentParametersView.class))).thenReturn(Either.left(service));
         Either<List<ComponentInstanceInput>, ResponseFormat> componentInstanceInputs = testInstance.getComponentInstanceInputs(USER_ID, COMPONENT_ID, COMPONENT_INSTANCE_ID);