### Question:
UnassignVnf { public void deleteInstanceGroups(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); List<InstanceGroup> instanceGroups = vnf.getInstanceGroups(); for (InstanceGroup instanceGroup : instanceGroups) { if (ModelInfoInstanceGroup.TYPE_VNFC .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup); } } } catch (Exception ex) { logger.error("Exception occurred in UnassignVnf deleteInstanceGroups", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } }  void deleteInstanceGroups(BuildingBlockExecution execution);  }### Answer:
@Test public void deleteInstanceGroupsSunnyDayTest() throws Exception { GenericVnf genericVnf = setGenericVnf(); ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup(); modelVnfc.setType("VNFC"); InstanceGroup instanceGroup1 = new InstanceGroup(); instanceGroup1.setId("test-001"); instanceGroup1.setModelInfoInstanceGroup(modelVnfc); genericVnf.getInstanceGroups().add(instanceGroup1); InstanceGroup instanceGroup2 = new InstanceGroup(); instanceGroup2.setId("test-002"); instanceGroup2.setModelInfoInstanceGroup(modelVnfc); genericVnf.getInstanceGroups().add(instanceGroup2); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))) .thenReturn(genericVnf); unassignVnf.deleteInstanceGroups(execution); verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1)); verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2)); }
@Test public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception { expectedException.expect(BpmnError.class); unassignVnf.deleteInstanceGroups(execution); }