### Question:
ContextWriteSessionState implements WriteSession { private void verifyExecutability() { checkState(!this.disposed,"Session has already been disposed"); checkState(!this.completed,"Session has already been completed"); } 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 testVerifyExecutability$breakIfCompleted() throws Exception { new Expectations() {{ delegate.saveChanges();times=1; }}; this.sut.saveChanges(); try { this.sut.saveChanges(); fail("Should break circuit if already completed"); } catch (IllegalStateException e) { assertThat(e.getMessage(),equalTo("Session has already been completed")); } }
@Test public void testVerifyExecutability$breakIfDisposed() throws Exception { new Expectations() {{ listener.onDispose(sut);times=1; delegate.close();times=1; }}; this.sut.close(); try { this.sut.saveChanges(); fail("Should break circuit if already disposed"); } catch (IllegalStateException e) { assertThat(e.getMessage(),equalTo("Session has already been disposed")); } }