use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserCachedTest method testUpdateUser_expectReferencesNonEqualityForReturnedDtos.
@Test
public void testUpdateUser_expectReferencesNonEqualityForReturnedDtos() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate.setDisplayName("Display name");
userToCreate = userService.createUser(userToCreate);
User foundUser = userService.getUserByUuid(userToCreate.getUuid());
userToCreate.setDisplayName("Another display name");
userService.updateUser(userToCreate);
User foundUserAgain = userService.getUserByUuid(userToCreate.getUuid());
assertTrue(foundUser != foundUserAgain);
assertTrue(foundUserAgain.getDisplayName().equals("Another display name"));
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserCachedTest method testPerformance_expectCacheFaster.
@Test
public void testPerformance_expectCacheFaster() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
int cycles = 1000;
long before = new Date().getTime();
for (int i = 0; i < cycles; i++) {
userService.getUserByUuid(userToCreate.getUuid());
}
long after = new Date().getTime() - before;
long beforeNonCached = new Date().getTime();
for (int i = 0; i < cycles; i++) {
userServiceNonCached.getUserByUuid(userToCreate.getUuid());
}
long afterNonCached = new Date().getTime() - beforeNonCached;
System.out.println("Cached: " + after + "ms");
System.out.println("Noncached: " + afterNonCached + "ms");
assertTrue(afterNonCached / 5 > after);
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserCachedTest method testGetUserByEmail_expectReferencesEqualityForReturnedDtos.
@Test
public void testGetUserByEmail_expectReferencesEqualityForReturnedDtos() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
User foundUser = userService.getUserByEmail(userToCreate.getEmail());
User foundUserCached = userService.getUserByEmail(userToCreate.getEmail());
assertTrue(foundUser == foundUserCached);
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserCachedTest method testGetUserByUuid_expectReferencesEqualityForReturnedDtos.
@Test
public void testGetUserByUuid_expectReferencesEqualityForReturnedDtos() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
User foundUser = userService.getUserByUuid(userToCreate.getUuid());
User foundUserCached = userService.getUserByUuid(userToCreate.getUuid());
assertTrue(foundUser == foundUserCached);
}
use of org.summerb.microservices.users.api.dto.User 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);
}
Aggregations