### Question:
HeatBridgeImpl implements HeatBridgeApi { @Override public void buildAddImagesToAaiAction(final List<org.openstack4j.model.compute.Image> images) throws HeatBridgeException { for (org.openstack4j.model.compute.Image image : images) { Image aaiImage = aaiHelper.buildImage(image); try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() .cloudRegion(cloudOwner, cloudRegionId).image(aaiImage.getImageId())); if (!resourcesClient.exists(uri)) { transaction.create(uri, aaiImage); logger.debug("Queuing AAI command to add image: " + aaiImage.getImageId()); } else { logger.debug("Nothing to add since image: " + aaiImage.getImageId() + "already exists in AAI."); } } catch (WebApplicationException e) { throw new HeatBridgeException( "Failed to update image to AAI: " + aaiImage.getImageId() + ". Error" + " cause: " + e, e); } } } HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity,
            @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId,
            @Nonnull final String tenantId, @Nonnull final NodeType nodeType);  HeatBridgeImpl(); @Override OpenstackClient authenticate(); @Override List<Resource> queryNestedHeatStackResources(final String heatStackId); @Override List<String> extractStackResourceIdsByResourceType(final List<Resource> stackResources,
            final String resourceType); @Override List<String> extractNetworkIds(final List<String> networkNameList); @Override List<Server> getAllOpenstackServers(final List<Resource> stackResources); @Override List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources); @Override List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers); @Override List<org.openstack4j.model.compute.Flavor> extractOpenstackFlavorsFromServers(final List<Server> servers); void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId,
            List<Network> networks); @Override void buildAddImagesToAaiAction(final List<org.openstack4j.model.compute.Image> images); @Override void buildAddFlavorsToAaiAction(final List<org.openstack4j.model.compute.Flavor> flavors); @Override void buildAddVserversToAaiAction(final String genericVnfId, final String vfModuleId,
            final List<Server> servers); @Override void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources,
            final List<String> oobMgtNetIds, String cloudOwner); @Override void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources); @Override void submitToAai(boolean dryrun); @Override void deleteVfModuleData(@Nonnull final String vnfId, @Nonnull final String vfModuleId);  }### Answer:
@Test public void testUpdateImagesToAai() throws HeatBridgeException { Image image1 = mock(Image.class); when(image1.getId()).thenReturn("test-image1-id"); when(image1.getName()).thenReturn("test-image1-name"); when(image1.getLinks()).thenReturn(new ArrayList<>()); Image image2 = mock(Image.class); when(image2.getId()).thenReturn("test-image2-id"); when(image2.getName()).thenReturn("test-image2-name"); when(image2.getLinks()).thenReturn(new ArrayList<>()); List<Image> images = Arrays.asList(image1, image2); heatbridge.buildAddImagesToAaiAction(images); verify(transaction, times(2)).create(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Image.class)); heatbridge.buildAddImagesToAaiAction(images); verify(transaction, times(4)).create(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Image.class)); }