use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class TestAdHocCertification method test030ModifyIndigo.
@Test
public void test030ModifyIndigo() throws Exception {
// GIVEN
Task task = getTestTask();
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
when();
@SuppressWarnings({ "unchecked", "raw" }) ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_DESCRIPTION).replace("new description").item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED).asObjectDelta(USER_INDIGO_OID);
executeChanges(delta, null, task, result);
// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
SearchResultList<PrismObject<AccessCertificationCampaignType>> campaigns = getAllCampaigns(result);
assertEquals("Wrong # of campaigns", 2, campaigns.size());
AccessCertificationCampaignType campaign = campaigns.stream().filter(c -> MODIFICATION_CERT_DEF_OID.equals(c.asObjectable().getDefinitionRef().getOid())).findFirst().orElseThrow(() -> new AssertionError("No modification-triggered campaign")).asObjectable();
campaign = getCampaignWithCases(campaign.getOid());
display("campaign", campaign);
// beware, maybe not all details would match (in the future) - then adapt this test
assertSanityAfterCampaignStart(campaign, modificationCertificationDefinition, 1);
// no cases, no problems
assertPercentCompleteAll(campaign, 0, 0, 0);
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class BasePrimaryChangeAspect method resolveReferenceFromFilter.
private <O extends ObjectType, F extends ObjectType> List<ObjectReferenceType> resolveReferenceFromFilter(Class<O> clazz, SearchFilterType filter, String sourceDescription, LensContext<F> lensContext, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment.ExpressionEnvironmentBuilder<F, PrismValue, ItemDefinition<?>>().lensContext(lensContext).currentResult(result).currentTask(task).build());
try {
PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
VariablesMap variables = ModelImplUtils.getDefaultVariablesMap(getFocusObjectable(lensContext), null, null, systemConfiguration.asObjectable(), prismContext);
ObjectFilter origFilter = prismContext.getQueryConverter().parseFilter(filter, clazz);
ObjectFilter evaluatedFilter = ExpressionUtil.evaluateFilterExpressions(origFilter, variables, MiscSchemaUtil.getExpressionProfile(), mappingFactory.getExpressionFactory(), prismContext, " evaluating approverRef filter expression ", task, result);
if (evaluatedFilter == null) {
throw new SchemaException("Filter could not be evaluated in approverRef in " + sourceDescription + "; original filter = " + origFilter);
}
SearchResultList<PrismObject<O>> targets = repositoryService.searchObjects(clazz, prismContext.queryFactory().createQuery(evaluatedFilter), null, result);
return targets.stream().map(object -> ObjectTypeUtil.createObjectRef(object, prismContext)).collect(Collectors.toList());
} finally {
ModelExpressionThreadLocalHolder.popExpressionEnvironment();
}
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class AuditSearchTest method test520SearchByChangedItemOrAnotherChangedItem.
@Test
public void test520SearchByChangedItemOrAnotherChangedItem() throws SchemaException {
// result should be similar to changedItem.eq(multiple values)
when("searching audit filtered by changed item OR another changed item");
SearchResultList<AuditEventRecordType> result = searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(UserType.F_ADDITIONAL_NAME)).or().item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(UserType.F_FAMILY_NAME)).build(), SelectorOptions.create(GetOperationOptions.createDistinct()));
then("only audit events having either of (and/or) specified changed items are returned");
assertThat(result).hasSize(2);
assertThat(result).extracting(aer -> aer.getParameter()).containsExactlyInAnyOrder("1", "2");
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class AuditSearchTest method test270SearchByChangedItemsMultipleValues.
@Test
public void test270SearchByChangedItemsMultipleValues() throws SchemaException {
// this tests multiple values for JOIN path
when("searching audit by changed items equal to multiple values");
SearchResultList<AuditEventRecordType> result = searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(UserType.F_ADDITIONAL_NAME), new ItemPathType(UserType.F_FAMILY_NAME)).build(), SelectorOptions.create(GetOperationOptions.createDistinct()));
then("audit events with changed items equal to any of the specified values are returned");
assertThat(result).hasSize(2);
assertThat(result).extracting(aer -> aer.getParameter()).containsExactlyInAnyOrder("1", "2");
}
use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.
the class SqaleRepoSearchTest method searchCaseWorkItemByOutcome.
private void searchCaseWorkItemByOutcome(String wiOutcome, String... expectedCaseOids) throws Exception {
when("searching case with query for workitem/output/outcome " + wiOutcome);
OperationResult operationResult = createOperationResult();
SearchResultList<CaseType> result = searchObjects(CaseType.class, prismContext.queryFor(CaseType.class).item(CaseType.F_WORK_ITEM, CaseWorkItemType.F_OUTPUT, AbstractWorkItemOutputType.F_OUTCOME).eq(wiOutcome).build(), operationResult);
then("case with the matching workitem outcome is returned");
assertThatOperationResult(operationResult).isSuccess();
assertThat(result).extracting(o -> o.getOid()).containsExactlyInAnyOrder(expectedCaseOids);
}
Aggregations