DiskQueue extends AbstractQueue<Payload> { @Override public Payload poll() { return readFromFile(true); } private  DiskQueue(Builder builder); @Override Iterator<Payload> iterator(); @Override int size(); @Override boolean offer(Payload payload); @Override Payload poll(); @Override Payload peek();  }
@Test(expected = RuntimeException.class) public void shouldDiscardInvalidPayloadsWithPoll() throws Exception { File queueFile = new File(queueFolder.getAbsolutePath(), String.format("%s.%s", UUID.randomUUID().toString(), "payload")); InputStream input = this.getClass().getClassLoader().getResource("invalid.payload").openStream(); Files.copy(input, queueFile.toPath()); Payload result = sut.poll(); assertThat(result, is(nullValue())); assertFalse(new File(queueFile.getPath()).exists()); }