From 6f3e34c38f4758f9e891bb437a1f46e49dfe12fe Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Mon, 4 May 2020 18:31:31 +0200 Subject: [PATCH] Multiaccounts: it compiles again! (MID-6242) --- .../model/impl/lens/AssignmentEvaluator.java | 6 +- .../impl/lens/EvaluatedAssignmentImpl.java | 19 ++- .../model/impl/lens/ItemValueWithOrigin.java | 1 + .../impl/lens/LensProjectionContext.java | 12 +- .../midpoint/model/impl/lens/LensUtil.java | 2 +- .../model/impl/lens/PersonaProcessor.java | 30 ++-- .../AbstractConstruction.java | 6 +- .../lens/{ => construction}/Construction.java | 13 +- .../ConstructionCollector.java | 8 +- .../construction/EvaluatedConstructible.java | 22 +++ .../EvaluatedConstructionImpl.java | 7 +- .../EvaluatedConstructionPack.java | 7 +- .../EvaluatedOutboundConstructionImpl.java | 26 +-- .../EvaluatedPersonaConstructionImpl.java | 40 +++++ .../OutboundConstruction.java | 53 +++--- .../PersonaConstruction.java | 14 +- .../ComplexConstructionConsumer.java | 8 +- .../projector/ConsolidationProcessor.java | 103 ++++++----- .../lens/projector/ConstructionProcessor.java | 7 +- ...EvaluatedConstructionMappingExtractor.java | 2 +- .../lens/projector/OutboundProcessor.java | 27 +-- .../projector/focus/AssignmentProcessor.java | 15 +- .../lens/TestAbstractAssignmentEvaluator.java | 20 ++- .../impl/lens/TestAssignmentProcessor.java | 161 ++++++++++-------- .../impl/lens/TestAssignmentProcessor2.java | 15 +- .../model/impl/lens/TestProjectorPersona.java | 2 + 26 files changed, 340 insertions(+), 286 deletions(-) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/AbstractConstruction.java (96%) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/Construction.java (98%) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{projector => construction}/ConstructionCollector.java (96%) create mode 100644 model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructible.java rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/EvaluatedConstructionImpl.java (98%) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/EvaluatedConstructionPack.java (88%) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/EvaluatedOutboundConstructionImpl.java (93%) create mode 100644 model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedPersonaConstructionImpl.java rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/OutboundConstruction.java (61%) rename model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/{ => construction}/PersonaConstruction.java (74%) diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java index e021f85c07c..24b25a41116 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentEvaluator.java @@ -13,8 +13,10 @@ import javax.xml.namespace.QName; import com.evolveum.midpoint.common.ActivationComputer; -import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction; import com.evolveum.midpoint.model.impl.lens.projector.AssignmentOrigin; import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader; import com.evolveum.midpoint.model.impl.lens.projector.mappings.AssignedFocusMappingEvaluationRequest; @@ -580,7 +582,7 @@ private void collectConstruction(AssignmentPathSegmentImpl segment, PlusMinusZer LOGGER.trace("Preparing construction '{}' in {}", constructionType.getDescription(), segment.source); - Construction construction = new Construction<>(constructionType, segment.source); + Construction> construction = new Construction<>(constructionType, segment.source); // We have to clone here as the path is constantly changing during evaluation construction.setAssignmentPath(ctx.assignmentPath.clone()); construction.setFocusOdo(focusOdo); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java index ff7ae0d2ada..6a133d4ac1e 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedAssignmentImpl.java @@ -13,6 +13,9 @@ import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction; import com.evolveum.midpoint.model.impl.lens.projector.AssignmentOrigin; import com.evolveum.midpoint.model.impl.lens.projector.mappings.AssignedFocusMappingEvaluationRequest; import com.evolveum.midpoint.prism.*; @@ -57,7 +60,7 @@ public class EvaluatedAssignmentImpl implements @NotNull private final ItemDeltaItem,PrismContainerDefinition> assignmentIdi; private final boolean evaluatedOld; - @NotNull private final DeltaSetTriple> constructionTriple; + @NotNull private final DeltaSetTriple>> constructionTriple; @NotNull private final DeltaSetTriple> personaConstructionTriple; @NotNull private final DeltaSetTriple roles; @NotNull private final Collection orgRefVals = new ArrayList<>(); @@ -153,7 +156,7 @@ public QName getNormalizedRelation(RelationRegistry relationRegistry) { } @NotNull - public DeltaSetTriple> getConstructionTriple() { + public DeltaSetTriple>> getConstructionTriple() { return constructionTriple; } @@ -166,15 +169,15 @@ public DeltaSetTriple> getConstructionTriple() { @NotNull public DeltaSetTriple getEvaluatedConstructions(@NotNull Task task, @NotNull OperationResult result) { DeltaSetTriple> rv = prismContext.deltaFactory().createDeltaSetTriple(); - for (Construction construction : constructionTriple.getPlusSet()) { + for (Construction> construction : constructionTriple.getPlusSet()) { for (EvaluatedConstructionImpl evaluatedConstruction : construction.getEvaluatedConstructionTriple().getNonNegativeValues()) { rv.addToPlusSet(evaluatedConstruction); } } - for (Construction construction : constructionTriple.getZeroSet()) { + for (Construction> construction : constructionTriple.getZeroSet()) { rv.merge(construction.getEvaluatedConstructionTriple()); } - for (Construction construction : constructionTriple.getMinusSet()) { + for (Construction> construction : constructionTriple.getMinusSet()) { for (EvaluatedConstructionImpl evaluatedConstruction : construction.getEvaluatedConstructionTriple().getNonPositiveValues()) { rv.addToPlusSet(evaluatedConstruction); } @@ -183,7 +186,7 @@ public DeltaSetTriple getEvaluatedConstructions(@NotNull return (DeltaSetTriple)rv; } - Collection> getConstructionSet(PlusMinusZero whichSet) { + Collection>> getConstructionSet(PlusMinusZero whichSet) { switch (whichSet) { case ZERO: return getConstructionTriple().getZeroSet(); case PLUS: return getConstructionTriple().getPlusSet(); @@ -192,7 +195,7 @@ Collection> getConstructionSet(PlusMinusZero whichSet) { } } - void addConstruction(Construction construction, PlusMinusZero whichSet) { + void addConstruction(Construction> construction, PlusMinusZero whichSet) { addToTriple(construction, constructionTriple, whichSet); } @@ -341,7 +344,7 @@ public void evaluateConstructions(ObjectDeltaObject focusOdo, PrismObject resourceConsumer, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, SecurityViolationException, ConfigurationException, CommunicationException { - for (Construction construction : constructionTriple.getAllValues()) { + for (Construction> construction : constructionTriple.getAllValues()) { construction.setFocusOdo(focusOdo); construction.setSystemConfiguration(systemConfiguration); construction.setWasValid(wasValid); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java index 0d802e7146d..ff87b42a04b 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/ItemValueWithOrigin.java @@ -10,6 +10,7 @@ import java.util.Collection; import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; import com.evolveum.midpoint.model.impl.lens.projector.ValueMatcher; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java index 4efb8e2cec2..c8db67a783b 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java @@ -19,6 +19,8 @@ import javax.xml.namespace.QName; import com.evolveum.midpoint.common.refinery.*; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.path.ItemPath; @@ -173,7 +175,7 @@ public class LensProjectionContext extends LensElementContext implem * Source: AssignmentProcessor * Target: ConsolidationProcessor / ReconciliationProcessor (via squeezed structures) */ - private transient PrismValueDeltaSetTriple> constructionDeltaSetTriple; + private transient DeltaSetTriple> constructionDeltaSetTriple; /** * Triples for outbound mappings; similar to the above. @@ -581,13 +583,13 @@ public ShadowKindType getKind() { return ShadowKindType.ACCOUNT; } - public PrismValueDeltaSetTriple>> getConstructionDeltaSetTriple() { + public DeltaSetTriple> getConstructionDeltaSetTriple() { //noinspection unchecked - return (PrismValueDeltaSetTriple)constructionDeltaSetTriple; + return (DeltaSetTriple)constructionDeltaSetTriple; } - public void setConstructionDeltaSetTriple(PrismValueDeltaSetTriple> constructionDeltaSetTriple) { - this.constructionDeltaSetTriple = constructionDeltaSetTriple; + public void setConstructionDeltaSetTriple(DeltaSetTriple> evaluatedConstructionDeltaSetTriple) { + this.constructionDeltaSetTriple = (DeltaSetTriple)evaluatedConstructionDeltaSetTriple; } public Construction getOutboundConstruction() { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java index d6c01110bba..e63de80d8ca 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensUtil.java @@ -100,7 +100,7 @@ public static ResourceType getResourceReadOnly(LensContex } @NotNull - static ResourceType getResourceReadOnly(LensContext context, String resourceOid, ObjectResolver objectResolver, + public static ResourceType getResourceReadOnly(LensContext context, String resourceOid, ObjectResolver objectResolver, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ResourceType resourceFromContext = context.getResource(resourceOid); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java index 15f9ae932e3..1143ccec9dd 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Evolveum and contributors + * Copyright (c) 2017-2020 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. @@ -13,8 +13,13 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionPack; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedPersonaConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -46,11 +51,6 @@ import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType; /** * Runs persona-related changes after the primary operation is all done. Executed directly from clockwork. @@ -115,7 +115,7 @@ public HookOperationMode processPersonaChangesFocus(LensCo DeltaSetTriple activePersonaKeyTriple = context.getPrismContext().deltaFactory().createDeltaSetTriple(); - ComplexConstructionConsumer> consumer = new ComplexConstructionConsumer>() { + ComplexConstructionConsumer> consumer = new ComplexConstructionConsumer>() { @Override public boolean before(PersonaKey key) { @@ -144,16 +144,16 @@ public void onUnassigned(PersonaKey key, String desc) { @Override public void after(PersonaKey key, String desc, - DeltaMapTriple>> constructionMapTriple) { + DeltaMapTriple>> constructionMapTriple) { } }; - DeltaMapTriple>> constructionMapTriple = + DeltaMapTriple>> constructionMapTriple = constructionProcessor.processConstructions(context, evaluatedAssignmentTriple, evaluatedAssignment -> evaluatedAssignment.getPersonaConstructionTriple(), - construction -> new PersonaKey(construction.getConstructionType()), + evaluatedConstruction -> new PersonaKey(((PersonaConstruction)evaluatedConstruction.getConstruction()).getConstructionType()), consumer); LOGGER.trace("activePersonaKeyTriple:\n{}", activePersonaKeyTriple.debugDumpLazily()); @@ -165,18 +165,18 @@ public void after(PersonaKey key, String desc, FocusType existingPersona = findPersona(existingPersonas, key); LOGGER.trace("existingPersona: {}", existingPersona); // TODO: add ability to merge several constructions - EvaluatedConstructionPack> pack = constructionMapTriple.getPlusMap().get(key); + EvaluatedConstructionPack> pack = constructionMapTriple.getPlusMap().get(key); if (pack == null) { pack = constructionMapTriple.getZeroMap().get(key); } - Collection>> constructions = pack.getEvaluatedConstructions(); - if (constructions.isEmpty()) { + Collection> evaluatedConstructions = pack.getEvaluatedConstructions(); + if (evaluatedConstructions.isEmpty()) { continue; } - if (constructions.size() > 1) { + if (evaluatedConstructions.size() > 1) { throw new UnsupportedOperationException("Merging of multiple persona constructions is not supported yet"); } - PersonaConstruction construction = constructions.iterator().next().getValue(); + PersonaConstruction construction = evaluatedConstructions.iterator().next().getConstruction(); LOGGER.trace("construction:\n{}", construction.debugDumpLazily()); if (existingPersona == null) { personaAdd(context, key, construction, task, result); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AbstractConstruction.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/AbstractConstruction.java similarity index 96% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AbstractConstruction.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/AbstractConstruction.java index e6568525d9a..c89df53b23f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AbstractConstruction.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/AbstractConstruction.java @@ -4,10 +4,12 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; import java.io.Serializable; +import com.evolveum.midpoint.model.impl.lens.AssignmentPathImpl; +import com.evolveum.midpoint.model.impl.lens.LensContext; import com.evolveum.midpoint.prism.OriginType; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; @@ -25,7 +27,7 @@ /** * @author Radovan Semancik */ -public abstract class AbstractConstruction> implements DebugDumpable, Serializable { +public abstract class AbstractConstruction> implements DebugDumpable, Serializable { private static final Trace LOGGER = TraceManager.getTrace(AbstractConstruction.class); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/Construction.java similarity index 98% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/Construction.java index 50ea0af51dd..da687e6ef84 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/Construction.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/Construction.java @@ -4,7 +4,7 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; import java.util.ArrayList; import java.util.Collection; @@ -13,6 +13,9 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.AssignmentPathVariables; +import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; +import com.evolveum.midpoint.model.impl.lens.LensUtil; import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader; import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; @@ -91,7 +94,7 @@ public Construction(ConstructionType constructionType, ObjectType source) { this.expressionProfile = MiscSchemaUtil.getExpressionProfile(); } - void setOrderOneObject(ObjectType orderOneObject) { + public void setOrderOneObject(ObjectType orderOneObject) { this.orderOneObject = orderOneObject; } @@ -151,7 +154,7 @@ public void setSystemConfiguration(PrismObject systemCo this.systemConfiguration = systemConfiguration; } - RefinedObjectClassDefinition getRefinedObjectClassDefinition() { + public RefinedObjectClassDefinition getRefinedObjectClassDefinition() { return refinedObjectClassDefinition; } @@ -328,7 +331,7 @@ public NextRecompute evaluate(Task task, OperationResult parentResult) assignmentPathVariables = LensUtil.computeAssignmentPathVariables(getAssignmentPath()); ResourceType resource = resolveResource(task, result); if (resource != null) { - evaluateKindIntentObjectClass(resource, task, result); + evaluateObjectClassDefinition(resource, task, result); createEvaluatedConstructions(task, result); evaluateConstructions(task, result); result.recordSuccess(); @@ -348,7 +351,7 @@ public NextRecompute evaluate(Task task, OperationResult parentResult) return null; } - private void evaluateKindIntentObjectClass(ResourceType resource, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { + private void evaluateObjectClassDefinition(ResourceType resource, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { if (getConstructionType().getResourceRef() != null) { String resourceOid = getConstructionType().getResourceRef().getOid(); if (resourceOid != null && !resource.getOid().equals(resourceOid)) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionCollector.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/ConstructionCollector.java similarity index 96% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionCollector.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/ConstructionCollector.java index e6f7c9e1f20..0732ff1d2c3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionCollector.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/ConstructionCollector.java @@ -4,7 +4,7 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens.projector; +package com.evolveum.midpoint.model.impl.lens.construction; import java.util.Collection; import java.util.Map; @@ -13,9 +13,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractConstructionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - import com.evolveum.midpoint.model.impl.lens.*; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.delta.DeltaMapTriple; @@ -25,7 +22,6 @@ import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; /** * Collects evaluated constructions from evaluatedAssignmentTriple into a single-level triple. @@ -33,7 +29,7 @@ * * @author Radovan Semancik */ -public class ConstructionCollector, EC extends EvaluatedConstructionImpl> { +public class ConstructionCollector, EC extends EvaluatedConstructible> { private DeltaMapTriple> evaluatedConstructionMapTriple; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructible.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructible.java new file mode 100644 index 00000000000..77a98e0d9cd --- /dev/null +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructible.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.model.impl.lens.construction; + +import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +/** + * @author Radovan Semancik + */ +public interface EvaluatedConstructible { + + AbstractConstruction getConstruction(); + +} diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionImpl.java similarity index 98% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionImpl.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionImpl.java index a62af78d188..9f998269f40 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionImpl.java @@ -5,20 +5,20 @@ * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.model.api.context.AssignmentPath; import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; import com.evolveum.midpoint.model.common.mapping.MappingImpl; +import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.ItemPathTypeUtil; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -39,7 +39,7 @@ * @author mederly * @author Radovan Semancik */ -public class EvaluatedConstructionImpl implements EvaluatedConstruction { +public class EvaluatedConstructionImpl implements EvaluatedConstructible, EvaluatedConstruction { private static final Trace LOGGER = TraceManager.getTrace(EvaluatedConstructionImpl.class); @@ -57,6 +57,7 @@ public class EvaluatedConstructionImpl implemen this.rsd = rsd; } + @Override public Construction getConstruction() { return construction; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionPack.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionPack.java similarity index 88% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionPack.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionPack.java index b0f71e8d282..8bfc092cf26 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedConstructionPack.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedConstructionPack.java @@ -4,23 +4,20 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; import java.util.ArrayList; import java.util.Collection; -import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; -import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.schema.util.SchemaDebugUtil; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; /** * @author semancik * */ -public class EvaluatedConstructionPack implements DebugDumpable { +public class EvaluatedConstructionPack implements DebugDumpable { private final Collection evaluatedConstructions = new ArrayList<>(); private boolean forceRecon; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedOutboundConstructionImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedOutboundConstructionImpl.java similarity index 93% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedOutboundConstructionImpl.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedOutboundConstructionImpl.java index 86b733103c6..e8808be3bab 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/EvaluatedOutboundConstructionImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedOutboundConstructionImpl.java @@ -5,9 +5,8 @@ * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -16,6 +15,9 @@ import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; +import com.evolveum.midpoint.model.impl.lens.LensContext; +import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; +import com.evolveum.midpoint.model.impl.lens.LensUtil; import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute; import com.evolveum.midpoint.prism.util.ObjectDeltaObject; @@ -26,18 +28,12 @@ import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.model.api.context.AssignmentPath; -import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; import com.evolveum.midpoint.model.common.mapping.MappingImpl; import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.ItemPathTypeUtil; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; @@ -47,7 +43,7 @@ /** * @author Radovan Semancik */ -public class EvaluatedOutboundConstructionImpl extends EvaluatedConstructionImpl { +public class EvaluatedOutboundConstructionImpl extends EvaluatedConstructionImpl { private static final Trace LOGGER = TraceManager.getTrace(EvaluatedOutboundConstructionImpl.class); @@ -67,12 +63,6 @@ public NextRecompute evaluate(Task task, OperationResult result) throws Communic return nextRecompute; } - - protected void initializeProjectionContext() { - projectionContext = construction.getLensContext().findProjectionContext(rsd); - // projection context may not exist yet (existence might not be yet decided) - } - private NextRecompute evaluateAttributes(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, CommunicationException { @@ -159,10 +149,10 @@ assocName, outputDefinition, getConstruction().getFocusOdo(), projectionOdo, ope } // TODO: unify with MappingEvaluator.evaluateOutboundMapping(...) - private MappingImpl evaluateMapping(final MappingImpl.Builder mappingBuilder, QName attributeQName, - D targetDefinition, ObjectDeltaObject focusOdo, ObjectDeltaObject projectionOdo, + private MappingImpl evaluateMapping(final MappingImpl.Builder mappingBuilder, QName attributeQName, + D targetDefinition, ObjectDeltaObject focusOdo, ObjectDeltaObject projectionOdo, String operation, RefinedObjectClassDefinition rOcDef, RefinedObjectClassDefinition assocTargetObjectClassDefinition, - LensContext context, LensProjectionContext projCtx, final Task task, OperationResult result) + LensContext context, LensProjectionContext projCtx, final Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { if (!mappingBuilder.isApplicableToChannel(context.getChannel())) { LOGGER.trace("Skipping outbound mapping for {} because the channel does not match", attributeQName); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedPersonaConstructionImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedPersonaConstructionImpl.java new file mode 100644 index 00000000000..90b921aea65 --- /dev/null +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/EvaluatedPersonaConstructionImpl.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010-2020 Evolveum and contributors + * + * This work is dual-licensed under the Apache License 2.0 + * and European Union Public License. See LICENSE file for details. + */ + +package com.evolveum.midpoint.model.impl.lens.construction; + +import org.jetbrains.annotations.NotNull; + +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +/** + * @author Radovan Semancik + */ +public class EvaluatedPersonaConstructionImpl implements EvaluatedConstructible { + + private static final Trace LOGGER = TraceManager.getTrace(EvaluatedPersonaConstructionImpl.class); + + private final PersonaConstruction construction; + + EvaluatedPersonaConstructionImpl(@NotNull final PersonaConstruction construction) { + this.construction = construction; + } + + @Override + public PersonaConstruction getConstruction() { + return construction; + } + + @Override + public String toString() { + return "EvaluatedPersonaConstructionImpl(" + + ", construction=" + getConstruction() + + ')'; + } +} diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/OutboundConstruction.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/OutboundConstruction.java similarity index 61% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/OutboundConstruction.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/OutboundConstruction.java index 426fb907fa3..1a969f6d242 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/OutboundConstruction.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/OutboundConstruction.java @@ -4,46 +4,23 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; -import java.util.Objects; -import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.LensProjectionContext; import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import com.evolveum.midpoint.common.refinery.*; -import com.evolveum.midpoint.model.common.mapping.MappingFactory; -import com.evolveum.midpoint.model.common.mapping.MappingImpl; -import com.evolveum.midpoint.model.impl.lens.projector.mappings.MappingEvaluator; -import com.evolveum.midpoint.model.impl.util.ModelImplUtils; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.DeltaSetTriple; -import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.repo.common.expression.ExpressionUtil; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.constants.ExpressionConstants; -import com.evolveum.midpoint.schema.expression.ExpressionProfile; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ReferentialIntegrityType; + +import org.jetbrains.annotations.NotNull; /** * Special construction subclass that represents outbound constructions. @@ -54,14 +31,16 @@ * implements Serializable interface only to be storable in the * PrismPropertyValue. */ -public class OutboundConstruction extends Construction { +public class OutboundConstruction extends Construction> { private static final Trace LOGGER = TraceManager.getTrace(OutboundConstruction.class); - public OutboundConstruction(RefinedObjectClassDefinition rOcDef, ResourceType source) { - super(null, source); - setResolvedResource(new Construction.ResolvedResource(source)); - setRefinedObjectClassDefinition(rOcDef); + @NotNull private final LensProjectionContext projectionContext; + + public OutboundConstruction(@NotNull LensProjectionContext projectionContext) { + super(null, projectionContext.getResource()); + this.projectionContext = projectionContext; + setResolvedResource(new Construction.ResolvedResource(projectionContext.getResource())); } @Override @@ -87,7 +66,13 @@ public NextRecompute evaluate(Task task, OperationResult parentResult) } } - private void initializeDefinitions() { + private void initializeDefinitions() throws SchemaException { + RefinedObjectClassDefinition rOcDef = projectionContext.getStructuralObjectClassDefinition(); + if (rOcDef == null) { + LOGGER.error("Definition for {} not found in the context, but it should be there, dumping context:\n{}", projectionContext.getResourceShadowDiscriminator(), getLensContext().debugDump(1)); + throw new IllegalStateException("Definition for " + projectionContext.getResourceShadowDiscriminator() + " not found in the context, but it should be there"); + } + setRefinedObjectClassDefinition(rOcDef); Collection auxiliaryObjectClassDefinitions = getRefinedObjectClassDefinition().getAuxiliaryObjectClassDefinitions(); for (RefinedObjectClassDefinition auxiliaryObjectClassDefinition: auxiliaryObjectClassDefinitions) { addAuxiliaryObjectClassDefinition(auxiliaryObjectClassDefinition); @@ -95,7 +80,7 @@ private void initializeDefinitions() { } @Override - protected EvaluatedConstructionImpl createEvaluatedConstruction(ResourceShadowDiscriminator rsd) { + protected EvaluatedOutboundConstructionImpl createEvaluatedConstruction(ResourceShadowDiscriminator rsd) { return new EvaluatedOutboundConstructionImpl<>(this, rsd); } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaConstruction.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/PersonaConstruction.java similarity index 74% rename from model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaConstruction.java rename to model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/PersonaConstruction.java index 8f6ecd6599e..72b5539bcf4 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/PersonaConstruction.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/construction/PersonaConstruction.java @@ -1,11 +1,12 @@ /* - * Copyright (c) 2017 Evolveum and contributors + * Copyright (c) 2017-2020 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ -package com.evolveum.midpoint.model.impl.lens; +package com.evolveum.midpoint.model.impl.lens.construction; +import com.evolveum.midpoint.prism.delta.DeltaSetTriple; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -15,12 +16,17 @@ * @author semancik * */ -public class PersonaConstruction extends AbstractConstruction { +public class PersonaConstruction extends AbstractConstruction> { - PersonaConstruction(PersonaConstructionType constructionType, ObjectType source) { + public PersonaConstruction(PersonaConstructionType constructionType, ObjectType source) { super(constructionType, source); } + public DeltaSetTriple> getEvaluatedConstructionTriple() { + // TODO: return single evaluated construction in zero set? + return null; + } + @Override public String debugDump(int indent) { StringBuilder sb = new StringBuilder(); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ComplexConstructionConsumer.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ComplexConstructionConsumer.java index 1704a43c62c..44945df8994 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ComplexConstructionConsumer.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ComplexConstructionConsumer.java @@ -6,9 +6,9 @@ */ package com.evolveum.midpoint.model.impl.lens.projector; -import com.evolveum.midpoint.model.impl.lens.AbstractConstruction; -import com.evolveum.midpoint.model.impl.lens.EvaluatedConstructionImpl; -import com.evolveum.midpoint.model.impl.lens.EvaluatedConstructionPack; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructible; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionPack; import com.evolveum.midpoint.prism.delta.DeltaMapTriple; import com.evolveum.midpoint.util.exception.SchemaException; @@ -16,7 +16,7 @@ * @author Radovan Semancik * */ -public interface ComplexConstructionConsumer { +public interface ComplexConstructionConsumer { boolean before(K key); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java index 2f9fae61c0c..9c5ca5cfb7f 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConsolidationProcessor.java @@ -11,6 +11,8 @@ import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision; import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer; import com.evolveum.midpoint.model.impl.lens.*; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; @@ -27,12 +29,7 @@ import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -800,9 +797,9 @@ private Ma return squeezedMap; } - private void squeezeMappingsFromConstructionTriple( + private void squeezeMappingsFromConstructionTriple( Map>> squeezedMap, - PrismValueDeltaSetTriple>> constructionDeltaSetTriple, EvaluatedConstructionMappingExtractor extractor, + PrismValueDeltaSetTriple>>> constructionDeltaSetTriple, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; @@ -825,140 +822,140 @@ private vo // in this way for a long time. It seems to be unnecessary but also harmless. So let's keep it there, for now. } - private void squeezeMappingsFromAccountConstructionSetStraight( + private void squeezeMappingsFromAccountConstructionSetStraight( Map>> squeezedMap, - Collection>> constructionSet, EvaluatedConstructionMappingExtractor extractor, + Collection>>> constructionSet, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (constructionSet == null) { return; } - for (PrismPropertyValue> construction: constructionSet) { + for (PrismPropertyValue>> construction: constructionSet) { squeezeMappingsFromConstructionStraight(squeezedMap, construction.getValue(), extractor, enforcement); } } - private void squeezeMappingsFromAccountConstructionSetNonminusToPlus( + private void squeezeMappingsFromAccountConstructionSetNonminusToPlus( Map>> squeezedMap, - Collection>> constructionSet, EvaluatedConstructionMappingExtractor extractor, + Collection>>> constructionSet, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (constructionSet == null) { return; } - for (PrismPropertyValue> construction: constructionSet) { + for (PrismPropertyValue>> construction: constructionSet) { squeezeMappingsFromConstructionNonminusToPlus(squeezedMap, construction.getValue(), extractor, enforcement); } } - private void squeezeMappingsFromConstructionSetNonminusToMinus( + private void squeezeMappingsFromConstructionSetNonminusToMinus( Map>> squeezedMap, - Collection>> constructionSet, EvaluatedConstructionMappingExtractor extractor, + Collection>>> constructionSet, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (constructionSet == null) { return; } - for (PrismPropertyValue> construction: constructionSet) { + for (PrismPropertyValue>> construction: constructionSet) { squeezeMappingsFromConstructionNonminusToMinus(squeezedMap, construction.getValue(), extractor, enforcement); } } - private void squeezeMappingsFromConstructionSetAllToMinus( + private void squeezeMappingsFromConstructionSetAllToMinus( Map>> squeezedMap, - Collection>> constructionSet, EvaluatedConstructionMappingExtractor extractor, + Collection>>> constructionSet, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (constructionSet == null) { return; } - for (PrismPropertyValue> construction: constructionSet) { + for (PrismPropertyValue>> construction: constructionSet) { squeezeMappingsFromConstructionAllToMinus(squeezedMap, construction.getValue(), extractor, enforcement); } } - private void squeezeMappingsFromConstructionStraight( + private void squeezeMappingsFromConstructionStraight( Map>> squeezedMap, - Construction construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + Construction> construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } - DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); + DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); if (evaluatedConstructionTriple == null) { return; } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { squeezeMappingsFromEvaluatedConstructionStraight(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { squeezeMappingsFromEvaluatedConstructionNonminusToPlus(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getMinusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getMinusSet()) { squeezeMappingsFromEvaluatedConstructionAllToMinus(squeezedMap, eConstruction, extractor, enforcement); } ///////////// } - private void squeezeMappingsFromConstructionNonminusToPlus( + private void squeezeMappingsFromConstructionNonminusToPlus( Map>> squeezedMap, - Construction construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + Construction> construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } - DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); + DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); if (evaluatedConstructionTriple == null) { return; } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { squeezeMappingsFromEvaluatedConstructionNonminusToPlus(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { squeezeMappingsFromEvaluatedConstructionNonminusToPlus(squeezedMap, eConstruction, extractor, enforcement); } // Ignore minus set } - private void squeezeMappingsFromConstructionNonminusToMinus( + private void squeezeMappingsFromConstructionNonminusToMinus( Map>> squeezedMap, - Construction construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + Construction> construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } - DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); + DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); if (evaluatedConstructionTriple == null) { return; } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { squeezeMappingsFromEvaluatedConstructionNonminusToMinus(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { squeezeMappingsFromEvaluatedConstructionNonminusToMinus(squeezedMap, eConstruction, extractor, enforcement); } // Ignore minus set } - private void squeezeMappingsFromConstructionAllToMinus( + private void squeezeMappingsFromConstructionAllToMinus( Map>> squeezedMap, - Construction construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + Construction> construction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } - DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); + DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); if (evaluatedConstructionTriple == null) { return; } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getZeroSet()) { squeezeMappingsFromEvaluatedConstructionAllToMinus(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getPlusSet()) { squeezeMappingsFromEvaluatedConstructionAllToMinus(squeezedMap, eConstruction, extractor, enforcement); } - for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getMinusSet()) { + for (EvaluatedConstructionImpl eConstruction : evaluatedConstructionTriple.getMinusSet()) { squeezeMappingsFromEvaluatedConstructionAllToMinus(squeezedMap, eConstruction, extractor, enforcement); } } - private void squeezeMappingsFromEvaluatedConstructionStraight( + private void squeezeMappingsFromEvaluatedConstructionStraight( Map>> squeezedMap, - EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { for (PrismValueDeltaSetTripleProducer mapping: extractor.getMappings(evaluatedConstruction)) { PrismValueDeltaSetTriple vcTriple = mapping.getOutputTriple(); if (vcTriple == null) { @@ -976,9 +973,9 @@ private vo } } - private void squeezeMappingsFromEvaluatedConstructionNonminusToPlus( + private void squeezeMappingsFromEvaluatedConstructionNonminusToPlus( Map>> squeezedMap, - EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { for (PrismValueDeltaSetTripleProducer mapping: extractor.getMappings(evaluatedConstruction)) { PrismValueDeltaSetTriple vcTriple = mapping.getOutputTriple(); if (vcTriple == null) { @@ -992,9 +989,9 @@ private vo } } - private void squeezeMappingsFromEvaluatedConstructionNonminusToMinus( + private void squeezeMappingsFromEvaluatedConstructionNonminusToMinus( Map>> squeezedMap, - EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } @@ -1016,9 +1013,9 @@ private vo } } - private void squeezeMappingsFromEvaluatedConstructionAllToMinus( + private void squeezeMappingsFromEvaluatedConstructionAllToMinus( Map>> squeezedMap, - EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { + EvaluatedConstructionImpl evaluatedConstruction, EvaluatedConstructionMappingExtractor extractor, AssignmentPolicyEnforcementType enforcement) { if (enforcement == AssignmentPolicyEnforcementType.NONE) { return; } @@ -1042,9 +1039,9 @@ private vo } - private void convertSqueezeSet(Collection fromSet, + private void convertSqueezeSet(Collection fromSet, Collection> toSet, - PrismValueDeltaSetTripleProducer mapping, EvaluatedConstructionImpl evaluatedConstruction) { + PrismValueDeltaSetTripleProducer mapping, EvaluatedConstructionImpl evaluatedConstruction) { if (fromSet != null) { for (V from: fromSet) { ItemValueWithOrigin pvwo = new ItemValueWithOrigin<>(from, mapping, evaluatedConstruction.getConstruction()); @@ -1053,7 +1050,7 @@ private vo } } - private DeltaSetTriple> getSqueezeMapTriple( + private DeltaSetTriple> getSqueezeMapTriple( Map>> squeezedMap, QName itemName) { DeltaSetTriple> triple = squeezedMap.get(itemName); if (triple == null) { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionProcessor.java index ddada1cccbb..71fa98e25ba 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/ConstructionProcessor.java @@ -6,11 +6,10 @@ */ package com.evolveum.midpoint.model.impl.lens.projector; -import java.util.Collection; -import java.util.Map; import java.util.function.Function; import com.evolveum.midpoint.model.impl.lens.*; +import com.evolveum.midpoint.model.impl.lens.construction.*; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractConstructionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; @@ -20,7 +19,6 @@ import com.evolveum.midpoint.prism.delta.DeltaMapTriple; import com.evolveum.midpoint.prism.delta.DeltaSetTriple; -import com.evolveum.midpoint.prism.delta.PlusMinusZero; import com.evolveum.midpoint.util.HumanReadableDescribable; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -30,7 +28,6 @@ import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; /** * @author Radovan Semancik @@ -42,7 +39,7 @@ public class ConstructionProcessor { private static final Trace LOGGER = TraceManager.getTrace(ConstructionProcessor.class); - public , EC extends EvaluatedConstructionImpl> + public , EC extends EvaluatedConstructible> DeltaMapTriple> processConstructions(LensContext context, DeltaSetTriple> evaluatedAssignmentTriple, Function, DeltaSetTriple> constructionTripleExtractor, diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/EvaluatedConstructionMappingExtractor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/EvaluatedConstructionMappingExtractor.java index 469334f8de9..839f6964362 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/EvaluatedConstructionMappingExtractor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/EvaluatedConstructionMappingExtractor.java @@ -9,7 +9,7 @@ import java.util.Collection; import com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer; -import com.evolveum.midpoint.model.impl.lens.EvaluatedConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType; diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java index 7ef4350d5ad..381cac3beb2 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/OutboundProcessor.java @@ -6,20 +6,13 @@ */ package com.evolveum.midpoint.model.impl.lens.projector; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; - import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.model.impl.ModelObjectResolver; import com.evolveum.midpoint.model.impl.lens.*; +import com.evolveum.midpoint.model.impl.lens.construction.OutboundConstruction; import com.evolveum.midpoint.model.impl.lens.projector.mappings.MappingEvaluator; import com.evolveum.midpoint.model.impl.lens.projector.mappings.NextRecompute; import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -27,20 +20,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.evolveum.midpoint.repo.common.expression.ValuePolicyResolver; -import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition; -import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.model.common.mapping.MappingImpl; import com.evolveum.midpoint.model.common.mapping.MappingFactory; import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.ObjectDeltaObject; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -64,7 +51,7 @@ public class OutboundProcessor { @Autowired private Clock clock; @Autowired private ModelObjectResolver objectResolver; - void processOutbound(LensContext context, LensProjectionContext projCtx, Task task, OperationResult result) throws SchemaException, + void processOutbound(LensContext context, LensProjectionContext projCtx, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { ResourceShadowDiscriminator discr = projCtx.getResourceShadowDiscriminator(); @@ -78,15 +65,9 @@ void processOutbound(LensContext context, LensProjectio LOGGER.trace("Processing outbound expressions for {} starting", discr); - RefinedObjectClassDefinition rOcDef = projCtx.getStructuralObjectClassDefinition(); - if (rOcDef == null) { - LOGGER.error("Definition for {} not found in the context, but it should be there, dumping context:\n{}", discr, context.debugDump()); - throw new IllegalStateException("Definition for " + discr + " not found in the context, but it should be there"); - } - - ObjectDeltaObject focusOdo = context.getFocusContext().getObjectDeltaObject(); + ObjectDeltaObject focusOdo = context.getFocusContext().getObjectDeltaObject(); - OutboundConstruction outboundConstruction = new OutboundConstruction<>(rOcDef, projCtx); + OutboundConstruction outboundConstruction = new OutboundConstruction(projCtx); outboundConstruction.setFocusOdo(focusOdo); outboundConstruction.setLensContext(context); outboundConstruction.setObjectResolver(objectResolver); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/focus/AssignmentProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/focus/AssignmentProcessor.java index 536dc36736a..37b35310e2d 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/focus/AssignmentProcessor.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/focus/AssignmentProcessor.java @@ -15,6 +15,9 @@ import javax.xml.namespace.QName; import com.evolveum.midpoint.model.impl.lens.*; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionPack; import com.evolveum.midpoint.model.impl.lens.projector.ComplexConstructionConsumer; import com.evolveum.midpoint.model.impl.lens.projector.ConstructionProcessor; import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader; @@ -32,7 +35,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.BooleanUtils; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -511,8 +513,8 @@ public void onUnassigned(ResourceShadowDiscriminator rsd, String desc) throws Sc @Override public void after(ResourceShadowDiscriminator rsd, String desc, DeltaMapTriple>> constructionMapTriple) { - PrismValueDeltaSetTriple> projectionConstructionDeltaSetTriple = - prismContext.deltaFactory().createPrismValueDeltaSetTriple( + DeltaSetTriple> projectionEvaluatedConstructionDeltaSetTriple = + prismContext.deltaFactory().createDeltaSetTriple( getConstructions(constructionMapTriple.getZeroMap().get(rsd), true), getConstructions(constructionMapTriple.getPlusMap().get(rsd), true), getConstructions(constructionMapTriple.getMinusMap().get(rsd), false)); @@ -521,9 +523,9 @@ public void after(ResourceShadowDiscriminator rsd, String desc, // This can be null in a exotic case if we delete already deleted account if (LOGGER.isTraceEnabled()) { LOGGER.trace("Construction delta set triple for {}:\n{}", rsd, - projectionConstructionDeltaSetTriple.debugDump(1)); + projectionEvaluatedConstructionDeltaSetTriple.debugDump(1)); } - projectionContext.setConstructionDeltaSetTriple(projectionConstructionDeltaSetTriple); + projectionContext.setConstructionDeltaSetTriple(projectionEvaluatedConstructionDeltaSetTriple); if (isForceRecon(constructionMapTriple.getZeroMap().get(rsd)) || isForceRecon( constructionMapTriple.getPlusMap().get(rsd)) || isForceRecon( constructionMapTriple.getMinusMap().get(rsd))) { @@ -660,8 +662,7 @@ private void processFocusDelete(LensContext } } - @NotNull - private Collection> getConstructions(EvaluatedConstructionPack accountEvaluatedConstructionPack, boolean validOnly) { + private Collection> getConstructions(EvaluatedConstructionPack> accountEvaluatedConstructionPack, boolean validOnly) { if (accountEvaluatedConstructionPack == null) { return Collections.emptySet(); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java index 80b7ce37cba..64200ed799b 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAbstractAssignmentEvaluator.java @@ -17,6 +17,8 @@ import java.util.*; import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader; import org.springframework.beans.factory.annotation.Autowired; @@ -114,7 +116,7 @@ public void test100Direct() throws Exception { assertEquals(1, evaluatedAssignment.getConstructionTriple().size()); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - Construction construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); + Construction> construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); displayDumpable("Evaluated construction", construction); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); @@ -152,7 +154,7 @@ public void test110DirectExpression() throws Exception { assertEquals(1, evaluatedAssignment.getConstructionTriple().size()); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - Construction construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); + Construction> construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); assertEquals("Wrong number of admin GUI configs", 0, evaluatedAssignment.getAdminGuiConfigurations().size()); @@ -197,7 +199,7 @@ public void test120DirectExpressionReplaceDescription() throws Exception { assertEquals(1, evaluatedAssignment.getConstructionTriple().size()); PrismAsserts.assertParentConsistency(user); - Construction construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); + Construction> construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); assertEquals(1, evaluatedConstructionTriple.size()); @@ -261,7 +263,7 @@ public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception assertEquals(1, evaluatedAssignment.getConstructionTriple().size()); PrismAsserts.assertParentConsistency(user); - Construction construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); + Construction> construction = evaluatedAssignment.getConstructionTriple().getZeroSet().iterator().next(); assertNotNull("No object class definition in construction", construction.getRefinedObjectClassDefinition()); DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); assertEquals(1, evaluatedConstructionTriple.size()); @@ -781,7 +783,7 @@ public void test310DisableRoleEngineer() throws Exception { assertEquals(2, evaluatedAssignment.getConstructionTriple().size()); PrismAsserts.assertParentConsistency(userTypeJack.asPrismObject()); - for (Construction construction : evaluatedAssignment.getConstructionSet(ZERO)) { + for (Construction> construction : evaluatedAssignment.getConstructionSet(ZERO)) { assertEquals("Wrong validity for " + construction, false, construction.isValid()); } @@ -841,8 +843,8 @@ public void test400UserFred() throws Exception { } protected void assertNoConstruction(EvaluatedAssignmentImpl evaluatedAssignment, PlusMinusZero constructionSet, String attributeName) { - Collection> constructions = evaluatedAssignment.getConstructionSet(constructionSet); - for (Construction construction : constructions) { + Collection>> constructions = evaluatedAssignment.getConstructionSet(constructionSet); + for (Construction> construction : constructions) { construction.getEvaluatedConstructionTriple().foreach( evaluatedConstruction -> { PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> mapping = evaluatedConstruction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); @@ -852,9 +854,9 @@ protected void assertNoConstruction(EvaluatedAssignmentImpl evaluatedA } protected void assertConstruction(EvaluatedAssignmentImpl evaluatedAssignment, PlusMinusZero constructionSet, String attributeName, PlusMinusZero attributeSet, String... expectedValues) { - Collection> constructions = evaluatedAssignment.getConstructionSet(constructionSet); + Collection>> constructions = evaluatedAssignment.getConstructionSet(constructionSet); Set realValues = new HashSet<>(); - for (Construction construction : constructions) { + for (Construction> construction : constructions) { construction.getEvaluatedConstructionTriple().foreach( evaluatedConstruction -> { PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> mapping = evaluatedConstruction.getAttributeMapping(new QName(MidPointConstants.NS_RI, attributeName)); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java index c9e88e6e9c7..e9d2d87c3c4 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor.java @@ -14,6 +14,11 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; + +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; + +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; @@ -118,7 +123,7 @@ public void test002ModifyUser() throws Exception { assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); displayDumpable("accountConstructionDeltaSetTriple", accountConstructionDeltaSetTriple); @@ -126,13 +131,13 @@ public void test002ModifyUser() throws Exception { PrismAsserts.assertTripleNoPlus(accountConstructionDeltaSetTriple); assertSetSize("zero", accountConstructionDeltaSetTriple.getZeroSet(), 2); - Construction zeroAccountConstruction = getZeroAccountConstruction(accountConstructionDeltaSetTriple, "Brethren account construction"); + EvaluatedConstructionImpl zeroEvaluatedAccountConstruction = getZeroEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, "Brethren account construction"); - assertNoZeroAttributeValues(zeroAccountConstruction, + assertNoZeroAttributeValues(zeroEvaluatedAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME)); - assertPlusAttributeValues(zeroAccountConstruction, + assertPlusAttributeValues(zeroEvaluatedAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME), "Tortuga"); - assertMinusAttributeValues(zeroAccountConstruction, + assertMinusAttributeValues(zeroEvaluatedAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME), "Caribbean"); } @@ -218,14 +223,14 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); PrismAsserts.assertTripleNoMinus(accountConstructionDeltaSetTriple); PrismAsserts.assertTripleNoZero(accountConstructionDeltaSetTriple); assertSetSize("plus", accountConstructionDeltaSetTriple.getPlusSet(), 1); - Construction plusAccountConstruction = getPlusAccountConstruction(accountConstructionDeltaSetTriple); + EvaluatedConstructionImpl plusAccountConstruction = getPlusEvaluatedAccountConstruction(accountConstructionDeltaSetTriple); assertZeroAttributeValues(plusAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME), @@ -285,13 +290,13 @@ public void test021AddAssignmentModifyAccountAssignment() throws Exception { assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); PrismAsserts.assertTripleNoMinus(accountConstructionDeltaSetTriple); assertSetSize("zero", accountConstructionDeltaSetTriple.getZeroSet(), 2); - Construction zeroAccountConstruction = getZeroAccountConstruction(accountConstructionDeltaSetTriple, + EvaluatedConstructionImpl zeroAccountConstruction = getZeroEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, "Brethren account construction"); assertZeroAttributeValues(zeroAccountConstruction, @@ -317,7 +322,7 @@ public void test021AddAssignmentModifyAccountAssignment() throws Exception { getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME)); assertSetSize("plus", accountConstructionDeltaSetTriple.getPlusSet(), 1); - Construction plusAccountConstruction = getPlusAccountConstruction(accountConstructionDeltaSetTriple, "Monkey account construction"); + EvaluatedConstructionImpl plusAccountConstruction = getPlusEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, "Monkey account construction"); assertZeroAttributeValues(plusAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME), "Rum"); @@ -386,13 +391,13 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); PrismAsserts.assertTripleNoPlus(accountConstructionDeltaSetTriple); assertSetSize("zero", accountConstructionDeltaSetTriple.getZeroSet(), 1); - Construction zeroAccountConstruction = getZeroAccountConstruction(accountConstructionDeltaSetTriple); + EvaluatedConstructionImpl zeroAccountConstruction = getZeroEvaluatedAccountConstruction(accountConstructionDeltaSetTriple); assertZeroAttributeValues(zeroAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME), "Caribbean"); @@ -410,7 +415,7 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME)); assertSetSize("minus", accountConstructionDeltaSetTriple.getMinusSet(), 1); - Construction minusAccountConstruction = getMinusAccountConstruction(accountConstructionDeltaSetTriple); + EvaluatedConstructionImpl minusAccountConstruction = getMinusEvaluatedAccountConstruction(accountConstructionDeltaSetTriple); assertZeroAttributeValues(minusAccountConstruction, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME), @@ -508,7 +513,7 @@ public void test100AddAssignmentWithConditionalMetarole() throws Exception { assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); PrismAsserts.assertTripleNoMinus(accountConstructionDeltaSetTriple); @@ -576,7 +581,7 @@ public void test102EnableConditionalMetarole() throws Exception { assignmentProcessor.processAssignmentsAccountValues(accContext, result); - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple = + DeltaSetTriple> accountConstructionDeltaSetTriple = accContext.getConstructionDeltaSetTriple(); PrismAsserts.assertTripleNoMinus(accountConstructionDeltaSetTriple); @@ -712,73 +717,90 @@ public void test210AssignEngineer() throws Exception { assertEquals("Wrong # of target policy rules", 5, policyRules.size()); } - private void assertAttributeValues(Collection>> accountConstructions, QName attrName, PlusMinusZero attrSet, T... expectedValue) { + private void assertAttributeValues(Collection> accountConstructions, QName attrName, PlusMinusZero attrSet, T... expectedValue) { Set realValues = getAttributeValues(accountConstructions, attrName, attrSet); assertEquals("Unexpected attributes", new HashSet<>(Arrays.asList(expectedValue)), realValues); } - private Set getAttributeValues(Collection>> accountConstructions, QName attrName, PlusMinusZero attributeSet) { + private Set getAttributeValues(Collection> accountEvaluatedConstructions, QName attrName, PlusMinusZero attributeSet) { Set retval = new HashSet<>(); - for (PrismPropertyValue> constructionPropVal : accountConstructions) { - constructionPropVal.getValue().getEvaluatedConstructionTriple().foreach( evaluatedConstruction -> { - MappingImpl, ? extends PrismPropertyDefinition> mapping = evaluatedConstruction.getAttributeMapping(attrName); - if (mapping != null && mapping.getOutputTriple() != null) { - Collection> values = (Collection) mapping.getOutputTriple().getSet(attributeSet); - if (values != null) { - for (PrismPropertyValue value : values) { - retval.add(value.getValue()); - } + for (EvaluatedConstructionImpl evaluatedConstruction : accountEvaluatedConstructions) { + MappingImpl, ? extends PrismPropertyDefinition> mapping = evaluatedConstruction.getAttributeMapping(attrName); + if (mapping != null && mapping.getOutputTriple() != null) { + Collection> values = (Collection) mapping.getOutputTriple().getSet(attributeSet); + if (values != null) { + for (PrismPropertyValue value : values) { + retval.add(value.getValue()); } } - }); + } } return retval; } - private EvaluatedConstructionImpl getSingleEvaluatedConstruction(Construction construction) { +// private Set getAttributeValues(Collection> accountConstructions, QName attrName, PlusMinusZero attributeSet) { +// Set retval = new HashSet<>(); +// for (PrismPropertyValue>> constructionPropVal : accountConstructions) { +// constructionPropVal.getValue().getEvaluatedConstructionTriple().foreach( evaluatedConstruction -> { +// MappingImpl, ? extends PrismPropertyDefinition> mapping = evaluatedConstruction.getAttributeMapping(attrName); +// if (mapping != null && mapping.getOutputTriple() != null) { +// Collection> values = (Collection) mapping.getOutputTriple().getSet(attributeSet); +// if (values != null) { +// for (PrismPropertyValue value : values) { +// retval.add(value.getValue()); +// } +// } +// } +// }); +// } +// return retval; +// } + + + private EvaluatedConstructionImpl getSingleEvaluatedConstruction(Construction> construction) { DeltaSetTriple> evaluatedConstructionTriple = construction.getEvaluatedConstructionTriple(); assertEquals("Unexpected evaluatedConstructionTriple size", 1, evaluatedConstructionTriple.size()); return evaluatedConstructionTriple.getZeroSet().iterator().next(); } - private void assertPlusAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertPlusAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName, T... expectedValue) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute " + attrName + " in plus set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple.getPlusSet()); TestUtil.assertSetEquals("Attribute " + attrName + " value in plus set", actual, expectedValue); } - private void assertZeroAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertZeroAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName, T... expectedValue) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute " + attrName + " in zero set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple.getZeroSet()); TestUtil.assertSetEquals("Attribute " + attrName + " value in zero set", actual, expectedValue); } - private void assertMinusAttributeValues(Construction accountConstruction, QName attrName, T... expectedValue) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertMinusAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName, T... expectedValue) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); assertNotNull("No value construction for attribute " + attrName + " in minus set", vc); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); Collection actual = getMultiValueFromDeltaSetTriple(triple.getMinusSet()); TestUtil.assertSetEquals("Attribute " + attrName + " value in minus set", actual, expectedValue); } - private void assertNoPlusAttributeValues(Construction accountConstruction, QName attrName) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertNoPlusAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoPlus(triple); } - private void assertNoZeroAttributeValues(Construction accountConstruction, QName attrName) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertNoZeroAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoZero(triple); } - private void assertNoMinusAttributeValues(Construction accountConstruction, QName attrName) { - PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = getSingleEvaluatedConstruction(accountConstruction).getAttributeMapping(attrName); + private void assertNoMinusAttributeValues(EvaluatedConstructionImpl evaluatedAccountConstruction, QName attrName) { + PrismValueDeltaSetTripleProducer, ? extends PrismPropertyDefinition> vc = evaluatedAccountConstruction.getAttributeMapping(attrName); PrismValueDeltaSetTriple> triple = vc.getOutputTriple(); PrismAsserts.assertTripleNoMinus(triple); } @@ -793,53 +815,52 @@ private Collection getMultiValueFromDeltaSetTriple( } private void assertSetSize( - String setName, Collection>> set, int expectedSize) { - assertEquals("Unexpected number of value in " + setName + " set", expectedSize, set.size()); + String setName, Collection> set, int expectedSize) { + assertEquals("Unexpected number of value in " + setName + " construction set", expectedSize, set.size()); } - private Construction getZeroAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple) { - return getZeroAccountConstruction(accountConstructionDeltaSetTriple, null); + private EvaluatedConstructionImpl getZeroEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple) { + return getZeroEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, null); } - private Construction getZeroAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple, + private EvaluatedConstructionImpl getZeroEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple, String description) { - Collection>> set = accountConstructionDeltaSetTriple.getZeroSet(); - return getAccountConstruction(description, set, "zero"); + @NotNull Collection> set = accountConstructionDeltaSetTriple.getZeroSet(); + return getEvaluatedAccountConstruction(description, set, "zero"); } - private Construction getPlusAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple) { - return getPlusAccountConstruction(accountConstructionDeltaSetTriple, null); + private EvaluatedConstructionImpl getPlusEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple) { + return getPlusEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, null); } - private Construction getPlusAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple, + private EvaluatedConstructionImpl getPlusEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple, String description) { - Collection>> set = accountConstructionDeltaSetTriple.getPlusSet(); - return getAccountConstruction(description, set, "plus"); + @NotNull Collection> set = accountConstructionDeltaSetTriple.getPlusSet(); + return getEvaluatedAccountConstruction(description, set, "plus"); } - private Construction getMinusAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple) { - return getMinusAccountConstruction(accountConstructionDeltaSetTriple, null); + private EvaluatedConstructionImpl getMinusEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple) { + return getMinusEvaluatedAccountConstruction(accountConstructionDeltaSetTriple, null); } - private Construction getMinusAccountConstruction( - PrismValueDeltaSetTriple>> accountConstructionDeltaSetTriple, + private EvaluatedConstructionImpl getMinusEvaluatedAccountConstruction( + DeltaSetTriple> accountConstructionDeltaSetTriple, String description) { - Collection>> set = accountConstructionDeltaSetTriple.getMinusSet(); - return getAccountConstruction(description, set, "minus"); + @NotNull Collection> set = accountConstructionDeltaSetTriple.getMinusSet(); + return getEvaluatedAccountConstruction(description, set, "minus"); } - private Construction getAccountConstruction( - String description, Collection>> set, String setName) { - for (PrismPropertyValue> constructionPVal : set) { - Construction accountConstruction = constructionPVal.getValue(); - if (description == null || description.equals(accountConstruction.getDescription())) { - assertNotNull("Null accountConstruction in " + setName + " set (description: '" + description + "')", accountConstruction); - return accountConstruction; + private EvaluatedConstructionImpl getEvaluatedAccountConstruction( + String description, Collection> set, String setName) { + for (EvaluatedConstructionImpl evaluatedConstruction : set) { + if (description == null || description.equals(evaluatedConstruction.getConstruction().getDescription())) { + assertNotNull("Null accountConstruction in " + setName + " set (description: '" + description + "')", evaluatedConstruction); + return evaluatedConstruction; } } return null; diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java index 05faee65512..deaaa763759 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignmentProcessor2.java @@ -12,6 +12,9 @@ import com.evolveum.midpoint.model.api.context.EvaluationOrder; import com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext; import com.evolveum.midpoint.model.common.mapping.MappingFactory; +import com.evolveum.midpoint.model.impl.lens.construction.AbstractConstruction; +import com.evolveum.midpoint.model.impl.lens.construction.Construction; +import com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionImpl; import com.evolveum.midpoint.model.impl.lens.projector.AssignmentOrigin; import com.evolveum.midpoint.model.impl.lens.projector.ContextLoader; import com.evolveum.midpoint.model.impl.lens.projector.focus.AssignmentProcessor; @@ -1295,10 +1298,10 @@ private RunInfo getRunInfo(String name) { @SuppressWarnings("unused") // why? private void showEvaluations(EvaluatedAssignmentImpl evaluatedAssignment, String name, int expectedConstructions, Task task, OperationResult result) throws Exception { - List> constructions = getConstructions(evaluatedAssignment, name); + List>> constructions = getConstructions(evaluatedAssignment, name); assertEquals("Wrong # of constructions: " + name, expectedConstructions, constructions.size()); for (int i = 0; i < constructions.size(); i++) { - Construction construction = constructions.get(i); + Construction> construction = constructions.get(i); System.out.println("Evaluating " + name + " #" + (i+1)); construction.evaluate(task, result); System.out.println("Done"); @@ -2423,13 +2426,13 @@ private void assertConstructions(EvaluatedAssignmentImpl ev assertConstructions("minus", evaluatedAssignment.getConstructionSet(PlusMinusZero.MINUS), minusValid, minusInvalid); } - private void assertConstructions(String type, Collection> constructions, List valid0, + private void assertConstructions(String type, Collection>> constructions, List valid0, List invalid0) { constructions = CollectionUtils.emptyIfNull(constructions); Collection expectedValid = CollectionUtils.emptyIfNull(valid0); Collection expectedInvalid = CollectionUtils.emptyIfNull(invalid0); - Collection> realValid = constructions.stream().filter(AbstractConstruction::isValid).collect(Collectors.toList()); - Collection> realInvalid = constructions.stream().filter(c -> !c.isValid()).collect(Collectors.toList()); + Collection>> realValid = constructions.stream().filter(AbstractConstruction::isValid).collect(Collectors.toList()); + Collection>> realInvalid = constructions.stream().filter(c -> !c.isValid()).collect(Collectors.toList()); assertUnsortedListsEquals("Wrong valid constructions in " + type + " set", expectedValid, realValid, AbstractConstruction::getDescription); assertUnsortedListsEquals("Wrong invalid constructions in " + type + " set", expectedInvalid, @@ -2447,7 +2450,7 @@ private Collection> assertAssig //endregion //region ============================================================= helper methods (misc) - private List> getConstructions(EvaluatedAssignmentImpl evaluatedAssignment, String name) { + private List>> getConstructions(EvaluatedAssignmentImpl evaluatedAssignment, String name) { return evaluatedAssignment.getConstructionTriple().getAllValues().stream() .filter(c -> name.equals(c.getDescription())) .collect(Collectors.toList()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java index 0952889a9ae..81bab10bf7d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorPersona.java @@ -8,6 +8,8 @@ import static org.testng.AssertJUnit.*; +import com.evolveum.midpoint.model.impl.lens.construction.PersonaConstruction; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration;