Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
…into post-3.7-fixes
  • Loading branch information
KaterynaHonchar committed Feb 9, 2018
2 parents 0084018 + 03c69d4 commit 353efd3
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
Expand Up @@ -1115,5 +1115,18 @@ Object executeAdHocProvisioningScript(String resourceOid, String language, Strin
throws SchemaException, ObjectNotFoundException,
ExpressionEvaluationException, CommunicationException, ConfigurationException,
SecurityViolationException, ObjectAlreadyExistsException;

/**
* Returns indication whether a script code is evaluating a new value.
* If this method returns true value then the script code is evaluating "new" value.
* That means a value that is going to be set to target, e.g.
* value from "add" or "replace" parts of the delta.
* If this method returns false value then the script code is evaluating "old" value.
* That means a value that is used for the purposes of removing values from target,
* e.g. value from "delete" part of the delta or values from an existing object.
* If this method returns null then the old/new status cannot be determined or this
* method is invoked in a situation when such a distinction is not applicable.
*/
Boolean isEvaluateNew();

}
Expand Up @@ -1638,4 +1638,13 @@ public Object executeAdHocProvisioningScript(String resourceOid, String language

return provisioningService.executeScript(resourceOid, script, getCurrentTask(), getCurrentResult());
}

@Override
public Boolean isEvaluateNew() {
ScriptExpressionEvaluationContext scriptContext = ScriptExpressionEvaluationContext.getThreadLocal();
if (scriptContext == null) {
return null;
}
return scriptContext.isEvaluateNew();
}
}
Expand Up @@ -3162,6 +3162,37 @@ public void test300AssignGuybrushDummyYellow() throws Exception {
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME,
"Some say elaine -- administrator");
}

@Test
public void test302ModifyGuybrushLocality() throws Exception {
final String TEST_NAME = "test302ModifyGuybrushLocality";
displayTestTitle(TEST_NAME);

// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString("Forbidden dodecahedron"));

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
display("User after", userAfter);
assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME,
USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);

// Check account in dummy resource
DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME,
ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
display("Dummy account", dummyAccount);
assertDummyAccountAttribute(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME,
DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME,
"Forbidden dodecahedron");
}

@Test
public void test309UnassignGuybrushDummyYellow() throws Exception {
Expand Down
Expand Up @@ -130,6 +130,16 @@
$c:user/c:locality
</path>
</source>
<expression>
<script>
<code>
def evaluateNew = midpoint.isEvaluateNew()
log.debug("Location outbound evaluateNew: {} : {}", evaluateNew, locality)
assert evaluateNew != null : "null evaluateNew"
return locality
</code>
</script>
</expression>
</outbound>
<inbound>
<channel>http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#import</channel>
Expand Down
Expand Up @@ -161,7 +161,12 @@
<expression>
<script>
<allowEmptyValues>false</allowEmptyValues>
<code>'The crew of ' + input</code>
<code>
def evaluateNew = midpoint.isEvaluateNew()
log.debug("Ship inbound evaluateNew: {} : {}", evaluateNew, input)
assert evaluateNew != null : "null evaluateNew"
'The crew of ' + input
</code>
</script>
</expression>
<target>
Expand Down

0 comments on commit 353efd3

Please sign in to comment.