### Question:
HeatBridgeImpl implements HeatBridgeApi { @Override public void buildAddFlavorsToAaiAction(final List<org.openstack4j.model.compute.Flavor> flavors) throws HeatBridgeException { for (org.openstack4j.model.compute.Flavor flavor : flavors) { Flavor aaiFlavor = aaiHelper.buildFlavor(flavor); try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() .cloudRegion(cloudOwner, cloudRegionId).flavor(aaiFlavor.getFlavorId())); transaction.createIfNotExists(uri, Optional.of(aaiFlavor)); } catch (WebApplicationException e) { throw new HeatBridgeException( "Failed to update flavor to AAI: " + aaiFlavor.getFlavorId() + ". 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 testUpdateFlavorsToAai() throws HeatBridgeException { Flavor flavor1 = mock(Flavor.class); when(flavor1.getId()).thenReturn("test-flavor1-id"); when(flavor1.getName()).thenReturn("test-flavor1-name"); when(flavor1.getLinks()).thenReturn(new ArrayList<>()); Flavor flavor2 = mock(Flavor.class); when(flavor2.getId()).thenReturn("test-flavor2-id"); when(flavor2.getName()).thenReturn("test-flavor2-name"); when(flavor2.getLinks()).thenReturn(new ArrayList<>()); List<Flavor> flavors = Arrays.asList(flavor1, flavor2); heatbridge.buildAddFlavorsToAaiAction(flavors); verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); }