### Question:
AzureVirtualMachineService { @Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5) public Map<String, VirtualMachine> getVirtualMachinesByName(AzureClient azureClient, String resourceGroup, Collection<String> privateInstanceIds) { LOGGER.debug("Starting to retrieve vm metadata from Azure for ids: {}", privateInstanceIds); PagedList<VirtualMachine> virtualMachines = azureClient.getVirtualMachines(resourceGroup); while (hasMissingVm(virtualMachines, privateInstanceIds) && virtualMachines.hasNextPage()) { virtualMachines.loadNextPage(); } validateResponse(virtualMachines, privateInstanceIds); return collectVirtualMachinesByName(privateInstanceIds, virtualMachines); }  @Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5) Map<String, VirtualMachine> getVirtualMachinesByName(AzureClient azureClient, String resourceGroup, Collection<String> privateInstanceIds); @Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5) Map<String, VirtualMachine> getVmsFromAzureAndFillStatuses(AuthenticatedContext ac, List<CloudInstance> cloudInstances,
            List<CloudVmInstanceStatus> statuses); @Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5) void refreshInstanceViews(Map<String, VirtualMachine> virtualMachines);  }### Answer:
@Test public void testGetVirtualMachinesByIdShouldReturnTheVirtualMachines() { Set<String> privateInstanceIds = createPrivateInstanceIds(); PagedList<VirtualMachine> virtualMachines = createPagedList(); when(azureClient.getVirtualMachines(RESOURCE_GROUP)).thenReturn(virtualMachines); Map<String, VirtualMachine> actual = underTest.getVirtualMachinesByName(azureClient, RESOURCE_GROUP, privateInstanceIds); assertEquals(INSTANCE_1, actual.get(INSTANCE_1).name()); assertEquals(INSTANCE_2, actual.get(INSTANCE_2).name()); assertEquals(INSTANCE_3, actual.get(INSTANCE_3).name()); }
@Test public void testGetVirtualMachinesByIdShouldReturnOneVirtualMachinesWhenOnlyTheFirstPageAvailable() { Set<String> privateInstanceIds = createPrivateInstanceIds(); PagedList<VirtualMachine> virtualMachinesWithOnePage = createPagedListWithOnePage(); when(azureClient.getVirtualMachines(RESOURCE_GROUP)).thenReturn(virtualMachinesWithOnePage); Map<String, VirtualMachine> actual = underTest.getVirtualMachinesByName(azureClient, RESOURCE_GROUP, privateInstanceIds); assertEquals(INSTANCE_1, actual.get(INSTANCE_1).name()); assertEquals(1, actual.size()); }