@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")); } }
private void verifyExecutability() { checkState(!this.disposed,"Session has already been disposed"); checkState(!this.completed,"Session has already been completed"); }
ContextWriteSessionState implements WriteSession { private void verifyExecutability() { checkState(!this.disposed,"Session has already been disposed"); checkState(!this.completed,"Session has already been completed"); } }
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); }
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(); }
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();  }