From 608a077f8ea3b18dddbfeb4d8b486661e05561c7 Mon Sep 17 00:00:00 2001 From: "r.bogacki" Date: Wed, 3 Apr 2019 14:00:21 +0200 Subject: Fixed Sonar blocker issues Fixed blockers according to Sonar analysis. Added tests for fixed issues. Change-Id: I8e259147082d722961048454fae9484cc0d8b0a8 Issue-ID: SO-1734 Signed-off-by: Robert Bogacki --- .../validation/CustomWorkflowValidation.java | 52 +++++++++------------- 1 file changed, 20 insertions(+), 32 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java index 695213bf20..0602f09796 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,44 +22,31 @@ package org.onap.so.apihandlerinfra.validation; -import java.util.List; -import java.util.Map; - import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestParameters; import com.google.common.base.Strings; -public class CustomWorkflowValidation implements ValidationRule{ - +public class CustomWorkflowValidation implements ValidationRule { + @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); - CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration(); - String workflowUuid = info.getInstanceIdMap().get("workflowUuid"); - + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); + CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); + if (cloudConfiguration == null) { - throw new ValidationException ("cloudConfiguration"); - }else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner ()))) { - throw new ValidationException ("cloudOwner"); - }else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId ()))) { - throw new ValidationException ("lcpCloudRegionId"); - }else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId ()))) { - throw new ValidationException ("tenantId"); - } - if(requestParameters == null){ - throw new ValidationException("requestParameters"); - } - - List> userParams = requestParameters.getUserParams(); - if (!validateCustomUserParams(userParams, workflowUuid)) { - throw new ValidationException("userParams"); - } - return info; - } - - private boolean validateCustomUserParams(List> userParams, String workflowUuid) { - return true; + throw new ValidationException("cloudConfiguration"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) { + throw new ValidationException("cloudOwner"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) { + throw new ValidationException("lcpCloudRegionId"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) { + throw new ValidationException("tenantId"); + } + if (requestParameters == null) { + throw new ValidationException("requestParameters"); + } + return info; } -} \ No newline at end of file +} -- cgit 1.2.3-korg