diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-10-26 16:07:29 +0530 |
---|---|---|
committer | Michael Lando <michael.lando@intl.att.com> | 2018-10-29 18:09:51 +0000 |
commit | eaefd11b8d0e3cedd50fca90c1deb85034581157 (patch) | |
tree | 54ede4146cea51d0ebc20731cc94a9bd7a0225fc /catalog-model | |
parent | 82d9bf1ef4ca9a3273ec8224a72f9d8d7163e413 (diff) |
UT-enhance ComponentInstanceOperationTest
UT for catalog model ComponentInstanceOperation class
Issue-ID: SDC-1775
Change-Id: I1805fea86f34f9cf67eaaa5e3c6c5750e91176c3
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'catalog-model')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java | 84 |
1 files changed, 62 insertions, 22 deletions
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<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); + } +} |