diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java index 5feac92d77a..4d4f885a588 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/roles/MemberOperationsHelper.java @@ -230,19 +230,24 @@ public static ObjectQuery createDirectMemberQuery(R q0 = prismContext.queryFor(FocusType.class) .type(objectType); } - S_AtomicFilterExit q = q0.item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF) + // Use exists filter to build a query like this: + // $a/targetRef = oid1 and $a/tenantRef = oid2 and $a/orgRef = oid3 + S_AtomicFilterExit q = q0.exists(FocusType.F_ASSIGNMENT) + .block() + .item(AssignmentType.F_TARGET_REF) .ref(createReferenceValuesList(targetObject, relations)); + if (tenant != null && tenant.getObjectType() != null) { - q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF).ref(ObjectTypeUtil.createObjectRef(tenant.getObjectType(), + q = q.and().item(AssignmentType.F_TENANT_REF).ref(ObjectTypeUtil.createObjectRef(tenant.getObjectType(), prismContext).asReferenceValue()); } if (project != null && project.getObjectType() != null) { - q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(ObjectTypeUtil.createObjectRef(project.getObjectType(), + q = q.and().item(AssignmentType.F_ORG_REF).ref(ObjectTypeUtil.createObjectRef(project.getObjectType(), prismContext).asReferenceValue()); } - ObjectQuery query = q.build(); + ObjectQuery query = q.endBlock().build(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Searching members of role {} with query:\n{}", targetObject.getOid(), query.debugDump()); } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java new file mode 100644 index 00000000000..041226e4219 --- /dev/null +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2010-2018 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.gui; + +import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; +import com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel; +import com.evolveum.midpoint.web.page.admin.roles.PageRole; +import com.evolveum.midpoint.web.util.OnePageParameterEncoder; +import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import org.apache.wicket.Page; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.tester.FormTester; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ActiveProfiles; +import org.testng.annotations.Test; + +import static com.evolveum.midpoint.web.AdminGuiTestConstants.USER_JACK_OID; +import static com.evolveum.midpoint.web.AdminGuiTestConstants.USER_JACK_USERNAME; +import static org.testng.Assert.assertNotNull; + +/** + * @author Hiroyuki Wada + */ +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +@ActiveProfiles("test") +@SpringBootTest(classes = TestMidPointSpringApplication.class) +public class TestPageRole extends AbstractInitializedGuiIntegrationTest { + + private static final Trace LOGGER = TraceManager.getTrace(TestPageOrg.class); + + private static final String MAIN_FORM = "mainPanel:mainForm"; + private static final String PATH_FORM_NAME = "tabPanel:panel:main:values:0:value:propertiesLabel:properties:0:property:values:0:valueContainer:form:input:originValueContainer:origValueWithButton:origValue:input"; + private static final String FORM_SAVE = "save"; + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + PrismObject systemConfig = parseObject(SYSTEM_CONFIGURATION_FILE); + + LOGGER.info("adding system config page"); + addObject(systemConfig, ModelExecuteOptions.createOverwrite(), initTask, initResult); + } + + @Test + public void test001testAddNewRole() throws Exception { + renderPage(PageRole.class); + + FormTester formTester = tester.newFormTester(MAIN_FORM, false); + formTester.setValue(PATH_FORM_NAME, "newRole"); + formTester = formTester.submit(FORM_SAVE); + + Thread.sleep(5000); + + PrismObject newRole = findObjectByName(RoleType.class, "newRole"); + assertNotNull(newRole, "New role not created."); + LOGGER.info("created role: {}", newRole.debugDump()); + } + + /** + * MID-6092 + */ + @Test + public void test002testMembers() throws Exception { + // GIVEN + PrismObject role1 = createObject(RoleType.class, "Role0001"); + PrismObject role2 = createObject(RoleType.class, "Role0002"); + String role1Oid = addObject(role1); + String role2Oid = addObject(role2); + Task task = createTask("assign"); + // Assign Role0001 with orgRef P0001 + assignParametricRole(USER_JACK_OID, role1Oid, ORG_SAVE_ELAINE_OID, null, task, task.getResult()); + assignRole(USER_ADMINISTRATOR_OID, role1Oid); + // Assign Role0002 with orgRef P0001 + assignParametricRole(USER_ADMINISTRATOR_OID, role2Oid, ORG_SAVE_ELAINE_OID, null, task, task.getResult()); + + String panel = "mainPanel:mainForm:tabPanel:panel"; + String memberTable = panel + ":form:memberContainer:memberTable:mainForm:table:box:tableContainer:table"; + + // WHEN + // Open Role0001 page + renderPage(PageRole.class, role1Oid); + // Show Members tab + clickOnTab(8); + + // THEN + tester.assertComponent(panel, AbstractRoleMemberPanel.class); + tester.debugComponentTrees(":rows:.*:cells:3:cell:link:label"); + // It should show all members who are assigned Role0001 + tester.hasLabel(memberTable + ":body:rows:1:cells:3:cell:link:label", USER_ADMINISTRATOR_USERNAME); + tester.hasLabel(memberTable + ":body:rows:2:cells:3:cell:link:label", USER_JACK_USERNAME); + tester.assertNotExists(memberTable + ":body:rows:3:cells:3:cell:link:label"); + + // WHEN + // Choose P0001 in 'Org/Project' filter selection + tester.clickLink(panel + ":form:project:inputContainer:choose"); + tester.clickLink("mainPopup:content:table:mainForm:table:box:tableContainer:table:body:rows:7:cells:2:cell:link"); + executeModalWindowCloseCallback("mainPopup"); + + // THEN + // It should show only one user who is assigned Role0001 with orgRef P0001 + tester.debugComponentTrees(":rows:.*:cells:3:cell:link:label"); + tester.hasLabel(memberTable + ":body:rows:3:cells:3:cell:link:label", USER_JACK_USERNAME); + tester.assertNotExists(memberTable + ":body:rows:4:cells:3:cell:link:label"); + } + + private void clickOnTab(int order) { + tester.assertRenderedPage(PageRole.class); + String tabPath = "mainPanel:mainForm:tabPanel:tabs-container:tabs:" + order + ":link"; + tester.clickLink(tabPath); + } + + private Page renderPage(Class expectedRenderedPageClass) { + return renderPage(expectedRenderedPageClass, null); + } + + private Page renderPage(Class expectedRenderedPageClass, String oid) { + LOGGER.info("render page role"); + PageParameters params = new PageParameters(); + if (oid != null) { + params.add(OnePageParameterEncoder.PARAMETER, oid); + } + Page pageRole = tester.startPage(expectedRenderedPageClass, params); + + tester.assertRenderedPage(expectedRenderedPageClass); + + return pageRole; + } +} diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java index a9f58416253..6d882b40bc0 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiIntegrationTest.java @@ -24,6 +24,12 @@ import javax.servlet.ServletException; import javax.xml.namespace.QName; +import org.apache.wicket.Component; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.behavior.AbstractAjaxBehavior; +import org.apache.wicket.behavior.Behavior; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; + import com.evolveum.midpoint.gui.api.prism.ItemStatus; import com.evolveum.midpoint.gui.api.prism.ItemWrapper; import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils; @@ -161,10 +167,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti LOGGER.info("after super init"); // WebComponentUtil.setStaticallyProvidedRelationRegistry(relationRegistry); - login(USER_ADMINISTRATOR_USERNAME); - LOGGER.info("user logged in"); + login(USER_ADMINISTRATOR_USERNAME); + LOGGER.info("user logged in"); - tester = new WicketTester(application, true); + tester = new WicketTester(application, true); } @BeforeMethod @@ -341,4 +347,23 @@ protected Task createSimpleTask(String operation) { task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); return task; } -} + + /** + * Emulate closing ModalWindow component. + * @param path + */ + protected void executeModalWindowCloseCallback(String path) { + Component component = tester.getComponentFromLastRenderedPage(path); + if (!(component instanceof ModalWindow)) { + fail("path: '" + path + "' is not ModalWindow: " + component.getClass()); + } + for (Behavior behavior : ((ModalWindow)component).getBehaviors()) { + if (behavior instanceof AbstractDefaultAjaxBehavior) { + String name = behavior.getClass().getSimpleName(); + if (name.startsWith("WindowClosedBehavior")) { + tester.executeBehavior((AbstractAjaxBehavior) behavior); + } + } + } + } +} \ No newline at end of file diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 3861e93b030..32e7ce2ffc3 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -288,23 +288,23 @@ protected void initDummyResource(String name, DummyResourceContoller controller) } protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, - FailableProcessor controllerInitLambda, - Task task, OperationResult result) throws Exception { + FailableProcessor controllerInitLambda, + Task task, OperationResult result) throws Exception { return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, controllerInitLambda, task, result); } protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { + Task task, OperationResult result) throws Exception { return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, null, task, result); } protected DummyResourceContoller initDummyResourcePirate(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { + Task task, OperationResult result) throws Exception { return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaPirate(), task, result); } protected DummyResourceContoller initDummyResourceAd(String name, File resourceFile, String resourceOid, - Task task, OperationResult result) throws Exception { + Task task, OperationResult result) throws Exception { return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaAd(), task, result); } @@ -655,7 +655,7 @@ protected ObjectDelta createOldNewPasswordDelta(String oid, String old newPasswordPs.setClearValue(newPassword); return deltaFor(UserType.class) - .item(PASSWORD_VALUE_PATH) + .item(PASSWORD_VALUE_PATH) .oldRealValue(oldPasswordPs) .replace(newPasswordPs) .asObjectDelta(oid); @@ -680,8 +680,8 @@ protected void modifyUserSetPassword(String userOid, String newPassword, Task ta PasswordType passwordType = new PasswordType(); passwordType.setValue(userPasswordPs); ObjectDelta delta = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).add(passwordType) - .asObjectDelta(userOid); + .item(SchemaConstants.PATH_PASSWORD).add(passwordType) + .asObjectDelta(userOid); executeChanges(delta, null, task, result); } @@ -695,8 +695,8 @@ protected void clearUserPassword(String userOid) throws SchemaException, ObjectA Task task = createTask("clearUserPassword"); OperationResult result = task.getResult(); List> itemDeltas = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).replace() - .asItemDeltas(); + .item(SchemaConstants.PATH_PASSWORD).replace() + .asItemDeltas(); repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); assertSuccess(result); } @@ -732,26 +732,26 @@ protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundE } protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, result); } protected void assignService(String userOid, String targetOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { assignService(UserType.class, userOid, targetOid, (ActivationType) null, task, result); } protected void assignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { assignRole(UserType.class, userOid, roleOid, (ActivationType) null, task, options, result); } protected void assignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { assignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); } @@ -768,14 +768,14 @@ protected void unassignRole(String userOid, String roleOid, ActivationType activ } protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { unassignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); } protected void unassignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); } @@ -805,7 +805,7 @@ protected void assignFocus(Class focusClass, String focusOi protected void assignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + PolicyViolationException, SecurityViolationException { modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, true, result); } @@ -817,7 +817,7 @@ protected void assignRole(String userOid, String roleOid, QName relation, ModelE protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { + PolicyViolationException, SecurityViolationException { Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); OperationResult result = task.getResult(); assignRole(userOid, roleOid, relation, task, result); @@ -893,15 +893,15 @@ protected void unassignRole(String userOid, String roleOid, PrismContainer ex } protected void unassignRole(String userOid, String roleOid, QName relation, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, result); } protected void unassignRole(String userOid, String roleOid, QName relation, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, null, null, false, options, result); } protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, @@ -1075,14 +1075,14 @@ protected void unassignOrg(Class type, String focusOid, } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, boolean add, OperationResult result) throws ObjectNotFoundException, + PrismContainer extension, boolean add, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, null, add, result); } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) + PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1090,8 +1090,8 @@ protected void modifyUserAssignment(String userOid, String roleOid, QName refTyp } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, - OperationResult result) + PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, + OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1100,7 +1100,7 @@ protected void modifyUserAssignment(String userOid, String roleOid, QName refTyp } protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) + PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1108,7 +1108,7 @@ protected void modifyAssignmentHolderAssignment } protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, OperationResult result) + PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { @@ -1117,31 +1117,31 @@ protected void modifyAssignmentHolderAssignment } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, OperationResult result) + Consumer modificationBlock, boolean add, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, result); } protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { modifyFocusAssignment(UserType.class, userOid, roleOid, refType, relation, task, modificationBlock, add, options, result); } protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, OperationResult result) + Consumer modificationBlock, boolean add, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { modifyFocusAssignment(focusClass, focusOid, roleOid, refType, relation, task, modificationBlock, add, null, result); } protected void modifyFocusAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { modifyFocusAssignment(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, task, modificationBlock, add, options, result); } protected void modifyFocusAssignment(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, Task task, - Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) + Consumer modificationBlock, boolean add, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); Collection> deltas = MiscSchemaUtil.createCollection(focusDelta); @@ -1159,7 +1159,7 @@ protected void deleteFocusAssignmentEmptyDelta(PrismObject } protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, - ModelExecuteOptions options, Task task, OperationResult result) + ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { ObjectDelta focusDelta = createAssignmentFocusEmptyDeleteDelta(existingFocus, targetOid, relation); executeChanges(focusDelta, options, task, result); @@ -1241,18 +1241,18 @@ protected void unassignAllReplace(String userOid, Task task, OperationResult res PolicyViolationException, SecurityViolationException { ObjectDelta userDelta = prismContext.deltaFactory().object() .createModificationReplaceContainer(UserType.class, userOid, - UserType.F_ASSIGNMENT, new PrismContainerValue[0]); + UserType.F_ASSIGNMENT, new PrismContainerValue[0]); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); } protected ContainerDelta createAssignmentModification(String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { return createAssignmentModification(UserType.class, FocusType.F_ASSIGNMENT, roleOid, refType, relation, extension, activationType, add); } protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { try { return createAssignmentModification(type, elementName, roleOid, refType, relation, assignment -> { @@ -1272,7 +1272,7 @@ protected ContainerDelta createAssignmentM protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { + Consumer modificationBlock, boolean add) throws SchemaException { ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); if (add) { @@ -1335,7 +1335,7 @@ private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QNam } protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); ObjectDelta userDelta = prismContext.deltaFactory().object() @@ -1344,24 +1344,24 @@ protected ObjectDelta createAssignmentUserDelta(String userOid, String } protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, - PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { + PrismContainer extension, ActivationType activationType, boolean add) throws SchemaException { Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(roleOid, refType, relation, extension, activationType, add))); return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); } protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { + Consumer modificationBlock, boolean add) throws SchemaException { return createAssignmentFocusDelta(UserType.class, userOid, roleOid, refType, relation, modificationBlock, add); } protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { + Consumer modificationBlock, boolean add) throws SchemaException { return createAssignmentFocusDelta(focusClass, focusOid, FocusType.F_ASSIGNMENT, roleOid, refType, relation, modificationBlock, add); } protected ObjectDelta createAssignmentFocusDelta(Class focusClass, String focusOid, QName elementName, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { + Consumer modificationBlock, boolean add) throws SchemaException { Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); @@ -1384,7 +1384,7 @@ protected PropertyDelta createUserPropertyReplaceModification(QName prope } protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, - String intent, boolean add) throws SchemaException { + String intent, boolean add) throws SchemaException { AssignmentType assignmentType = createConstructionAssignment(resourceOid, kind, intent); return createAssignmentModification(assignmentType, add); } @@ -1447,11 +1447,15 @@ protected ObjectDelta createParametricAssignmentDelta(String userOid, if (orgOid != null) { PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); orgRef.getValue().setOid(orgOid); + orgRef.getValue().setTargetType(OrgType.COMPLEX_TYPE); + orgRef.getValue().setRelation(ORG_DEFAULT); } if (tenantOid != null) { PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); tenantRef.getValue().setOid(tenantOid); + tenantRef.getValue().setTargetType(OrgType.COMPLEX_TYPE); + tenantRef.getValue().setRelation(ORG_DEFAULT); } @@ -1542,7 +1546,7 @@ protected ObjectDelta createAccountAssignmentUserDelta(String focusOid } protected ObjectDelta createAssignmentDelta(Class type, String focusOid, - String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { + String resourceOid, ShadowKindType kind, String intent, boolean add) throws SchemaException { Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(resourceOid, kind, intent, add)); ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type @@ -1688,7 +1692,7 @@ protected PrismObject findAccountByUsername(String username, PrismOb } protected PrismObject findAccountByUsername(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ObjectQuery query = createAccountShadowQuery(username, resource); List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); if (accounts.isEmpty()) { @@ -1699,7 +1703,7 @@ protected PrismObject findAccountByUsername(String username, PrismOb } protected Collection> listAccounts(PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); @@ -1751,7 +1755,7 @@ protected void assertNoObject(Class type, String oid) protected void assertNoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { try { PrismObject object = modelService.getObject(type, oid, null, task, result); - display("Unexpected object", object); + AssertJUnit.fail("Expected that "+object+" does not exist, but it does"); } catch (ObjectNotFoundException e) { // This is expected @@ -1782,7 +1786,7 @@ protected void assertNoObjectByName(Class type, String } protected void assertNoShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { ObjectQuery query = createAccountShadowQuery(username, resource); List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); if (accounts.isEmpty()) { @@ -1793,7 +1797,7 @@ protected void assertNoShadow(String username, PrismObject resourc } protected void assertHasShadow(String username, PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { + Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { ObjectQuery query = createAccountShadowQuery(username, resource); List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); if (accounts.isEmpty()) { @@ -1819,7 +1823,7 @@ protected ShadowAsserter assertShadow(String username, PrismObject assertShadowByName(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, OperationResult result) + PrismObject resource, String message, OperationResult result) throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException { PrismObject shadow = findShadowByName(kind, intent, name, resource, result); @@ -1828,7 +1832,7 @@ protected ShadowAsserter assertShadowByName(ShadowKindType kind, String in } protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, Task task, OperationResult result) + PrismObject resource, String message, Task task, OperationResult result) throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { PrismObject shadow = findShadowByNameViaModel(kind, intent, name, resource, task, result); @@ -1837,7 +1841,7 @@ protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, S } protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Task task, OperationResult result) + PrismObject resource, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return findShadowByNameViaModel(kind, intent, name, resource, schemaHelper.getOperationOptionsBuilder().noFetch().build(), @@ -1845,8 +1849,8 @@ protected PrismObject findShadowByNameViaModel(ShadowKindType kind, } protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Collection> options, Task task, - OperationResult result) + PrismObject resource, Collection> options, Task task, + OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); @@ -2619,7 +2623,7 @@ protected PrismObject createAccount(PrismObject resour protected void addAttributeToShadow(PrismObject shadow, PrismObject resource, String attrName, T attrValue) throws SchemaException { ResourceAttributeContainer attrs = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeDefinition attrSnDef = attrs.getDefinition().findAttributeDefinition( - new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); + new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); ResourceAttribute attr = attrSnDef.instantiate(); attr.setRealValue(attrValue); attrs.add(attr); @@ -2731,7 +2735,7 @@ protected void setConflictResolution(QName objectType, String subType, ConflictR ContainerDelta addDelta = prismContext.deltaFactory().container() .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); + SystemConfigurationType.class, newFocusPolicyType); ((Collection)modifications).add(addDelta); @@ -3154,7 +3158,7 @@ private class TaskFinishChecker implements Checker { private long progressLastShown; public TaskFinishChecker(String taskOid, OperationResult waitResult, boolean checkSubresult, - boolean errorOk, int timeout, int showProgressEach) { + boolean errorOk, int timeout, int showProgressEach) { super(); this.taskOid = taskOid; this.waitResult = waitResult; @@ -3356,9 +3360,9 @@ public void timeout() { OperationResult result = freshTask.getResult(); LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; } catch (ObjectNotFoundException | SchemaException e) { LOGGER.error("Exception during task refresh: {}", e, e); @@ -3370,9 +3374,9 @@ public void timeout() { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); LOGGER.debug("Final task:\n{}", freshTask.debugDump()); display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); return taskResultHolder.getValue(); } @@ -3567,9 +3571,9 @@ public void timeout() { OperationResult result = freshTask.getResult(); LOGGER.debug("Timed-out task:\n{}", freshTask.debugDump()); display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" next run. Last result "+result; } catch (ObjectNotFoundException | SchemaException e) { LOGGER.error("Exception during task refresh: {}", e, e); @@ -3581,9 +3585,9 @@ public void timeout() { Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); LOGGER.debug("Final task:\n{}", freshTask.debugDump()); display("Times", "origLastRunStartTimestamp="+longTimeToString(origLastRunStartTimestamp) - + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) - + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) - + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); + + ", origLastRunFinishTimestamp=" + longTimeToString(origLastRunFinishTimestamp) + + ", freshTask.getLastRunStartTimestamp()=" + longTimeToString(freshTask.getLastRunStartTimestamp()) + + ", freshTask.getLastRunFinishTimestamp()=" + longTimeToString(freshTask.getLastRunFinishTimestamp())); return taskResultHolder.getValue(); } @@ -3986,8 +3990,8 @@ protected void addTriggers(String oid, Collection timestam .map(ts -> makeDistinct ? addRandomValue(ts) : ts) .collect(Collectors.toList()); ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).addRealValues(triggers) - .asObjectDeltaCast(oid); + .item(ObjectType.F_TRIGGER).addRealValues(triggers) + .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4015,8 +4019,8 @@ protected void replaceTriggers(String oid, Collection time .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) .collect(Collectors.toList()); ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) - .asObjectDeltaCast(oid); + .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) + .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4235,7 +4239,7 @@ protected void assertDummyAccountAttribute(String dummyInstanceName, String user } assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username, values); assertEquals("Unexpected number of values for attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + - ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, + ". Expected: " + Arrays.toString(expectedAttributeValues) + ", was: " + values, expectedAttributeValues.length, values.size()); for (Object expectedValue: expectedAttributeValues) { if (!values.contains(expectedValue)) { @@ -4382,21 +4386,21 @@ protected void assertSituation(PrismObject shadow, SynchronizationSi } protected void assertEnableTimestampFocus(PrismObject focus, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getEnableTimestamp(); TestUtil.assertBetween("Wrong user enableTimestamp in "+focus, startTime, endTime, userDisableTimestamp); } protected void assertDisableTimestampFocus(PrismObject focus, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); TestUtil.assertBetween("Wrong user disableTimestamp in "+focus, startTime, endTime, userDisableTimestamp); } protected void assertEnableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { ActivationType activationType = shadow.asObjectable().getActivation(); assertNotNull("No activation in "+shadow, activationType); XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); @@ -4405,7 +4409,7 @@ protected void assertEnableTimestampShadow(PrismObject sha } protected void assertDisableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); TestUtil.assertBetween("Wrong shadow disableTimestamp in "+shadow, startTime, endTime, userDisableTimestamp); @@ -4628,9 +4632,9 @@ protected Collection getSecurityContextAuthorizations() { protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { Collection actualActions = autzs.stream() - .map(a -> a.getAction()) - .flatMap(List::stream) - .collect(Collectors.toList()); + .map(a -> a.getAction()) + .flatMap(List::stream) + .collect(Collectors.toList()); PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); } @@ -4705,7 +4709,7 @@ protected ObjectSynchronizationType determineSynchronization(ResourceType resour } protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, - String expectedIntent) throws ObjectNotFoundException, SchemaException { + String expectedIntent) throws ObjectNotFoundException, SchemaException { OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowKindIntent"); PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); result.computeStatus(); @@ -4714,7 +4718,7 @@ protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedK } protected void assertShadowKindIntent(PrismObject shadow, ShadowKindType expectedKind, - String expectedIntent) { + String expectedIntent) { assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); } @@ -4749,7 +4753,7 @@ protected void modifyRoleAddConstruction(String roleOid, long inducementId, Stri construction.setResourceRef(resourceRedRef); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationAddContainer(RoleType.class, roleOid, - ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), + ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), construction); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); result.computeStatus(); @@ -4757,7 +4761,7 @@ protected void modifyRoleAddConstruction(String roleOid, long inducementId, Stri } protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { if (task == null) { task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget"); } @@ -4768,7 +4772,7 @@ protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, b inducement.setTargetRef(targetRef); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationAddContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); + RoleType.F_INDUCEMENT, inducement); ModelExecuteOptions options = nullToEmpty(defaultOptions); options.setReconcileAffected(reconcileAffected); executeChanges(roleDelta, options, task, result); @@ -4915,7 +4919,7 @@ protected AssignmentType findInducementByTarget(String roleOid, String targetOid } protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, - ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducementTarget"); OperationResult result = task.getResult(); AssignmentType inducement = findInducementByTarget(roleOid, targetOid); @@ -4928,7 +4932,7 @@ protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid } protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { if (task == null) { task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement"); } @@ -4938,7 +4942,7 @@ protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boo inducement.setId(inducementId); ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationDeleteContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); + RoleType.F_INDUCEMENT, inducement); ModelExecuteOptions options = nullToEmpty(defaultOptions); options.setReconcileAffected(reconcileAffected); executeChanges(roleDelta, options, task, result); @@ -5549,9 +5553,9 @@ protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Ta PrismObject rules = prismContext.parserFor(configWithGlobalRulesFile).parse(); ObjectDelta delta = prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_GLOBAL_POLICY_RULE).add( - rules.asObjectable().getGlobalPolicyRule().stream() - .map(r -> r.clone().asPrismContainerValue()) - .collect(Collectors.toList())) + rules.asObjectable().getGlobalPolicyRule().stream() + .map(r -> r.clone().asPrismContainerValue()) + .collect(Collectors.toList())) .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); } @@ -5620,7 +5624,7 @@ protected UserValuePolicyOriginResolver createUserOriginResolver(PrismObject> getTasksForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) + Collection> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { ObjectQuery query = prismContext.queryFor(TaskType.class) @@ -5630,7 +5634,7 @@ protected List> getTasksForObject(String oid, QName type, } protected List> getCasesForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) + Collection> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { ObjectQuery query = prismContext.queryFor(CaseType.class) @@ -5705,22 +5709,22 @@ protected void assertPendingOperationDeltas(PrismObject shadow, int } protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { return assertSinglePendingOperation(shadow, requestStart, requestEnd, OperationResultStatusType.IN_PROGRESS, null, null); } protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { assertPendingOperationDeltas(shadow, 1); return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), null, null, expectedExecutionStatus, expectedResultStatus, null, null); } protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - OperationResultStatusType expectedStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + OperationResultStatusType expectedStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { assertPendingOperationDeltas(shadow, 1); return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), requestStart, requestEnd, expectedStatus, completionStart, completionEnd); @@ -5790,33 +5794,33 @@ protected PendingOperationType assertPendingOperation( } protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus) { + PendingOperationExecutionStatusType expectedExecutionStaus) { return findPendingOperation(shadow, expectedExecutionStaus, null, null, null); } protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult) { + OperationResultStatusType expectedResult) { return findPendingOperation(shadow, null, expectedResult, null, null); } protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ItemPath itemPath) { + OperationResultStatusType expectedResult, ItemPath itemPath) { return findPendingOperation(shadow, null, expectedResult, null, itemPath); } protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { + PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { return findPendingOperation(shadow, expectedExecutionStaus, null, null, itemPath); } protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { + OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { return findPendingOperation(shadow, null, expectedResult, expectedChangeType, null); } protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, - ChangeTypeType expectedChangeType, ItemPath itemPath) { + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, + ChangeTypeType expectedChangeType, ItemPath itemPath) { List pendingOperations = shadow.asObjectable().getPendingOperation(); for (PendingOperationType pendingOperation: pendingOperations) { if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { @@ -6026,7 +6030,7 @@ protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFou PrismObject repoShadow = getShadowModel(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); asserter - .display(); + .display(); return asserter; } @@ -6034,7 +6038,7 @@ protected ShadowAsserter assertModelShadowNoFetch(String oid) throws Objec PrismObject repoShadow = getShadowModelNoFetch(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); asserter - .display(); + .display(); return asserter; } @@ -6042,7 +6046,7 @@ protected ShadowAsserter assertModelShadowFuture(String oid) throws Object PrismObject repoShadow = getShadowModelFuture(oid); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); asserter - .display(); + .display(); return asserter; } @@ -6052,7 +6056,7 @@ protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws PrismObject repoShadow = getShadowModel(oid, options, true); ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); asserter - .display(); + .display(); return asserter; } @@ -6162,7 +6166,7 @@ protected void assertSearchRaw(Class type, ObjectQuery } protected void assertSearchDeny(Class type, ObjectQuery query, - Collection> options) throws Exception { + Collection> options) throws Exception { try { assertSearch(type, query, options, 0); } catch (SecurityViolationException e) { @@ -6173,7 +6177,7 @@ protected void assertSearchDeny(Class type, ObjectQuer protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, int expectedResults) throws Exception { + Collection> options, int expectedResults) throws Exception { ObjectQuery originalQuery = query != null ? query.clone() : null; return assertSearch(type, query, options, new SearchAssertion() { @@ -6196,7 +6200,7 @@ public void assertCount(int count) throws Exception { } } - }); + }); } protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { @@ -6204,7 +6208,7 @@ protected void assertSearch(Class type, ObjectQuery qu } protected void assertSearchFilter(Class type, ObjectFilter filter, - Collection> options, String... expectedOids) throws Exception { + Collection> options, String... expectedOids) throws Exception { assertSearch(type, prismContext.queryFactory().createQuery(filter), options, expectedOids); } @@ -6213,7 +6217,7 @@ protected void assertSearchFilter(Class type, ObjectFi } protected void assertSearch(Class type, ObjectQuery query, - Collection> options, String... expectedOids) throws Exception { + Collection> options, String... expectedOids) throws Exception { assertSearch(type, query, options, new SearchAssertion() { @@ -6232,11 +6236,11 @@ public void assertCount(int count) throws Exception { } } - }); + }); } protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, SearchAssertion assertion) throws Exception { + Collection> options, SearchAssertion assertion) throws Exception { Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects"); OperationResult result = task.getResult(); SearchResultList> objects; @@ -6639,4 +6643,4 @@ protected ExpressionVariables createVariables(Object... params) { return ExpressionVariables.create(prismContext, params); } -} +} \ No newline at end of file