Skip to content

Commit

Permalink
Workflow test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 13, 2017
1 parent f751205 commit 80a374d
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ContainerDelta;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
Expand Down Expand Up @@ -1206,22 +1207,27 @@ boolean decideOnApproval(String executionId) throws Exception {
protected void modifyAssignmentConstruction(LensContext<UserType> context, UserType jack,
String attributeName, String value, boolean add) throws SchemaException {
assertEquals("jack's assignments", 1, jack.getAssignment().size());
PrismPropertyDefinition<ResourceAttributeDefinitionType> attributeDef =
PrismContainerDefinition<ResourceAttributeDefinitionType> attributeDef =
prismContext.getSchemaRegistry()
.findObjectDefinitionByCompileTimeClass(UserType.class)
.findPropertyDefinition(new ItemPath(UserType.F_ASSIGNMENT,
.findContainerDefinition(new ItemPath(UserType.F_ASSIGNMENT,
AssignmentType.F_CONSTRUCTION,
ConstructionType.F_ATTRIBUTE));
assertNotNull("no attributeDef", attributeDef);

Long assignmentId = jack.getAssignment().get(0).getId();
PropertyDelta<ResourceAttributeDefinitionType> attributeDelta = new PropertyDelta<ResourceAttributeDefinitionType>(
ContainerDelta<ResourceAttributeDefinitionType> attributeDelta = new ContainerDelta<ResourceAttributeDefinitionType>(
new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT),
new IdItemPathSegment(assignmentId),
new NameItemPathSegment(AssignmentType.F_CONSTRUCTION),
new NameItemPathSegment(ConstructionType.F_ATTRIBUTE)),
attributeDef, prismContext);
ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType();
if (add) {
attributeDelta.addValueToAdd(attributeDefinitionType.asPrismContainerValue());
} else {
attributeDelta.addValueToDelete(attributeDefinitionType.asPrismContainerValue());
}
attributeDefinitionType.setRef(new ItemPathType(new ItemPath(new QName(RESOURCE_DUMMY_NAMESPACE, attributeName))));
MappingType outbound = new MappingType();
outbound.setStrength(MappingStrengthType.STRONG); // to see changes on the resource
Expand All @@ -1230,11 +1236,6 @@ protected void modifyAssignmentConstruction(LensContext<UserType> context, UserT
outbound.setExpression(expression);
attributeDefinitionType.setOutbound(outbound);

if (add) {
attributeDelta.addValueToAdd(new PrismPropertyValue<>(attributeDefinitionType));
} else {
attributeDelta.addValueToDelete(new PrismPropertyValue<>(attributeDefinitionType));
}

ObjectDelta<UserType> userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext);
userDelta.setOid(USER_JACK_OID);
Expand Down

0 comments on commit 80a374d

Please sign in to comment.