Fix issue Null pointer exception 07/27407/3
authoramitjai <amitjai@amdocs.com>
Thu, 4 Jan 2018 13:22:19 +0000 (18:52 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Sun, 7 Jan 2018 10:42:49 +0000 (10:42 +0000)
If feature group list is empty or null we should ignore check.

Change-Id: I6fcf20501353f6f32ad166a6096074f4f393dd00
Issue-ID: SDC-876
Signed-off-by: amitjai <amitjai@amdocs.com>
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java

index 3f3d305..14c5044 100644 (file)
@@ -106,8 +106,8 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
         getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), version);
     String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
         .getFeatureGroupId();
-      if (featureGroup != null && featureGroup.trim().length() > 0
-              && isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup)))) {
+    if (featureGroup != null && featureGroup.trim().length() > 0
+          && (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup))))) {
         ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
             .getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
                 version);
@@ -115,8 +115,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
             LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
             LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
         throw new CoreException(deploymentFlavorErrorBuilder);
-      }
-
+    }
     validateComponentComputeAssociation(deploymentFlavorEntity, version);
   }
 
index be53a1a..1c2aade 100644 (file)
@@ -149,6 +149,22 @@ public class DeploymentFlavorManagerImplTest {
     }
   }
 
+  @Test
+  public void testCreateManualDepFlavorWithNoFGNInDFAndInVSP() {
+    DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+    final DeploymentFlavor deploymentFlavor =
+        JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
+    deploymentFlavor.setFeatureGroupId(null);
+    expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
+
+    doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+    VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+    doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+    deploymentFlavorManager.createDeploymentFlavor(expected);
+    verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
+  }
+
   @Test
   public void testCreateManualDepFlavorWithNullCompInAssociation() {
     DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);