UT-enhance ComponentInstanceOperationTest 09/71309/3
authorSindhuri.A <arcot.sindhuri@huawei.com>
Fri, 26 Oct 2018 10:37:29 +0000 (16:07 +0530)
committerMichael Lando <michael.lando@intl.att.com>
Mon, 29 Oct 2018 18:09:51 +0000 (18:09 +0000)
UT for catalog model ComponentInstanceOperation class

Issue-ID: SDC-1775

Change-Id: I1805fea86f34f9cf67eaaa5e3c6c5750e91176c3
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java

index 4e97dc5..70e866b 100644 (file)
@@ -1,44 +1,84 @@
+/*
+
+ * Copyright (c) 2018 AT&T Intellectual Property.
+
+ *
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+
+ * you may not use this file except in compliance with the License.
+
+ * You may obtain a copy of the License at
+
+ *
+
+ *     http://www.apache.org/licenses/LICENSE-2.0
+
+ *
+
+ * Unless required by applicable law or agreed to in writing, software
+
+ * distributed under the License is distributed on an "AS IS" BASIS,
+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+ * See the License for the specific language governing permissions and
+
+ * limitations under the License.
+
+ */
 package org.openecomp.sdc.be.model.operations.impl;
 
+import com.thinkaurelius.titan.core.TitanVertex;
 import fj.data.Either;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
 import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
 import org.openecomp.sdc.be.model.ComponentInstanceInput;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
 
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
 public class ComponentInstanceOperationTest {
 
-       private ComponentInstanceOperation createTestSubject() {
-               return new ComponentInstanceOperation();
-       }
+       @InjectMocks
+       private ComponentInstanceOperation componentInstanceOperation;
+
+       @Mock
+       protected TitanGenericDao titanGenericDao;
 
-       
-       @Test
-       public void testSetTitanGenericDao() throws Exception {
-               ComponentInstanceOperation testSubject;
-               TitanGenericDao titanGenericDao = null;
 
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setTitanGenericDao(titanGenericDao);
+       @Test
+       public void testSetTitanGenericDao() {
+               componentInstanceOperation.setTitanGenericDao(titanGenericDao);
        }
 
        @Test
-       public void testUpdateInputValueInResourceInstance() throws Exception {
-               ComponentInstanceOperation testSubject;
+       public void testUpdateInputValueInResourceInstance() {
                ComponentInstanceInput input = null;
                String resourceInstanceId = "";
                boolean b = false;
                Either<ComponentInstanceInput, StorageOperationStatus> result;
 
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.updateInputValueInResourceInstance(input, resourceInstanceId, b);
+               result = componentInstanceOperation.updateInputValueInResourceInstance(input, resourceInstanceId, b);
+               assertNull(result);
        }
 
-       
-
-
-       
-
-}
\ No newline at end of file
+       @Test
+       public void testUpdateCustomizationUUID() {
+               StorageOperationStatus result;
+               String componentInstanceId = "instanceId";
+               TitanVertex titanVertex = Mockito.mock(TitanVertex.class);
+               when(titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(),componentInstanceId)).thenReturn(Either.left(titanVertex));
+               result = componentInstanceOperation.updateCustomizationUUID(componentInstanceId);
+               assertEquals(StorageOperationStatus.OK, result);
+       }
+}