### Question:
MessageArchive implements AutoCloseable { void save(byte[] message, long timestamp) throws Exception { if (indexFile == null) openFiles(timestamp); if ((message.length + dataFile.length()) >= (MAXIMUM_ARCHIVE_SIZE_MB * 1_000_000)) { close(); openFiles(timestamp); } indexFile.seek(indexFile.length()); dataFile.seek(dataFile.length()); long dataPos = dataFile.getFilePointer(); try { indexFile.write(message, 0, HEADER_SIZE); indexFile.writeLong(dataPos); dataFile.write(message, HEADER_SIZE, message.length - HEADER_SIZE); } catch(Exception e) { LoggingService.logError(MODULE_NAME, "Error saving archive", new AgentSystemException(e.getMessage(), e)); } } MessageArchive(String name); void close(); List<Message> messageQuery(long from, long to);  }### Answer:
@Test public void testSave() { try { messageArchive.save(message.getBytes(UTF_8),timestamp); PowerMockito.verifyPrivate(messageArchive).invoke("openFiles", anyLong()); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).seek(anyLong()); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).length(); Mockito.verify(randomAccessFile, Mockito.atLeastOnce()).getFilePointer(); } catch (Exception e) { fail("This shall never happen"); } }