use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class UserExtensionsTest method testCreatePersonFromJsonString.
@Test
@Parameters({ "test.scim2.userext.create_json" })
public void testCreatePersonFromJsonString(final String createJson) throws Exception {
System.out.println(" testCreatePersonFromJsonString() ");
// Create custom attributes
// String, not
GluuAttribute scimCustomFirst = null;
// multi-valued
if (attributeService.getAttributeByName("scimCustomFirst") == null) {
scimCustomFirst = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomFirst", "Custom First", "First custom attribute", GluuAttributeDataType.STRING, OxMultivalued.FALSE);
}
// Date, multi-valued
GluuAttribute scimCustomSecond = null;
if (attributeService.getAttributeByName("scimCustomSecond") == null) {
scimCustomSecond = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomSecond", "Custom Second", "Second custom attribute", GluuAttributeDataType.DATE, OxMultivalued.TRUE);
}
// Numeric, not
GluuAttribute scimCustomThird = null;
// multi-valued
if (attributeService.getAttributeByName("scimCustomThird") == null) {
scimCustomThird = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomThird", "Custom Third", "Third custom attribute", GluuAttributeDataType.NUMERIC, OxMultivalued.FALSE);
}
// String CREATEJSON =
// "{\"schemas\":[\"urn:ietf:params:scim:schemas:core:2.0:User\",\"urn:ietf:params:scim:schemas:extension:gluu:2.0:User\"],\"urn:ietf:params:scim:schemas:extension:gluu:2.0:User\":
// {\"scimCustomFirst\":\"[1000,2000]\",\"scimCustomSecond\":[\"2016-02-23T15:35:22Z\"],\"scimCustomThird\":3000},\"externalId\":\"scimclient\",\"userName\":\"userjson.add.username\",\"name\":{\"givenName\":\"json\",\"familyName\":\"json\",\"middleName\":\"N/A\",\"honorificPrefix\":\"N/A\",\"honorificSuffix\":\"N/A\"},\"displayName\":\"json
// json\",\"nickName\":\"json\",\"profileUrl\":\"http://www.gluu.org/\",\"emails\":[{\"value\":\"json@gluu.org\",\"type\":\"work\",\"primary\":\"true\"},{\"value\":\"json2@gluu.org\",\"type\":\"home\",\"primary\":\"false\"}],\"addresses\":[{\"type\":\"work\",\"streetAddress\":\"621
// East 6th Street Suite
// 200\",\"locality\":\"Austin\",\"region\":\"TX\",\"postalCode\":\"78701\",\"country\":\"US\",\"formatted\":\"621
// East 6th Street Suite 200 Austin , TX 78701
// US\",\"primary\":\"true\"}],\"phoneNumbers\":[{\"value\":\"646-345-2346\",\"type\":\"work\"}],\"ims\":[{\"value\":\"nynytest_user\",\"type\":\"Skype\"}],\"userType\":\"CEO\",\"title\":\"CEO\",\"preferredLanguage\":\"en-us\",\"locale\":\"en_US\",\"active\":\"true\",\"password\":\"secret\",\"roles\":[{\"value\":\"Owner\"}],\"entitlements\":[{\"value\":\"full
// access\"}],\"x509Certificates\":[{\"value\":\"MIIDQzCCAqygAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwTjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAoMC2V4YW1wbGUuY29tMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0xMTEwMjIwNjI0MzFaFw0xMjEwMDQwNjI0MzFa
// MH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQKDAtleGFtcGxlLmNvbTEhMB8GA1UEAwwYTXMuIEJhcmJhcmEgSiBKZW5zZW4gSUlJMSIwIAYJKoZIhvcNAQkBFhNiamVuc2VuQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7Kr+Dcds/JQ5GwejJFcBIP682X3xpjis56AK02bc1FLgzdLI8auoR+cC9/Vrh5t66HkQIOdA4unHh0AaZ4xL5PhVbXIPMB5vAPKpzz5iPSi8xO8SL7I7SDhcBVJhqVqr3HgllEG6UClDdHO7nkLuwXq8HcISKkbT5WFTVfFZzidPl8HZ7DhXkZIRtJwBweq4bvm3hM1Os7UQH05ZS6cVDgweKNwdLLrT51ikSQG3DYrl+ft781UQRIqxgwqCfXEuDiinPh0kkvIi5jivVu1Z9QiwlYEdRbLJ4zJQBmDrSGTMYn4lRc2HgHO4DqB/bnMVorHB0CC6AV1QoFK4GPe1LwIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU8pD0U0vsZIsaA16lL8En8bx0F/gwHwYDVR0jBBgwFoAUdGeKitcaF7gnzsNwDx708kqaVt0wDQYJKoZIhvcNAQEFBQADgYEAA81SsFnOdYJtNg5Tcq+/ByEDrBgnusx0jloUhByPMEVkoMZ3J7j1ZgI8rAbOkNngX8+pKfTiDz1RC4+dx8oU6Za+4NJXUjlL5CvV6BEYb1+QAEJwitTVvxB/A67g42/vzgAtoRUeDov1+GFiBZ+GNF/cAYKcMtGcrs2i97ZkJMo=\"}],\"meta\":{\"created\":\"2010-01-23T04:56:22Z\",\"lastModified\":\"2011-05-13T04:42:34Z\",\"version\":\"aversion\",\"location\":\"http://localhost:8080/identity/seam/resource/restv1/Users/8c4b6c26-efaf-4840-bddf-c0146a8eb2a9\"}}";
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, ""));
simpleModule.addDeserializer(User.class, new UserDeserializer());
mapper.registerModule(simpleModule);
User user = mapper.readValue(createJson, User.class);
String testUserName = user.getUserName() + " (" + System.currentTimeMillis() + ")";
user.setUserName(testUserName);
Extension extension = user.getExtension(Constants.USER_EXT_SCHEMA_ID);
assertNotNull(extension, "(Deserialization) Custom extension not deserialized.");
Extension.Field customFirstField = extension.getFields().get("scimCustomFirst");
assertNotNull(customFirstField, "(Deserialization) \"scimCustomFirst\" field not deserialized.");
assertEquals(customFirstField.getValue(), "[1000,2000]");
System.out.println("##### (Deserialization) customFirstField.getValue() = " + customFirstField.getValue());
Extension.Field customSecondField = extension.getFields().get("scimCustomSecond");
assertNotNull(customSecondField, "(Deserialization) \"scimCustomSecond\" field not deserialized.");
List<Date> dateList = Arrays.asList(mapper.readValue(customSecondField.getValue(), Date[].class));
assertEquals(dateList.size(), 1);
System.out.println("##### (Deserialization) dateList.get(0) = " + dateList.get(0));
Extension.Field customThirdField = extension.getFields().get("scimCustomThird");
assertNotNull(customThirdField, "(Deserialization) \"scimCustomThird\" field not deserialized.");
assertEquals(new BigDecimal(customThirdField.getValue()), new BigDecimal(3000));
System.out.println("##### (Deserialization) customThirdField.getValue() = " + customThirdField.getValue());
// Create Person
GluuCustomPerson gluuPerson = copyUtils2.copy(user, null, false);
assertNotNull(gluuPerson, "gluuPerson is null!");
System.out.println(">>>>> gluuPerson.getUid() = " + gluuPerson.getUid());
String inum = personService.generateInumForNewPerson();
String dn = personService.getDnForPerson(inum);
String iname = personService.generateInameForNewPerson(user.getUserName());
gluuPerson.setDn(dn);
gluuPerson.setInum(inum);
gluuPerson.setIname(iname);
gluuPerson.setCommonName(gluuPerson.getGivenName() + " " + gluuPerson.getSurname());
personService.addPerson(gluuPerson);
// Retrieve Person
GluuCustomPerson retrievedPerson = personService.getPersonByUid(gluuPerson.getUid());
assertNotNull(retrievedPerson, "Failed to find person.");
User newPerson = copyUtils2.copy(retrievedPerson, null);
extension = newPerson.getExtension(Constants.USER_EXT_SCHEMA_ID);
assertNotNull(extension, "(Persistence) Custom extension not persisted.");
customFirstField = extension.getFields().get("scimCustomFirst");
assertNotNull(customFirstField, "(Persistence) \"scimCustomFirst\" field not persisted.");
assertEquals(customFirstField.getValue(), "[1000,2000]");
System.out.println("##### (Persistence) customFirstField.getValue() = " + customFirstField.getValue());
customSecondField = extension.getFields().get("scimCustomSecond");
assertNotNull(customSecondField, "(Persistence) \"scimCustomSecond\" field not persisted.");
dateList = Arrays.asList(mapper.readValue(customSecondField.getValue(), Date[].class));
assertEquals(dateList.size(), 1);
System.out.println("##### (Persistence) dateList.get(0) = " + dateList.get(0));
customThirdField = extension.getFields().get("scimCustomThird");
assertNotNull(customThirdField, "(Persistence) \"scimCustomThird\" field not persisted.");
assertEquals(new BigDecimal(customThirdField.getValue()), new BigDecimal(3000));
System.out.println("##### (Persistence) customThirdField.getValue() = " + customThirdField.getValue());
// Remove Person
memberService.removePerson(retrievedPerson);
// Remove custom attributes
// schemaService.removeAttributeTypeFromObjectClass(scimCustomFirst.getOrigin(),
// scimCustomFirst.getName());
// schemaService.removeStringAttribute(scimCustomFirst.getName());
// attributeService.removeAttribute(scimCustomFirst);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomSecond.getOrigin(),
// scimCustomSecond.getName());
// schemaService.removeStringAttribute(scimCustomSecond.getName());
// attributeService.removeAttribute(scimCustomSecond);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomThird.getOrigin(),
// scimCustomThird.getName());
// schemaService.removeStringAttribute(scimCustomThird.getName());
// attributeService.removeAttribute(scimCustomThird);
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1MixedCreate.
@Test
public void testCopyScim1MixedCreate() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
ScimPerson source = new ScimPerson();
source.setActive("false");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setLocality(null);
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("");
meta.setLastModified("");
meta.setLocation("");
meta.setVersion("");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("");
source.setTitle("title");
source.setUserName("userName");
source.setUserType("userType");
source.setX509Certificates(null);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNotNull(copy);
assertEquals(copy.getUid(), "userName");
assertEquals(copy.getGivenName(), "givenName");
assertEquals(copy.getSurname(), "familyName");
assertEquals(copy.getDisplayName(), "displayName");
assertNull(copy.getPreferredLanguage());
assertNull(copy.getTimezone());
assertEquals(copy.getUserPassword(), "password");
assertNotNull(copy.getMemberOf());
assertEquals(copy.getMemberOf().size(), 0);
assertEquals(copy.getAttribute(GLUU_STATUS), "false");
assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
assertNull(copy.getAttribute(OX_TRUST_REGION));
assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
assertNull(copy.getAttribute(OX_TRUST_STREET));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
assertNull(copy.getAttribute(OX_TRUST_META_LOCATION));
assertNull(copy.getAttribute(OX_TRUST_META_VERSION));
assertNull(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED));
assertNull(copy.getAttribute(OX_TRUST_META_CREATED));
assertNull(copy.getAttribute(OX_TRUSTX509_CERTIFICATE));
assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "false");
assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":null,\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"\",\"primary\":\"address_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1EmptyCreate.
@Test
public void testCopyScim1EmptyCreate() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
ScimPerson source = new ScimPerson();
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNull(copy);
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1FilledMultipleAttributesCreate.
@Test
public void testCopyScim1FilledMultipleAttributesCreate() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
ScimPerson source = new ScimPerson();
source.setActive("true");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
ScimCustomAttributes customattribute = new ScimCustomAttributes();
customattribute.setName("custom_name");
List<String> values = new ArrayList<String>();
values.add("value1");
values.add("value3");
values.add("value2");
values.add("value4");
customattribute.setValues(values);
customAttributes.add(customattribute);
source.setCustomAttributes(customAttributes);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group1 = new ScimPersonGroups();
group1.setDisplay("group_display");
group1.setValue("group_value");
ScimPersonGroups group2 = new ScimPersonGroups();
group2.setDisplay("group_display1");
group2.setValue("group_value1");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group1);
groups.add(group2);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("userName");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNotNull(copy);
assertEquals(copy.getUid(), "userName");
assertEquals(copy.getGivenName(), "givenName");
assertEquals(copy.getSurname(), "familyName");
assertEquals(copy.getDisplayName(), "displayName");
assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
assertEquals(copy.getTimezone(), "timezone");
assertEquals(copy.getUserPassword(), "password");
assertNotNull(copy.getMemberOf());
assertEquals(copy.getMemberOf().size(), 2);
assertEquals(copy.getMemberOf().get(0), "Mocked DN");
assertEquals(copy.getMemberOf().get(1), "Mocked DN1");
assertEquals(copy.getAttribute(GLUU_STATUS), "true");
assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
assertNull(copy.getAttribute(OX_TRUST_REGION));
assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
assertNull(copy.getAttribute(OX_TRUST_STREET));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "true");
assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class CopyUtilsTestCreate method testCopyScim1FilledNullCustomAttributesCreate.
@Test
public void testCopyScim1FilledNullCustomAttributesCreate() throws Exception {
GluuCustomPerson destination = new GluuCustomPerson();
ScimPerson source = new ScimPerson();
source.setActive("active");
ScimPersonAddresses address = new ScimPersonAddresses();
address.setCountry("country");
address.setFormatted("formatted");
address.setLocality("locality");
address.setPostalCode("postalCode");
address.setPrimary("address_primary");
address.setRegion("region");
address.setStreetAddress("streetAddress");
address.setType("address_type");
List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
addresses.add(address);
source.setAddresses(addresses);
source.setCustomAttributes(null);
source.setDisplayName("displayName");
ScimPersonEmails email = new ScimPersonEmails();
email.setPrimary("email_primary");
email.setType("email_type");
email.setValue("email_value");
List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
emails.add(email);
source.setEmails(emails);
ScimEntitlements entitlement = new ScimEntitlements();
entitlement.setValue("entitlement_value");
List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
entitlements.add(entitlement);
source.setEntitlements(entitlements);
source.setExternalId("externalId");
ScimPersonGroups group1 = new ScimPersonGroups();
group1.setDisplay("group_display");
group1.setValue("group_value");
ScimPersonGroups group2 = new ScimPersonGroups();
group2.setDisplay("group_display1");
group2.setValue("group_value1");
List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
groups.add(group1);
groups.add(group2);
source.setGroups(groups);
source.setId("id");
ScimPersonIms personims = new ScimPersonIms();
personims.setType("ims_type");
personims.setValue("ims_value");
List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
ims.add(personims);
source.setIms(ims);
source.setLocale("locale");
PersonMeta meta = new PersonMeta();
meta.setCreated("created");
meta.setLastModified("lastModified");
meta.setLocation("location");
meta.setVersion("version");
source.setMeta(meta);
ScimName name = new ScimName();
name.setFamilyName("familyName");
name.setGivenName("givenName");
name.setHonorificPrefix("honorificPrefix");
name.setHonorificSuffix("honorificSuffix");
name.setMiddleName("middleName");
source.setName(name);
source.setNickName("nickName");
source.setPassword("password");
ScimPersonPhones phonenumber = new ScimPersonPhones();
phonenumber.setType("phone_type");
phonenumber.setValue("phone_value");
List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
phoneNumbers.add(phonenumber);
source.setPhoneNumbers(phoneNumbers);
ScimPersonPhotos photo = new ScimPersonPhotos();
photo.setType("photo_type");
photo.setValue("photo_value");
List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
photos.add(photo);
source.setPhotos(photos);
source.setPreferredLanguage("preferredLanguage");
source.setProfileUrl("profileUrl");
ScimRoles role = new ScimRoles();
role.setValue("role_value");
List<ScimRoles> roles = new ArrayList<ScimRoles>();
roles.add(role);
source.setRoles(roles);
List<String> schemas = new ArrayList<String>();
schemas.add("shema");
source.setSchemas(schemas);
source.setTimezone("timezone");
source.setTitle("title");
source.setUserName("userName");
source.setUserType("userType");
Scimx509Certificates cert = new Scimx509Certificates();
cert.setValue("cert_value");
List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
x509Certificates.add(cert);
source.setX509Certificates(x509Certificates);
GluuCustomPerson copy = copyUtils.copy(source, destination, false);
assertNotNull(copy);
assertEquals(copy.getUid(), "userName");
assertEquals(copy.getGivenName(), "givenName");
assertEquals(copy.getSurname(), "familyName");
assertEquals(copy.getDisplayName(), "displayName");
assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
assertEquals(copy.getTimezone(), "timezone");
assertEquals(copy.getUserPassword(), "password");
assertNotNull(copy.getMemberOf());
assertEquals(copy.getMemberOf().size(), 2);
assertEquals(copy.getMemberOf().get(0), "Mocked DN");
assertEquals(copy.getMemberOf().get(1), "Mocked DN1");
assertNull(copy.getAttribute(GLUU_STATUS));
assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
assertNull(copy.getAttribute(OX_TRUST_REGION));
assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
assertNull(copy.getAttribute(OX_TRUST_STREET));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "active");
assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
}
Aggregations