@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"));
  }
  @Test
  @DataSet
  public void testUpdateAccount() {
    Account account = new Account();
    account.setId(1);
    account.setAccountname("abc");
    account.setSaccountid(1);
    accountService.updateWithSession(account, "hai79");

    SimpleAccount simpleAccount = accountService.findById(1, 1);
    assertThat(simpleAccount.getAccountname()).isEqualTo("abc");
    assertThat(simpleAccount.getIndustry()).isEqualTo(null);
  }
  @SuppressWarnings("unchecked")
  @DataSet
  @Test
  public void testSearchByCriteria() {
    List<SimpleAccount> accounts =
        accountService.findPagableListByCriteria(
            new SearchRequest<>(getCriteria(), 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 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"));
  }
  @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"));
  }
 @DataSet
 @Test
 public void testGetTotalCounts() {
   assertThat(accountService.getTotalCount(getCriteria())).isEqualTo(2);
 }
Example #10
0
 @Test
 @DataSet
 public void testFindAccountById() {
   SimpleAccount account = accountService.findById(1, 1);
   assertThat(account.getAccountname()).isEqualTo("xyz");
 }