### Question:
BBInputSetup implements JavaDelegate { protected void mapCollection(List<AAIResultWrapper> collections, ServiceInstance serviceInstance) { if (!collections.isEmpty()) { AAIResultWrapper collectionWrapper = collections.get(0); Optional<org.onap.aai.domain.yang.Collection> aaiCollectionOp = collectionWrapper.asBean(org.onap.aai.domain.yang.Collection.class); aaiCollectionOp.ifPresent( collection -> serviceInstanceSetCollection(serviceInstance, collectionWrapper, collection)); } }  BBInputSetupUtils getBbInputSetupUtils(); void setCloudInfoFromAAI(CloudInfoFromAAI cloudInfoFromAAI); void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils); BBInputSetupMapperLayer getMapperLayer(); void setMapperLayer(BBInputSetupMapperLayer mapperLayer); @Override void execute(DelegateExecution execution); ServiceInstance getExistingServiceInstance(org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI);  }### Answer:
@Test public void testMapCollection() throws JsonProcessingException { List<AAIResultWrapper> collections = new ArrayList<>(); ServiceInstance serviceInstance = new ServiceInstance(); org.onap.aai.domain.yang.Collection aaiCollection = new org.onap.aai.domain.yang.Collection(); org.onap.aai.domain.yang.RelationshipList collectionRelationshipList = new org.onap.aai.domain.yang.RelationshipList(); org.onap.aai.domain.yang.Relationship collectionInstanceGroupRelationship = new org.onap.aai.domain.yang.Relationship(); collectionRelationshipList.getRelationship().add(collectionInstanceGroupRelationship); aaiCollection.setRelationshipList(collectionRelationshipList); collections.add(new AAIResultWrapper( new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiCollection))); Collection collection = new Collection(); ModelInfoCollection modelInfoCollection = new ModelInfoCollection(); List<InstanceGroup> instanceGroupsList = new ArrayList<>(); InstanceGroup instanceGroup = new InstanceGroup(); instanceGroupsList.add(instanceGroup); NetworkCollectionResourceCustomization networkCollectionCust = Mockito.mock(NetworkCollectionResourceCustomization.class); CollectionResource collectionResource = new CollectionResource(); doReturn(collection).when(bbInputSetupMapperLayer) .mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class)); doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any()); doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils) .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId()); doReturn(collectionResource).when(networkCollectionCust).getCollectionResource(); doReturn(modelInfoCollection).when(bbInputSetupMapperLayer) .mapCatalogCollectionToCollection(networkCollectionCust, collectionResource); SPY_bbInputSetup.mapCollection(collections, serviceInstance); assertEquals(collection, serviceInstance.getCollection()); assertEquals(instanceGroup, collection.getInstanceGroup()); instanceGroupsList.clear(); collection = new Collection(); SPY_bbInputSetup.mapCollection(collections, serviceInstance); assertEquals(collection, serviceInstance.getCollection()); assertNull(collection.getInstanceGroup()); }