Add null tests in `createComponentExternal` 93/106393/2
authorChris André <chris.andre@yoppworks.com>
Wed, 22 Apr 2020 00:41:08 +0000 (20:41 -0400)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Wed, 22 Apr 2020 10:56:30 +0000 (10:56 +0000)
Issue-ID: SDC-2916
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: Ieb0a79c8d3a891a08cd758e1a4ebab7679166476

catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java

index 0c2f673..4f374e0 100644 (file)
@@ -264,19 +264,19 @@ public class CrudExternalServlet extends AbstractValidationsServlet {
                 }
 
                 //validate name exist
-                if(responseWrapper.isEmpty() &&  isNullOrEmpty(service.getName())){
+                if(responseWrapper.isEmpty() && service != null && isNullOrEmpty(service.getName())){
                     responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
                     ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue()));
                 }
 
                 //validate category
-                if(responseWrapper.isEmpty() && service.getCategories().size()>0 && !ExternalCategoryTypeEnum.containsIgnoreCase(service.getCategories().get(0).getName())){
+                if(responseWrapper.isEmpty() && service != null && service.getCategories() != null && !service.getCategories().isEmpty() && !ExternalCategoryTypeEnum.containsIgnoreCase(service.getCategories().get(0).getName())){
                     log.debug("Service category is not supported {}", service.getCategories().get(0).getName());
                     responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
                             ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.SERVICE.getValue()));
                 }
 
-                if(responseWrapper.isEmpty()){
+                if(responseWrapper.isEmpty() && service != null){
                     service.setSystemName(ValidationUtils.convertToSystemName(service.getName()));
                     log.debug("Service system name :"+service.getSystemName());
                 }