@Test @DisplayName("throw InvalidEntityStateException if state is invalid") void rejectInvalidState() { AbstractEntity<?, NaturalNumber> entity = new NaturalNumberEntity(0L); NaturalNumber invalidNaturalNumber = newNaturalNumber(-1); try { entity.updateState(newNaturalNumber(1)); entity.updateState(invalidNaturalNumber); fail("Exception expected."); } catch (InvalidEntityStateException e) { assertThat(e.error() .getValidationError() .getConstraintViolationList()).hasSize(1); } }
final void updateState(S state) { checkNotNull(state); validate(state); setState(state); }
AbstractEntity implements Entity<I, S>, HandlerLifecycle { final void updateState(S state) { checkNotNull(state); validate(state); setState(state); } }
AbstractEntity implements Entity<I, S>, HandlerLifecycle { final void updateState(S state) { checkNotNull(state); validate(state); setState(state); } protected  AbstractEntity(); protected  AbstractEntity(I id); protected  AbstractEntity(I id, Function<I, S> defaultState); }
AbstractEntity implements Entity<I, S>, HandlerLifecycle { final void updateState(S state) { checkNotNull(state); validate(state); setState(state); } protected  AbstractEntity(); protected  AbstractEntity(I id); protected  AbstractEntity(I id, Function<I, S> defaultState); @Override I id(); @Override final S state(); @Override String idAsString(); @Override String toString(); @Override LifecycleFlags getLifecycleFlags(); @Override final boolean isArchived(); @Override final boolean isDeleted(); @Override boolean lifecycleFlagsChanged(); @Override Version version(); Timestamp whenModified(); @OverridingMethodsMustInvokeSuper @Override void beforeInvoke(HandlerMethod<?, ?, ?, ?> method); @OverridingMethodsMustInvokeSuper @Override void afterInvoke(HandlerMethod<?, ?, ?, ?> method); final FluentLogger.Api at(Level logLevel); @Override boolean equals(Object o); @Override int hashCode(); }
AbstractEntity implements Entity<I, S>, HandlerLifecycle { final void updateState(S state) { checkNotNull(state); validate(state); setState(state); } protected  AbstractEntity(); protected  AbstractEntity(I id); protected  AbstractEntity(I id, Function<I, S> defaultState); @Override I id(); @Override final S state(); @Override String idAsString(); @Override String toString(); @Override LifecycleFlags getLifecycleFlags(); @Override final boolean isArchived(); @Override final boolean isDeleted(); @Override boolean lifecycleFlagsChanged(); @Override Version version(); Timestamp whenModified(); @OverridingMethodsMustInvokeSuper @Override void beforeInvoke(HandlerMethod<?, ?, ?, ?> method); @OverridingMethodsMustInvokeSuper @Override void afterInvoke(HandlerMethod<?, ?, ?, ?> method); final FluentLogger.Api at(Level logLevel); @Override boolean equals(Object o); @Override int hashCode();  }