Skip to content

Commit

Permalink
Add a test for MID-7968
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 5, 2022
1 parent 3a3b974 commit f1f365f
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
*/
package com.evolveum.midpoint.model.intest.gensync;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.*;

import java.io.File;
import java.util.Collection;
import java.util.List;

import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
Expand Down Expand Up @@ -1406,6 +1409,44 @@ public void test900AddReconciliationTask() throws Exception {
assertSuccess(result);
}

/**
* We should be able to do a low-level "get" operation on hidden (multivalued) property. See MID-7968.
*
* !!! REPLACES ALL OF "defaultObjectPolicyConfiguration" IN SYSTEM CONFIG WITH ITS OWN VALUE !!!
*/
@Test
public void test910GetHiddenProperty() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();

given("policy configuration marks `subtype` as hidden");
repositoryService.modifyObject(
SystemConfigurationType.class,
SystemObjectsType.SYSTEM_CONFIGURATION.value(),
deltaFor(SystemConfigurationType.class)
.item(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION)
.replace(new ObjectPolicyConfigurationType()
.type(UserType.COMPLEX_TYPE)
.itemConstraint(new ItemConstraintType()
.path(new ItemPathType(UserType.F_SUBTYPE))
.visibility(UserInterfaceElementVisibilityType.HIDDEN)))
.asItemDeltas(),
result);

when("user is retrieved");
PrismObject<UserType> user = modelService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, task, result);

and("edit object definition is applied to it");
PrismObjectDefinition<UserType> editDef =
modelInteractionService.getEditObjectDefinition(user, AuthorizationPhaseType.REQUEST, task, result);
user.applyDefinition(editDef, true);

then("we can ask for its subtype");
assertThat(user.asObjectable().getSubtype())
.as("user subtype collection")
.isEmpty();
}

private <O extends ObjectType, T> void assertProperty(PrismObject<O> object, ItemPath path,
Validator<PrismPropertyDefinition<T>> validator) throws Exception {
assertPropertyValues(object, path, validator, (T[]) null);
Expand Down

0 comments on commit f1f365f

Please sign in to comment.