Skip to content

Commit

Permalink
Adapt TestPlentyOfAssignments
Browse files Browse the repository at this point in the history
Since 473467d the association
target search evaluator looks for kind/intent (not for object class).

Because this test creates groups manually, it had to be adapted
to provide correct intent to them.
  • Loading branch information
mederly committed May 27, 2022
1 parent 473467d commit 0aed65f
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,25 +302,37 @@ public void test200DummyGroups() throws Exception {
PrismObjectDefinition<ShadowType> shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
PrismObjectDefinition<RoleType> roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class);
ResourceSchema rSchema = ResourceSchemaFactory.getCompleteSchema(getDummyResourceObject());
getDummyResourceController();
ResourceObjectClassDefinition rOcDef =
rSchema.findObjectClassDefinition(RI_GROUP_OBJECT_CLASS);
ResourceObjectClassDefinition rOcDef = rSchema.findObjectClassDefinitionRequired(RI_GROUP_OBJECT_CLASS);

ObjectFactory objectFactory = new ObjectFactory();
ItemPath nameAttributePath = ItemPath.create(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME);
for (int i = 0; i < NUMBER_OF_GENERATED_DUMMY_GROUPS; i++) {
PrismObject<ShadowType> shadow = shadowDef.instantiate();
ShadowType shadowType = shadow.asObjectable();
// Note that we have to explicitly set kind/intent. The reason is that intent not filled-in by default.
// (Classification is done when object is fetched from resource, not when it is added to it.)
// And the associationTargetSearch evaluator looks for kind/intent since 4.6.
shadowType
.resourceRef(RESOURCE_DUMMY_OID, ResourceType.COMPLEX_TYPE)
.objectClass(rOcDef.getTypeName());
.objectClass(rOcDef.getTypeName())
.kind(ShadowKindType.ENTITLEMENT)
.intent("group");
ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, rOcDef);
ResourceAttribute<String> nameAttribute = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME);
String groupName = formatGroupName(i);
nameAttribute.setRealValue(groupName);
display("Group shadow " + i, shadow);
addObject(shadow, task, result);

if (i == 0) {
PrismObject<ShadowType> createdShadow = getShadowRepo(shadow.getOid());
assertShadow(createdShadow, "after creation")
.display()
.assertObjectClass(rOcDef.getTypeName())
.assertKind(ShadowKindType.ENTITLEMENT)
.assertIntent("group");
}

PrismObject<RoleType> role = roleDef.instantiate();
RoleType roleType = role.asObjectable();
ItemPathType assPath = new ItemPathType(ItemPath.create(RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME));
Expand Down

0 comments on commit 0aed65f

Please sign in to comment.