Skip to content

Commit

Permalink
Add tests for cond. change in assigned mappings
Browse files Browse the repository at this point in the history
(See MID-5783.)
  • Loading branch information
mederly committed Sep 21, 2019
1 parent ab141fe commit 2d0514b
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 29 deletions.
Expand Up @@ -235,7 +235,6 @@ public OperationResult build() {
if (!building) {
throw new IllegalStateException("Not being built");
}
// todo only if profiled!
recordStart(this, operation, createArguments());
building = false;
if (futureParent != null) {
Expand All @@ -253,6 +252,9 @@ private void recordCallerReason(OperationResult parent) {
}

private static void recordStart(OperationResult result, String operation, Object[] arguments) {
// TODO for very minor operation results (e.g. those dealing with mapping and script execution)
// we should consider skipping creation of invocationRecord. It includes some string manipulation(s)
// and a call to System.nanoTime that could unnecessarily slow down midPoint operation.
result.invocationRecord = OperationInvocationRecord.create(operation, arguments);
result.invocationId = result.invocationRecord.getInvocationId();
result.start = System.currentTimeMillis();
Expand Down Expand Up @@ -287,11 +289,11 @@ private Object[] createArguments() {
}

public OperationResult createSubresult(String operation) {
return createSubresult(operation, false, true, new Object[0]);
return createSubresult(operation, false, new Object[0]);
}

public OperationResult createMinorSubresult(String operation) {
return createSubresult(operation, true, true, null); // temporarily profiled todo make this configurable
return createSubresult(operation, true, null);
}

// public static OperationResult createProfiled(String operation) {
Expand All @@ -304,20 +306,19 @@ public OperationResult createMinorSubresult(String operation) {
// return result;
// }

private OperationResult createSubresult(String operation, boolean minor, boolean profiled, Object[] arguments) {
private OperationResult createSubresult(String operation, boolean minor, Object[] arguments) {
OperationResult subresult = new OperationResult(operation);
subresult.recordCallerReason(this);
addSubresult(subresult);
if (profiled) {
recordStart(subresult, operation, arguments);
}
recordStart(subresult, operation, arguments);
subresult.importance = minor ? MINOR : NORMAL;
return subresult;
}

// todo determine appropriate places where recordEnd() should be called
public void recordEnd() {
if (invocationRecord != null) {
// TODO use lambda here to avoid string manipulation if not necessary (i.e. if profiling logging is turned off)
String returnValue = getReturns().toString();
if (cause != null) {
returnValue += "; " + cause.getClass().getName() + ": " + cause.getMessage();
Expand Down
Expand Up @@ -864,7 +864,7 @@ private void evaluateSegmentTarget(AssignmentPathSegmentImpl segment, PlusMinusZ
AssignmentPathVariables assignmentPathVariables = LensUtil.computeAssignmentPathVariables(ctx.assignmentPath);
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> conditionTriple = evaluateCondition(roleCondition,
segment.source, assignmentPathVariables,
"condition in " + segment.getSourceDescription(), ctx, result);
"condition in " + segment.getTargetDescription(), ctx, result);
boolean condOld = ExpressionUtil.computeConditionResult(conditionTriple.getNonPositiveValues());
boolean condNew = ExpressionUtil.computeConditionResult(conditionTriple.getNonNegativeValues());
PlusMinusZero modeFromCondition = ExpressionUtil.computeConditionResultMode(condOld, condNew);
Expand Down
Expand Up @@ -348,11 +348,18 @@ public ObjectType getSource() {
return source;
}

@SuppressWarnings("unused")
public String getSourceDescription() {
return sourceDescription;
}

public String getTargetDescription() {
if (target != null) {
return target + " in " + sourceDescription;
} else {
return "(target) in " + sourceDescription;
}
}

public boolean isPathToSourceValid() {
return pathToSourceValid;
}
Expand Down
Expand Up @@ -252,7 +252,7 @@ private <AH extends AssignmentHolderType, F extends FocusType> void processAssig
evaluatedAssignmentTriple = assignmentTripleEvaluator.processAllAssignments();
context.setEvaluatedAssignmentTriple((DeltaSetTriple)evaluatedAssignmentTriple);

// TODO implement isMemberOf invocation result change check here!
// TODO implement isMemberOf invocation result change check here! MID-5784
// Actually, we should factor out the relevant code to avoid code duplication.

policyRuleProcessor.addGlobalPolicyRulesToAssignments(context, evaluatedAssignmentTriple, task, result);
Expand Down

0 comments on commit 2d0514b

Please sign in to comment.