From 5ec955ce08cd3101eed327bbb6d1ceb3903f5bfc Mon Sep 17 00:00:00 2001 From: Remigiusz Janeczek Date: Thu, 9 Jan 2020 12:23:18 +0100 Subject: Align AssignPnfBB with Service Macro Create -move and align logic of BB delegates with tests -remove unnecessary classes -add tests cases for Pnfs in ExtractPojosForBBTests Issue-ID: SO-2568 Signed-off-by: Remigiusz Janeczek Change-Id: Ic48e2c1c6ab852c33837091da3e7916b71c26466 --- .../ExtractPojosForBBTest.java | 91 +++++++++------------- 1 file changed, 36 insertions(+), 55 deletions(-) (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java index 7bd2beeb92..dbd5000387 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java @@ -115,6 +115,12 @@ public class ExtractPojosForBBTest extends BaseTest { instanceGroupsPend.add(instanceGroupPend); lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId()); + List pnfsPend = serviceInstancePend.getPnfs(); + Pnf pnfPend = new Pnf(); + pnfPend.setPnfId("abc"); + pnfsPend.add(pnfPend); + lookupKeyMap.put(ResourceKey.PNF, pnfPend.getPnfId()); + customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend); gBBInput.setCustomer(customer); @@ -143,89 +149,49 @@ public class ExtractPojosForBBTest extends BaseTest { InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId()); + + Pnf extractPnfPend = extractPojos.extractByKey(execution, ResourceKey.PNF); + assertEquals(extractPnfPend.getPnfId(), pnfPend.getPnfId()); } @Test public void siError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - - extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.SERVICE_INSTANCE_ID); } @Test public void vnfError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.GENERIC_VNF_ID); } @Test public void vfModuleError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VF_MODULE_ID); } @Test public void configurationError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.CONFIGURATION_ID); } @Test public void allotedError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.ALLOTTED_RESOURCE_ID); } @Test public void vpnBindingError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_ID); } @Test public void vpnBondingLinkError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_BONDING_LINK_ID); + } + + @Test + public void pnfError() throws BBObjectNotFoundException { + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.PNF); } @Test @@ -239,4 +205,19 @@ public class ExtractPojosForBBTest extends BaseTest { ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId()); } + + private void assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey key) + throws BBObjectNotFoundException { + expectedException.expect(BBObjectNotFoundException.class); + setCustomerWithEmptyServiceInstance(); + extractPojos.extractByKey(execution, key); + } + + private void setCustomerWithEmptyServiceInstance() { + Customer customer = new Customer(); + customer.setServiceSubscription(new ServiceSubscription()); + ServiceInstance serviceInstance = new ServiceInstance(); + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + gBBInput.setCustomer(customer); + } } -- cgit 1.2.3-korg