DiskQueue extends AbstractQueue<String> { @Override public boolean offer(String element) { if (element == null) { throw new NullPointerException("Element cannot be null for AbstractQueue"); } boolean hasFileQueue = fileQueue != null; boolean offerRejected = false; if (!hasFileQueue) { offerRejected = !memoryQueue.offer(element); if (offerRejected) { memoryIterator = memoryQueue.iterator(); } } if (hasFileQueue || offerRejected) { try { openFile(); fileOut.write(element); fileOut.newLine(); fileElementCount++; } catch (IOException e) { LOG.severe(MessageFormat.format("Error writing to {0} backing store", DiskQueue.class.getSimpleName())); return false; } } return true; } DiskQueue(int maxInMemorySize);  DiskQueue(int maxInMemorySize, File tempDir); @Override Iterator<String> iterator(); @Override int size(); @Override boolean offer(String element); @Override String peek(); @Override String remove(); @Override String poll(); @Override void clear();  }
@Test public void testOffer() { Queue<String> instance = new DiskQueue<String>(1); boolean result = instance.offer("test1"); assertTrue(result); }
@Test public void testOffer_null() { assertThrows(NullPointerException.class, () -> { Queue<String> instance = new DiskQueue<String>(1); instance.offer(null); }); }