Search in sources :

Example 91 with ObjectQuery

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 92 with ObjectQuery

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 93 with ObjectQuery

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 94 with ObjectQuery

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 95 with ObjectQuery

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)697 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)453 Test (org.testng.annotations.Test)335 PrismObject (com.evolveum.midpoint.prism.PrismObject)284 Task (com.evolveum.midpoint.task.api.Task)268 QName (javax.xml.namespace.QName)111 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)78 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)76 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)64 ArrayList (java.util.ArrayList)61 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)58 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)53 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)41 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)41 SystemException (com.evolveum.midpoint.util.exception.SystemException)38 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)37 NotNull (org.jetbrains.annotations.NotNull)35 List (java.util.List)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27