use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class TestSchemaRestService method test025getNonExistingSchema.
@Test
public void test025getNonExistingSchema() {
WebClient client = prepareClient();
when();
client.path("/non-existing.xsd");
client.accept(MediaType.TEXT_PLAIN_TYPE, MediaType.APPLICATION_JSON_TYPE);
Response response = client.get();
then();
assertStatus(response, 404);
OperationResultType result = response.readEntity(OperationResultType.class);
assertNotNull("Error result must not be null", result);
assertFailure("Unknown schema", result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class AuditDeltaOperationResultTest method test140StoringCleanedUpSuccessResults.
@Test
public void test140StoringCleanedUpSuccessResults() throws Exception {
// this is like default without any settings
OperationResult result = createOperationResult();
given("clear audit and audit configuration set to TOP");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.CLEANED_UP)));
when("audit event with delta operation executions is stored");
createAuditRecordWithDeltas(result);
then("success result for delta preserved completely");
QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
assertThat(selectOne(a)).isNotNull();
QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
List<MAuditDelta> deltaRows = select(d);
assertThat(deltaRows).hasSize(2).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).anyMatch(ort -> // warning is preserved fully
ort.getPartialResults().size() == 3 && ort.getStatus() == OperationResultStatusType.WARNING).anyMatch(ort -> ort.getPartialResults().size() == 2 && ort.getStatus() == OperationResultStatusType.SUCCESS);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class AuditDeltaOperationResultTest method test130StoringOnlyTopSuccessResults.
@Test
public void test130StoringOnlyTopSuccessResults() throws Exception {
OperationResult result = createOperationResult();
given("clear audit and audit configuration set to TOP");
clearAudit();
auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.TOP)));
when("audit event with delta operation executions is stored");
createAuditRecordWithDeltas(result);
then("success result for delta preserved completely");
QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
assertThat(selectOne(a)).isNotNull();
QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
List<MAuditDelta> deltaRows = select(d);
assertThat(deltaRows).hasSize(2).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).anyMatch(ort -> // warning is preserved fully
ort.getPartialResults().size() == 3 && ort.getStatus() == OperationResultStatusType.WARNING).anyMatch(ort -> // no subresults for success
ort.getPartialResults().isEmpty() && ort.getStatus() == OperationResultStatusType.SUCCESS);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class QTaskMapping method toSchemaObject.
@Override
public TaskType toSchemaObject(Tuple row, QTask entityPath, Collection<SelectorOptions<GetOperationOptions>> options) throws SchemaException {
TaskType task = super.toSchemaObject(row, entityPath, options);
// We need to check options too for proper setting of incompleteness.
byte[] fullResult = row.get(entityPath.fullResult);
if (fullResult != null) {
PrismObject<TaskType> taskPrismObject = task.asPrismObject();
PrismProperty<OperationResultType> resultProperty = taskPrismObject.findOrCreateProperty(TaskType.F_RESULT);
resultProperty.setRealValue(parseSchemaObject(fullResult, "opResult", OperationResultType.class));
resultProperty.setIncomplete(false);
} else if (SelectorOptions.hasToLoadPath(F_RESULT, options)) {
PrismUtil.setPropertyNullAndComplete(task.asPrismObject(), TaskType.F_RESULT);
}
return task;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class ExpressionValidator method validate.
@Override
public void validate(IValidatable<T> validatable) {
ExpressionType expressionType = expressionTypeModel.getObject();
if (expressionType == null) {
return;
}
PrismContext prismContext = serviceLocator.getPrismContext();
Object valueToValidate = getValueToValidate(validatable);
String contextDesc = " form component expression validation ";
PrismPropertyDefinition<OperationResultType> outputDefinition = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, OperationResultType.COMPLEX_TYPE);
Task task = serviceLocator.createSimpleTask(OPERATION_EVALUATE_EXPRESSION);
OperationResult result = new OperationResult(OPERATION_EVALUATE_EXPRESSION);
ExpressionFactory expressionFactory = serviceLocator.getExpressionFactory();
Expression<PrismPropertyValue<OperationResultType>, PrismPropertyDefinition<OperationResultType>> expression;
try {
expression = expressionFactory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, result);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException e) {
ValidationError error = new ValidationError();
error.setMessage("Cannot make expression: " + e.getMessage());
validatable.error(error);
return;
}
VariablesMap variables = new VariablesMap();
Class typeClass = (valueToValidate == null ? String.class : valueToValidate.getClass());
variables.put(ExpressionConstants.VAR_INPUT, valueToValidate, typeClass);
variables.putObject(ExpressionConstants.VAR_OBJECT, (ObjectType) getObjectType(), ObjectType.class);
ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task);
PrismValueDeltaSetTriple<PrismPropertyValue<OperationResultType>> outputTriple;
try {
outputTriple = expression.evaluate(context, result);
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
ValidationError error = new ValidationError();
error.setMessage("Cannot evaluate expression: " + e.getMessage());
validatable.error(error);
return;
}
if (outputTriple == null) {
return;
}
Collection<PrismPropertyValue<OperationResultType>> outputValues = outputTriple.getNonNegativeValues();
if (outputValues.isEmpty()) {
return;
}
if (outputValues.size() > 1) {
ValidationError error = new ValidationError();
error.setMessage("Expression " + contextDesc + " produced more than one value");
validatable.error(error);
}
OperationResultType operationResultType = outputValues.iterator().next().getRealValue();
if (operationResultType == null) {
return;
}
OperationResult returnResult = OperationResult.createOperationResult(operationResultType);
if (!returnResult.isSuccess()) {
ValidationError error = new ValidationError();
if (returnResult.getUserFriendlyMessage() != null) {
error.setMessage(WebModelServiceUtils.translateMessage(returnResult, serviceLocator));
} else {
error.setMessage(returnResult.getMessage());
}
validatable.error(error);
}
}
Aggregations