diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-09-20 14:23:06 +0530 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-09-25 21:00:17 +0000 |
commit | 901ca72302b79cdbd1ad85e6aadff6a789c6e803 (patch) | |
tree | 262f5272906bba03aca36182799c209df84ed922 /asdctool | |
parent | 4225214bf638bf6bdde552ebcbb89cb56872b625 (diff) |
UT-asdctool DeleteComponentHandler
UT for asdctool DeleteComponentHandler class
Issue-ID: SDC-1775
Change-Id: Ifc574602d0451ad561a4d362f9d6bd0e4d17ff75
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'asdctool')
-rw-r--r-- | asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java new file mode 100644 index 0000000000..315f615fb4 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java @@ -0,0 +1,91 @@ +/* + + * Copyright (c) 2018 Huawei 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.asdctool.impl.internal.tool; + +import com.thinkaurelius.titan.core.TitanVertex; +import fj.data.Either; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; +import org.openecomp.sdc.be.dao.jsongraph.TitanDao; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate; +import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; + +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class DeleteComponentHandlerTest { + @InjectMocks + private DeleteComponentHandler test; + + @Mock + private TitanDao titanDao; + + @Mock + private TopologyTemplateOperation topologyTemplateOperation; + + @Mock + TopologyTemplate toscaElement; + + @Test + public void testDeleteComponent() { + + String input = "yes"; + InputStream in = new ByteArrayInputStream(input.getBytes()); + Scanner scanner = new Scanner(in); + String id = "start"; + GraphVertex loc = new GraphVertex(); + TitanVertex vertex = Mockito.mock(TitanVertex.class); + loc.setVertex(vertex); + + Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>(); + metadataProperties.put(GraphPropertyEnum.USERID, loc.getUniqueId()); + metadataProperties.put(GraphPropertyEnum.LABEL, VertexTypeEnum.USER.getName()); + metadataProperties.put(GraphPropertyEnum.NAME, "user1"); + loc.setMetadataProperties(metadataProperties); + + when(titanDao.getVertexById(id)).thenReturn(Either.left(loc)); + when(topologyTemplateOperation.deleteToscaElement(ArgumentMatchers.any(GraphVertex.class))).thenReturn(Either.left(toscaElement)); + + test.deleteComponent(id,scanner); + } +} |