diff options
author | Sindhuri.A <arcot.sindhuri@huawei.com> | 2018-09-22 19:36:52 +0530 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-09-25 20:16:27 +0000 |
commit | bbf6e981f2e8ec14fb9a047a980f2b5a05d3325f (patch) | |
tree | a0384b976fa46ed10b89b617523c311db897473d /asdctool/src/test/java/org/openecomp | |
parent | aaef76a03467d7e867d9cccf38e71fd081277fc3 (diff) |
UT-asdctool CsarGenerator
UT for asdctool CsarGenerator class
Issue-ID: SDC-1775
Change-Id: I3ccc58d8d17dfab0baf5666ac9ce0d1b4adcd684
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
Diffstat (limited to 'asdctool/src/test/java/org/openecomp')
-rw-r--r-- | asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java new file mode 100644 index 0000000000..4e80f8e119 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java @@ -0,0 +1,92 @@ +/* + + * 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 fj.data.Either; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +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.EdgeLabelEnum; +import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class CsarGeneratorTest { + @InjectMocks + private CsarGenerator test; + + @Mock + private TitanDao titanDao; + + @Mock + private Component component; + + @Mock + ToscaOperationFacade toscaOperationFacade; + + @Test + public void testGenerateCsar() { + String uuid = "yes"; + InputStream in = new ByteArrayInputStream(uuid.getBytes()); + Scanner scanner = new Scanner(in); + String uniqueId = "123"; + List<GraphVertex> list = new ArrayList<>(); + GraphVertex graphVertex = new GraphVertex(); + graphVertex.setUniqueId(uniqueId); + list.add(graphVertex); + + Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class); + props.put(GraphPropertyEnum.UUID, uuid); + props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + props.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); + graphVertex.setMetadataProperties(props); + + when(titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, props)).thenReturn(Either.left(list)); + when(toscaOperationFacade.getToscaFullElement(any(String.class))).thenReturn(Either.left(component)); + when(titanDao.getChildVertex(graphVertex, EdgeLabelEnum.TOSCA_ARTIFACTS, JsonParseFlagEnum.ParseJson)).thenReturn(Either.left(graphVertex)); + + test.generateCsar(uuid,scanner); + } +} |