use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method testExtensionReferenceNull.
@Test
public void testExtensionReferenceNull() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(GenericObjectType.class, prismContext).item(ObjectType.F_EXTENSION, new QName("referenceType")).isNull().build();
OperationResult result = new OperationResult("search");
List<PrismObject<GenericObjectType>> cases = repositoryService.searchObjects(GenericObjectType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find no object", 0, cases.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method caseSensitiveSearchTest.
@Test
public void caseSensitiveSearchTest() throws Exception {
final String existingNameOrig = "Test UserX00003";
final String nonExistingNameOrig = "test UserX00003";
final String nameNorm = "test userx00003";
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_FULL_NAME).eqPoly(existingNameOrig, nameNorm).matchingOrig().build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_FULL_NAME).eqPoly(nonExistingNameOrig, nameNorm).matchingOrig().build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Found user (shouldn't) because case insensitive search was used", 0, users.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method iterateEmptySet.
@Test
public void iterateEmptySet() throws Exception {
OperationResult result = new OperationResult("search empty");
ResultHandler handler = (object, parentResult) -> {
fail();
return false;
};
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eqPoly("asdf", "asdf").matchingStrict().build();
repositoryService.searchObjectsIterative(UserType.class, query, handler, null, false, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method testShadowPendingOperation.
@Test
public void testShadowPendingOperation() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext).exists(ShadowType.F_PENDING_OPERATION).build();
OperationResult result = new OperationResult("search");
List<PrismObject<ShadowType>> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one object", 1, shadows.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method personaSearchTest.
@Test
public void personaSearchTest() throws Exception {
PrismReferenceValue u000 = new PrismReferenceValue("u000", UserType.COMPLEX_TYPE);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_PERSONA_REF).ref(u000).build();
OperationResult result = new OperationResult("search");
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00003", users.get(0).getName().getOrig());
PrismReferenceValue r789 = new PrismReferenceValue("r789", RoleType.COMPLEX_TYPE);
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_PERSONA_REF).ref(r789).build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find no users", 0, users.size());
}
Aggregations