summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java12
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml7
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java5
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java32
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java70
7 files changed, 110 insertions, 22 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index 0d4cb9c0ba..0f2c0e7ee1 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -20,20 +20,19 @@
package org.openecomp.sdc.healing.impl;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Map;
@@ -77,8 +76,7 @@ public class HealingManagerImpl implements HealingManager {
}
private static Map<String, String> initHealers() {
- InputStream healingConfigurationJson = FileUtils.getFileInputStream(HEALING_CONF_FILE);
- return JsonUtil.json2Object(healingConfigurationJson, Map.class);
+ return FileUtils.readViaInputStream(HEALING_CONF_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
}
private Healer getHealerImplInstance(String implClassName)
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
index 618922c2af..03ee98dd4e 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -33,6 +33,13 @@
<artifactId>openecomp-sdc-vendor-license-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index bdb7bc3a93..9800d02ba6 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -27,6 +27,7 @@ import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
@@ -49,7 +50,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
@@ -300,7 +300,8 @@ public class CompositionDataHealer implements Healer {
FileContentHandler fileContentHandler;
try {
fileContentHandler =
- CommonUtil.validateAndUploadFileContent(uploadData.getContentData().array());
+ CommonUtil.validateAndUploadFileContent(
+ OnboardingTypesEnum.ZIP, uploadData.getContentData().array());
return HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
} catch (Exception e) {
return null;
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
index e0b7adb6d3..0d484440cf 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -94,7 +95,7 @@ public class FileDataStructureHealer implements Healer {
byte[] byteContentData = uploadData.getContentData().array();
FileContentHandler fileContentHandler;
try{
- fileContentHandler = CommonUtil.validateAndUploadFileContent(byteContentData);
+ fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
Map<String, List<ErrorMessage>> errors = new HashMap<>();
OrchestrationTemplateCandidateData candidateDataEntity =
new CandidateEntityBuilder(candidateService)
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
index d5ccd36c95..44b6062e89 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
@@ -8,6 +8,7 @@ import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
@@ -53,7 +54,7 @@ public class HeatToToscaTranslationHealer implements Healer {
FileContentHandler fileContentHandler;
TranslatorOutput translatorOutput;
try {
- fileContentHandler = CommonUtil.validateAndUploadFileContent(uploadData
+ fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
.getContentData().array());
translatorOutput =
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
index 5d6050a7f0..0b06fb1c83 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
@@ -1,11 +1,10 @@
package org.openecomp.sdc.healing.healers;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -15,15 +14,18 @@ import java.util.Map;
import java.util.Objects;
public class VspOnboardingMethodHealer implements Healer {
- /*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();*/
- private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
+ private static VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
public VspOnboardingMethodHealer(){
+ }
+ public VspOnboardingMethodHealer( VendorSoftwareProductInfoDao inVendorSoftwareProductInfoDao){
+ vendorSoftwareProductInfoDao = inVendorSoftwareProductInfoDao;
}
+
+
@Override
public Object heal(Map<String, Object> healingParams) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null, null);
@@ -33,14 +35,22 @@ public class VspOnboardingMethodHealer implements Healer {
Version version = (Version) healingParams.get(SdcCommon.VERSION);
VspDetails vendorSoftwareProductInfo =
vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
- vendorSoftwareProductInfo.getOnboardingMethod();
+ String onboardingValue = vendorSoftwareProductInfo.getOnboardingMethod();
- if(Objects.isNull(vendorSoftwareProductInfo.getOnboardingMethod())) {
- onboardingMethod="HEAT";
- vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
- vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
- //vendorSoftwareProductDao.updateVendorSoftwareProductInfo(vendorSoftwareProductInfo);
+ if(Objects.isNull(onboardingValue)) {
+ onboardingMethod="NetworkPackage";
+
+ updateVSPInfo(OnboardingTypesEnum.ZIP.toString(), onboardingMethod, vendorSoftwareProductInfo);
+ } else if (onboardingValue.equals("HEAT")){
+ onboardingMethod="NetworkPackage";
+ updateVSPInfo(OnboardingTypesEnum.ZIP.toString(),onboardingMethod, vendorSoftwareProductInfo);
}
return onboardingMethod;
}
+
+ private void updateVSPInfo(String onboardingOrigin, String onboardingMethod, VspDetails vendorSoftwareProductInfo) {
+ vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
+ vendorSoftwareProductInfo.setOnboardingOrigin(onboardingOrigin);
+ vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
new file mode 100644
index 0000000000..b732cb03b6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
@@ -0,0 +1,70 @@
+package org.openecomp.sdc.healing.healers;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+
+public class VspOnboardingMethodHealerTest{
+
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
+ }
+
+ @Test
+ public void checkHealingWithNullOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod(null);
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
+ assertEquals(vspDetails.getOnboardingOrigin(),"zip");
+ }
+
+ @Test
+ public void checkHealingWithHEATOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod("HEAT");
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
+ assertEquals(vspDetails.getOnboardingOrigin(),"zip");
+ }
+
+ @Test
+ public void checkHealingWithManualOnboarding() throws Exception{
+ VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
+ Map<String,Object> params = new HashMap<>();
+ params.put(SdcCommon.VSP_ID,"1");
+ params.put(SdcCommon.VERSION, new Version(1,1));
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod("Manual");
+ Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
+ vspOnboardingMethodHealer.heal(params);
+ assertEquals(vspDetails.getOnboardingMethod(),"Manual");
+ assertEquals(vspDetails.getOnboardingOrigin(),null);
+ }
+} \ No newline at end of file