@Test
  public void syncBinder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    // add 2 sections
    for (int i = 0; i < 2; i++) {
      portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
      dbInstance.commit();
    }

    List<Section> templateSections = portfolioService.getSections(templateBinder);
    Assert.assertNotNull(templateSections);
    Assert.assertEquals(3, templateSections.size());

    // user get a the binder from the template
    Binder binder =
        portfolioService.assignBinder(id, templateBinder, templateEntry, "ac-234", new Date());
    dbInstance.commit();
    Assert.assertNotNull(binder);
    boolean inUse = portfolioService.isTemplateInUse(templateBinder, templateEntry, "ac-234");
    Assert.assertTrue(inUse);

    // update the template with 2 more sections
    for (int i = 2; i < 4; i++) {
      portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
      dbInstance.commit();
    }

    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    Assert.assertNotNull(synchedBinder);
    dbInstance.commit();
    Assert.assertTrue(synchedBinder.isChanged());
    Assert.assertEquals(binder, synchedBinder.getBinder());
    List<Section> synchedSections = portfolioService.getSections(synchedBinder.getBinder());
    Assert.assertEquals(5, synchedSections.size());
  }