@PostConstruct
    public void synchronize() throws IOException {
        try {
            synchronizeConfig();
        } catch (NonTransientDataAccessException | StaleStateException e) {
            logger.error("Database exception while synchronizing configurations", e);
        }
    }
@Test
    public void test() throws IOException {
        Configuration conf1 = new Configuration();
        conf1.setName("1");
        conf1.setValue("1");
        conf1.setDefaultValue("2"); // updated defaultValue
        Configuration conf2 = new Configuration();
        conf2.setName("2");
        conf2.setValue("200");
        conf2.setDefaultValue("2"); // existing conf
        Configuration conf3 = new Configuration();
        conf3.setName("3");
        conf3.setValue("3");
        Configuration conf4 = new Configuration();
        conf4.setName("4");
        conf4.setValue("4");
        conf4.setDefaultValue("4"); // new conf

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

        Mockito.when(repo.findAll()).thenReturn(db);
        Mockito.when(repo.save(Mockito.isA(Configuration.class))).thenReturn(null);
        service.synchronize();
        Mockito.verify(repo, Mockito.times(1)).delete(conf3);
        Mockito.verify(repo, Mockito.times(0)).delete(conf1);
        Mockito.verify(repo, Mockito.times(0)).delete(conf2);
        Mockito.verify(repo, Mockito.times(0)).save(conf2);
        Mockito.verify(repo, Mockito.times(1)).save(conf1);

    }