@Test
  @DataSet
  public void testRemoveAccountBySearchCriteria() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setIndustries(new SetSearchField<String>(SearchField.AND, new String[] {"a"}));
    criteria.setSaccountid(new NumberSearchField(1));

    accountService.removeByCriteria(criteria, 1);

    criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));
    Assert.assertEquals(1, accountService.getTotalCount(criteria));
  }
  @SuppressWarnings("unchecked")
  @Test
  @DataSet
  public void testMassUpdate() {
    List<Integer> updateKeys = Arrays.asList(1, 2, 3);
    Account account = new Account();
    account.setAssignuser("hai79");
    account.setIndustry("aaa");
    accountService.massUpdateWithSession(account, updateKeys, 1);

    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));

    assertThat(accounts.size()).isEqualTo(3);
    assertThat(accounts)
        .extracting("id", "accountname", "industry", "assignuser")
        .contains(
            tuple(1, "xyz", "aaa", "hai79"),
            tuple(2, "xyz1", "aaa", "hai79"),
            tuple(3, "xyz2", "aaa", "hai79"));
  }
 private AccountSearchCriteria getCriteria() {
   AccountSearchCriteria criteria = new AccountSearchCriteria();
   criteria.setAccountname(new StringSearchField(SearchField.AND, "xy"));
   criteria.setAssignUsers(new SetSearchField<>("hai79", "linhduong"));
   criteria.setIndustries(new SetSearchField<>("a", "b"));
   criteria.setTypes(new SetSearchField<>("a", "b"));
   criteria.setSaccountid(new NumberSearchField(1));
   return criteria;
 }
  @DataSet
  @Test
  public void testSearchAnyMailField() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setAnyMail(new StringSearchField(SearchField.AND, "abc"));
    criteria.setSaccountid(new NumberSearchField(1));

    Assert.assertEquals(2, accountService.getTotalCount(criteria));
  }
  @Test
  @DataSet
  public void testRemoveAccounts() {
    accountService.massRemoveWithSession(Arrays.asList(1, 2), "hai79", 1);
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));

    Assert.assertEquals(1, accountService.getTotalCount(criteria));
  }
  @SuppressWarnings("unchecked")
  @Test
  @DataSet
  public void testRemoveAccountBySearchCriteria() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setIndustries(new SetSearchField<>("a"));
    criteria.setSaccountid(new NumberSearchField(1));

    accountService.removeByCriteria(criteria, 1);

    criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));

    assertThat(accounts.size()).isEqualTo(2);
    assertThat(accounts)
        .extracting("id", "accountname", "industry")
        .contains(tuple(2, "xyz1", "b"), tuple(3, "xyz2", "c"));
  }
  @SuppressWarnings("unchecked")
  @Test
  @DataSet
  public void testQueryAccountWithExtOneValueSearchField() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));
    criteria.addExtraField(
        new OneValueSearchField(SearchField.AND, "m_crm_account.accountName = ", "xyz"));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));
    assertThat(accounts.size()).isEqualTo(1);
    assertThat(accounts).extracting("id", "accountname", "industry").contains(tuple(1, "xyz", "a"));
  }
  @SuppressWarnings("unchecked")
  @Test
  @DataSet
  public void testSearchByAssignUserName() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setAssignUser(new StringSearchField("hai79"));
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));

    assertThat(accounts.size()).isEqualTo(1);
    assertThat(accounts).extracting("id", "accountname", "industry").contains(tuple(1, "xyz", "a"));
  }
  @Test
  @DataSet
  public void testSearchByAssignUserName() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setAssignUserName(new StringSearchField(SearchField.AND, "Nguyen Phuc Hai"));
    criteria.setSaccountid(new NumberSearchField(1));

    Assert.assertEquals(1, accountService.getTotalCount(criteria));
    Assert.assertEquals(
        1,
        accountService
            .findPagableListByCriteria(
                new SearchRequest<AccountSearchCriteria>(criteria, 0, Integer.MAX_VALUE))
            .size());
  }
Beispiel #10
0
  @Test
  @DataSet
  public void tesSearchAnyCity() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setAnyCity(new StringSearchField(SearchField.AND, "ha noi"));
    criteria.setSaccountid(new NumberSearchField(1));

    Assert.assertEquals(2, accountService.getTotalCount(criteria));
    Assert.assertEquals(
        2,
        accountService
            .findPagableListByCriteria(
                new SearchRequest<AccountSearchCriteria>(criteria, 0, Integer.MAX_VALUE))
            .size());
  }
Beispiel #11
0
  @Test
  @DataSet
  public void testSearchWebsite() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setWebsite(new StringSearchField(SearchField.AND, "http://www.esofthead.com"));
    criteria.setSaccountid(new NumberSearchField(1));

    Assert.assertEquals(3, accountService.getTotalCount(criteria));
    Assert.assertEquals(
        3,
        accountService
            .findPagableListByCriteria(
                new SearchRequest<AccountSearchCriteria>(criteria, 0, Integer.MAX_VALUE))
            .size());
  }
  @SuppressWarnings("unchecked")
  @DataSet
  @Test
  public void testSearchAnyPhoneField() {
    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setAnyPhone(new StringSearchField(SearchField.AND, "111"));
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));
    assertThat(accounts.size()).isEqualTo(2);
    assertThat(accounts)
        .extracting("id", "accountname", "industry")
        .contains(tuple(1, "xyz", "a"), tuple(2, "xyz1", "b"));
  }
  @SuppressWarnings("unchecked")
  @Test
  @DataSet
  public void testRemoveAccounts() {
    accountMapper.removeKeysWithSession(Arrays.asList(1, 2));

    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(criteria, 0, Integer.MAX_VALUE));

    assertThat(accounts.size()).isEqualTo(1);
    assertThat(accounts)
        .extracting("id", "accountname", "industry")
        .contains(tuple(3, "xyz2", "c"));
  }
Beispiel #14
0
  @Test
  @DataSet
  public void testMassUpdate() {
    List<Integer> updateKeys = Arrays.asList(1, 2, 3);
    Account account = new Account();
    account.setAssignuser("hai79");
    account.setIndustry("aaa");
    accountService.massUpdateWithSession(account, updateKeys, 1);

    AccountSearchCriteria criteria = new AccountSearchCriteria();
    criteria.setSaccountid(new NumberSearchField(1));

    List<SimpleAccount> accountList =
        accountService.findPagableListByCriteria(
            new SearchRequest<AccountSearchCriteria>(criteria, 0, Integer.MAX_VALUE));
    Assert.assertEquals(3, accountList.size());
    for (SimpleAccount account1 : accountList) {
      Assert.assertEquals("hai79", account1.getAssignuser());
    }
  }