dao.getJdbcTemplate().execute("truncate music.lastfmgroup cascade");
PostgreSQLUtil.loadFunction(dao, UPDATE_LASTFMGROUP);
List<LastFmGroup> groups;
dao.setLastFmGroups(asList(new LastFmGroup("G1"), new LastFmGroup("G2")));
groups = dao.getLastFmGroups();
Assert.assertEquals(2, groups.size());
Assert.assertEquals("G1", groups.get(0).getName());
Assert.assertEquals("G2", groups.get(1).getName());
dao.setLastFmGroups(asList(new LastFmGroup("G1")));
groups = dao.getLastFmGroups();
Assert.assertEquals(1, groups.size());
Assert.assertEquals("G1", groups.get(0).getName());
dao.setLastFmGroups(asList(new LastFmGroup("G1"), new LastFmGroup("G2")));
groups = dao.getLastFmGroups();
Assert.assertEquals(2, groups.size());
Assert.assertEquals("G1", groups.get(0).getName());
Assert.assertEquals("G2", groups.get(1).getName());
}