summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/common/utils/CommonUtil.java36
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java47
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/CandidateServiceFactoryMock.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/NoSqlDbFactoryMock.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/PackageInfoDaoFactoryImplMock.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java12
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java3
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java6
9 files changed, 151 insertions, 16 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 3dd118e8ec..d217c31f65 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -7,6 +7,8 @@ import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.errors.GeneralErrorBuilder;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
@@ -37,11 +39,8 @@ import java.util.Optional;
public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
- private static Logger logger =
- LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private ToscaConverter toscaConverter = new ToscaConverterImpl();
- private CandidateService candidateService =
- CandidateServiceFactory.getInstance().createInterface();
+ private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
@Override
@@ -64,12 +63,17 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
processCsar(vspId, version, fileContentHandler, candidateData, response);
} catch (CoreException e){
logger.error(e.getMessage());
- throw e;
- } catch (Exception e){
- logger.error(e.getMessage());
+ response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
+ } catch (IOException ioe) {
+ logger.error(ioe.getMessage());
+ ErrorCode errorCode = new GeneralErrorBuilder(ioe.getMessage()).build();
+ response.addErrorMessageToMap(errorCode.id(), errorCode.message(),ErrorLevel.ERROR);
+ }
+ } else {
+ if (!uploadFileResponse.getErrors().isEmpty()) {
+ response.addStructureErrors(uploadFileResponse.getErrors());
}
}
-
return response;
}
@@ -77,8 +81,6 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
FileContentHandler fileContentHandler,
OrchestrationTemplateCandidateData candidateData,
OrchestrationTemplateActionResponse response) throws IOException {
-
-
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler, response);
if(!isValid(errors)){
@@ -104,7 +106,7 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
orchestrationUtil.saveUploadData(
vspId, version, zipByteArrayInputStream.get(), fileContentHandler, tree);
- ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler);
+ ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
orchestrationUtil.saveServiceModel(vspId, version, toscaServiceModel, toscaServiceModel);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/common/utils/CommonUtil.java
new file mode 100644
index 0000000000..29b404664e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.common.utils;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+
+import java.io.IOException;
+
+public class CommonUtil {
+
+ public static FileContentHandler validateAndUploadFileContent(OnboardingTypesEnum type,
+ byte[] uploadedFileData)
+ throws IOException {
+ throw new IOException();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
new file mode 100644
index 0000000000..c2a207d6d9
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
@@ -0,0 +1,47 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
+import org.openecomp.core.factory.impl.AbstractFactoryBase;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.CandidateServiceFactoryMock;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.NoSqlDbFactoryMock;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.PackageInfoDaoFactoryImplMock;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.VendorSoftwareProductDaoFactoryMock;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationTemplateProcessCsarHandler;
+import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.nio.ByteBuffer;
+
+import static org.junit.Assert.assertFalse;
+public class OrchestrationTemplateProcessCsarHandlerTest {
+
+
+ @Before
+ public void insertMocks(){
+ EnrichmentManagerFactory.getInstance();
+ AbstractFactoryBase.registerFactory(NoSqlDbFactory.class, NoSqlDbFactoryMock.class);
+ AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase.registerFactory(VendorSoftwareProductDaoFactory.class, VendorSoftwareProductDaoFactoryMock.class);
+ AbstractFactoryBase.registerFactory(CandidateServiceFactory.class, CandidateServiceFactoryMock.class);
+ }
+
+
+
+ @Test
+ public void validateErrorHandling(){
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new OrchestrationTemplateCandidateData(ByteBuffer.wrap("".getBytes()),"");
+ OrchestrationTemplateProcessCsarHandler handler = new OrchestrationTemplateProcessCsarHandler();
+ OrchestrationTemplateActionResponse response = handler.process(vspDetails, orchestrationTemplateCandidateData, "007");
+ assertFalse(response.getErrors().isEmpty());
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/CandidateServiceFactoryMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/CandidateServiceFactoryMock.java
new file mode 100644
index 0000000000..424f00b3ae
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/CandidateServiceFactoryMock.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
+
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+
+public class CandidateServiceFactoryMock extends CandidateServiceFactory {
+
+ @Override
+ public CandidateService createInterface() {
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/NoSqlDbFactoryMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/NoSqlDbFactoryMock.java
new file mode 100644
index 0000000000..436f27fd22
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/NoSqlDbFactoryMock.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
+
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+
+public class NoSqlDbFactoryMock extends NoSqlDbFactory {
+
+
+ @Override
+ public NoSqlDb createInterface() {
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/PackageInfoDaoFactoryImplMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/PackageInfoDaoFactoryImplMock.java
new file mode 100644
index 0000000000..657939feb5
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/PackageInfoDaoFactoryImplMock.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
+
+public class PackageInfoDaoFactoryImplMock extends PackageInfoDaoFactory {
+
+ @Override
+ public PackageInfoDao createInterface() {
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
new file mode 100644
index 0000000000..ede8620cf9
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+
+public class VendorSoftwareProductDaoFactoryMock extends VendorSoftwareProductDaoFactory {
+
+ @Override
+ public VendorSoftwareProductDao createInterface() {
+ return null;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
index 18b4b06811..519d7b160b 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
@@ -29,7 +29,6 @@ import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.google.common.base.Optional;
-import org.apache.commons.lang.ArrayUtils;
import org.openecomp.core.nosqldb.util.CassandraUtils;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -109,7 +108,7 @@ public class CassandraSessionFactory {
}
private static void setConsistencyLevel(Cluster.Builder builder, String[] addresses) {
- if (ArrayUtils.isNotEmpty(addresses) && addresses.length > 1) {
+ if (addresses != null && addresses.length > 1) {
String consistencyLevel = CassandraUtils.getConsistencyLevel();
if (Objects.nonNull(consistencyLevel)) {
log.info(
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
index fd7c1043e8..5723a6fe61 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
@@ -20,6 +20,7 @@
package org.openecomp.core.nosqldb.util;
+import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -116,9 +117,10 @@ public class ConfigurationManager {
return addresses.split(",");
}
List lsAddresses = (ArrayList) cassandraConfiguration.get(CASSANDRA_HOSTS_KEY);
- if (Objects.isNull(addresses) || addresses.length() == 0) {
- throw new RuntimeException("Missing Cassandra hose.Cassandra host missing is mandatory.");
+ if (CollectionUtils.isEmpty(lsAddresses)) {
+ log.info("No Cassandra hosts are defined.");
}
+
String[] addressesArray;
addressesArray = (String[]) lsAddresses.toArray(new String[lsAddresses.size()]);
return addressesArray;