use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class MultipleResourcesSearchTest method search6.
@Test(dependsOnMethods = "search5")
public void search6() {
// Irrelevant since no results will be returned
sr.setStartIndex(5);
// Returns no resources, only total
sr.setCount(0);
Response response = client.searchResourcesPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
assertEquals(listResponse.getTotalResults(), anotherLR.getTotalResults());
assertNull(anotherLR.getResources());
// unassigned
assertEquals(anotherLR.getItemsPerPage(), 0);
// unassigned
assertEquals(anotherLR.getStartIndex(), 0);
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class MultipleResourcesSearchTest method search2.
@Test(dependsOnMethods = "search1")
public void search2() {
// Move forward the start index
sr.setStartIndex(2);
Response response = client.searchResourcesPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
// Verify one result less was returned
assertEquals(listResponse.getTotalResults(), anotherLR.getResources().size() + 1);
assertEquals(anotherLR.getResources().size(), anotherLR.getItemsPerPage());
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class MultipleResourcesSearchTest method search4.
@Test(dependsOnMethods = "search3")
public void search4() {
// Verify there are no results when start index is greater than the number of available results
sr.setStartIndex(listResponse.getTotalResults() + 1);
Response response = client.searchResourcesPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
// unassigned
assertEquals(anotherLR.getItemsPerPage(), 0);
// unassigned
assertEquals(anotherLR.getStartIndex(), 0);
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class SimpleSearchUserTest method searchComplexAttrPost.
@Test(dependsOnMethods = "create", groups = "search")
public void searchComplexAttrPost() {
String givenName = user.getName().getGivenName();
logger.debug("Searching user with attribute givenName = {} using POST verb", givenName);
SearchRequest sr = new SearchRequest();
sr.setFilter("name.givenName eq \"" + givenName + "\"");
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
assertTrue(listResponse.getResources().size() > 0);
// Retrieve first user in results
UserResource other = listResponse.getResources().stream().map(usrClass::cast).findFirst().get();
assertEquals(other.getName().getGivenName(), givenName);
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class SimpleSearchUserTest method searchComplexMultivaluedPost.
@Test(dependsOnMethods = "create", groups = "search")
public void searchComplexMultivaluedPost() {
String ghost = user.getEmails().get(0).getValue();
final String host = ghost.substring(ghost.indexOf("@") + 1);
logger.debug("Searching user with attribute emails.value like {} or phone numbers with type unassigned or value containing '+' using POST verb", host);
SearchRequest sr = new SearchRequest();
sr.setFilter("emails[value ew \"" + host + "\"] or urn:ietf:params:scim:schemas:core:2.0:User:phoneNumbers[value co \"+\" or type eq null]");
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
assertTrue(listResponse.getResources().size() > 0);
// Retrieve first user in results
UserResource other = listResponse.getResources().stream().map(usrClass::cast).findFirst().get();
boolean cond1 = false, cond2 = false, cond3 = false;
if (other.getEmails() != null) {
cond1 = other.getEmails().stream().anyMatch(mail -> mail.getValue().endsWith(host));
}
if (other.getPhoneNumbers() != null) {
cond2 = other.getPhoneNumbers().stream().anyMatch(phone -> phone.getValue().contains("+"));
cond3 = other.getPhoneNumbers().stream().anyMatch(phone -> phone.getType() == null);
}
assertTrue(cond1 || cond2 || cond3);
}
Aggregations