Search in sources :

Example 11 with PagerParams

use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.

the class UserServiceImplTest method testFindUsersByDisplayNamePartial_whitebox_expectUserServiceUnexpectedException.

@Test(expected = UserServiceUnexpectedException.class)
public void testFindUsersByDisplayNamePartial_whitebox_expectUserServiceUnexpectedException() throws Exception {
    UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
    fixture.findUsersByDisplayNamePartial(UserFactory.EXISTENT_USER, new PagerParams(20, 40));
    fail();
}
Also used : PagerParams(org.summerb.easycrud.api.dto.PagerParams) Test(org.junit.Test)

Example 12 with PagerParams

use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.

the class UserDaoImplTest method testFindUsersByDisplayNamePartial_expectUsersWillBeFound.

@Test
public void testFindUsersByDisplayNamePartial_expectUsersWillBeFound() throws Exception {
    User user = UserFactory.createNewUserTemplate();
    user.setDisplayName("oneUHapqoiwez");
    user.setEmail("email1@aaa.ru");
    userService.createUser(user);
    user = UserFactory.createNewUserTemplate();
    user.setDisplayName("twoUHapqoiwez");
    user.setEmail("email2@aaa.ru");
    userService.createUser(user);
    user = UserFactory.createNewUserTemplate();
    user.setDisplayName("threeUHapqoiwez");
    user.setEmail("email3@aaa.ru");
    userService.createUser(user);
    user = UserFactory.createNewUserTemplate();
    user.setDisplayName("other");
    user.setEmail("other@aaa.ru");
    userService.createUser(user);
    PaginatedList<User> results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams());
    assertNotNull(results);
    assertNotNull(results.getItems());
    assertTrue(results.getItems().size() == 3);
    assertTrue(results.getTotalResults() == 3);
    results = userService.findUsersByDisplayNamePartial("eUHapqoiwez", new PagerParams());
    assertTrue(results.getItems().size() == 2);
    assertTrue(results.getTotalResults() == 2);
    results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams(0, 1));
    assertTrue(results.getItems().size() == 1);
    assertTrue(results.getTotalResults() == 3);
}
Also used : User(org.summerb.users.api.dto.User) PagerParams(org.summerb.easycrud.api.dto.PagerParams) Test(org.junit.Test)

Example 13 with PagerParams

use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.

the class EasyCrudControllerBase method getList.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView getList(HttpServletResponse response) throws Exception {
    ModelAndView ret = new ModelAndView(viewNameForList);
    if (initialPageSize > 0) {
        ret.addObject(ATTR_LIST, service.query(new PagerParams(0, initialPageSize), null));
    }
    // TBD: Shouldn't we cache such things?
    Map<String, Boolean> perms = getPermissionsMapForCurrentUser();
    ret.addObject(ATTR_PERMISSIONS, gson.toJson(perms));
    return ret;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PagerParams(org.summerb.easycrud.api.dto.PagerParams) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with PagerParams

use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.

the class UserDaoImplTest method testFindUsersByDisplayNamePartial_expectCorrectSorting.

@Test
public // @Rollback(false)
void testFindUsersByDisplayNamePartial_expectCorrectSorting() throws Exception {
    User user = UserFactory.createNewUserTemplate();
    user.setDisplayName("ooUHapqoiwez");
    user.setEmail("email2@aaa.ru");
    userService.createUser(user);
    user = UserFactory.createNewUserTemplate();
    user.setDisplayName("oooUHapqoiwez");
    user.setEmail("email3@aaa.ru");
    userService.createUser(user);
    user = UserFactory.createNewUserTemplate();
    user.setDisplayName("oUHapqoiwez");
    user.setEmail("email1@aaa.ru");
    userService.createUser(user);
    PaginatedList<User> results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams());
    assertNotNull(results);
    List<User> items = results.getItems();
    assertNotNull(items);
    assertTrue(items.size() == 3);
    assertTrue(results.getTotalResults() == 3);
    assertEquals("email1@aaa.ru", items.get(0).getEmail());
    assertEquals("email2@aaa.ru", items.get(1).getEmail());
    assertEquals("email3@aaa.ru", items.get(2).getEmail());
}
Also used : User(org.summerb.users.api.dto.User) PagerParams(org.summerb.easycrud.api.dto.PagerParams) Test(org.junit.Test)

Example 15 with PagerParams

use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.

the class AuthTokenServiceDbImplFactory method createAuthTokenServiceDbImpl.

public static AuthTokenServiceImpl createAuthTokenServiceDbImpl() {
    AuthTokenServiceImpl ret = new AuthTokenServiceImpl();
    ret.setPasswordService(PasswordServiceDbImplFactory.createPasswordServiceDbImpl());
    ret.setUserService(UserServiceImplFactory.createUsersServiceImpl());
    AuthTokenDao authTokenDao = Mockito.mock(AuthTokenDao.class);
    ret.setAuthTokenDao(authTokenDao);
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXCEPTION)).thenThrow(new IllegalStateException("test simulate exception"));
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXISTENT)).thenReturn(AuthTokenFactory.createAuthTokenForExistentUser());
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_NOT_EXISTENT)).thenReturn(null);
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXPIRED)).thenReturn(AuthTokenFactory.createExpiredAuthToken());
    List<AuthToken> expiredTokens = new LinkedList<AuthToken>();
    expiredTokens.add(AuthTokenFactory.createExpiredAuthToken());
    PaginatedList<AuthToken> expiredAuthTokens = new PaginatedList<AuthToken>(new PagerParams(), expiredTokens, 1);
    return ret;
}
Also used : AuthTokenDao(org.summerb.users.impl.dao.AuthTokenDao) PagerParams(org.summerb.easycrud.api.dto.PagerParams) AuthToken(org.summerb.users.api.dto.AuthToken) PaginatedList(org.summerb.easycrud.api.dto.PaginatedList) LinkedList(java.util.LinkedList)

Aggregations

PagerParams (org.summerb.easycrud.api.dto.PagerParams)31 Test (org.junit.Test)27 PaginatedList (org.summerb.easycrud.api.dto.PaginatedList)6 EasyCrudService (org.summerb.easycrud.api.EasyCrudService)3 Query (org.summerb.easycrud.api.query.Query)3 User (org.summerb.users.api.dto.User)3 TestDto1 (integr.org.summerb.easycrud.TestDto1)2 HasId (org.summerb.easycrud.api.dto.HasId)2 AliasEntry (org.summerb.properties.impl.dao.AliasEntry)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Entry (java.util.Map.Entry)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 Attachment (org.summerb.minicms.api.dto.Attachment)1 PropertyServiceUnexpectedException (org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException)1 StringIdAliasDao (org.summerb.properties.impl.dao.StringIdAliasDao)1 AuthToken (org.summerb.users.api.dto.AuthToken)1 AuthTokenDao (org.summerb.users.impl.dao.AuthTokenDao)1