From 3de22e1c6c2711072ce996335e7250445a39d320 Mon Sep 17 00:00:00 2001 From: Gautam Shah Date: Sat, 21 Apr 2018 16:18:37 +0530 Subject: Reducing onboarding backend maven build time Reducing onboarding backend maven build time Change-Id: Id0178cbf010e46f741f4bff11e14b0801f14d4b8 Issue-ID: SDC-1189 Signed-off-by: GAUTAMS --- .../openecomp-sdc-translator-core/pom.xml | 10 +- .../helper/impl/NameExtractorServiceImpl.java | 19 -- .../BaseFullTranslationTest.java | 224 ++++++++++----------- .../openecomp-sdc-translator-impl/pom.xml | 52 ----- .../openecomp-sdc-translator-sdk/pom.xml | 45 ----- .../lib/openecomp-sdc-translator-lib/pom.xml | 2 - 6 files changed, 115 insertions(+), 237 deletions(-) delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/impl/NameExtractorServiceImpl.java delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-impl/pom.xml delete mode 100644 openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-sdk/pom.xml (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib') diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml index b08067b6b4..0535d9dba1 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/pom.xml @@ -93,7 +93,7 @@ classes 1 - 0 + ${fork.count} false true 1 @@ -103,12 +103,14 @@ src/test/resources/logback-test.xml - - org.openecomp.sdc:build-helper - + ${useSystemClassLoader} + + false + + diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/impl/NameExtractorServiceImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/impl/NameExtractorServiceImpl.java deleted file mode 100644 index 3867dadaeb..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/impl/NameExtractorServiceImpl.java +++ /dev/null @@ -1,19 +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========================================================= - */ 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 2387390df9..801f2c67a0 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 @@ -18,11 +18,22 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import static org.junit.Assert.assertEquals; +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; -import org.junit.Rule; -import org.junit.rules.TestName; import org.openecomp.core.translator.api.HeatToToscaTranslator; import org.openecomp.core.translator.datatypes.TranslatorOutput; import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory; @@ -39,133 +50,116 @@ import org.openecomp.sdc.translator.TestUtils; import org.togglz.testing.TestFeatureManager; import org.togglz.testing.TestFeatureManagerProvider; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.ByteArrayInputStream; -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; - public class BaseFullTranslationTest { - public static final String IN_POSTFIX = "/in"; - public static final String OUT_POSTFIX = "/out"; - - @Rule - public TestName name = new TestName(); - - protected static TestFeatureManager manager; - private static File tempDir = new File(System.getProperty("java.io.tmpdir")); - - @BeforeClass - public static void enableToggleableFeatures(){ - manager = new TestFeatureManager(ToggleableFeature.class); - manager.enableAll(); - 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); - } - - protected byte[] initTranslatorAndTranslate(String path) throws IOException { - HeatToToscaTranslator heatToToscaTranslator = HeatToToscaTranslatorFactory.getInstance().createInterface(); - return translateZipFile(path, heatToToscaTranslator); - } - - protected void testTranslation(String basePath, byte[] translatedZipFile) throws IOException { - - URL url = BaseFullTranslationTest.class.getResource(basePath + OUT_POSTFIX); - Set expectedResultFileNameSet = new HashSet<>(); - Map expectedResultMap = new HashMap<>(); - - String path = url.getPath(); - File pathFile = new File(path); - File[] files = pathFile.listFiles(); - Assert.assertNotNull("manifest files is empty", files); - for (File expectedFile : files) { - expectedResultFileNameSet.add(expectedFile.getName()); - try (FileInputStream input = new FileInputStream(expectedFile)) { - expectedResultMap.put(expectedFile.getName(), FileUtils.toByteArray(input)); - } + public static final String IN_POSTFIX = "/in"; + public static final String OUT_POSTFIX = "/out"; + + + protected static TestFeatureManager manager; + + @BeforeClass + public static void enableToggleableFeatures() { + manager = new TestFeatureManager(ToggleableFeature.class); + manager.enableAll(); + TestFeatureManagerProvider.setFeatureManager(manager); } - 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) { + public static void disableToggleableFeatures() { + manager.disableAll(); + manager = null; + TestFeatureManagerProvider.setFeatureManager(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); + protected void testTranslationWithInit(String path) throws IOException { + byte[] translatedZipFile = initTranslatorAndTranslate(path); + testTranslation(path, translatedZipFile); + } - expectedResultFileNameSet.remove(name); - } - } - if (expectedResultFileNameSet.isEmpty()) { - expectedResultFileNameSet.forEach(System.out::println); - } + protected byte[] initTranslatorAndTranslate(String path) throws IOException { + HeatToToscaTranslator heatToToscaTranslator = HeatToToscaTranslatorFactory.getInstance().createInterface(); + return translateZipFile(path, heatToToscaTranslator); } - assertEquals(0, expectedResultFileNameSet.size()); - } - - private byte[] translateZipFile(String basePath, HeatToToscaTranslator heatToToscaTranslator) throws IOException { - URL inputFilesUrl = this.getClass().getResource(basePath + IN_POSTFIX); - String path = inputFilesUrl.getPath(); - TestUtils.addFilesToTranslator(heatToToscaTranslator, path); - TranslatorOutput translatorOutput = heatToToscaTranslator.translate(); - Assert.assertNotNull(translatorOutput); - if (MapUtils.isNotEmpty(translatorOutput.getErrorMessages()) && MapUtils.isNotEmpty( - MessageContainerUtil - .getMessageByLevel(ErrorLevel.ERROR, translatorOutput.getErrorMessages()))) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage( - "Error in validation " + getErrorAsString(translatorOutput.getErrorMessages())) - .withId("Validation Error").withCategory(ErrorCategory.APPLICATION).build()); + + protected void testTranslation(String basePath, byte[] translatedZipFile) throws IOException { + + URL url = BaseFullTranslationTest.class.getResource(basePath + OUT_POSTFIX); + Set expectedResultFileNameSet = new HashSet<>(); + Map expectedResultMap = new HashMap<>(); + + String path = url.getPath(); + File pathFile = new File(path); + File[] files = pathFile.listFiles(); + Assert.assertNotNull("manifest files is empty", files); + for (File expectedFile : files) { + expectedResultFileNameSet.add(expectedFile.getName()); + try (FileInputStream input = new FileInputStream(expectedFile)) { + expectedResultMap.put(expectedFile.getName(), FileUtils.toByteArray(input)); + } + } + + 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); + } + } + assertEquals(0, expectedResultFileNameSet.size()); } - byte[] data = new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); + private byte[] translateZipFile(String basePath, HeatToToscaTranslator heatToToscaTranslator) throws IOException { + URL inputFilesUrl = this.getClass().getResource(basePath + IN_POSTFIX); + String path = inputFilesUrl.getPath(); + TestUtils.addFilesToTranslator(heatToToscaTranslator, path); + TranslatorOutput translatorOutput = heatToToscaTranslator.translate(); + Assert.assertNotNull(translatorOutput); + if (MapUtils.isNotEmpty(translatorOutput.getErrorMessages()) && MapUtils.isNotEmpty( + MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, translatorOutput.getErrorMessages()))) { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage( + "Error in validation " + getErrorAsString(translatorOutput.getErrorMessages())) + .withId("Validation Error") + .withCategory(ErrorCategory.APPLICATION).build()); + } - return data; - } + byte[] data = + new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); - 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 data; + } - return sb.toString(); - } + 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()))); - 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 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(); + } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-impl/pom.xml deleted file mode 100644 index 8b59f02f95..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-impl/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - 4.0.0 - - openecomp-sdc-translator-impl - openecomp-sdc-translator-impl - - - - org.openecomp.sdc - openecomp-sdc-lib - 1.2.0-SNAPSHOT - ../.. - - - - - ch.qos.logback - logback-classic - ${logback.version} - - - junit - junit - ${junit.version} - test - - - org.openecomp.sdc - openecomp-sdc-translator-api - ${project.version} - - - org.openecomp.sdc.core - openecomp-heat-lib - ${project.version} - - - org.openecomp.sdc.core - openecomp-tosca-lib - ${project.version} - - - - org.openecomp.sdc - openecomp-sdc-translator-core - ${project.version} - - - - diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-sdk/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-sdk/pom.xml deleted file mode 100644 index 6e48011eb2..0000000000 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-sdk/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - 4.0.0 - - openecomp-sdc-translator-sdk - openecomp-sdc-translator-sdk - - - - org.openecomp.sdc - openecomp-sdc-lib - 1.2.0-SNAPSHOT - ../.. - - - - - ch.qos.logback - logback-classic - ${logback.version} - - - junit - junit - ${junit.version} - test - - - org.openecomp.sdc - openecomp-sdc-translator-api - ${project.version} - - - org.openecomp.sdc.core - openecomp-heat-lib - ${project.version} - - - org.openecomp.sdc.core - openecomp-tosca-lib - ${project.version} - - - diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-translator-lib/pom.xml index bf7f5aa957..814b152daf 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/pom.xml @@ -16,9 +16,7 @@ openecomp-sdc-translator-api - openecomp-sdc-translator-sdk openecomp-sdc-translator-core - openecomp-sdc-translator-impl -- cgit 1.2.3-korg