Search in sources :

Example 31 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionFalseToTrue.

public void testScriptSystemVariablesConditionFalseToTrue(String filename) throws Exception {
    // GIVEN
    final String TEST_NAME = "testScriptSystemVariablesConditionFalseToTrue";
    System.out.println("===[ " + TEST_NAME + "]===");
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack"));
    delta.addModificationAddProperty(evaluator.toPath("employeeType"), "CAPTAIN");
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 32 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testEmployeeTypeDeltaNulldeleteB.

@Test
public void testEmployeeTypeDeltaNulldeleteB() throws Exception {
    final String TEST_NAME = "testEmployeeTypeDeltaNulldeleteB";
    TestUtil.displayTestTile(TEST_NAME);
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = employeeTypeDeltaDelete(TEST_NAME, "B");
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTripleNoPlus(outputTriple);
    PrismAsserts.assertTripleMinus(outputTriple, "B");
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 33 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testPasswordString.

@Test
public void testPasswordString() throws Exception {
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-password.xml", "testPasswordString", // target
    "employeeType", // changed property
    new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), // changed values
    evaluator.createProtectedString("weighAnch0r"));
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, "weighAnch0r");
    PrismAsserts.assertTripleMinus(outputTriple, "d3adM3nT3llN0Tal3s");
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 34 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionTrueToFalse.

public void testScriptSystemVariablesConditionTrueToFalse(String filename) throws Exception {
    // GIVEN
    final String TEST_NAME = "testScriptSystemVariablesConditionTrueToFalse";
    System.out.println("===[ " + TEST_NAME + "]===");
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), "Jack");
    delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN");
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
    PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
    user.asObjectable().getEmployeeType().add("CAPTAIN");
    mapping.getSourceContext().recompute();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTripleNoPlus(outputTriple);
    PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack"));
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 35 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method updateShadowActivation.

private void updateShadowActivation(AjaxRequestTarget target, List<FocusSubwrapperDto<ShadowType>> accounts, boolean enabled) {
    if (!isAnyProjectionSelected(target, projectionModel)) {
        return;
    }
    for (FocusSubwrapperDto<ShadowType> account : accounts) {
        if (!account.isLoadedOK()) {
            continue;
        }
        ObjectWrapper<ShadowType> wrapper = account.getObject();
        ContainerWrapper<ActivationType> activation = wrapper.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
        if (activation == null) {
            warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
            continue;
        }
        PropertyWrapper enabledProperty = (PropertyWrapper) activation.findPropertyWrapper(ActivationType.F_ADMINISTRATIVE_STATUS);
        if (enabledProperty == null || enabledProperty.getValues().size() != 1) {
            warn(getString("pageAdminFocus.message.noEnabledPropertyFound", wrapper.getDisplayName()));
            continue;
        }
        ValueWrapper value = (ValueWrapper) enabledProperty.getValues().get(0);
        ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
        ((PrismPropertyValue) value.getValue()).setValue(status);
        wrapper.setSelected(false);
    }
    target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)176 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)93 Test (org.testng.annotations.Test)83 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)81 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)60 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)43 QName (javax.xml.namespace.QName)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ArrayList (java.util.ArrayList)16 Task (com.evolveum.midpoint.task.api.Task)12 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)11 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)10 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)9 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)9 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)8 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 File (java.io.File)8