summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2018-01-03 17:49:51 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-01-04 09:25:28 +0000
commit594a37fa17c3b9adfa9825510e0a7128fcf5632d (patch)
tree96306be375076989ed6d758759ccfa95abe5824e /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
parentb85fc88176d7cce7c9a7c7955cafe5f9f8bf4644 (diff)
fix failing tests
fix failing tests in uploadCSARFileTest.java, and changing error messages Change-Id: Ied1384d87551242d3eb48987990a6e8a72b26916 Issue-ID: SDC-874 Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java49
6 files changed, 28 insertions, 57 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
index 8e8b273015..d278962bdb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -57,6 +57,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
private final ComponentArtifactDao componentArtifactDao;
@@ -109,7 +111,8 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
LoggerErrorCode.DATA_ERROR.getErrorCode(), INVALID + type
.toString() + " zip file");
throw new CoreException(new MonitoringUploadErrorBuilder(
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
+ getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
+ "zip")).build());
} else {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
try {
@@ -137,7 +140,7 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), INVALID + type
- .toString() + "zip file" );
+ .toString() + "zip file");
throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index c9bb956a18..093192e858 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -55,6 +55,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public class OrchestrationTemplateCandidateManagerImpl
implements OrchestrationTemplateCandidateManager {
private static final Logger LOGGER =
@@ -156,7 +158,8 @@ public class OrchestrationTemplateCandidateManagerImpl
if (!candidateDataEntity.isPresent()) {
ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage());
+ getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage
+ (), ""));
LOGGER.error(errorMessage.getMessage());
MDC_DATA_DEBUG_MESSAGE.debugExitMessage(VSP_ID, vspId);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
index d20dc07b63..f25f6d780b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
@@ -31,12 +31,12 @@ public abstract class BaseOrchestrationTemplateHandler implements OrchestrationT
CandidateService candidateService) {
UploadFileResponse uploadFileResponse = new UploadFileResponse();
uploadFileResponse.setOnboardingType(getHandlerType());
- if (isNotEmptyFileToUpload(fileToUpload, uploadFileResponse, candidateService)) {
+ if (isNotEmptyFileToUpload(fileSuffix, fileToUpload, uploadFileResponse, candidateService)) {
return uploadFileResponse;
}
byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload);
- if (isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService)) {
+ if (isInvalidRawZipData(fileSuffix, uploadFileResponse, uploadedFileData, candidateService)) {
return uploadFileResponse;
}
@@ -75,11 +75,11 @@ public abstract class BaseOrchestrationTemplateHandler implements OrchestrationT
CandidateService candidateService,
UploadFileResponse uploadFileResponse);
- private boolean isNotEmptyFileToUpload(InputStream fileToUpload,
+ private boolean isNotEmptyFileToUpload(String fileSuffix, InputStream fileToUpload,
UploadFileResponse uploadFileResponse,
CandidateService candidateService) {
Optional<ErrorMessage> errorMessage =
- candidateService.validateNonEmptyFileToUpload(fileToUpload);
+ candidateService.validateNonEmptyFileToUpload(fileToUpload, fileSuffix);
if (errorMessage.isPresent()) {
uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
return true;
@@ -87,11 +87,12 @@ public abstract class BaseOrchestrationTemplateHandler implements OrchestrationT
return false;
}
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ protected boolean isInvalidRawZipData(String fileSuffix,
+ UploadFileResponse uploadFileResponse,
byte[] uploadedFileData,
CandidateService candidateService) {
Optional<ErrorMessage> errorMessage;
- errorMessage = candidateService.validateRawZipData(uploadedFileData);
+ errorMessage = candidateService.validateRawZipData(fileSuffix, uploadedFileData);
if (errorMessage.isPresent()) {
uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
return true;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index 16147553fe..bc999de4fe 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -160,9 +160,10 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH
}
@Override
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ protected boolean isInvalidRawZipData(String fileSuffix,
+ UploadFileResponse uploadFileResponse,
byte[] uploadedFileData,
CandidateService candidateService) {
- return super.isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService);
+ return super.isInvalidRawZipData(fileSuffix, uploadFileResponse, uploadedFileData, candidateService);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
index 09e7a40ec5..316b1a4049 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
@@ -64,7 +64,7 @@ public class ValidationResponse {
valid = false;
}
- VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, serviceName, targetServiceName);
+ VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, targetServiceName);
}
@@ -103,7 +103,7 @@ public class ValidationResponse {
}
VendorSoftwareProductUtils
- .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
+ .setErrorsIntoLogger(uploadDataErrors, targetServiceName);
}
public Map<String, List<ErrorMessage>> getCompilationErrors() {
@@ -125,7 +125,7 @@ public class ValidationResponse {
}
VendorSoftwareProductUtils
- .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
+ .setErrorsIntoLogger(uploadDataErrors, targetServiceName);
}
public QuestionnaireValidationResult getQuestionnaireValidationResult() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
index 08528408d6..369efe38bc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
@@ -34,7 +34,6 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.slf4j.MDC;
@@ -48,9 +47,8 @@ import java.util.Map;
public class VendorSoftwareProductUtils {
- private static final String MANUAL = "Manual";
protected static Logger logger =
- (Logger) LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
+ LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
/**
* Add file names to upload file response.
@@ -69,21 +67,6 @@ public class VendorSoftwareProductUtils {
uploadFileResponse.removeFileFromList(SdcCommon.MANIFEST_NAME);
}
- /**
- * Validate raw zip data.
- *
- * @param uploadedFileData the uploaded file data
- * @param errors the errors
- */
- public static void validateRawZipData(byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- if (uploadedFileData.length == 0) {
- MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors).add(
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
- }
/**
* Validate content zip data.
@@ -94,7 +77,7 @@ public class VendorSoftwareProductUtils {
public static void validateContentZipData(FileContentHandler contentMap,
Map<String, List<ErrorMessage>> errors) {
MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
- if (contentMap.getFileList().size() == 0) {
+ if (contentMap.getFileList().isEmpty()) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
}
@@ -119,21 +102,13 @@ public class VendorSoftwareProductUtils {
}
- private static boolean isTrapOrPoll(MonitoringUploadType type) {
- return type.equals(MonitoringUploadType.SNMP_POLL) ||
- type.equals(MonitoringUploadType.SNMP_TRAP);
- }
-
-
/**
* Sets errors into logger.
- *
- * @param errors the errors
- * @param serviceName the service name
+ * @param errors the errors
* @param targetServiceName the target service name
*/
public static void setErrorsIntoLogger(Map<String, List<ErrorMessage>> errors,
- LoggerServiceName serviceName, String targetServiceName) {
+ String targetServiceName) {
MdcDataErrorMessage mdcDataErrorMessage =
new MdcDataErrorMessage(targetServiceName, LoggerConstants.TARGET_ENTITY_DB,
ErrorLevel.ERROR.name(), null, null);
@@ -153,13 +128,11 @@ public class VendorSoftwareProductUtils {
/**
* Sets errors into logger.
- *
- * @param errors the errors
- * @param serviceName the service name
+ * @param errors the errors
* @param targetServiceName the target service name
*/
public static void setErrorsIntoLogger(Collection<ErrorCode> errors,
- LoggerServiceName serviceName, String targetServiceName) {
+ String targetServiceName) {
MdcDataErrorMessage mdcDataErrorMessage =
new MdcDataErrorMessage(targetServiceName, LoggerConstants.TARGET_ENTITY_DB,
ErrorLevel.ERROR.name(), null, null);
@@ -173,14 +146,4 @@ public class VendorSoftwareProductUtils {
logger.error(error.message());
}
}
-
- /*public static boolean isManual(String vspId, Version version, VendorSoftwareProductInfoDao
- vspInfoDao) {
- String onboardingMethod = vspInfoDao.get(new VspDetails(vspId, version)).getOnboardingMethod();
- if (MANUAL.equals(onboardingMethod)) {
- return true;
- }
- return false;
- }*/
-
}