ChangesetManager implements Closeable { public void addChangesetIfRequired(long changesetId, OsmUser user) { if (!doesChangesetExist(changesetId)) { addChangeset(changesetId, user.getId()); } } ChangesetManager(DatabaseContext dbCtx); void addChangesetIfRequired(long changesetId, OsmUser user); @Override void close();  }
@Test public void testChangeset() { OsmUser user; long changesetId; user = new OsmUser(1, "user"); changesetId = 2; try (DatabaseContext dbCtx = dbUtils.createDatabaseContext()) { dbUtils.truncateDatabase(); try (UserManager userManager = new UserManager(dbCtx)) { userManager.addOrUpdateUser(user); } try (ChangesetManager changesetManager = new ChangesetManager(dbCtx)) { changesetManager.addChangesetIfRequired(changesetId, user); changesetManager.addChangesetIfRequired(changesetId, user); } try (ChangesetManager changesetManager = new ChangesetManager(dbCtx)) { changesetManager.addChangesetIfRequired(changesetId, user); } } }