use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getCustomAttribute_existentAttribute_user.
@Test
private void getCustomAttribute_existentAttribute_user() {
User user = spy(getBasicUser("123", "dn123"));
CustomObjectAttribute customAttribute1 = new CustomObjectAttribute("attribute1", "value1");
CustomObjectAttribute customAttribute2 = new CustomObjectAttribute("attribute2", "value2");
user.setCustomAttributes(new ArrayList<>());
user.getCustomAttributes().add(customAttribute1);
user.getCustomAttributes().add(customAttribute2);
CustomObjectAttribute resultAttribute = userService.getCustomAttribute(user, "attribute1");
assertNotNull(resultAttribute);
assertEquals(resultAttribute.getName(), "attribute1");
assertEquals(resultAttribute.getValue(), "value1");
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUserByInum_validDnWithAttributes_user.
@Test
private void getUserByInum_validDnWithAttributes_user() {
when(persistenceEntryManager.find(anyString(), any(), any())).thenReturn(new User());
User user = userService.getUserByInum("123", null);
assertNotNull(user);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method addUserAttributeByUserInum_existentAttributeNoValue_user.
@Test
private void addUserAttributeByUserInum_existentAttributeNoValue_user() {
String inumUser = "inumUser";
User user = spy(getBasicUser("123", "dn123"));
user.setDn("dn123");
CustomObjectAttribute customAttribute1 = new CustomObjectAttribute("attribute1", "value1");
CustomObjectAttribute customAttribute2 = new CustomObjectAttribute("attribute2", "value2");
user.setCustomAttributes(new ArrayList<>());
user.getCustomAttributes().add(customAttribute1);
user.getCustomAttributes().add(customAttribute2);
when(persistenceEntryManager.find(any(), any(), any())).thenReturn(user);
doNothing().when(persistenceEntryManager).merge(user);
User resultUser = userService.addUserAttributeByUserInum(inumUser, "attribute2", "value3");
assertNotNull(resultUser);
assertTrue(resultUser.getCustomAttributes().size() == 2);
assertEquals(resultUser.getCustomAttributes().get(0).getName(), "attribute1");
assertEquals(resultUser.getCustomAttributes().get(0).getValue(), "value1");
assertEquals(resultUser.getCustomAttributes().get(1).getName(), "attribute2");
assertTrue(resultUser.getCustomAttributes().get(1).getValues().size() == 2);
assertEquals(resultUser.getCustomAttributes().get(1).getValues().get(0), "value2");
assertEquals(resultUser.getCustomAttributes().get(1).getValues().get(1), "value3");
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getCustomAttribute_noExistentAttribute_null.
@Test
private void getCustomAttribute_noExistentAttribute_null() {
User user = spy(getBasicUser("123", "dn123"));
user.setCustomAttributes(new ArrayList<>());
CustomObjectAttribute resultAttribute = userService.getCustomAttribute(user, "attribute1");
assertNull(resultAttribute);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUser_findEmpty_null.
@Test
private void getUser_findEmpty_null() {
String userId = "123";
when(dataSourceTypeService.isSpanner(anyString())).thenReturn(true);
when(persistenceEntryManager.findEntries(anyString(), any(), any(), any())).thenReturn(new ArrayList<>());
User user = userService.getUser(userId, null);
assertNull(user);
}
Aggregations