From fd342cfa82ad12f32802fb5f5f1287a59df6070f Mon Sep 17 00:00:00 2001 From: ojasdubey Date: Mon, 14 May 2018 19:31:21 +0530 Subject: Renamed classes to include skipped tests 1. Renamed test classes to align with junit test naming convention to include them in the build 2. Fixed static analysis issues in test classes 2. Refactored methods for code smells Change-Id: Idacf6646ed8650cc7a96d5f539e7276e684bfb66 Issue-ID: SDC-1331 Signed-off-by: ojasdubey --- .../org/openecomp/sdc/translator/TestUtils.java | 85 ++++++++++++---- .../nested/multi/TranslateHeatNestedMultiTest.java | 37 +++++++ .../nested/multi/Translate_Heat_Nested_Multi.java | 37 ------- .../nestedvolumelocal/NestedVolumeLocalTest.java | 34 +++++++ .../nestedvolumelocal/NestedVolumelocal.java | 37 ------- .../NestedVolumeSeperateFile.java | 37 ------- .../NestedVolumeSeperateFileTest.java | 34 +++++++ .../TranslateHeatNestedFromMultiBaseTest.java | 37 +++++++ .../Translate_Heat_Nested_From_Multi_Base.java | 40 -------- .../nested/single/TranslateHeatNestedSingle.java | 57 ----------- .../single/TranslateHeatNestedSingleTest.java | 57 +++++++++++ .../buildconsolidationdata/TestConstants.java | 7 +- .../BaseFullTranslationTest.java | 84 ++++------------ .../BaseResourceTranslationTest.java | 110 ++++++--------------- ...ceTranslationContrailV2VmInterfaceImplTest.java | 9 +- .../ResourceTranslationNeutronPortImplTest.java | 12 +-- 16 files changed, 319 insertions(+), 395 deletions(-) create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/TranslateHeatNestedMultiTest.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/Translate_Heat_Nested_Multi.java create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumeLocalTest.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumelocal.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFile.java create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFileTest.java create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/TranslateHeatNestedFromMultiBaseTest.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/Translate_Heat_Nested_From_Multi_Base.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingle.java create mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingleTest.java (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java') diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java index a0a6d12cb9..95adef3a8c 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java @@ -16,22 +16,43 @@ package org.openecomp.sdc.translator; +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.NotDirectoryException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.tuple.Pair; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; -import org.openecomp.core.translator.api.HeatToToscaTranslator; -import org.openecomp.core.utilities.file.FileUtils; -import org.openecomp.sdc.common.utils.SdcCommon; -import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.onap.sdc.tosca.datatypes.model.GroupDefinition; import org.onap.sdc.tosca.datatypes.model.NodeTemplate; import org.onap.sdc.tosca.datatypes.model.RequirementAssignment; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.onap.sdc.tosca.datatypes.model.TopologyTemplate; +import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; +import org.openecomp.core.translator.api.HeatToToscaTranslator; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.common.utils.SdcCommon; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.tosca.services.ToscaConstants; -import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData; @@ -48,21 +69,6 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData; import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.NotDirectoryException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - public class TestUtils { private static final String MANIFEST_NAME = SdcCommon.MANIFEST_NAME; private static String zipFilename = "VSP.zip"; @@ -675,4 +681,43 @@ public class TestUtils { return initServiceTemplate; } + public static void compareTranslatedOutput(Set expectedResultFileNameSet, + Map expectedResultMap, + ZipInputStream zis) throws IOException { + ZipEntry entry; + String name; + String expected; + String actual; + + while ((entry = zis.getNextEntry()) != null) { + + name = entry.getName() + .substring(entry.getName().lastIndexOf(File.separator) + 1, entry.getName().length()); + if (expectedResultFileNameSet.contains(name)) { + expected = new String(expectedResultMap.get(name)).trim().replace("\r", ""); + actual = new String(FileUtils.toByteArray(zis)).trim().replace("\r", ""); + assertEquals("difference in file: " + name, expected, actual); + + expectedResultFileNameSet.remove(name); + } + } + if (expectedResultFileNameSet.isEmpty()) { + expectedResultFileNameSet.forEach(System.out::println); + } + } + + public static String getErrorAsString(Map> errorMessages) { + StringBuilder sb = new StringBuilder(); + errorMessages.forEach((file, errorList) -> sb.append("File:").append(file).append(System.lineSeparator()) + .append(getErrorList(errorList))); + + return sb.toString(); + } + + private static String getErrorList(List errors) { + StringBuilder sb = new StringBuilder(); + errors.forEach(error -> sb.append(error.getMessage()).append("[").append(error.getLevel()).append("]") + .append(System.lineSeparator())); + return sb.toString(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/TranslateHeatNestedMultiTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/TranslateHeatNestedMultiTest.java new file mode 100644 index 0000000000..38beb60c65 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/TranslateHeatNestedMultiTest.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.translator.impl.heattotosca.nested.multi; + +import org.junit.Test; +import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; + +public class TranslateHeatNestedMultiTest extends BaseResourceTranslationTest { + + { + inputFilesPath = "/mock/heat/nested/multi/inputs"; + outputFilesPath = "/mock/heat/nested/multi/expectedoutputfiles"; + } + + @Test + public void testTranslate() throws Exception { + testTranslation(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/Translate_Heat_Nested_Multi.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/Translate_Heat_Nested_Multi.java deleted file mode 100644 index 10462c2838..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/multi/Translate_Heat_Nested_Multi.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.translator.impl.heattotosca.nested.multi; - -import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; - -public class Translate_Heat_Nested_Multi extends BaseResourceTranslationTest { - - { - inputFilesPath = "/mock/heat/nested/multi/inputs"; - outputFilesPath = "/mock/heat/nested/multi/expectedoutputfiles"; - } - - @Test - public void testTranslate() throws Exception { - testTranslation(); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumeLocalTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumeLocalTest.java new file mode 100644 index 0000000000..951e5d4c46 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumeLocalTest.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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.translator.impl.heattotosca.nested.nestedvolumelocal; + +import org.junit.Test; +import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; + +public class NestedVolumeLocalTest extends BaseResourceTranslationTest { + + { + inputFilesPath = "/mock/heat/nested/nestedvolumelocal/inputs"; + outputFilesPath = "/mock/heat/nested/nestedvolumelocal/expectedoutputfiles"; + } + + @Test + public void testTranslate() throws Exception { + testTranslation(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumelocal.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumelocal.java deleted file mode 100644 index 84f05ce891..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumelocal/NestedVolumelocal.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.translator.impl.heattotosca.nested.nestedvolumelocal; - -import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; - -public class NestedVolumelocal extends BaseResourceTranslationTest { - - { - inputFilesPath = "/mock/heat/nested/nestedvolumelocal/inputs"; - outputFilesPath = "/mock/heat/nested/nestedvolumelocal/expectedoutputfiles"; - } - - @Test - public void testTranslate() throws Exception { - testTranslation(); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFile.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFile.java deleted file mode 100644 index bd59303305..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFile.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.translator.impl.heattotosca.nested.nestedvolumeseperatefile; - -import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; - -public class NestedVolumeSeperateFile extends BaseResourceTranslationTest { - - { - inputFilesPath = "/mock/heat/nested/nestedvolumeseperatefile/inputs"; - outputFilesPath = "/mock/heat/nested/nestedvolumeseperatefile/expectedoutputfiles"; - } - - @Test - public void testTranslate() throws Exception { - testTranslation(); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFileTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFileTest.java new file mode 100644 index 0000000000..8ea3808da5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/nestedvolumeseperatefile/NestedVolumeSeperateFileTest.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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.translator.impl.heattotosca.nested.nestedvolumeseperatefile; + +import org.junit.Test; +import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; + +public class NestedVolumeSeperateFileTest extends BaseResourceTranslationTest { + + { + inputFilesPath = "/mock/heat/nested/nestedvolumeseperatefile/inputs"; + outputFilesPath = "/mock/heat/nested/nestedvolumeseperatefile/expectedoutputfiles"; + } + + @Test + public void testTranslate() throws Exception { + testTranslation(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/TranslateHeatNestedFromMultiBaseTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/TranslateHeatNestedFromMultiBaseTest.java new file mode 100644 index 0000000000..9405bc0f78 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/TranslateHeatNestedFromMultiBaseTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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.translator.impl.heattotosca.nested.reusenestedfrommultibase; + +import org.junit.Test; +import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants; +import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; + +public class TranslateHeatNestedFromMultiBaseTest extends BaseResourceTranslationTest { + + { + inputFilesPath = "/mock/heat/nested/reusenestedfrommultibase/inputs"; + outputFilesPath = "/mock/heat/nested/reusenestedfrommultibase/expectedoutputfiles"; + } + + @Test + public void testTranslate() throws Exception { + testTranslation(); + validateNestedTemplateConsolidationData(TestConstants.TEST_MULTIPLE_NESTED_RESOURCE); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/Translate_Heat_Nested_From_Multi_Base.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/Translate_Heat_Nested_From_Multi_Base.java deleted file mode 100644 index b715316146..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/reusenestedfrommultibase/Translate_Heat_Nested_From_Multi_Base.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.translator.impl.heattotosca.nested.reusenestedfrommultibase; - -import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants; -import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; - -public class Translate_Heat_Nested_From_Multi_Base extends BaseResourceTranslationTest { - - { - inputFilesPath = "/mock/heat/nested/reusenestedfrommultibase/inputs"; - outputFilesPath = "/mock/heat/nested/reusenestedfrommultibase/expectedoutputfiles"; - } - - @Test - public void testTranslate() throws Exception { - testTranslation(); - validateNestedTemplateConsolidationData(TestConstants.TEST_MULTIPLE_NESTED_RESOURCE); - } - -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingle.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingle.java deleted file mode 100644 index 640da0c12b..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingle.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.translator.impl.heattotosca.nested.single; - -import org.junit.Before; -import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants; -import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; - -import java.io.IOException; - -public class TranslateHeatNestedSingle extends BaseResourceTranslationTest { - - @Override - @Before - public void setUp() throws IOException { - // do not delete this function. it prevents the superclass setup from running - } - - - @Test - public void testTranslate() throws Exception { - inputFilesPath = "/mock/heat/nested/single/inputs"; - outputFilesPath = "/mock/heat/nested/single/expectedoutputfiles"; - - initTranslatorAndTranslate(); - testTranslation(); - validateNestedTemplateConsolidationData(TestConstants.TEST_SINGLE_NESTED_RESOURCE); - } - - @Test - public void testTranslateNestedWithoutNodeTemplates() throws IOException { - inputFilesPath = "/mock/heat/nested/nestedwithoutNodeTemplates/inputs"; - outputFilesPath = "/mock/heat/nested/nestedwithoutNodeTemplates/expectedoutputfiles"; - - initTranslatorAndTranslate(); - testTranslation(); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingleTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingleTest.java new file mode 100644 index 0000000000..29020cd96d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/nested/single/TranslateHeatNestedSingleTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.translator.impl.heattotosca.nested.single; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants; +import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseResourceTranslationTest; + +import java.io.IOException; + +public class TranslateHeatNestedSingleTest extends BaseResourceTranslationTest { + + @Override + @Before + public void setUp() throws IOException { + // do not delete this function. it prevents the superclass setup from running + } + + + @Test + public void testTranslate() throws Exception { + inputFilesPath = "/mock/heat/nested/single/inputs"; + outputFilesPath = "/mock/heat/nested/single/expectedoutputfiles"; + + initTranslatorAndTranslate(); + testTranslation(); + validateNestedTemplateConsolidationData(TestConstants.TEST_SINGLE_NESTED_RESOURCE); + } + + @Test + public void testTranslateNestedWithoutNodeTemplates() throws IOException { + inputFilesPath = "/mock/heat/nested/nestedwithoutNodeTemplates/inputs"; + outputFilesPath = "/mock/heat/nested/nestedwithoutNodeTemplates/expectedoutputfiles"; + + initTranslatorAndTranslate(); + testTranslation(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/TestConstants.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/TestConstants.java index 3b97be7f33..f8a922b963 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/TestConstants.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/TestConstants.java @@ -2,19 +2,14 @@ package org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata public class TestConstants{ - public static final String MAIN_SERVICE_TEMPLATE = "MainServiceTemplate.yaml"; + static final String MAIN_SERVICE_TEMPLATE = "MainServiceTemplate.yaml"; public static final String TEST_GROUP_POSITIVE = "TestGroupsPositive"; - public static final String TEST_GROUP_NEGATIVE = "TestGroupsNegative"; public static final String TEST_VOLUME_POSITIVE = "TestVolumePositive"; public static final String TEST_VOLUME_NEGATIVE = "TestVolumeNegative"; public static final String TEST_PORT_POSITIVE = "TestPortPositive"; - public static final String TEST_PORT_NEGATIVE = "TestPortNegative"; - - public static final String TEST_CONNECTIVITY_POSITIVE = "TestConnectivityPositive"; - public static final String TEST_CONNECTIVITY_NEGATIVE = "TestConnectivityNegative"; public static final String TEST_DEPENDS_ON_NODES_CONNECTED_IN = "TestDependsOnNodesConnectedIn"; public static final String TEST_DEPENDS_ON_NODES_CONNECTED_OUT = "TestDependsOnNodesConnectedOut"; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java index 801f2c67a0..758271bf46 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java @@ -17,20 +17,8 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.translator.TestUtils.getErrorAsString; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URL; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; import org.apache.commons.collections4.MapUtils; import org.junit.Assert; import org.junit.BeforeClass; @@ -44,18 +32,28 @@ import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl; import org.openecomp.sdc.translator.TestUtils; import org.togglz.testing.TestFeatureManager; import org.togglz.testing.TestFeatureManagerProvider; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipInputStream; -public class BaseFullTranslationTest { - public static final String IN_POSTFIX = "/in"; - public static final String OUT_POSTFIX = "/out"; +public class BaseFullTranslationTest { + private static final String IN_POSTFIX = "/in"; + private static final String OUT_POSTFIX = "/out"; protected static TestFeatureManager manager; @@ -66,13 +64,6 @@ public class BaseFullTranslationTest { TestFeatureManagerProvider.setFeatureManager(manager); } - - public static void disableToggleableFeatures() { - manager.disableAll(); - manager = null; - TestFeatureManagerProvider.setFeatureManager(null); - } - protected void testTranslationWithInit(String path) throws IOException { byte[] translatedZipFile = initTranslatorAndTranslate(path); testTranslation(path, translatedZipFile); @@ -101,27 +92,9 @@ public class BaseFullTranslationTest { } try (ByteArrayInputStream fis = new ByteArrayInputStream(translatedZipFile); - BufferedInputStream bis = new BufferedInputStream(fis); ZipInputStream zis = new ZipInputStream(bis)) { - ZipEntry entry; - String name; - String expected; - String actual; - - while ((entry = zis.getNextEntry()) != null) { - - name = entry.getName() - .substring(entry.getName().lastIndexOf(File.separator) + 1, entry.getName().length()); - if (expectedResultFileNameSet.contains(name)) { - expected = new String(expectedResultMap.get(name)).trim().replace("\r", ""); - actual = new String(FileUtils.toByteArray(zis)).trim().replace("\r", ""); - assertEquals("difference in file: " + name, expected, actual); - - expectedResultFileNameSet.remove(name); - } - } - if (expectedResultFileNameSet.isEmpty()) { - expectedResultFileNameSet.forEach(System.out::println); - } + BufferedInputStream bis = new BufferedInputStream(fis); + ZipInputStream zis = new ZipInputStream(bis)) { + TestUtils.compareTranslatedOutput(expectedResultFileNameSet, expectedResultMap, zis); } assertEquals(0, expectedResultFileNameSet.size()); } @@ -140,26 +113,7 @@ public class BaseFullTranslationTest { .withCategory(ErrorCategory.APPLICATION).build()); } - byte[] data = - new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); - - return data; - } - - private String getErrorAsString(Map> errorMessages) { - StringBuilder sb = new StringBuilder(); - errorMessages.entrySet().forEach( - entry -> sb.append("File:").append(entry.getKey()).append(System.lineSeparator()) - .append(getErrorList(entry.getValue()))); - - return sb.toString(); - } - - private String getErrorList(List errors) { - StringBuilder sb = new StringBuilder(); - errors.forEach(error -> sb.append(error.getMessage()).append("[").append(error.getLevel()).append("]") - .append(System.lineSeparator())); - return sb.toString(); + return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java index 80c20360d2..f399cc15e0 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java @@ -34,8 +34,7 @@ import org.apache.commons.collections4.MapUtils; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.rules.TestName; +import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.core.translator.datatypes.TranslatorOutput; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; @@ -45,11 +44,9 @@ import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile; -import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl; import org.openecomp.sdc.translator.TestUtils; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; @@ -64,8 +61,11 @@ import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata. import org.togglz.testing.TestFeatureManager; import org.togglz.testing.TestFeatureManagerProvider; - -import java.io.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.net.URL; import java.util.Collection; import java.util.HashMap; @@ -73,7 +73,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -81,17 +80,11 @@ public class BaseResourceTranslationTest { protected String inputFilesPath; protected String outputFilesPath; - protected TranslationContext translationContext; + TranslationContext translationContext; - @Rule - public TestName name = new TestName(); - - private String zipFilename = "VSP.zip"; private TranslationService translationService; private byte[] translatedZipFile; - private static File tempDir = new File(System.getProperty("java.io.tmpdir")); - private Map expectedResultMap = new HashMap<>(); private Set expectedResultFileNameSet = new HashSet<>(); @@ -101,12 +94,7 @@ public class BaseResourceTranslationTest { public static void enableToggleableFeatures(){ manager = new TestFeatureManager(ToggleableFeature.class); manager.enableAll(); - } - - public static void disableToggleableFeatures() { - manager.disableAll(); - manager = null; - TestFeatureManagerProvider.setFeatureManager(null); + TestFeatureManagerProvider.setFeatureManager(manager); } @Before @@ -136,28 +124,10 @@ public class BaseResourceTranslationTest { } } - try (ByteArrayInputStream fis = new ByteArrayInputStream(translatedZipFile); BufferedInputStream bis = new BufferedInputStream(fis); + try (ByteArrayInputStream fis = new ByteArrayInputStream(translatedZipFile); + BufferedInputStream bis = new BufferedInputStream(fis); ZipInputStream zis = new ZipInputStream(bis)) { - ZipEntry entry; - String name; - String expected; - String actual; - - while ((entry = zis.getNextEntry()) != null) { - - name = entry.getName() - .substring(entry.getName().lastIndexOf(File.separator) + 1, entry.getName().length()); - if (expectedResultFileNameSet.contains(name)) { - expected = new String(expectedResultMap.get(name)).trim().replace("\r", ""); - actual = new String(FileUtils.toByteArray(zis)).trim().replace("\r", ""); - assertEquals("difference in file: " + name, expected, actual); - - expectedResultFileNameSet.remove(name); - } - } - if (expectedResultFileNameSet.isEmpty()) { - expectedResultFileNameSet.forEach(System.out::println); - } + TestUtils.compareTranslatedOutput(expectedResultFileNameSet, expectedResultMap, zis); } assertEquals(0, expectedResultFileNameSet.size()); } @@ -172,34 +142,15 @@ public class BaseResourceTranslationTest { MessageContainerUtil .getMessageByLevel(ErrorLevel.ERROR, translatorOutput.getErrorMessages()))) { throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage( - "Error in validation " + getErrorAsString(translatorOutput.getErrorMessages())) + "Error in validation " + TestUtils.getErrorAsString(translatorOutput.getErrorMessages())) .withId("Validation Error").withCategory(ErrorCategory.APPLICATION).build()); } - byte[] data = new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); - - return data; - } - - - private String getErrorAsString(Map> errorMessages) { - StringBuilder sb = new StringBuilder(); - errorMessages.entrySet().forEach( - entry -> sb.append("File:").append(entry.getKey()).append(System.lineSeparator()) - .append(getErrorList(entry.getValue()))); - - return sb.toString(); + return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); } - private String getErrorList(List errors) { - StringBuilder sb = new StringBuilder(); - errors.forEach( - error -> sb.append(error.getMessage()).append("[").append(error.getLevel()).append("]") - .append(System.lineSeparator())); - return sb.toString(); - } - public void addFilesToTranslator(TranslationContext translationContext, String path) + private void addFilesToTranslator(TranslationContext translationContext, String path) throws IOException { File manifestFile = new File(path); File[] files = manifestFile.listFiles(); @@ -214,9 +165,10 @@ public class BaseResourceTranslationTest { fileContent = FileUtils.toByteArray(fis); if (file.getName().equals(MANIFEST_NAME)) { - addManifest(translationContext, MANIFEST_NAME, fileContent); + addManifest(translationContext, fileContent); } else { String validationFilename = "validationOutput.json"; + String zipFilename = "VSP.zip"; if (!file.getName().equals(zipFilename) && (!file.getName().equals(validationFilename))) { addFile(translationContext, file.getName(), fileContent); } @@ -225,20 +177,20 @@ public class BaseResourceTranslationTest { } } - public static void addManifest(TranslationContext translationContext, - String name, byte[] content) { + private static void addManifest(TranslationContext translationContext, + byte[] content) { ManifestContent manifestData = JsonUtil.json2Object(new String(content), ManifestContent.class); ManifestFile manifest = new ManifestFile(); - manifest.setName(name); + manifest.setName(MANIFEST_NAME); manifest.setContent(manifestData); translationContext.setManifest(manifest); - translationContext.addFile(name, content); + translationContext.addFile(MANIFEST_NAME, content); addFilesFromManifestToTranslationContextManifestFilesMap(translationContext, manifestData .getData()); } - public static void addFile(TranslationContext translationContext, - String name, byte[] content) { + private static void addFile(TranslationContext translationContext, + String name, byte[] content) { translationContext.addFile(name, content); } @@ -249,7 +201,7 @@ public class BaseResourceTranslationTest { } } - public void validateNodeTemplateIdInNestedConsolidationData(){ + void validateNodeTemplateIdInNestedConsolidationData(){ ConsolidationData consolidationData = translationContext.getConsolidationData(); Map expectedServiceTemplateModels = TestUtils.getServiceTemplates (expectedResultMap); @@ -257,9 +209,9 @@ public class BaseResourceTranslationTest { validateNestedConsolidationDataNodeTemplateIds(consolidationData,expectedServiceTemplateModels); } - public void validateComputeTemplateConsolidationData(ConsolidationDataValidationType - validationType, - String testName) { + protected void validateComputeTemplateConsolidationData(ConsolidationDataValidationType + validationType, + String testName) { ConsolidationData consolidationData = translationContext.getConsolidationData(); Map expectedServiceTemplateModels = TestUtils.getServiceTemplates (expectedResultMap); @@ -322,19 +274,17 @@ public class BaseResourceTranslationTest { } } - public void validateGetAttribute(String testName){ + protected void validateGetAttribute(String testName){ Map expectedServiceTemplateModels = TestUtils.getServiceTemplates (expectedResultMap); validateGetAttr(translationContext,expectedServiceTemplateModels,testName); } - public void validateNestedTemplateConsolidationData(String testName){ + protected void validateNestedTemplateConsolidationData(String testName){ validateNestedConsolidationData(translationContext, testName); } - public void validatePortTemplateConsolidationData(ConsolidationDataValidationType - validationType, - String testName) { + void validatePortTemplateConsolidationData() { ConsolidationData consolidationData = translationContext.getConsolidationData(); Map expectedServiceTemplateModels = TestUtils.getServiceTemplates (expectedResultMap); @@ -358,7 +308,7 @@ public class BaseResourceTranslationTest { for(String portNodeTemplateId : portNodeTemplateIds) { PortTemplateConsolidationData portTemplateConsolidationData = filePortConsolidationData.getPortTemplateConsolidationData(portNodeTemplateId); - switch(validationType){ + switch(ConsolidationDataValidationType.VALIDATE_CONNECTIVITY){ case VALIDATE_CONNECTIVITY: validatePortConnectivityIn(portTemplateConsolidationData,expectedServiceTemplate); validatePortConnectivityOut(portNodeTemplateId, portTemplateConsolidationData, diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java index 74a6ce5a5b..85557cb19f 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java @@ -22,12 +22,9 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import org.junit.Before; import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType; import java.io.IOException; -import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE; - /** * @author Avrahamg * @since August 10, 2016 @@ -46,8 +43,7 @@ public class ResourceTranslationContrailV2VmInterfaceImplTest extends BaseResour outputFilesPath = "/mock/services/heattotosca/contrailv2VMinterface/oneNet/expectedoutputfiles"; initTranslatorAndTranslate(); testTranslation(); - validatePortTemplateConsolidationData(ConsolidationDataValidationType - .VALIDATE_CONNECTIVITY, TEST_CONNECTIVITY_POSITIVE); + validatePortTemplateConsolidationData(); } @Test @@ -57,8 +53,7 @@ public class ResourceTranslationContrailV2VmInterfaceImplTest extends BaseResour "/mock/services/heattotosca/contrailv2VMinterface/listNet/expectedoutputfiles"; initTranslatorAndTranslate(); testTranslation(); - validatePortTemplateConsolidationData(ConsolidationDataValidationType - .VALIDATE_CONNECTIVITY, TEST_CONNECTIVITY_POSITIVE); + validatePortTemplateConsolidationData(); } @Test diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java index 96e7af7414..2e55cb96bf 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java @@ -22,12 +22,9 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import org.junit.Before; import org.junit.Test; -import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType; import java.io.IOException; -import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE; - public class ResourceTranslationNeutronPortImplTest extends BaseResourceTranslationTest { @@ -43,8 +40,7 @@ public class ResourceTranslationNeutronPortImplTest extends BaseResourceTranslat outputFilesPath = "/mock/services/heattotosca/neutron_port_translation/expectedoutputfiles"; initTranslatorAndTranslate(); testTranslation(); - validatePortTemplateConsolidationData(ConsolidationDataValidationType - .VALIDATE_CONNECTIVITY, TEST_CONNECTIVITY_POSITIVE); + validatePortTemplateConsolidationData(); } @Test @@ -54,8 +50,7 @@ public class ResourceTranslationNeutronPortImplTest extends BaseResourceTranslat "/mock/services/heattotosca/neutron_security_group_translation/expectedoutputfiles"; initTranslatorAndTranslate(); testTranslation(); - validatePortTemplateConsolidationData(ConsolidationDataValidationType - .VALIDATE_CONNECTIVITY, TEST_CONNECTIVITY_POSITIVE); + validatePortTemplateConsolidationData(); } @Test @@ -65,7 +60,6 @@ public class ResourceTranslationNeutronPortImplTest extends BaseResourceTranslat "/mock/services/heattotosca/neutron_dual_stacks/expectedoutputfiles"; initTranslatorAndTranslate(); testTranslation(); - validatePortTemplateConsolidationData(ConsolidationDataValidationType - .VALIDATE_CONNECTIVITY, TEST_CONNECTIVITY_POSITIVE); + validatePortTemplateConsolidationData(); } } -- cgit 1.2.3-korg