@Test public void testGetVirtualMachineCustomImageShouldReturnTheImageWhenDoesNotExistsOnProviderSide() { Azure azure = PowerMockito.mock(Azure.class); when(azureClient.getAzure()).thenReturn(azure); when(azure.virtualMachineCustomImages()).thenReturn(virtualMachineCustomImages); when(virtualMachineCustomImages.getByResourceGroup(RESOURCE_GROUP, IMAGE_NAME)).thenReturn(null); Optional<VirtualMachineCustomImage> actual = underTest.findVirtualMachineCustomImage(RESOURCE_GROUP, IMAGE_NAME, azureClient); assertTrue(actual.isEmpty()); verify(azureClient).getAzure(); verify(azure).virtualMachineCustomImages(); verify(virtualMachineCustomImages).getByResourceGroup(RESOURCE_GROUP, IMAGE_NAME); }
public Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client) { VirtualMachineCustomImage image = findImage(resourceGroup, imageName, client); if (image != null) { LOGGER.debug("Custom image {} is present in resource group {}", imageName, resourceGroup); return Optional.of(image); } else { LOGGER.debug("Custom image {} is not present in resource group {}", imageName, resourceGroup); return Optional.empty(); } }
AzureManagedImageService { public Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client) { VirtualMachineCustomImage image = findImage(resourceGroup, imageName, client); if (image != null) { LOGGER.debug("Custom image {} is present in resource group {}", imageName, resourceGroup); return Optional.of(image); } else { LOGGER.debug("Custom image {} is not present in resource group {}", imageName, resourceGroup); return Optional.empty(); } } }
AzureManagedImageService { public Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client) { VirtualMachineCustomImage image = findImage(resourceGroup, imageName, client); if (image != null) { LOGGER.debug("Custom image {} is present in resource group {}", imageName, resourceGroup); return Optional.of(image); } else { LOGGER.debug("Custom image {} is not present in resource group {}", imageName, resourceGroup); return Optional.empty(); } }  }
AzureManagedImageService { public Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client) { VirtualMachineCustomImage image = findImage(resourceGroup, imageName, client); if (image != null) { LOGGER.debug("Custom image {} is present in resource group {}", imageName, resourceGroup); return Optional.of(image); } else { LOGGER.debug("Custom image {} is not present in resource group {}", imageName, resourceGroup); return Optional.empty(); } }  Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client); }
AzureManagedImageService { public Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client) { VirtualMachineCustomImage image = findImage(resourceGroup, imageName, client); if (image != null) { LOGGER.debug("Custom image {} is present in resource group {}", imageName, resourceGroup); return Optional.of(image); } else { LOGGER.debug("Custom image {} is not present in resource group {}", imageName, resourceGroup); return Optional.empty(); } }  Optional<VirtualMachineCustomImage> findVirtualMachineCustomImage(String resourceGroup, String imageName, AzureClient client);  }