Search in sources :

Example 81 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class ConsistencyTest method test284ModifyObjectAssignToGroupCommunicationProblem.

@Test
public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Exception {
    final String TEST_NAME = "test284ModifyObjectAssignToGroupCommunicationProblem";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance();
    OperationResult parentResult = new OperationResult(TEST_NAME);
    // GIVEN
    openDJController.addEntriesFromLdifFile(LDIF_CREATE_ADMINS_GROUP_FILENAME);
    ObjectQuery filter = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext);
    SearchResultList<PrismObject<ShadowType>> shadows = modelService.searchObjects(ShadowType.class, filter, null, task, parentResult);
    for (PrismObject<ShadowType> shadow : shadows) {
        LOGGER.info("SHADOW ===> {}", shadow.debugDump());
    }
    // WHEN
    openDJController.assumeStopped();
    String accountOid = assertUserOneAccountRef(USER_DONALD_OID);
    requestToExecuteChanges(REQUEST_USER_MODIFY_ASSIGN_ROLE_ADMINS, USER_DONALD_OID, UserType.class, task, null, parentResult);
    // Get user's account with noFetch option - changes shouldn't be applied, bud should be still saved in shadow
    PrismObject<ShadowType> johnAccount = modelService.getObject(ShadowType.class, accountOid, GetOperationOptions.createNoFetchCollection(), task, parentResult);
    ShadowType johnAccountType = checkPostponedAccountBasic(johnAccount, FailedOperationTypeType.MODIFY, true, parentResult);
    ObjectDelta deltaInAccount = DeltaConvertor.createObjectDelta(johnAccountType.getObjectChange(), prismContext);
    assertTrue("Delta stored in account must contain association modification", deltaInAccount.hasItemDelta(new ItemPath(ShadowType.F_ASSOCIATION)));
    //		assertFalse("Delta stored in account must not contain employeeType modification", deltaInAccount.hasItemDelta(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(resourceTypeOpenDjrepo.getNamespace(), "employeeType"))));
    assertNotNull("Donald's account must contain reference on the resource", johnAccountType.getResourceRef());
    //THEN recompute the user - postponed changes should be applied
    openDJController.assumeRunning();
    LOGGER.info("recompute user - account with weak mapping after stopping opendj.");
    ObjectDelta<UserType> emptyDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_DONALD_OID, prismContext);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    deltas.add(emptyDelta);
    modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, parentResult);
    accountOid = assertUserOneAccountRef(USER_DONALD_OID);
    johnAccountType = checkNormalizedShadowWithAttributes(accountOid, "donald", "donalld", "trump", "donald trump", false, task, parentResult);
    openDJController.assertUniqueMember("cn=admins,ou=groups,dc=example,dc=com", "uid=donald,ou=people,dc=example,dc=com");
//TODO: check on user if it was processed successfully (add this check also to previous (30) test..
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 82 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class TestOpenDj method test202SearchObjectsCompexFilter.

@Test
public void test202SearchObjectsCompexFilter() throws Exception {
    final String TEST_NAME = "test202SearchObjectsCompexFilter";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    provisioningService.applyDefinition(ShadowType.class, query, task, result);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    List<PrismObject<ShadowType>> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    for (PrismObject<ShadowType> objType : objListType) {
        assertNotNull("Null search result", objType);
        display("found object", objType);
    }
    assertEquals("Unexpected number of objects found", 1, objListType.size());
    assertConnectorOperationIncrement(1, 3);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 83 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class TestOpenDj method test250CountObjects.

@Test
public void test250CountObjects() throws Exception {
    final String TEST_NAME = "test250CountObjects";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    // WHEN
    Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    assertSuccess(result);
    assertEquals("Unexpected number of search results", (Integer) 14, count);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 84 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class SearchTest method testMultivaluedExtensionPropertyEqualsQualified.

@Test
public void testMultivaluedExtensionPropertyEqualsQualified() throws SchemaException {
    ObjectQuery query = QueryBuilder.queryFor(GenericObjectType.class, prismContext).item(ObjectType.F_EXTENSION, new QName("http://example.com/p", "multivalued")).eq("Bratislava").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 85 with ObjectQuery

use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.

the class SearchTest method roleAssignmentSearchTest.

@Test
public void roleAssignmentSearchTest() throws Exception {
    PrismReferenceValue r456 = new PrismReferenceValue("r123", RoleType.COMPLEX_TYPE);
    ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_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", "atestuserX00002", users.get(0).getName().getOrig());
}
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