use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUserInum_userId_inum.
@Test
private void getUserInum_userId_inum() {
User user = spy(getBasicUser("123", "dn123"));
when(user.getAttribute("inum")).thenReturn("inumExample");
when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(user));
String inum = userService.getUserInum("123");
assertNotNull(inum);
assertEquals(inum, "inumExample");
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUserInum_userNull_null.
@Test
private void getUserInum_userNull_null() {
User user = null;
String inum = userService.getUserInum(user);
assertNull(inum);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUsersWithPersistentJwts_noParams_listUsers.
@Test
private void getUsersWithPersistentJwts_noParams_listUsers() {
String userId = "123";
String baseDn = "dn123";
when(persistenceEntryManager.findEntries(anyString(), any(), any())).thenReturn(getListBasicOneUser(userId, baseDn));
List<User> list = userService.getUsersWithPersistentJwts();
assertNotNull(list);
assertTrue(list.size() == 1);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method addDefaultUser_withUidNoEmptyPersonCustomObject_user.
@Test
private void addDefaultUser_withUidNoEmptyPersonCustomObject_user() {
String uid = UUID.randomUUID().toString();
User user = getBasicUser(uid, "dn123");
user.setCustomObjectClasses(TestUserService.DEFAULT_PERSON_CUSTOM_OBJECT_CLASS_LIST);
doNothing().when(persistenceEntryManager).persist(any());
when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(user));
when(inumService.generatePeopleInum()).thenReturn(uid);
userService.setReturnTestListPersonCustomObjectClassList(true);
User resultUser = userService.addDefaultUser(uid);
assertNotNull(resultUser);
assertNotNull(resultUser.getUserId());
assertEquals(resultUser.getUserId(), uid);
assertTrue(resultUser.getCustomObjectClasses().length == 2);
assertTrue(resultUser.getCustomObjectClasses()[0].equals(user.getCustomObjectClasses()[0]));
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method removeUserAttribute_noExistentAttribute_null.
@Test
private void removeUserAttribute_noExistentAttribute_null() {
String userId = "123";
String baseDn = "dn123";
User user = spy(getBasicUser("123", "dn123"));
CustomObjectAttribute customAttribute1 = new CustomObjectAttribute("attribute1", "value1");
user.setCustomAttributes(new ArrayList<>());
user.getCustomAttributes().add(customAttribute1);
when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(getListBasicOneUser(userId, baseDn));
User resultUser = userService.removeUserAttributeValue(userId, "attribute2", "value2");
assertNull(resultUser);
}
Aggregations