use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method addDefaultUser_withUidEmptyPersonCustomObject_user.
@Test
private void addDefaultUser_withUidEmptyPersonCustomObject_user() {
String uid = UUID.randomUUID().toString();
User user = getBasicUser(uid, "dn123");
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(false);
User resultUser = userService.addDefaultUser(uid);
assertNotNull(resultUser);
assertNotNull(resultUser.getUserId());
assertEquals(resultUser.getUserId(), uid);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUniqueUserByAttributes_attributeNamesEmpty_null.
@Test
private void getUniqueUserByAttributes_attributeNamesEmpty_null() {
List<String> lisAttributes = new ArrayList<>();
User resultUser = userService.getUniqueUserByAttributes(lisAttributes, null);
assertNull(resultUser);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUniqueUserByAttributes_exceptionFindEntriesNull_null.
@Test
private void getUniqueUserByAttributes_exceptionFindEntriesNull_null() {
String attributeName = "attribute1";
String attributeValue = "value1";
List<String> lisAttributes = new ArrayList<>();
lisAttributes.add(attributeName);
when(persistenceEntryManager.findEntries(any())).thenReturn(null);
User resultUser = userService.getUniqueUserByAttributes(lisAttributes, attributeValue);
assertNull(resultUser);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method addUserAttribute_newAttribute_user.
@Test
private void addUserAttribute_newAttribute_user() {
String attributeName = "attribute1";
String attributeValue = "value1";
User user = spy(getBasicUser("123", "dn123"));
user.setCustomAttributes(new ArrayList<>());
Boolean result = userService.addUserAttribute(user, attributeName, attributeValue, null);
assertTrue(result);
assertTrue(user.getCustomAttributes().size() == 1);
assertEquals(user.getCustomAttributes().get(0).getName(), attributeName);
assertEquals(user.getCustomAttributes().get(0).getValue(), attributeValue);
}
use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserServiceTest method getUniqueUserByAttributes_attributeNamesSizeOne_null.
@Test
private void getUniqueUserByAttributes_attributeNamesSizeOne_null() {
String userId = "123";
String baseDn = "baseDn";
String attributeName = "attribute1";
String attributeValue = "value1";
List<String> lisAttributes = new ArrayList<>();
lisAttributes.add(attributeName);
when(persistenceEntryManager.findEntries(any())).thenReturn(getListBasicOneUser(userId, baseDn));
User resultUser = userService.getUniqueUserByAttributes(lisAttributes, attributeValue);
assertNotNull(resultUser);
}
Aggregations