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