CommandDispatcher<BeanEvictionContext<String>> dispatcher = mock(CommandDispatcher.class);
Batcher<TransactionBatch> batcher = mock(Batcher.class);
TransactionBatch batch = mock(TransactionBatch.class);
Evictor<String> evictor = mock(Evictor.class);
PassivationConfiguration<Bean<Object, String, Object>> config = mock(PassivationConfiguration.class);
BeanPassivationConfiguration passivationConfig = mock(BeanPassivationConfiguration.class);
ArgumentCaptor<Command> capturedCommand = ArgumentCaptor.forClass(Command.class);
ArgumentCaptor<BeanEvictionContext> capturedContext = ArgumentCaptor.forClass(BeanEvictionContext.class);
when(dispatcherFactory.createCommandDispatcher(same(name), (BeanEvictionContext<String>) capturedContext.capture())).thenReturn(dispatcher);
when(config.getConfiguration()).thenReturn(passivationConfig);
when(passivationConfig.getMaxSize()).thenReturn(1);
try (Scheduler<String> scheduler = new BeanEvictionScheduler<>(name, batcher, evictor, dispatcherFactory, config)) {
BeanEvictionContext<String> context = capturedContext.getValue();
assertSame(scheduler, context);