public Applications(CuratorDb db) {
        this.db = db;
        // read and write all to make sure they are stored in the latest version of the serialized format
        for (ApplicationId id : ids()) {
            try (Mutex lock = db.lock(id)) {
                get(id).ifPresent(application -> put(application, lock));
            } catch (ApplicationLockException e) {
                throw new ApplicationLockException(e);
            }
        }
    }
@Test
    public void testApplications() {
        Applications applications = new NodeRepositoryTester().nodeRepository().applications();
        ApplicationId app1 = ApplicationId.from("t1", "a1", "i1");
        ApplicationId app2 = ApplicationId.from("t1", "a2", "i1");
        ApplicationId app3 = ApplicationId.from("t1", "a2", "default");

        assertTrue(applications.get(app1).isEmpty());
        assertEquals(List.of(), applications.ids());
        applications.put(Application.empty(app1), () -> {});
        assertEquals(app1, applications.get(app1).get().id());
        assertEquals(List.of(app1), applications.ids());
        NestedTransaction t = new NestedTransaction();
        applications.remove(new ApplicationTransaction(provisionLock(app1), t));
        t.commit();
        assertTrue(applications.get(app1).isEmpty());
        assertEquals(List.of(), applications.ids());

        applications.put(Application.empty(app1), () -> {});
        applications.put(Application.empty(app2), () -> {});
        t = new NestedTransaction();
        applications.put(Application.empty(app3), new ApplicationTransaction(provisionLock(app1), t));
        assertEquals(List.of(app1, app2), applications.ids());
        t.commit();
        assertEquals(List.of(app1, app2, app3), applications.ids());
        t = new NestedTransaction();
        applications.remove(new ApplicationTransaction(provisionLock(app1), t));
        applications.remove(new ApplicationTransaction(provisionLock(app2), t));
        applications.remove(new ApplicationTransaction(provisionLock(app3), t));
        assertEquals(List.of(app1, app2, app3), applications.ids());
        t.commit();
        assertTrue(applications.get(app1).isEmpty());
        assertEquals(List.of(), applications.ids());
    }