### Question:
GenericItemSourcePool implements ItemSourcePool<T> { @Override public void start() { if (!isStarted()) { incrementPoolSize(initialPoolSize); this.executor = createExecutor(poolName); startRecyclerTask(); if (monitored) { startMonitorTask(monitorTaskInterval, pooledObjectOps.createMetricsSupplier()); } state = State.STARTED; } } GenericItemSourcePool(String poolName,
                                 PooledObjectOps<T> pooledObjectOps,
                                 ResizePolicy resizePolicy,
                                 long resizeTimeout,
                                 boolean monitored,
                                 long monitorTaskInterval,
                                 int initialPoolSize); @Override final void incrementPoolSize(int delta); @Override final void incrementPoolSize(); @Override final ItemSource<T> getPooled(); @Override final boolean remove(); @Override final String getName(); @Override final int getInitialSize(); @Override final int getTotalSize(); @Override final int getAvailableSize(); @Override // TODO: add shutdown(timeout) void shutdown(); @Override void start(); @Override void stop(); @Override boolean isStarted(); @Override boolean isStopped(); static final String THREAD_NAME_FORMAT; }### Answer:
@Test public void monitoredPoolExecutorSchedulesMetricPrinterThread() { final ScheduledExecutorService spiedExecutor = spy(ScheduledExecutorService.class); GenericItemSourcePool pool = createDefaultTestGenericItemSourcePool(true, spiedExecutor); pool.start(); ArgumentCaptor<GenericItemSourcePool.Recycler> runnableCaptor = ArgumentCaptor.forClass(GenericItemSourcePool.Recycler.class); verify(spiedExecutor).scheduleAtFixedRate(runnableCaptor.capture(), anyLong(), eq(DEFAULT_TEST_MONITOR_TASK_INTERVAL), any(TimeUnit.class)); }
@Test public void lifecycleStartCreatesScheduledExecutor() { GenericItemSourcePool pool = createDefaultTestGenericItemSourcePool(1, false); pool.start(); assertNotNull(pool.executor); }