@Test
public void testTemplateScheduledForDownloadInOnePool() {

    VMTemplateVO mockTemplate = mock(VMTemplateVO.class);
    StoragePoolVO mockPool = mock(StoragePoolVO.class);
    PrimaryDataStore mockPrimaryDataStore = mock(PrimaryDataStore.class);
    VMTemplateStoragePoolVO mockTemplateStore = mock(VMTemplateStoragePoolVO.class);
    when(mockPrimaryDataStore.getId()).thenReturn(2l);
    when(mockPool.getId()).thenReturn(2l);
    when(mockPool.getStatus()).thenReturn(StoragePoolStatus.Up);
    when(mockPool.getDataCenterId()).thenReturn(1l);
    when(mockTemplate.getId()).thenReturn(202l);
    when(mockTemplateStore.getDownloadState()).thenReturn(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
    when(vmTemplateDao.findById(anyLong())).thenReturn(mockTemplate);
    when(dataStoreManager.getPrimaryDataStore(anyLong())).thenReturn(mockPrimaryDataStore);
    when(vmTemplateDao.findById(anyLong(), anyBoolean())).thenReturn(mockTemplate);
    when(vmTemplatePoolDao.findByPoolTemplate(anyLong(), anyLong())).thenReturn(mockTemplateStore);
    when(primaryDataStoreDao.findById(anyLong())).thenReturn(mockPool);
    doNothing().when(mockTemplateStore).setMarkedForGC(anyBoolean());
    ExecutorService preloadExecutor = new CustomThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(),
            new NamedThreadFactory("Template-Preloader"));
    templateManager._preloadExecutor = preloadExecutor;
    templateManager.prepareTemplate(202, 1, 2l);
    assertTrue("Test template is scheduled for seeding to on pool", ((CustomThreadPoolExecutor)preloadExecutor).getCount() == 1);
}