@Test public void testBuildWithNullComponents() { List<CloudIdentity> cloudIdentities = getCloudIdentities(); CloudStorage cloudStorage = getCloudStorage(cloudIdentities); FileSystem fileSystem = getFileSystem(cloudStorage); Map<String, Set<String>> componentsByHostGroup = new HashMap<>(); InstanceGroup idBrokerGroup = getIdBrokerGroup(componentsByHostGroup); InstanceGroup computeGroup = new InstanceGroup(); computeGroup.setGroupName(COMPUTE_INSTANCE_GROUP_NAME); componentsByHostGroup.put(COMPUTE_INSTANCE_GROUP_NAME, null); Optional<CloudFileSystemView> idBrokerGroupResult = cloudFileSystemViewProvider .getCloudFileSystemView(fileSystem, componentsByHostGroup, idBrokerGroup); Assertions.assertEquals(idBrokerGroupResult.get().getCloudIdentityType(), CloudIdentityType.ID_BROKER); Optional<CloudFileSystemView> computeGroupResult = cloudFileSystemViewProvider .getCloudFileSystemView(fileSystem, componentsByHostGroup, computeGroup); Assertions.assertEquals(computeGroupResult.get().getCloudIdentityType(), CloudIdentityType.LOG); }
public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) { Optional<CloudFileSystemView> fileSystemView; if (fileSystem != null) { SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem); Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName()); CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components); if (identityType == CloudIdentityType.ID_BROKER) { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } else { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } } else { fileSystemView = Optional.empty(); } return fileSystemView; }
CloudFileSystemViewProvider { public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) { Optional<CloudFileSystemView> fileSystemView; if (fileSystem != null) { SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem); Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName()); CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components); if (identityType == CloudIdentityType.ID_BROKER) { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } else { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } } else { fileSystemView = Optional.empty(); } return fileSystemView; } }
CloudFileSystemViewProvider { public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) { Optional<CloudFileSystemView> fileSystemView; if (fileSystem != null) { SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem); Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName()); CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components); if (identityType == CloudIdentityType.ID_BROKER) { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } else { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } } else { fileSystemView = Optional.empty(); } return fileSystemView; }  }
CloudFileSystemViewProvider { public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) { Optional<CloudFileSystemView> fileSystemView; if (fileSystem != null) { SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem); Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName()); CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components); if (identityType == CloudIdentityType.ID_BROKER) { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } else { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } } else { fileSystemView = Optional.empty(); } return fileSystemView; }  Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem,
            Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup); }
CloudFileSystemViewProvider { public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) { Optional<CloudFileSystemView> fileSystemView; if (fileSystem != null) { SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem); Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName()); CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components); if (identityType == CloudIdentityType.ID_BROKER) { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } else { instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG); fileSystemView = spiFileSystem.getCloudFileSystems().stream() .filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())) .findFirst(); } } else { fileSystemView = Optional.empty(); } return fileSystemView; }  Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem,
            Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup);  }