avoid null exception 79/43679/4
authorYulian Han <elaine.hanyulian@huawei.com>
Thu, 19 Apr 2018 03:16:14 +0000 (11:16 +0800)
committerYulian Han <elaine.hanyulian@huawei.com>
Thu, 19 Apr 2018 11:28:07 +0000 (11:28 +0000)
Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064304
Issue-ID: SO-578
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java
bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java

index de50fe1..09561a6 100644 (file)
@@ -110,7 +110,7 @@ public abstract class AbstractBuilder<IN, OUT> {
      protected String getRequestActoin(DelegateExecution execution) {
           String action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.getName();
           String operType = (String) execution.getVariable(OPERATION_TYPE);
-          String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase();
+          String resourceType = (String)execution.getVariable(RESOURCE_TYPE);
           if (!StringUtils.isBlank(operType)) {
                if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) {
                     if (isOverlay(resourceType)) {
@@ -134,17 +134,17 @@ public abstract class AbstractBuilder<IN, OUT> {
      }
 
      private boolean isOverlay(String resourceType) {
-          return !StringUtils.isBlank(resourceType) && resourceType.contains("overlay");
+          return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("overlay");
      }
 
      private boolean isUnderlay(String resourceType) {
-          return !StringUtils.isBlank(resourceType) && resourceType.contains("underlay");
+          return !StringUtils.isBlank(resourceType) && resourceType.toLowerCase().contains("underlay");
      }
 
      protected String getSvcAction(DelegateExecution execution) {
           String action = /*SdncRequestHeader.*/SvcAction.Create.getName();
           String operType = (String) execution.getVariable(OPERATION_TYPE);
-          String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase();
+          String resourceType = (String)execution.getVariable(RESOURCE_TYPE);
           if (!StringUtils.isBlank(operType)) {
                if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) {
                     if (isOverlay(resourceType)) {
index e2ec7e0..99a87de 100644 (file)
@@ -310,12 +310,12 @@ public class AbstractBuilderTest {
         abstractBuilder.build(null, null);
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void getRequestActoinTest() throws Exception {
         abstractBuilder.getRequestActoin(delegateExecution);
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void getSvcActionTest() throws Exception {
         abstractBuilder.getSvcAction(delegateExecution);
     }
@@ -340,7 +340,7 @@ public class AbstractBuilderTest {
         abstractBuilder.getParamEntities(new HashMap<>());
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void getRequestInformationEntityTest() throws Exception {
         abstractBuilder.getRequestInformationEntity(delegateExecution);
     }