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