@EventListener({ ContextRefreshedEvent.class })
	void contextRefreshedEvent() {
		for (Task task : repository.findByActiveTrue()) {
            addTaskToScheduler(task.getId(), new SimpleTaskRunnable(task, clientFactory.getClientForApplication(task.getApplication())), task.getCron() );
        }
	}
@Test
    public void tasksAreScheduledOnApplicationStart() {
        Task taskA = new Task();
        taskA.setId(1l);
        taskA.setCron("0 0 * * * *");
        Task taskB = new Task();
        taskB.setId(2l);
        taskB.setCron("0 0 * * * *");
        Task taskC = new Task();
        taskC.setId(3l);
        taskC.setCron("0 0 * * * *");
        when(repository.findByActiveTrue()).thenReturn(List.of(taskA, taskB, taskC));

        service.contextRefreshedEvent();

        verify(scheduler, times(3)).schedule(any(Runnable.class), any(CronTrigger.class));
        assertEquals(3, ((Map<Long, ScheduledFuture<?>>) ReflectionTestUtils.getField(service, "jobsMap")).size());
    }