diff options
Diffstat (limited to 'openecomp-be')
12 files changed, 306 insertions, 370 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml index 7668337396..6a6dd0aa73 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml @@ -72,7 +72,7 @@ <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> - <version>2.0.1</version> + <version>${ws.rs.version}</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> @@ -144,6 +144,11 @@ <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> </dependencies> <!-- Should be removed once TogglZ usage in pom files is fixed --> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml index 2b1b9893b3..1e41ed246c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml @@ -13,7 +13,7 @@ <context-param> <param-name>org.togglz.core.manager.TogglzConfig</param-name> - <param-value>org.openecomp.sdc.common.togglz.TogglzConfiguration</param-value> + <param-value>org.openecomp.sdc.be.togglz.TogglzConfiguration</param-value> </context-param> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/pom.xml index 2d26276316..fb523705a5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/pom.xml @@ -14,48 +14,54 @@ <dependencies> - <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>javax.ws.rs-api</artifactId> - <version>${ws.rs.version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${spring.framework.version}</version> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <version>${javax.inject.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.core</groupId> - <artifactId>openecomp-common-lib</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>togglz-rest-types</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-common-rest</artifactId> - <version>${project.version}</version> - </dependency> - <!-- CXF --> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - <version>${cxf.version}</version> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>togglz-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.be</groupId> + <artifactId>common-be</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> </project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java index 7fe65427e9..c6fbed672e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java @@ -15,15 +15,14 @@ */ package org.openecomp.sdcrests.togglz.rest.mapping; -import org.openecomp.sdc.common.togglz.ToggleableFeature; -import org.openecomp.sdcrests.mapping.MappingBase; -import org.openecomp.sdcrests.togglz.types.FeatureDto; -import org.openecomp.sdcrests.togglz.types.FeatureSetDto; - import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; +import org.openecomp.sdc.be.togglz.ToggleableFeature; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.togglz.types.FeatureDto; +import org.openecomp.sdcrests.togglz.types.FeatureSetDto; public class MapToggleableFeatureToDto extends MappingBase<Collection<ToggleableFeature>, FeatureSetDto> { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java index d62dd4add1..4777d0a656 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java @@ -15,12 +15,11 @@ */ package org.openecomp.sdcrests.togglz.rest.services; - -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdcrests.togglz.rest.TogglzFeatures; import org.openecomp.sdcrests.togglz.rest.mapping.MapToggleableFeatureToDto; import org.openecomp.sdcrests.togglz.types.FeatureDto; import org.openecomp.sdcrests.togglz.types.FeatureSetDto; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.togglz.core.Feature; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/test/java/org/openecomp/TogglzFeatureRestTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/test/java/org/openecomp/TogglzFeatureRestTest.java index 8035f11eec..9b9eed15fc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/test/java/org/openecomp/TogglzFeatureRestTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/test/java/org/openecomp/TogglzFeatureRestTest.java @@ -22,7 +22,7 @@ package org.openecomp; import com.google.common.collect.Sets; import org.junit.Test; -import org.openecomp.sdc.common.togglz.ToggleableFeature; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.openecomp.sdcrests.togglz.rest.TogglzFeatures; import org.openecomp.sdcrests.togglz.rest.mapping.MapToggleableFeatureToDto; import org.openecomp.sdcrests.togglz.rest.services.TogglzFeaturesImpl; diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java deleted file mode 100644 index 440a5083fb..0000000000 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 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.common.togglz; - -import org.togglz.core.Feature; -import org.togglz.core.annotation.Label; -import org.togglz.core.context.FeatureContext; - -public enum ToggleableFeature implements Feature { - - @Label("Default Feature") - DEFAULT_FEATURE; - - public boolean isActive() { - return FeatureContext.getFeatureManager().isActive(this); - } -} diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java deleted file mode 100644 index 8b58e5a5ac..0000000000 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/TogglzConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 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.common.togglz; - -import org.togglz.core.Feature; -import org.togglz.core.manager.TogglzConfig; -import org.togglz.core.repository.StateRepository; -import org.togglz.core.repository.file.FileBasedStateRepository; -import org.togglz.core.user.SimpleFeatureUser; -import org.togglz.core.user.UserProvider; - -import java.io.File; - -public class TogglzConfiguration implements TogglzConfig { - @Override - public Class<? extends Feature> getFeatureClass() { - return ToggleableFeature.class; - } - - @Override - public StateRepository getStateRepository() { - return new FileBasedStateRepository(new File("/tmp/features.properties")); - } - - @Override - public UserProvider getUserProvider() { - return () -> new SimpleFeatureUser("admin", true); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java index 39ee8b7b3c..71dfeb9f53 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java @@ -37,7 +37,6 @@ import org.onap.sdc.tosca.datatypes.model.RelationshipTemplate; import org.onap.sdc.tosca.datatypes.model.RequirementAssignment; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition; -import org.openecomp.sdc.common.togglz.ToggleableFeature; import org.openecomp.sdc.heat.datatypes.HeatBoolean; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; 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 cae53f5695..31dbb21a4c 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 @@ -16,6 +16,20 @@ 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.Map; +import java.util.Set; +import java.util.zip.ZipInputStream; import org.apache.commons.collections4.MapUtils; import org.junit.Assert; import org.junit.BeforeClass; @@ -24,27 +38,16 @@ import org.openecomp.core.translator.datatypes.TranslatorOutput; import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.validation.util.MessageContainerUtil; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.openecomp.sdc.common.errors.CoreException; 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.tosca.services.impl.ToscaFileOutputServiceCsarImpl; import org.openecomp.sdc.translator.TestUtils; import org.togglz.testing.TestFeatureManager; import org.togglz.testing.TestFeatureManagerProvider; -import java.io.*; -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; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.translator.TestUtils.getErrorAsString; - public class BaseFullTranslationTest { @@ -88,8 +91,7 @@ public class BaseFullTranslationTest { } try (ByteArrayInputStream fis = new ByteArrayInputStream(translatedZipFile); - BufferedInputStream bis = new BufferedInputStream(fis); - ZipInputStream zis = new ZipInputStream(bis)) { + BufferedInputStream bis = new BufferedInputStream(fis); ZipInputStream zis = new ZipInputStream(bis)) { TestUtils.compareTranslatedOutput(expectedResultFileNameSet, expectedResultMap, zis); } assertEquals(0, expectedResultFileNameSet.size()); @@ -105,8 +107,8 @@ public class BaseFullTranslationTest { 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()); + .withId("Validation Error").withCategory(ErrorCategory.APPLICATION) + .build()); } 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 5e5bda3997..42f4cfdfd5 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 @@ -16,6 +16,33 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; +import static org.junit.Assert.assertEquals; +import static org.openecomp.sdc.common.utils.SdcCommon.MANIFEST_NAME; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityIn; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityOut; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateDependsOnInConsolidationData; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGetAttr; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGroupsInConsolidationData; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationData; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationDataNodeTemplateIds; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityIn; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityOut; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortsInConsolidationData; +import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateVolumeInConsolidationData; + +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; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipInputStream; import org.apache.commons.collections4.MapUtils; import org.junit.Assert; import org.junit.Before; @@ -25,272 +52,253 @@ import org.openecomp.core.translator.datatypes.TranslatorOutput; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.validation.util.MessageContainerUtil; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.openecomp.sdc.common.errors.CoreException; 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.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile; -import org.openecomp.sdc.tosca.services.ToscaFileOutputService; import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl; import org.openecomp.sdc.translator.TestUtils; import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; -import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.*; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.FileComputeConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.FilePortConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData; import org.openecomp.sdc.translator.services.heattotosca.TranslationService; import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType; import org.togglz.testing.TestFeatureManager; import org.togglz.testing.TestFeatureManagerProvider; -import java.io.*; -import java.net.URL; -import java.util.*; -import java.util.zip.ZipInputStream; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.common.utils.SdcCommon.MANIFEST_NAME; -import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.*; - public class BaseResourceTranslationTest { - protected String inputFilesPath; - protected String outputFilesPath; - TranslationContext translationContext; + protected String inputFilesPath; + protected String outputFilesPath; + TranslationContext translationContext; - private TranslationService translationService; - private byte[] translatedZipFile; + private TranslationService translationService; + private byte[] translatedZipFile; - private Map<String, byte[]> expectedResultMap = new HashMap<>(); - private Set<String> expectedResultFileNameSet = new HashSet<>(); + private Map<String, byte[]> expectedResultMap = new HashMap<>(); + private Set<String> expectedResultFileNameSet = new HashSet<>(); - protected static TestFeatureManager manager; + protected static TestFeatureManager manager; - @BeforeClass - public static void enableToggleableFeatures(){ - manager = new TestFeatureManager(ToggleableFeature.class); - manager.enableAll(); - TestFeatureManagerProvider.setFeatureManager(manager); - } + @BeforeClass + public static void enableToggleableFeatures() { + manager = new TestFeatureManager(ToggleableFeature.class); + manager.enableAll(); + TestFeatureManagerProvider.setFeatureManager(manager); + } - @Before - public void setUp() throws IOException { - initTranslatorAndTranslate(); - } + @Before + public void setUp() throws IOException { + initTranslatorAndTranslate(); + } - protected void initTranslatorAndTranslate() throws IOException { - translationService = new TranslationService(); - translationContext = new TranslationContext(); - translatedZipFile = translateZipFile(); - } + protected void initTranslatorAndTranslate() throws IOException { + translationService = new TranslationService(); + translationContext = new TranslationContext(); + translatedZipFile = translateZipFile(); + } - protected void testTranslation() throws IOException { + protected void testTranslation() throws IOException { - URL url = BaseResourceTranslationTest.class.getResource(outputFilesPath); + URL url = BaseResourceTranslationTest.class.getResource(outputFilesPath); - 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)); - } - } + 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)) { - TestUtils.compareTranslatedOutput(expectedResultFileNameSet, expectedResultMap, zis); + try (ByteArrayInputStream fis = new ByteArrayInputStream(translatedZipFile); + BufferedInputStream bis = new BufferedInputStream(fis); ZipInputStream zis = new ZipInputStream(bis)) { + TestUtils.compareTranslatedOutput(expectedResultFileNameSet, expectedResultMap, zis); + } + assertEquals(0, expectedResultFileNameSet.size()); } - assertEquals(0, expectedResultFileNameSet.size()); - } - - private byte[] translateZipFile() throws IOException { - URL inputFilesUrl = this.getClass().getResource(inputFilesPath); - String path = inputFilesUrl.getPath(); - addFilesToTranslator(translationContext, path); - TranslatorOutput translatorOutput = translationService.translateHeatFiles(translationContext); - 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 " + TestUtils.getErrorAsString(translatorOutput.getErrorMessages())) - .withId("Validation Error").withCategory(ErrorCategory.APPLICATION).build()); + + private byte[] translateZipFile() throws IOException { + URL inputFilesUrl = this.getClass().getResource(inputFilesPath); + String path = inputFilesUrl.getPath(); + addFilesToTranslator(translationContext, path); + TranslatorOutput translatorOutput = translationService.translateHeatFiles(translationContext); + 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 " + TestUtils.getErrorAsString(translatorOutput.getErrorMessages())) + .withId("Validation Error").withCategory(ErrorCategory.APPLICATION) + .build()); + } + + return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); + } - - return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null); - - } - private void addFilesToTranslator(TranslationContext translationContext, String path) - throws IOException { - File manifestFile = new File(path); - File[] files = manifestFile.listFiles(); - byte[] fileContent; + private void addFilesToTranslator(TranslationContext translationContext, String path) throws IOException { + File manifestFile = new File(path); + File[] files = manifestFile.listFiles(); + byte[] fileContent; - Assert.assertNotNull("manifest files is empty", files); + Assert.assertNotNull("manifest files is empty", files); - for (File file : files) { + for (File file : files) { - try (FileInputStream fis = new FileInputStream(file)) { + try (FileInputStream fis = new FileInputStream(file)) { - fileContent = FileUtils.toByteArray(fis); + fileContent = FileUtils.toByteArray(fis); - if (file.getName().equals(MANIFEST_NAME)) { - 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); - } + if (file.getName().equals(MANIFEST_NAME)) { + 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); + } + } + } } - } } - } - - private static void addManifest(TranslationContext translationContext, - byte[] content) { - ManifestContent manifestData = JsonUtil.json2Object(new String(content), ManifestContent.class); - ManifestFile manifest = new ManifestFile(); - manifest.setName(MANIFEST_NAME); - manifest.setContent(manifestData); - translationContext.setManifest(manifest); - translationContext.addFile(MANIFEST_NAME, content); - addFilesFromManifestToTranslationContextManifestFilesMap(translationContext, manifestData - .getData()); - } - - private static void addFile(TranslationContext translationContext, - String name, byte[] content) { - translationContext.addFile(name, content); - } - - private static void addFilesFromManifestToTranslationContextManifestFilesMap( - TranslationContext translationContext, List<FileData> fileDataListFromManifest) { - for (FileData fileFromManfiest : fileDataListFromManifest) { - translationContext.addManifestFile(fileFromManfiest.getFile(), fileFromManfiest.getType()); + + private static void addManifest(TranslationContext translationContext, byte[] content) { + ManifestContent manifestData = JsonUtil.json2Object(new String(content), ManifestContent.class); + ManifestFile manifest = new ManifestFile(); + manifest.setName(MANIFEST_NAME); + manifest.setContent(manifestData); + translationContext.setManifest(manifest); + translationContext.addFile(MANIFEST_NAME, content); + addFilesFromManifestToTranslationContextManifestFilesMap(translationContext, manifestData.getData()); + } + + private static void addFile(TranslationContext translationContext, String name, byte[] content) { + translationContext.addFile(name, content); } - } - - void validateNodeTemplateIdInNestedConsolidationData(){ - ConsolidationData consolidationData = translationContext.getConsolidationData(); - Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates - (expectedResultMap); - Assert.assertNotNull(consolidationData); - validateNestedConsolidationDataNodeTemplateIds(consolidationData,expectedServiceTemplateModels); - } - - protected void validateComputeTemplateConsolidationData(ConsolidationDataValidationType - validationType, - String testName) { - ConsolidationData consolidationData = translationContext.getConsolidationData(); - Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates - (expectedResultMap); - Assert.assertNotNull(consolidationData); - Assert.assertNotNull(consolidationData.getComputeConsolidationData()); - Set<String> serviceTemplateFileNames = consolidationData.getComputeConsolidationData() - .getAllServiceTemplateFileNames(); - Assert.assertNotNull(serviceTemplateFileNames); - for(String serviceTemplateName : serviceTemplateFileNames){ - Assert.assertTrue(expectedServiceTemplateModels.containsKey(serviceTemplateName)); - ServiceTemplate expectedServiceTemplate = expectedServiceTemplateModels.get - (serviceTemplateName); - FileComputeConsolidationData fileComputeConsolidationData = consolidationData - .getComputeConsolidationData().getFileComputeConsolidationData(serviceTemplateName); - Assert.assertNotNull(fileComputeConsolidationData); - Set<String> computeTypes = fileComputeConsolidationData.getAllComputeTypes(); - Assert.assertNotNull(computeTypes); - for(String computeType : computeTypes) { - TypeComputeConsolidationData typeComputeConsolidationData = fileComputeConsolidationData - .getTypeComputeConsolidationData(computeType); - Assert.assertNotNull(typeComputeConsolidationData); - - Collection<String> computeNodeTemplateIds = typeComputeConsolidationData - .getAllComputeNodeTemplateIds(); - Assert.assertNotNull(computeNodeTemplateIds); - Assert.assertNotEquals(computeNodeTemplateIds.size(), 0); - - for(String computeNodeTemplateId : computeNodeTemplateIds) { - ComputeTemplateConsolidationData computeTemplateConsolidationData = - typeComputeConsolidationData.getComputeTemplateConsolidationData - (computeNodeTemplateId); - switch(validationType){ - case VALIDATE_GROUP: - validateGroupsInConsolidationData(computeNodeTemplateId, - computeTemplateConsolidationData, expectedServiceTemplate); - break; - case VALIDATE_PORT: - validatePortsInConsolidationData(computeNodeTemplateId, - computeTemplateConsolidationData, - expectedServiceTemplate); - break; - case VALIDATE_VOLUME: - validateVolumeInConsolidationData(computeNodeTemplateId, - computeTemplateConsolidationData, expectedServiceTemplate, testName); - break; - case VALIDATE_CONNECTIVITY: - validateComputeConnectivityIn(computeTemplateConsolidationData, - expectedServiceTemplate); - validateComputeConnectivityOut(computeNodeTemplateId, computeTemplateConsolidationData, - expectedServiceTemplate); - break; - case VALIDATE_DEPENDS_ON: - validateDependsOnInConsolidationData(computeNodeTemplateId, - computeTemplateConsolidationData, - expectedServiceTemplate, testName); - break; - } + + private static void addFilesFromManifestToTranslationContextManifestFilesMap(TranslationContext translationContext, + List<FileData> fileDataListFromManifest) { + for (FileData fileFromManfiest : fileDataListFromManifest) { + translationContext.addManifestFile(fileFromManfiest.getFile(), fileFromManfiest.getType()); + } + } + + void validateNodeTemplateIdInNestedConsolidationData() { + ConsolidationData consolidationData = translationContext.getConsolidationData(); + Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates(expectedResultMap); + Assert.assertNotNull(consolidationData); + validateNestedConsolidationDataNodeTemplateIds(consolidationData, expectedServiceTemplateModels); + } + + protected void validateComputeTemplateConsolidationData(ConsolidationDataValidationType validationType, + String testName) { + ConsolidationData consolidationData = translationContext.getConsolidationData(); + Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates(expectedResultMap); + Assert.assertNotNull(consolidationData); + Assert.assertNotNull(consolidationData.getComputeConsolidationData()); + Set<String> serviceTemplateFileNames = + consolidationData.getComputeConsolidationData().getAllServiceTemplateFileNames(); + Assert.assertNotNull(serviceTemplateFileNames); + for (String serviceTemplateName : serviceTemplateFileNames) { + Assert.assertTrue(expectedServiceTemplateModels.containsKey(serviceTemplateName)); + ServiceTemplate expectedServiceTemplate = expectedServiceTemplateModels.get(serviceTemplateName); + FileComputeConsolidationData fileComputeConsolidationData = consolidationData.getComputeConsolidationData() + .getFileComputeConsolidationData( + serviceTemplateName); + Assert.assertNotNull(fileComputeConsolidationData); + Set<String> computeTypes = fileComputeConsolidationData.getAllComputeTypes(); + Assert.assertNotNull(computeTypes); + for (String computeType : computeTypes) { + TypeComputeConsolidationData typeComputeConsolidationData = + fileComputeConsolidationData.getTypeComputeConsolidationData(computeType); + Assert.assertNotNull(typeComputeConsolidationData); + + Collection<String> computeNodeTemplateIds = typeComputeConsolidationData.getAllComputeNodeTemplateIds(); + Assert.assertNotNull(computeNodeTemplateIds); + Assert.assertNotEquals(computeNodeTemplateIds.size(), 0); + + for (String computeNodeTemplateId : computeNodeTemplateIds) { + ComputeTemplateConsolidationData computeTemplateConsolidationData = + typeComputeConsolidationData.getComputeTemplateConsolidationData(computeNodeTemplateId); + switch (validationType) { + case VALIDATE_GROUP: + validateGroupsInConsolidationData(computeNodeTemplateId, computeTemplateConsolidationData, + expectedServiceTemplate); + break; + case VALIDATE_PORT: + validatePortsInConsolidationData(computeNodeTemplateId, computeTemplateConsolidationData, + expectedServiceTemplate); + break; + case VALIDATE_VOLUME: + validateVolumeInConsolidationData(computeNodeTemplateId, computeTemplateConsolidationData, + expectedServiceTemplate, testName); + break; + case VALIDATE_CONNECTIVITY: + validateComputeConnectivityIn(computeTemplateConsolidationData, expectedServiceTemplate); + validateComputeConnectivityOut(computeNodeTemplateId, computeTemplateConsolidationData, + expectedServiceTemplate); + break; + case VALIDATE_DEPENDS_ON: + validateDependsOnInConsolidationData(computeNodeTemplateId, + computeTemplateConsolidationData, expectedServiceTemplate, testName); + break; + } + } + } } - } } - } protected void validateGetAttribute(String testName) { validateGetAttr(translationContext, testName); } - protected void validateNestedTemplateConsolidationData(String testName){ - validateNestedConsolidationData(translationContext, testName); - } - - void validatePortTemplateConsolidationData() { - ConsolidationData consolidationData = translationContext.getConsolidationData(); - Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates - (expectedResultMap); - Assert.assertNotNull(consolidationData); - Assert.assertNotNull(consolidationData.getPortConsolidationData()); - Set<String> serviceTemplateFileNames = consolidationData.getPortConsolidationData() - .getAllServiceTemplateFileNames(); - Assert.assertNotNull(serviceTemplateFileNames); - for(String serviceTemplateName : serviceTemplateFileNames){ - Assert.assertTrue(expectedServiceTemplateModels.containsKey(serviceTemplateName)); - ServiceTemplate expectedServiceTemplate = expectedServiceTemplateModels.get - (serviceTemplateName); - FilePortConsolidationData filePortConsolidationData = consolidationData - .getPortConsolidationData().getFilePortConsolidationData(serviceTemplateName); - Assert.assertNotNull(filePortConsolidationData); - - Set<String> portNodeTemplateIds = filePortConsolidationData.getAllPortNodeTemplateIds(); - Assert.assertNotNull(portNodeTemplateIds); - Assert.assertNotEquals(portNodeTemplateIds.size(), 0); - - for(String portNodeTemplateId : portNodeTemplateIds) { - PortTemplateConsolidationData portTemplateConsolidationData = - filePortConsolidationData.getPortTemplateConsolidationData(portNodeTemplateId); - switch(ConsolidationDataValidationType.VALIDATE_CONNECTIVITY){ - case VALIDATE_CONNECTIVITY: - validatePortConnectivityIn(portTemplateConsolidationData,expectedServiceTemplate); - validatePortConnectivityOut(portNodeTemplateId, portTemplateConsolidationData, expectedServiceTemplate); - break; + protected void validateNestedTemplateConsolidationData(String testName) { + validateNestedConsolidationData(translationContext, testName); + } + + void validatePortTemplateConsolidationData() { + ConsolidationData consolidationData = translationContext.getConsolidationData(); + Map<String, ServiceTemplate> expectedServiceTemplateModels = TestUtils.getServiceTemplates(expectedResultMap); + Assert.assertNotNull(consolidationData); + Assert.assertNotNull(consolidationData.getPortConsolidationData()); + Set<String> serviceTemplateFileNames = + consolidationData.getPortConsolidationData().getAllServiceTemplateFileNames(); + Assert.assertNotNull(serviceTemplateFileNames); + for (String serviceTemplateName : serviceTemplateFileNames) { + Assert.assertTrue(expectedServiceTemplateModels.containsKey(serviceTemplateName)); + ServiceTemplate expectedServiceTemplate = expectedServiceTemplateModels.get(serviceTemplateName); + FilePortConsolidationData filePortConsolidationData = + consolidationData.getPortConsolidationData().getFilePortConsolidationData(serviceTemplateName); + Assert.assertNotNull(filePortConsolidationData); + + Set<String> portNodeTemplateIds = filePortConsolidationData.getAllPortNodeTemplateIds(); + Assert.assertNotNull(portNodeTemplateIds); + Assert.assertNotEquals(portNodeTemplateIds.size(), 0); + + for (String portNodeTemplateId : portNodeTemplateIds) { + PortTemplateConsolidationData portTemplateConsolidationData = + filePortConsolidationData.getPortTemplateConsolidationData(portNodeTemplateId); + switch (ConsolidationDataValidationType.VALIDATE_CONNECTIVITY) { + case VALIDATE_CONNECTIVITY: + validatePortConnectivityIn(portTemplateConsolidationData, expectedServiceTemplate); + validatePortConnectivityOut(portNodeTemplateId, portTemplateConsolidationData, + expectedServiceTemplate); + break; + } + } } - } } - } } 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/ResourceTranslationNovaServerImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImplTest.java index b19c822d11..1d6e6b1a9e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImplTest.java @@ -24,7 +24,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.openecomp.sdc.common.togglz.ToggleableFeature; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType; import org.togglz.testing.TestFeatureManagerProvider; |