FileSystemOperations { public void validFileSize(String uri) throws IOException { boolean remote = remoteDirectoryManager.isRemote(uri); long actualSizeInBytes = getFileSizeInBytes(uri, remote); long maxFileSizeInBytes = convertToBytes(getMaxRemoteFileSizeMB()); String locationType = remote ? "Remote" : "Local"; LOG.info("{} file / directory path is {} with size: {} bytes." + " Allowed maximum file / directory size is {} bytes.", locationType, uri, actualSizeInBytes, maxFileSizeInBytes); if (actualSizeInBytes > maxFileSizeInBytes) { throw new IOException( String.format("Size of file / directory %s: %d bytes. " + "This exceeded the configured maximum " + "file / directory size, which is %d bytes.", uri, actualSizeInBytes, maxFileSizeInBytes)); } } FileSystemOperations(ClientContext clientContext); String downloadAndZip(String remoteDir, String destFileName); String download(String remoteDir, String zipFileName); void deleteFiles(String localUri); @VisibleForTesting void uploadToRemoteFileAndLocalizeToContainerWorkDir(Path stagingDir,
      String fileToUpload, String destFilename, Component comp); Path uploadToRemoteFile(Path stagingDir, String fileToUpload); void validFileSize(String uri); void setPermission(Path destPath, FsPermission permission); static boolean needHdfs(List<String> stringsToCheck); static boolean needHdfs(String content); Set<Path> getUploadedFiles();  }
@Test public void testValidFileSize() throws IOException { ClientContext clientContext = mock(ClientContext.class); RemoteDirectoryManager remoteDirectoryManager = mock(RemoteDirectoryManager.class); when(clientContext.getRemoteDirectoryManager()) .thenReturn(remoteDirectoryManager); when(remoteDirectoryManager.isRemote(anyString())).thenReturn(true); when(remoteDirectoryManager.getRemoteFileSize(anyString())) .thenReturn(20000L); SubmarineConfiguration config = SubmarineConfiguration.newInstance(); config.setLong(SubmarineConfVars .ConfVars.SUBMARINE_LOCALIZATION_MAX_ALLOWED_FILE_SIZE_MB, 21L); when(clientContext.getSubmarineConfig()).thenReturn(config); fileSystemOperations = new FileSystemOperations(clientContext); }