Skip to content

Commit

Permalink
Fixing TestTrafo, which may also fix other toleratnt inbound issues
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 6, 2016
1 parent b99a3c2 commit b36b8d5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
Expand Up @@ -468,6 +468,10 @@ public void resetValuesToAdd() {
public void resetValuesToDelete() {
valuesToDelete = null;
}

public void resetValuesToReplace() {
valuesToReplace = null;
}

public void setValuesToReplace(Collection<V> newValues) {
if (newValues == null) {
Expand Down Expand Up @@ -513,7 +517,7 @@ public void setValuesToReplace(V... newValues) {
val.recompute();
}
}

/**
* Sets empty value to replace. This efficiently means removing all values.
*/
Expand Down Expand Up @@ -546,6 +550,25 @@ public void setValueToReplace(V newValue) {
}
}

public void addValueToReplace(V newValue) {
if (valuesToAdd != null) {
throw new IllegalStateException("Delta " + this
+ " already has values to add, attempt to set value to replace");
}
if (valuesToDelete != null) {
throw new IllegalStateException("Delta " + this
+ " already has values to delete, attempt to set value to replace");
}
if (valuesToReplace == null) {
valuesToReplace = newValueCollection();
}
if (newValue != null) {
valuesToReplace.add(newValue);
newValue.setParent(this);
newValue.recompute();
}
}

public void mergeValuesToReplace(Collection<V> newValues) {
// No matter what type the delta was before. We are just discarding all the previous
// state as the replace that we are applying will overwrite that anyway.
Expand Down
Expand Up @@ -547,9 +547,28 @@ private <A, F extends FocusType, V extends PrismValue,D extends ItemDefinition>
}
if (diffDelta != null) {
if (mapping.isTolerant() == Boolean.TRUE) {
diffDelta.resetValuesToDelete();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Removing delete part of the diff delta because mapping is tolerant:\n{}", diffDelta.debugDump());
if (diffDelta.isReplace()) {
if (diffDelta.getValuesToReplace().isEmpty()) {
diffDelta.resetValuesToReplace();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Removing empty replace part of the diff delta because mapping is tolerant:\n{}", diffDelta.debugDump());
}
} else {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Making sure that the replace part of the diff contains old values delta because mapping is tolerant:\n{}", diffDelta.debugDump());
}
for (Object shouldBeValueObj: shouldBeItem.getValues()) {
PrismValue shouldBeValue = (PrismValue)shouldBeValueObj;
if (!PrismValue.containsRealValue(diffDelta.getValuesToReplace(), shouldBeValue)) {
diffDelta.addValueToReplace(shouldBeValue.clone());
}
}
}
} else {
diffDelta.resetValuesToDelete();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Removing delete part of the diff delta because mapping is tolerant:\n{}", diffDelta.debugDump());
}
}
}
diffDelta.setElementName(ItemPath.getName(targetFocusItemPath.last()));
Expand Down
3 changes: 2 additions & 1 deletion testing/story/src/test/resources/logback-test.xml
Expand Up @@ -48,7 +48,8 @@
<logger name="com.evolveum.midpoint.model.impl.lens.LensUtil" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ValueMatcher" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ConsolidationProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ReconciliationProcessor" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ReconciliationProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.InboundProcessor" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.expr" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync" level="DEBUG" />
Expand Down
Expand Up @@ -280,10 +280,10 @@ if (basic.stringify(employeeType) == 'T' || basic.stringify(employeeType) == 'R'
</expression>
</outbound>
<inbound>
<tolerant>true</tolerant>
<target>
<path>$user/extension/trafo:homedir</path>
</target>

</inbound>
</attribute>
<attribute>
Expand Down

0 comments on commit b36b8d5

Please sign in to comment.