ContextAwarePolicyAdapter implements ContextAwarePolicy { public void setFallbackPolicy(Policy fallbackPolicy) { Policy p = fallbackPolicy; while (p != null) { if (!(p instanceof ContextAwarePolicy)) { throw new IllegalArgumentException("Fallback policy must be instance of ContextAwarePolicy"); } p = p.getFallbackPolicy(); } this.policy.setFallbackPolicy(fallbackPolicy); } private  ContextAwarePolicyAdapter(Policy policy, PolicyContext context); static ContextAwarePolicy createInternalPolicy(); static ContextAwarePolicy createKeyPolicy(PublicationsHandler handler); static ContextAwarePolicy createPublicationsFilePolicy(PublicationsHandler handler); static ContextAwarePolicy createPublicationsFilePolicy(PublicationsHandler handler, Extender extender); static ContextAwarePolicy createCalendarPolicy(Extender extender); static ContextAwarePolicy createUserProvidedPublicationPolicy(PublicationData publicationData); static ContextAwarePolicy createUserProvidedPublicationPolicy(PublicationData publicationData, Extender extender); static ContextAwarePolicy createDefaultPolicy(PublicationsHandler handler, Extender extender); static ContextAwarePolicy createPolicy(Policy policy, PublicationsHandler handler, KSIExtendingService extendingService); PolicyContext getPolicyContext(); List<Rule> getRules(); String getName(); String getType(); Policy getFallbackPolicy(); void setFallbackPolicy(Policy fallbackPolicy);  }
@Test public void testSetFallbackPolicy() { ContextAwarePolicy keyBasedPolicy = ContextAwarePolicyAdapter.createPolicy(new KeyBasedVerificationPolicy(), Mockito.mock(PublicationsHandler.class), Mockito.mock(KSIExtendingService.class)); ContextAwarePolicy userProvidedPublicationPolicy = ContextAwarePolicyAdapter.createUserProvidedPublicationPolicy(Mockito.mock(PublicationData.class), null); userProvidedPublicationPolicy.setFallbackPolicy(keyBasedPolicy); assertNotNull(userProvidedPublicationPolicy.getFallbackPolicy()); }