Search in sources :

Example 86 with ObjectQuery

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());
}
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 87 with ObjectQuery

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());
}
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 88 with ObjectQuery

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());
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) Test(org.testng.annotations.Test) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) DeltaBuilder(com.evolveum.midpoint.prism.delta.builder.DeltaBuilder) Objectable(com.evolveum.midpoint.prism.Objectable) BeforeClass(org.testng.annotations.BeforeClass) PrismObject(com.evolveum.midpoint.prism.PrismObject) AssertJUnit.fail(org.testng.AssertJUnit.fail) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) File(java.io.File) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) SystemException(com.evolveum.midpoint.util.exception.SystemException) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QName(javax.xml.namespace.QName) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 89 with ObjectQuery

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());
}
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 90 with ObjectQuery

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());
}
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