Esempio n. 1
0
  @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"));
  }
Esempio n. 2
0
  @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);
  }
Esempio n. 3
0
  @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"));
  }
Esempio n. 4
0
  @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"));
  }
Esempio n. 5
0
  @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"));
  }
Esempio n. 6
0
  @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"));
  }
Esempio n. 7
0
  @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"));
  }
Esempio n. 8
0
  @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"));
  }
Esempio n. 9
0
 @DataSet
 @Test
 public void testGetTotalCounts() {
   assertThat(accountService.getTotalCount(getCriteria())).isEqualTo(2);
 }
Esempio n. 10
0
 @Test
 @DataSet
 public void testFindAccountById() {
   SimpleAccount account = accountService.findById(1, 1);
   assertThat(account.getAccountname()).isEqualTo("xyz");
 }