@Test public void testAddCollaborator() { River river = riverDao.findById(1L); Account account = accountDao.findByUsernameOrEmail("user4"); riverDao.addCollaborator(river, account, true); em.flush(); String sql = "SELECT river_id, account_id, collaborator_active, read_only FROM river_collaborators WHERE river_id = ? AND account_id = ?"; Map<String, Object> results = this.jdbcTemplate.queryForMap(sql, 1L, 6L); assertEquals(false, results.get("collaborator_active")); assertEquals(true, results.get("read_only")); }
@Test public void updateRiver() { River river = riverDao.findById(2L); river.setRiverName("updated river name"); river.setDescription("updated description"); river.setRiverPublic(true); riverDao.update(river); em.flush(); String sql = "SELECT river_name, river_name_canonical, description, river_public FROM rivers WHERE id = ?"; Map<String, Object> results = this.jdbcTemplate.queryForMap(sql, 2); assertEquals("updated river name", (String) results.get("river_name")); assertEquals( TextUtil.getURLSlug("updated river name"), (String) results.get("river_name_canonical")); assertEquals("updated description", (String) results.get("description")); assertEquals(true, results.get("river_public")); }
@Test public void findById() { River r = riverDao.findById(1L); assertEquals("Public River 1", r.getRiverName()); }