From: Sindhuri.A Date: Fri, 26 Oct 2018 10:37:29 +0000 (+0530) Subject: UT-enhance ComponentInstanceOperationTest X-Git-Tag: 1.3.2~19 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=eaefd11b8d0e3cedd50fca90c1deb85034581157;p=sdc.git UT-enhance ComponentInstanceOperationTest UT for catalog model ComponentInstanceOperation class Issue-ID: SDC-1775 Change-Id: I1805fea86f34f9cf67eaaa5e3c6c5750e91176c3 Signed-off-by: Sindhuri.A --- diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java index 4e97dc58e5..70e866b5cd 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java @@ -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 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); + } +}