### Question:
NamingServiceCreateTasks { public void createInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException { InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); String policyInstanceName = execution.getVariable("policyInstanceName"); String nfNamingCode = execution.getVariable("nfNamingCode"); String generatedInstanceGroupName = ""; try { generatedInstanceGroupName = namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } instanceGroup.setInstanceGroupName(generatedInstanceGroupName); }  void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils); void createInstanceGroupName(BuildingBlockExecution execution); void createWanTransportServiceName(BuildingBlockExecution execution); void createVpnBondingServiceName(BuildingBlockExecution execution);  }### Answer:
@Test public void createInstanceGroupTest() throws Exception { String policyInstanceName = "policyInstanceName"; String nfNamingCode = "nfNamingCode"; String generatedName = "generatedInstanceGroupName"; execution.setVariable(policyInstanceName, policyInstanceName); execution.setVariable(nfNamingCode, nfNamingCode); doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); namingServiceCreateTasks.createInstanceGroupName(execution); verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); assertEquals(instanceGroup.getInstanceGroupName(), generatedName); }
@Test public void createInstanceGroupExceptionTest() throws Exception { expectedException.expect(BBObjectNotFoundException.class); lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound"); doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)); String policyInstanceName = "policyInstanceName"; String nfNamingCode = "nfNamingCode"; execution.setVariable(policyInstanceName, policyInstanceName); execution.setVariable(nfNamingCode, nfNamingCode); doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); namingServiceCreateTasks.createInstanceGroupName(execution); verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); }