use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method emptyRoleTypeSearchTest.
@Test
public void emptyRoleTypeSearchTest() throws Exception {
ObjectQuery query = QueryBuilder.queryFor(RoleType.class, prismContext).item(RoleType.F_ROLE_TYPE).isNull().build();
OperationResult result = new OperationResult("search");
List<PrismObject<RoleType>> roles = repositoryService.searchObjects(RoleType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find two roles", 2, roles.size());
int judge = roles.get(0).getName().getOrig().startsWith("J") ? 0 : 1;
assertEquals("Wrong role1 name", "Judge", roles.get(judge).getName().getOrig());
assertEquals("Wrong role2 name", "Admin-owned role", roles.get(1 - judge).getName().getOrig());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method testMultivaluedExtensionPropertySubstringUnqualified.
@Test
public void testMultivaluedExtensionPropertySubstringUnqualified() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(GenericObjectType.class, prismContext).item(ObjectType.F_EXTENSION, new QName("multivalued")).contains("slava").build();
OperationResult result = new OperationResult("search");
List<PrismObject<GenericObjectType>> resources = repositoryService.searchObjects(GenericObjectType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one object", 1, resources.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method testOperationExecutionAny.
@Test
public void testOperationExecutionAny() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(CaseType.class, prismContext).item(ObjectType.F_OPERATION_EXECUTION, OperationExecutionType.F_STATUS).eq(OperationResultStatusType.FATAL_ERROR).build();
OperationResult result = new OperationResult("search");
List<PrismObject<CaseType>> cases = repositoryService.searchObjects(CaseType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one object", 1, cases.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method testOperationExecutionWithTask.
@Test
public void testOperationExecutionWithTask() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(CaseType.class, prismContext).exists(ObjectType.F_OPERATION_EXECUTION).block().item(OperationExecutionType.F_TASK_REF).ref("task-oid-2").and().item(OperationExecutionType.F_STATUS).eq(OperationResultStatusType.SUCCESS).endBlock().build();
OperationResult result = new OperationResult("search");
List<PrismObject<CaseType>> cases = repositoryService.searchObjects(CaseType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one object", 1, cases.size());
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchTest method roleMembershipSearchTest.
@Test
public void roleMembershipSearchTest() throws Exception {
PrismReferenceValue r456 = new PrismReferenceValue("r456", RoleType.COMPLEX_TYPE);
r456.setRelation(SchemaConstants.ORG_DEFAULT);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r456).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 r123 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r123).build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find two users", 2, users.size());
PrismReferenceValue r123approver = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
r123approver.setRelation(SchemaConstants.ORG_APPROVER);
query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ROLE_MEMBERSHIP_REF).ref(r123approver).build();
users = repositoryService.searchObjects(UserType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find no users", 0, users.size());
}
Aggregations