### Question:
ChronicleMapRetryFailoverPolicy implements FailoverPolicy<ItemSource>, LifeCycle { @Override public <U extends FailoverListener> void addListener(U failoverListener) { if (failoverListener instanceof RetryListener) { List<RetryListener> listeners = new ArrayList<>(Arrays.asList(this.retryListeners)); listeners.add((RetryListener) failoverListener); this.retryListeners = listeners.toArray(new RetryListener[0]); } } protected  ChronicleMapRetryFailoverPolicy(Builder builder); @Override void addListener(U failoverListener); @Override void deliver(ItemSource failedItemSource); @PluginBuilderFactory static ChronicleMapRetryFailoverPolicy.Builder newBuilder(); @Override void start(); @Override void stop(); @Override LifeCycle stop(long timeout, boolean async); @Override boolean isStarted(); @Override boolean isStopped(); static final String PLUGIN_NAME; }### Answer:
@Test public void failoverListenerIsAddedIfInstanceOfRetryListener() throws IOException { ChronicleMapRetryFailoverPolicy.Builder builder = createDefaultTestFailoverPolicyBuilder() .withRetryDelay(DEFAULT_TEST_RETRY_INTERVAL); ChronicleMapRetryFailoverPolicy failoverPolicy = spy(builder.build()); failoverPolicy.addListener(mock(RetryListener.class)); assertEquals(1, failoverPolicy.retryListeners.length); }
@Test public void failoverListenerIsNotAddedIfNotInstanceOfRetryListener() throws IOException { ChronicleMapRetryFailoverPolicy.Builder builder = createDefaultTestFailoverPolicyBuilder() .withRetryDelay(DEFAULT_TEST_RETRY_INTERVAL); ChronicleMapRetryFailoverPolicy failoverPolicy = spy(builder.build()); failoverPolicy.addListener(mock(FailoverListener.class)); assertEquals(0, failoverPolicy.retryListeners.length); }