CheckedDatastore extends CheckedDatastoreReaderWriter { Key allocateId(IncompleteKey newKey) throws IOException { return call(() -> datastore.allocateId(newKey)); } CheckedDatastore(Datastore datastore);   }
@Test public void allocateId() throws IOException { when(datastore.allocateId(incompleteKey)).thenReturn(key); assertThat(sut.allocateId(incompleteKey), is(key)); verify(datastore).allocateId(incompleteKey); }
@Test public void allocateIdShouldThrowCheckedException() throws IOException { when(datastore.allocateId(incompleteKey)).thenThrow(CAUSE); exception.expect(DatastoreIOException.class); exception.expectCause(is(CAUSE)); sut.allocateId(incompleteKey); }