Search in sources :

Example 96 with OperationResultType

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);
}
Also used : Response(javax.ws.rs.core.Response) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.testng.annotations.Test)

Example 97 with OperationResultType

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);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 98 with OperationResultType

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);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 99 with OperationResultType

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;
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)

Example 100 with OperationResultType

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);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismContext(com.evolveum.midpoint.prism.PrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) ValidationError(org.apache.wicket.validation.ValidationError) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)172 Test (org.testng.annotations.Test)106 Holder (javax.xml.ws.Holder)78 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)75 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)63 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)57 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)56 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)53 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)49 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)47 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)34 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)34 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)32 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)26 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)18 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)18 QName (javax.xml.namespace.QName)18 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)17