@Before
  public void setup() {
    mockAccountDao = mock(AccountDao.class);
    mockFormDao = mock(FormDao.class);
    mockFormFieldDao = mock(FormFieldDao.class);
    mockAccountService = mock(AccountService.class);

    account = new Account();
    account.setId(1L);
    form = new Form();
    form.setAccount(account);
    form.setFields(new ArrayList<FormField>());
    field = new FormField();
    field.setForm(form);
    form.getFields().add(field);

    when(mockAccountDao.findByUsernameOrEmail("user")).thenReturn(account);
    when(mockFormDao.findById(1L)).thenReturn(form);
    when(mockFormFieldDao.findById(1L)).thenReturn(field);

    formService = new FormService();
    formService.setAccountDao(mockAccountDao);
    formService.setMapper(mapper);
    formService.setFormDao(mockFormDao);
    formService.setFormFieldDao(mockFormFieldDao);
    formService.setAccountService(mockAccountService);
  }
  @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 testCreateRiver() {
    River river = new River();
    Account account = accountDao.findByUsernameOrEmail("user1");

    river.setRiverName("Test river");
    river.setDescription("test description");
    river.setAccount(account);
    river.setRiverPublic(false);

    riverDao.create(river);

    assertNotNull(river.getId());
    String sql =
        "SELECT account_id, river_name, description, river_public, river_name_canonical FROM rivers WHERE id = ?";

    Map<String, Object> results = this.jdbcTemplate.queryForMap(sql, river.getId());
    assertEquals("Test river", (String) results.get("river_name"));
    assertEquals(3L, ((Number) results.get("account_id")).longValue());
    assertEquals(TextUtil.getURLSlug("Test river"), (String) results.get("river_name_canonical"));
    assertEquals("test description", (String) results.get("description"));
    assertEquals(false, results.get("river_public"));
  }