Search in sources :

Example 1 with Address

use of io.jans.scim.model.scim2.user.Address in project jans by JanssenProject.

the class PatchValueFilterUserTest method getDummyUser.

private UserResource getDummyUser() {
    user = new UserResource();
    user.setUserName("" + System.currentTimeMillis());
    user.setEmails(new ArrayList<>());
    user.setPhoneNumbers(new ArrayList<>());
    Email email = new Email();
    email.setValue("bjane@gluu.org");
    email.setDisplay("bjane");
    email.setPrimary(true);
    email.setType("work");
    user.getEmails().add(email);
    email = new Email();
    email.setValue("bjane@acme.org");
    email.setDisplay("bjane acme");
    email.setType("hobby");
    user.getEmails().add(email);
    PhoneNumber pn = new PhoneNumber();
    pn.setValue("+57 1234 56789");
    pn.setType("home");
    user.getPhoneNumbers().add(pn);
    pn = new PhoneNumber();
    pn.setValue("+1 1234 56789");
    pn.setType("work");
    pn.setPrimary(true);
    user.getPhoneNumbers().add(pn);
    Address address = new Address();
    address.setCountry("EG");
    address.setPrimary(false);
    address.setRegion("Somewhere");
    address.setStreetAddress("59 Acacia avenue");
    address.setLocality("Donington");
    user.setAddresses(Collections.singletonList(address));
    return user;
}
Also used : Email(io.jans.scim.model.scim2.user.Email) Address(io.jans.scim.model.scim2.user.Address) UserResource(io.jans.scim.model.scim2.user.UserResource) PhoneNumber(io.jans.scim.model.scim2.user.PhoneNumber)

Example 2 with Address

use of io.jans.scim.model.scim2.user.Address in project jans by JanssenProject.

the class PatchReplaceUserTest method jsonPathPatch2.

@Parameters({ "user_patchreplace_4" })
@Test(dependsOnMethods = "jsonPathPatch1")
public void jsonPathPatch2(String patchRequest) {
    Response response = client.patchUser(patchRequest, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    assertNotEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
    assertNotEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
    assertNotEquals(user.getName().getFormatted(), other.getName().getFormatted());
    // Verify change in the streetAddress
    Address adr = other.getAddresses().get(0);
    assertNotEquals(user.getAddresses().get(0).getStreetAddress(), adr.getStreetAddress());
    // Verify postal code is there
    assertNotNull(adr.getPostalCode());
    // Verify change in phone number values
    int num = user.getPhoneNumbers().size();
    assertEquals(num, other.getPhoneNumbers().size());
    Set<String> set1 = user.getPhoneNumbers().stream().map(PhoneNumber::getValue).collect(Collectors.toSet());
    Set<String> set2 = other.getPhoneNumbers().stream().map(PhoneNumber::getValue).collect(Collectors.toSet());
    assertFalse(set2.removeAll(set1));
    // Verify x509Certs disappeared
    assertNotNull(other.getX509Certificates());
    user = other;
}
Also used : Response(javax.ws.rs.core.Response) Address(io.jans.scim.model.scim2.user.Address) InstantMessagingAddress(io.jans.scim.model.scim2.user.InstantMessagingAddress) UserResource(io.jans.scim.model.scim2.user.UserResource) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 3 with Address

use of io.jans.scim.model.scim2.user.Address in project jans by JanssenProject.

the class PatchReplaceUserTest method jsonNoPathPatch2.

@Parameters({ "user_patchreplace_2" })
@Test(dependsOnMethods = "jsonNoPathPatch1")
public void jsonNoPathPatch2(String patchRequest) {
    Response response = client.patchUser(patchRequest, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    assertNotEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
    assertNotEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
    assertNotEquals(user.getName().getFormatted(), other.getName().getFormatted());
    // Verify change in the streetAddress
    Address adr = other.getAddresses().get(0);
    assertNotEquals(user.getAddresses().get(0).getStreetAddress(), adr.getStreetAddress());
    // Verify other attributes were nulled
    assertNull(adr.getPostalCode());
    assertNull(adr.getRegion());
    // Verify change in number of phone numbers
    assertNotEquals(user.getPhoneNumbers().size(), other.getPhoneNumbers().size());
    // Verify new user has different phone numbers
    String phone = user.getPhoneNumbers().get(0).getValue();
    assertTrue(other.getPhoneNumbers().stream().map(PhoneNumber::getValue).noneMatch(phone::equals));
    // Verify x509Certs disappeared
    assertNull(other.getX509Certificates());
    // Verify "roles" are still there intact
    assertEquals(user.getRoles().size(), other.getRoles().size());
    assertEquals(user.getRoles().get(0).getValue(), other.getRoles().get(0).getValue());
    user = other;
}
Also used : Response(javax.ws.rs.core.Response) Address(io.jans.scim.model.scim2.user.Address) InstantMessagingAddress(io.jans.scim.model.scim2.user.InstantMessagingAddress) UserResource(io.jans.scim.model.scim2.user.UserResource) PhoneNumber(io.jans.scim.model.scim2.user.PhoneNumber) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Aggregations

Address (io.jans.scim.model.scim2.user.Address)3 UserResource (io.jans.scim.model.scim2.user.UserResource)3 InstantMessagingAddress (io.jans.scim.model.scim2.user.InstantMessagingAddress)2 PhoneNumber (io.jans.scim.model.scim2.user.PhoneNumber)2 UserBaseTest (io.jans.scim2.client.UserBaseTest)2 Response (javax.ws.rs.core.Response)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 Email (io.jans.scim.model.scim2.user.Email)1