@Test public void getListWithUnknownCloudResource() { TargetResource t = new TargetResource(); t.withResourceType("unknown"); t.withResourceName(VM_NAME); PagedList<DeploymentOperation> operationList = Mockito.spy(PagedList.class); DeploymentOperations operations = Mockito.mock(DeploymentOperations.class); DeploymentOperation operation = Mockito.mock(DeploymentOperation.class); operationList.add(operation); when(deployment.deploymentOperations()).thenReturn(operations); when(deployment.deploymentOperations().list()).thenReturn(operationList); when(operation.targetResource()).thenReturn(t); when(operation.provisioningState()).thenReturn("succeeded"); List<CloudResource> cloudResourceList = underTest.getDeploymentCloudResources(deployment); assertEquals(0, cloudResourceList.size()); }
public List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment) { PagedList<DeploymentOperation> operations = templateDeployment.deploymentOperations().list(); return operations.stream() .filter(Predicate.not(Predicate.isEqual(null))) .filter(deploymentOperation -> Objects.nonNull(deploymentOperation.targetResource()) && StringUtils.isNotBlank(deploymentOperation.provisioningState())) .map(deploymentOperation -> convert(deploymentOperation.targetResource(), convertProvisioningState(deploymentOperation.provisioningState()))) .filter(Objects::nonNull) .collect(Collectors.toList()); }
AzureCloudResourceService { public List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment) { PagedList<DeploymentOperation> operations = templateDeployment.deploymentOperations().list(); return operations.stream() .filter(Predicate.not(Predicate.isEqual(null))) .filter(deploymentOperation -> Objects.nonNull(deploymentOperation.targetResource()) && StringUtils.isNotBlank(deploymentOperation.provisioningState())) .map(deploymentOperation -> convert(deploymentOperation.targetResource(), convertProvisioningState(deploymentOperation.provisioningState()))) .filter(Objects::nonNull) .collect(Collectors.toList()); } }
AzureCloudResourceService { public List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment) { PagedList<DeploymentOperation> operations = templateDeployment.deploymentOperations().list(); return operations.stream() .filter(Predicate.not(Predicate.isEqual(null))) .filter(deploymentOperation -> Objects.nonNull(deploymentOperation.targetResource()) && StringUtils.isNotBlank(deploymentOperation.provisioningState())) .map(deploymentOperation -> convert(deploymentOperation.targetResource(), convertProvisioningState(deploymentOperation.provisioningState()))) .filter(Objects::nonNull) .collect(Collectors.toList()); }  }
AzureCloudResourceService { public List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment) { PagedList<DeploymentOperation> operations = templateDeployment.deploymentOperations().list(); return operations.stream() .filter(Predicate.not(Predicate.isEqual(null))) .filter(deploymentOperation -> Objects.nonNull(deploymentOperation.targetResource()) && StringUtils.isNotBlank(deploymentOperation.provisioningState())) .map(deploymentOperation -> convert(deploymentOperation.targetResource(), convertProvisioningState(deploymentOperation.provisioningState()))) .filter(Objects::nonNull) .collect(Collectors.toList()); }  List<CloudResource> getNetworkResources(List<CloudResource> resources); List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment); List<CloudResource> getInstanceCloudResources(String stackName, List<CloudResource> cloudResourceList, List<Group> groups,
            String resourceGroupName); CloudResource buildCloudResource(String name, String id, ResourceType type); List<CloudResource> getAttachedOsDiskResources(AuthenticatedContext authenticatedContext, List<CloudResource> instanceList,
            String resourceGroupName); void saveCloudResources(PersistenceNotifier notifier, CloudContext cloudContext, List<CloudResource> cloudResources); void deleteCloudResources(PersistenceNotifier notifier, CloudContext cloudContext, List<CloudResource> cloudResources); List<CloudResource> collectAndSaveNetworkAndSubnet(String resourceGroupName, String virtualNetwork, PersistenceNotifier notifier,
            CloudContext cloudContext, List<String> subnetNameList, String networkName, AzureClient client); }
AzureCloudResourceService { public List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment) { PagedList<DeploymentOperation> operations = templateDeployment.deploymentOperations().list(); return operations.stream() .filter(Predicate.not(Predicate.isEqual(null))) .filter(deploymentOperation -> Objects.nonNull(deploymentOperation.targetResource()) && StringUtils.isNotBlank(deploymentOperation.provisioningState())) .map(deploymentOperation -> convert(deploymentOperation.targetResource(), convertProvisioningState(deploymentOperation.provisioningState()))) .filter(Objects::nonNull) .collect(Collectors.toList()); }  List<CloudResource> getNetworkResources(List<CloudResource> resources); List<CloudResource> getDeploymentCloudResources(Deployment templateDeployment); List<CloudResource> getInstanceCloudResources(String stackName, List<CloudResource> cloudResourceList, List<Group> groups,
            String resourceGroupName); CloudResource buildCloudResource(String name, String id, ResourceType type); List<CloudResource> getAttachedOsDiskResources(AuthenticatedContext authenticatedContext, List<CloudResource> instanceList,
            String resourceGroupName); void saveCloudResources(PersistenceNotifier notifier, CloudContext cloudContext, List<CloudResource> cloudResources); void deleteCloudResources(PersistenceNotifier notifier, CloudContext cloudContext, List<CloudResource> cloudResources); List<CloudResource> collectAndSaveNetworkAndSubnet(String resourceGroupName, String virtualNetwork, PersistenceNotifier notifier,
            CloudContext cloudContext, List<String> subnetNameList, String networkName, AzureClient client);  }