### Question:
EntriesFile { public Entry loadEntry(long offset, EntryFactory factory) throws IOException { if (offset > seekableFile.size()) { throw new IllegalArgumentException("offset > size"); } seekableFile.seek(offset); int kind = seekableFile.readInt(); int index = seekableFile.readInt(); int term = seekableFile.readInt(); int length = seekableFile.readInt(); byte[] bytes = new byte[length]; seekableFile.read(bytes); return factory.create(kind, index, term, bytes); } EntriesFile(File file);  EntriesFile(SeekableFile seekableFile); long appendEntry(Entry entry); Entry loadEntry(long offset, EntryFactory factory); long size(); void clear(); void truncate(long offset); void close();  }### Answer:
@Test public void testLoadEntry() throws IOException { ByteArraySeekableFile seekableFile = new ByteArraySeekableFile(); EntriesFile file = new EntriesFile(seekableFile); Assert.assertEquals(0L, file.appendEntry(new NoOpEntry(2, 3))); Assert.assertEquals(16L, file.appendEntry(new GeneralEntry(3, 3, "test".getBytes()))); Assert.assertEquals(36L, file.appendEntry(new GeneralEntry(4, 3, "foo".getBytes()))); EntryFactory factory = new EntryFactory(); Entry entry = file.loadEntry(0L, factory); Assert.assertEquals(Entry.KIND_NO_OP, entry.getKind()); Assert.assertEquals(2, entry.getIndex()); Assert.assertEquals(3, entry.getTerm()); entry = file.loadEntry(36L, factory); Assert.assertEquals(Entry.KIND_GENERAL, entry.getKind()); Assert.assertEquals(4, entry.getIndex()); Assert.assertEquals(3, entry.getTerm()); Assert.assertArrayEquals("foo".getBytes(), entry.getCommandBytes()); }