From 454cfef267e87a2e0fba46964106c6fe03c220fd Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Thu, 4 Oct 2018 13:02:56 +0300 Subject: fix csar creation fix required not populated based on DB fix bad packaging of the normative types in csar fix import logic to correctly read boolean fields Change-Id: Idca39ddb070f5f816916a90f124c5c40dae415af Issue-ID: SDC-1447 Signed-off-by: Michael Lando --- .../sdc/be/components/impl/ImportUtilsTest.java | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'catalog-be/src/test/java') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java index f5357e735f..b23b8abd1e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java @@ -21,13 +21,17 @@ package org.openecomp.sdc.be.components.impl; import fj.data.Either; +import mockit.Mock; import org.junit.Test; +import org.mockito.Mockito; import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; +import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations; import org.openecomp.sdc.be.utils.TypeUtils; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.yaml.snakeyaml.Yaml; @@ -48,6 +52,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; public class ImportUtilsTest { + + @Test public void testStringTypeFindToscaElements() throws IOException { Either, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map) loadJsonFromFile("normative-types-string-list-test.yml"), "stringTestTag", ToscaElementTypeEnum.STRING, new ArrayList<>()); @@ -295,6 +301,21 @@ public class ImportUtilsTest { } + @Test + public void testGetInputsFromYml() throws IOException { + + Map toscaJson = (Map) loadJsonFromFile("importToscaInputs.yml"); + + AnnotationTypeOperations annotationTypeOperations= Mockito.mock(AnnotationTypeOperations.class); + Mockito.when(annotationTypeOperations.getLatestType(Mockito.anyString())).thenReturn(null); + + Either, ResultStatusEnum> actualInputs = ImportUtils.getInputs(toscaJson,annotationTypeOperations); + assertTrue(actualInputs.isLeft()); + Map> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS); + compareProperties(expectedProperties, actualInputs.left().value()); + + } + private void compareAttributes(Map> expected, Map actual) { Map singleExpectedAttribute; @@ -322,11 +343,11 @@ public class ImportUtilsTest { } - private void compareProperties(Map> expected, Map actual) { + private void compareProperties(Map> expected, Map actual) { Map singleExpectedProperty; PropertyDefinition actualProperty, expectedPropertyModel; - // attributes of resource + for (Map.Entry> expectedProperty : expected.entrySet()) { singleExpectedProperty = expectedProperty.getValue(); -- cgit 1.2.3-korg