### Question:
ActionFile { public DownloadRequest[] load() throws IOException { if (!exists()) { return new DownloadRequest[0]; } InputStream inputStream = null; try { inputStream = atomicFile.openRead(); DataInputStream dataInputStream = new DataInputStream(inputStream); int version = dataInputStream.readInt(); if (version > VERSION) { throw new IOException("Unsupported action file version: " + version); } int actionCount = dataInputStream.readInt(); ArrayList<DownloadRequest> actions = new ArrayList<>(); for (int i = 0; i < actionCount; i++) { try { actions.add(readDownloadRequest(dataInputStream)); } catch (UnsupportedRequestException e) { } } return actions.toArray(new DownloadRequest[0]); } finally { Util.closeQuietly(inputStream); } } ActionFile(File actionFile); boolean exists(); void delete(); DownloadRequest[] load();  }### Answer:
@Test public void testLoadNoDataThrowsIOException() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_no_data.exi"); try { actionFile.load(); Assert.fail(); } catch (IOException e) { } }
@Test public void testLoadIncompleteHeaderThrowsIOException() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_incomplete_header.exi"); try { actionFile.load(); Assert.fail(); } catch (IOException e) { } }
@Test public void testLoadZeroActions() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_zero_actions.exi"); DownloadRequest[] actions = actionFile.load(); assertThat(actions).isNotNull(); assertThat(actions).hasLength(0); }
@Test public void testLoadOneAction() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_one_action.exi"); DownloadRequest[] actions = actionFile.load(); assertThat(actions).hasLength(1); assertThat(actions[0]).isEqualTo(expectedAction1); }
@Test public void testLoadTwoActions() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_two_actions.exi"); DownloadRequest[] actions = actionFile.load(); assertThat(actions).hasLength(2); assertThat(actions[0]).isEqualTo(expectedAction1); assertThat(actions[1]).isEqualTo(expectedAction2); }
@Test public void testLoadUnsupportedVersion() throws Exception { ActionFile actionFile = getActionFile("offline/action_file_unsupported_version.exi"); try { actionFile.load(); Assert.fail(); } catch (IOException e) { } }