mardi 29 janvier 2019

How to mock executorService.submit()

How can I mock executorService.submit() in the below scenerio. I have to mock

cacheController.someMethod(); but as submit method is called it creates a thread and cacheController.someMethod(); never gets called for test class.

@Autowired
CacheController cacheController;
protected static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(1);

EXECUTOR.submit(() -> {
        try {
            cacheController.someMethod();
        } catch (Exception e) {
            e.printStackTrace();
        }
    });

Aucun commentaire:

Enregistrer un commentaire