aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorsiddharth0905 <siddharth.singh4@amdocs.com>2018-05-08 12:45:29 +0530
committerOren Kleks <orenkle@amdocs.com>2018-05-08 12:19:41 +0000
commit7a81ddecef54cc8d37c264bc22c01851595d81f2 (patch)
tree76f8ee5564f32695d8add2076b1a565617b20d97 /openecomp-be
parent5a7f092400ddb7a86e4be77531dcbe26f81c1c26 (diff)
Junit Test Failure
Junit test were failing in local due to folder name change in common Change-Id: Ie78e2b8cbe41ce568b3f77928e7dd746d9ed3c95 Issue-ID: SDC-1312 Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/Constants.java57
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java149
2 files changed, 103 insertions, 103 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/Constants.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/Constants.java
index d0b1dd0096..848e6d7040 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/Constants.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/Constants.java
@@ -17,30 +17,37 @@
package org.openecomp.sdc.translator.services.heattotosca;
public class Constants {
- //Service Template - Template Names
- public static final String GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME = "GlobalSubstitutionTypes";
- public static final String MAIN_TEMPLATE_NAME = "Main";
- //properties
- public static final String MAX_INSTANCES_PROPERTY_NAME = "max_instances";
- public static final String DESCRIPTION_PROPERTY_NAME = "description";
- public static final String NAME_PROPERTY_NAME = "name";
- public static final String SECURITY_GROUPS_PROPERTY_NAME = "security_groups";
- public static final String PORT_PROPERTY_NAME = "port";
- static final String VFC_PARENT_PORT_ROLE = "vfc_parent_port_role";
- static final String SUB_INTERFACE_ROLE = "subinterface_role";
- //General
- public static final String PROP = "properties";
- public static final String ATTR = "attributes";
- public static final String SERVICE_INSTANCE_PORT_PREFIX = "port_";
- public static final String SERVICE_INSTANCE_LINK_PREFIX = "link_";
- static final String GROUP = "group";
- //Unified model
- static final String COMPUTE_IDENTICAL_VALUE_PROPERTY_PREFIX = "vm_";
- static final String COMPUTE_IDENTICAL_VALUE_PROPERTY_SUFFIX = "_name";
- static final String PORT_IDENTICAL_VALUE_PROPERTY_PREFIX = "port_";
- static final String SUB_INTERFACE_PROPERTY_VALUE_PREFIX = "subinterface_";
- public static final String ABSTRACT_NODE_TEMPLATE_ID_PREFIX = "abstract_";
- private Constants() {
- }
+ //Service Template - Template Names
+ public static final String GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME = "GlobalSubstitutionTypes";
+ public static final String MAIN_TEMPLATE_NAME = "Main";
+ //properties
+ public static final String MAX_INSTANCES_PROPERTY_NAME = "max_instances";
+ public static final String DESCRIPTION_PROPERTY_NAME = "description";
+ public static final String NAME_PROPERTY_NAME = "name";
+ public static final String SECURITY_GROUPS_PROPERTY_NAME = "security_groups";
+ public static final String PORT_PROPERTY_NAME = "port";
+ static final String VFC_PARENT_PORT_ROLE = "vfc_parent_port_role";
+ static final String SUB_INTERFACE_ROLE = "subinterface_role";
+ //General
+ public static final String PROP = "properties";
+ public static final String ATTR = "attributes";
+ public static final String SERVICE_INSTANCE_PORT_PREFIX = "port_";
+ public static final String SERVICE_INSTANCE_LINK_PREFIX = "link_";
+ static final String GROUP = "group";
+ //Unified model
+ static final String COMPUTE_IDENTICAL_VALUE_PROPERTY_PREFIX = "vm_";
+ static final String COMPUTE_IDENTICAL_VALUE_PROPERTY_SUFFIX = "_name";
+ static final String PORT_IDENTICAL_VALUE_PROPERTY_PREFIX = "port_";
+ static final String SUB_INTERFACE_PROPERTY_VALUE_PREFIX = "subinterface_";
+ public static final String ABSTRACT_NODE_TEMPLATE_ID_PREFIX = "abstract_";
+ //GlobalTypesServiceTemplates
+ public static final String INVALID_ONBOARDING_TYPE = "Invalid Onboarding Type";
+ public static final String GLOBAL_TYPES_READ_ERROR = "GlobalTypes Read Error";
+ public static final String FAILED_TO_GENERATE_GLOBAL_TYPES = "Failed to generate globalTypes";
+ public static final String OPENECOMP_INVENTORY = "openecomp-inventory";
+ public static final String GLOBAL_TYPES = "globalTypes";
+
+ private Constants() {
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
index f53cf59c95..a982233a23 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * 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.
@@ -16,101 +16,94 @@
package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
import org.openecomp.sdc.translator.utils.ResourceWalker;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-
public class GlobalTypesServiceTemplates {
- private static final String FAILED_TO_GENERATE_GLOBAL_TYPES = "Failed to generate globalTypes";
+ private static final String ONAP_FILEPATH_REGEX = ".*" + Constants.GLOBAL_TYPES + "(/onap/|\\\\onap\\\\).*";
+ private static final Map<OnboardingTypesEnum, Map<String, ServiceTemplate>> onboardingGlobalTypesServiceTemplates;
- private static final Map<OnboardingTypesEnum, Map<String, ServiceTemplate>>
- onboardingGlobalTypesServiceTemplates;
-
- private GlobalTypesServiceTemplates() {
- }
+ private GlobalTypesServiceTemplates() {
+ }
- static {
- Map<String, String> globalTypes;
- try {
- globalTypes = ResourceWalker.readResourcesFromDirectory("globalTypes");
- } catch (CoreException coreException) {
- throw coreException;
- } catch (Exception exception) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(FAILED_TO_GENERATE_GLOBAL_TYPES)
- .withId("GlobalTypes Read Error").withCategory(ErrorCategory.APPLICATION).build(),
- exception);
+ static {
+ Map<String, String> globalTypes;
+ try {
+ globalTypes = ResourceWalker.readResourcesFromDirectory(Constants.GLOBAL_TYPES);
+ } catch (CoreException coreException) {
+ throw coreException;
+ } catch (Exception exception) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Constants.FAILED_TO_GENERATE_GLOBAL_TYPES)
+ .withId(Constants.GLOBAL_TYPES_READ_ERROR)
+ .withCategory(ErrorCategory.APPLICATION).build(), exception);
+ }
+ onboardingGlobalTypesServiceTemplates = init(globalTypes);
}
- onboardingGlobalTypesServiceTemplates = init(globalTypes);
- }
- public static Map<String, ServiceTemplate> getGlobalTypesServiceTemplates(OnboardingTypesEnum
- onboardingType) {
- if (onboardingType == null) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(FAILED_TO_GENERATE_GLOBAL_TYPES)
- .withId("Invalid Onboarding Type").withCategory(ErrorCategory.APPLICATION).build());
+ public static Map<String, ServiceTemplate> getGlobalTypesServiceTemplates(OnboardingTypesEnum onboardingType) {
+ if (onboardingType == null) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Constants.FAILED_TO_GENERATE_GLOBAL_TYPES)
+ .withId(Constants.INVALID_ONBOARDING_TYPE)
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
+ return onboardingGlobalTypesServiceTemplates.get(onboardingType);
}
- return onboardingGlobalTypesServiceTemplates.get(onboardingType);
- }
- private static Map<OnboardingTypesEnum, Map<String, ServiceTemplate>>
- init(Map<String, String> globalTypes) {
- Map<OnboardingTypesEnum, Map<String, ServiceTemplate>>
- onboardingGlobalTypesServiceTemplates = new EnumMap<>(OnboardingTypesEnum.class);
- Map<String, ServiceTemplate> zipOnboardingGlobalTypes =
- getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.ZIP);
- Map<String, ServiceTemplate> csarOnboardingGlobalTypes =
- getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.CSAR);
- Map<String, ServiceTemplate> manualOnboardingGlobalTypes =
- getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.MANUAL);
- Map<String, ServiceTemplate> defaultOnboardingGlobalTypes =
- getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.NONE);
- onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.ZIP, zipOnboardingGlobalTypes);
- onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.CSAR, csarOnboardingGlobalTypes);
- onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.MANUAL,
- manualOnboardingGlobalTypes);
- onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.NONE,
- defaultOnboardingGlobalTypes);
- return onboardingGlobalTypesServiceTemplates;
- }
+ private static Map<OnboardingTypesEnum, Map<String, ServiceTemplate>> init(Map<String, String> globalTypes) {
+ Map<OnboardingTypesEnum, Map<String, ServiceTemplate>> onboardingGlobalTypesServiceTemplates =
+ new EnumMap<>(OnboardingTypesEnum.class);
+ Map<String, ServiceTemplate> zipOnboardingGlobalTypes =
+ getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.ZIP);
+ Map<String, ServiceTemplate> csarOnboardingGlobalTypes =
+ getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.CSAR);
+ Map<String, ServiceTemplate> manualOnboardingGlobalTypes =
+ getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.MANUAL);
+ Map<String, ServiceTemplate> defaultOnboardingGlobalTypes =
+ getOnboardingGlobalTypes(globalTypes, OnboardingTypesEnum.NONE);
+ onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.ZIP, zipOnboardingGlobalTypes);
+ onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.CSAR, csarOnboardingGlobalTypes);
+ onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.MANUAL, manualOnboardingGlobalTypes);
+ onboardingGlobalTypesServiceTemplates.put(OnboardingTypesEnum.NONE, defaultOnboardingGlobalTypes);
+ return onboardingGlobalTypesServiceTemplates;
+ }
- private static Map<String, ServiceTemplate> getOnboardingGlobalTypes(Map<String, String>
- globalTypes,
- OnboardingTypesEnum
- onboardingType) {
- Map<String, ServiceTemplate> globalTypesServiceTemplates = new HashMap<>();
- ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- for (Map.Entry<String, String> globalTypeContent : globalTypes.entrySet()) {
- if (!isTypeValidCandidateForCsarPacking(globalTypeContent.getKey(), onboardingType)) {
- // this global types folders should not be processed to the CSAR
- continue;
- }
- ToscaUtil.addServiceTemplateToMapWithKeyFileName(globalTypesServiceTemplates,
- toscaExtensionYamlUtil.yamlToObject(globalTypeContent.getValue(), ServiceTemplate.class));
+ private static Map<String, ServiceTemplate> getOnboardingGlobalTypes(Map<String, String> globalTypes,
+ OnboardingTypesEnum onboardingType) {
+ Map<String, ServiceTemplate> globalTypesServiceTemplates = new HashMap<>();
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ for (Map.Entry<String, String> globalTypeContent : globalTypes.entrySet()) {
+ if (!isTypeValidCandidateForCsarPacking(globalTypeContent.getKey(), onboardingType)) {
+ // this global types folders should not be processed to the CSAR
+ continue;
+ }
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(globalTypesServiceTemplates,
+ toscaExtensionYamlUtil.yamlToObject(globalTypeContent.getValue(), ServiceTemplate.class));
+ }
+ return globalTypesServiceTemplates;
}
- return globalTypesServiceTemplates;
- }
- private static boolean isTypeValidCandidateForCsarPacking(String globalTypeResourceKey,
- OnboardingTypesEnum
- onboardingType) {
- if (globalTypeResourceKey.contains("openecomp-inventory")) {
- // this global types folders should not be processed to the CSAR
- return false;
+ private static boolean isTypeValidCandidateForCsarPacking(String globalTypeResourceKey,
+ OnboardingTypesEnum onboardingType) {
+ if (globalTypeResourceKey.contains(Constants.OPENECOMP_INVENTORY)) {
+ // this global types folders should not be processed to the CSAR
+ return false;
+ }
+ //Global types specific to csar onboarding should not be packed for other onboarding types
+ return !globalTypeResourceKey.matches(ONAP_FILEPATH_REGEX) || onboardingType == OnboardingTypesEnum.CSAR;
}
- //Global types specific to csar onboarding should not be packed for other onboarding types
- return !globalTypeResourceKey.contains("onap") || onboardingType == OnboardingTypesEnum.CSAR;
- }
}