### Question:
RemoteDataContextWorkaroundService { public FileSystem prepareFilesytem(Cluster requestedCluster, DatalakeResources datalakeResources) { Stack stack = stackService.getById(datalakeResources.getDatalakeStackId()); prepareFilesystemIfNotPresentedButSdxHasIt(requestedCluster, stack); if (hasFilesystem(requestedCluster.getFileSystem())) { FileSystem fileSystem = requestedCluster.getFileSystem(); if (hasLocations(fileSystem)) { CloudStorage cloudStorage = fileSystem.getCloudStorage(); FileSystem dlFileSystem = stack.getCluster().getFileSystem(); if (hasFilesystem(dlFileSystem)) { if (hasLocations(dlFileSystem)) { List<StorageLocation> dlStorageLocations = dlFileSystem.getCloudStorage().getLocations(); List<StorageLocation> hiveRelatedStorageConfigs = getHiveRelatedStorageConfigs(dlStorageLocations); if (sdxHasHiveStorageConfiguration(hiveRelatedStorageConfigs)) { List<StorageLocation> storageLocations = getStorageLocationsWithoutHiveRelatedLocations(cloudStorage.getLocations()); storageLocations.addAll(hiveRelatedStorageConfigs); cloudStorage.setLocations(storageLocations); fileSystem.setCloudStorage(cloudStorage); } } } } } return requestedCluster.getFileSystem(); }  Set<RDSConfig> prepareRdsConfigs(Cluster requestedCluster, DatalakeResources datalakeResources); FileSystem prepareFilesytem(Cluster requestedCluster, DatalakeResources datalakeResources);  }### Answer:
@Test public void testFileSystemWhenHivePathPresentedInDistroXButSdxDoesNotContainsItShouldReturnWithDistroXConfigs() throws IOException { when(stackService.getById(anyLong())).thenReturn(mockStack()); FileSystem fileSystem = underTest .prepareFilesytem( mockRequestedCluster(mockStorageLocation(3), mockStorageLocation(4)), mockDatalakeResources()); List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations(); Assert.assertEquals(2, locations.size()); Assert.assertTrue(hasPropretyWithIndex(locations, 3)); Assert.assertTrue(hasPropretyWithIndex(locations, 4)); }
@Test public void testFileSystemWhenHiveInSdxAndDistroXShouldReturnWithSdxHiveConfigs() throws IOException { when(stackService.getById(anyLong())).thenReturn(mockStack(mockStorageLocation(1), mockStorageLocation(2))); FileSystem fileSystem = underTest .prepareFilesytem( mockRequestedCluster(mockStorageLocation(3), mockStorageLocation(4)), mockDatalakeResources()); List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations(); Assert.assertEquals(2, locations.size()); Assert.assertTrue(hasPropretyWithIndex(locations, 1)); Assert.assertTrue(hasPropretyWithIndex(locations, 2)); }
@Test public void testFileSystemWhenHivePathNotPresentedInDistroXButSdxDoesContainsItShouldReturnWithSdxConfigs() throws IOException { when(nameGenerator.generateName(APIResourceType.FILESYSTEM)).thenReturn("appletree"); when(stackService.getById(anyLong())).thenReturn(mockStack(mockStorageLocation(1), mockStorageLocation(2))); FileSystem fileSystem = underTest .prepareFilesytem( mockRequestedCluster(mockRds(HIVE)), mockDatalakeResources()); List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations(); Assert.assertEquals(2, locations.size()); Assert.assertTrue(hasPropretyWithIndex(locations, 1)); Assert.assertTrue(hasPropretyWithIndex(locations, 2)); }
@Test public void testFileSystemWhenHivePathNotPresentedInDistroXAndSdxDoesNotContainsItShouldReturnWithSdxConfigs() throws IOException { when(nameGenerator.generateName(APIResourceType.FILESYSTEM)).thenReturn("appletree"); when(stackService.getById(anyLong())).thenReturn(mockStack()); FileSystem fileSystem = underTest .prepareFilesytem( mockRequestedCluster(mockRds(HIVE)), mockDatalakeResources()); List<StorageLocation> locations = fileSystem.getCloudStorage().getLocations(); Assert.assertEquals(0, locations.size()); }