### Question:
ContextWriteSessionState implements WriteSession { synchronized void dispose() { LOGGER.warn("Closing session {} which was not closed by the user...",this); try { doDispose(); } catch (SessionTerminationException e) { LOGGER.error("Could not close session {}",this,e); } } ContextWriteSessionState(WriteSession delegate, ContextWriteSessionStateListener listener); @Override synchronized S resolve(Class<? extends S> snapshotClass, Individual<?, ?> individual); @Override synchronized S find(Class<? extends S> snapshotClass, Name<?> id, Class<? extends ResourceHandler> handlerClass); @Override synchronized void modify(ResourceSnapshot resource); @Override synchronized void delete(ResourceSnapshot resource); @Override synchronized void saveChanges(); @Override synchronized void discardChanges(); @Override synchronized void close(); @Override synchronized String toString();  }### Answer:
@Test public void testDispose$happyPath() throws Exception { new Expectations() {{ delegate.close();times=1; listener.onDispose(sut);times=1; }}; this.sut.dispose(); }