Change serviceInstance CM retrieval 19/88119/1
authorElena Kuleshov <evn@att.com>
Mon, 20 May 2019 21:22:18 +0000 (17:22 -0400)
committerElena Kuleshov <evn@att.com>
Mon, 20 May 2019 21:23:40 +0000 (17:23 -0400)
Change serviceInstance CM retrieval

Issue-ID: SO-1903
Signed-off-by: Kuleshov, Elena <evn@att.com>
Change-Id: I6bc1e3f0d219d6c9feff083ce43cd6afdec1c439

bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java

index 86bbead..b76316b 100644 (file)
@@ -57,8 +57,13 @@ public class ExtractPojosForBB {
             GenericVnf vnf;
             switch (key) {
                 case SERVICE_INSTANCE_ID:
-                    result = lookupObjectInList(gBBInput.getCustomer().getServiceSubscription().getServiceInstances(),
-                            value);
+                    if (gBBInput.getCustomer().getServiceSubscription() == null
+                            && gBBInput.getServiceInstance() != null) {
+                        result = Optional.of((T) gBBInput.getServiceInstance());
+                    } else {
+                        result = lookupObjectInList(
+                                gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value);
+                    }
                     break;
                 case GENERIC_VNF_ID:
                     serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
index 8ab2c8e..7bd2bee 100644 (file)
@@ -227,4 +227,16 @@ public class ExtractPojosForBBTest extends BaseTest {
         gBBInput.setCustomer(customer);
         extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
     }
+
+    @Test
+    public void getServiceInstanceWithNoCustomer() throws BBObjectNotFoundException {
+        ServiceInstance serviceInstancePend = new ServiceInstance();
+        serviceInstancePend.setServiceInstanceId("abc");
+        lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstancePend.getServiceInstanceId());
+        Customer customer = new Customer();
+        gBBInput.setCustomer(customer);
+        gBBInput.setServiceInstance(serviceInstancePend);
+        ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+        assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId());
+    }
 }