@PostConstruct
    public void synchronize() throws IOException {
        try {
            synchronizeTask();
        } catch (NonTransientDataAccessException | StaleStateException e) {
            logger.error("Database exception while synchronizing tasks", e);
        }
    }
@Test
    public void synchronizeTasksBetweenYamlAndDatabase() throws IOException {
        Task conf1 = new Task();
        conf1.setName("1");
        conf1.setCron("1");
        Task conf2 = new Task();
        conf2.setName("2");
        conf2.setCron("200");
        Task conf3 = new Task();
        conf3.setName("3");
        conf3.setCron("3");
        Task conf4 = new Task();
        conf4.setName("4");
        conf4.setCron("4");

        List<Task> db = new ArrayList<>(); // removed conf
        db.add(conf1);
        db.add(conf2);
        db.add(conf3);
        db.add(conf4);

        Mockito.when(repo.findAll()).thenReturn(db);
        Mockito.when(repo.save(Mockito.isA(Task.class))).thenReturn(null);

        service.synchronize();

        Mockito.verify(repo, times(1)).save(any(Task.class)); // save 5
        Mockito.verify(repo, times(2)).delete(any(Task.class)); // 3 + 4
    }