From c58f445fcef56a6440f3b21d54b390700623c48c Mon Sep 17 00:00:00 2001 From: siddharth0905 Date: Tue, 21 Aug 2018 17:55:30 +0530 Subject: Test coverage Increase test coverage Change-Id: I43e3149d0d4b07dc8e260f3d5fac025197882f3a Issue-ID: SDC-1673 Signed-off-by: siddharth0905 --- .../sdcrests/errors/DefaultExceptionMapper.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index 34ede43d1e..618ac59fa4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -28,12 +28,18 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; +import org.apache.commons.collections4.CollectionUtils; import org.codehaus.jackson.map.JsonMappingException; import org.hibernate.validator.internal.engine.path.PathImpl; -import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.common.errors.*; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.ErrorCodeAndMessage; +import org.openecomp.sdc.common.errors.GeneralErrorBuilder; +import org.openecomp.sdc.common.errors.JsonMappingErrorBuilder; +import org.openecomp.sdc.common.errors.ValidationErrorBuilder; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -98,14 +104,14 @@ public class DefaultExceptionMapper implements ExceptionMapper { String message; String fieldName = null; - if (!CommonMethods.isEmpty(constraintViolationSet)) { + if (CollectionUtils.isEmpty(constraintViolationSet)) { + message = validationException.getMessage(); + } else { // getting the first violation message for the output response. ConstraintViolation constraintViolation = constraintViolationSet.iterator().next(); message = constraintViolation.getMessage(); fieldName = getFieldName(constraintViolation.getPropertyPath()); - } else { - message = validationException.getMessage(); } ErrorCode validationErrorCode = new ValidationErrorBuilder(message, fieldName).build(); -- cgit 1.2.3-korg