AbstractPolicyEventStrategy implements EventStrategy<T, Policy> { @Nullable @Override public Policy handle(final T event, @Nullable final Policy policy, final long revision) { if (null != policy) { PolicyBuilder policyBuilder = policy.toBuilder() .setRevision(revision) .setModified(event.getTimestamp().orElse(null)); policyBuilder = applyEvent(event, policy, policyBuilder); return policyBuilder.build(); } return null; } protected  AbstractPolicyEventStrategy(); @Nullable @Override Policy handle(final T event, @Nullable final Policy policy, final long revision);  }
@Test public void testHandleReturnsNullForNullEntity() { assertThat(getStrategyUnderTest().handle(getPolicyEvent(instant, policy), null, 0L)).isNull(); }
@Test public void testHandlePolicyEvent() { final Policy policyWithEventApplied = strategy.handle(policyEvent, policy, 10L); assertThat(policyWithEventApplied).isNotNull(); assertThat(policyWithEventApplied.getModified()).contains(instant); assertThat(policyWithEventApplied.getRevision()).contains(PolicyRevision.newInstance(10L)); additionalAssertions(policyWithEventApplied); }