@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")); }
@DataSet @Test public void testSaveAccount() { List accountList = accountService.findPagableListByCriteria( new SearchRequest<AccountSearchCriteria>( new AccountSearchCriteria(), 0, Integer.MAX_VALUE)); System.out.println("List: " + accountList.size()); Account account = new Account(); account.setAccountname("aaa"); account.setSaccountid(1); accountService.saveWithSession(account, "aaa"); accountList = accountService.findPagableListByCriteria( new SearchRequest<AccountSearchCriteria>( new AccountSearchCriteria(), 0, Integer.MAX_VALUE)); System.out.println("List: " + accountList.size()); }
@DataSet @Test public void testSearchByCriteria() { Assert.assertEquals( 2, accountService .findPagableListByCriteria( new SearchRequest<AccountSearchCriteria>(getCriteria(), 0, Integer.MAX_VALUE)) .size()); }
@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 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()); }
@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()); }
@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 testSearchAnyMailField() { AccountSearchCriteria criteria = new AccountSearchCriteria(); criteria.setAnyMail(new StringSearchField(SearchField.AND, "abc")); 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 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")); }
@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()); } }