diff --git a/build-tools/pom.xml b/build-tools/pom.xml deleted file mode 100644 index 54487bd8a4c..00000000000 --- a/build-tools/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - 4.0.0 - - - - com.evolveum.midpoint - build-tools - 4.1-SNAPSHOT - jar - - midPoint build tools - - - UTF-8 - true - - - - - evolveum-nexus - Internal Releases - https://nexus.evolveum.com/nexus/content/repositories/releases/ - - - evolveum-nexus - Internal Snapshots - https://nexus.evolveum.com/nexus/content/repositories/snapshots/ - - - - - - evolveum - Evolveum Public Releases - https://nexus.evolveum.com/nexus/content/groups/public - - - evolveum-snapshots - Evolveum Snapshots - https://nexus.evolveum.com/nexus/content/repositories/snapshots/ - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - - - diff --git a/build-tools/src/main/resources/midpoint-build/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml similarity index 58% rename from build-tools/src/main/resources/midpoint-build/checkstyle-suppressions.xml rename to config/checkstyle/checkstyle-suppressions.xml index cc09de5cfa5..f6e18d5c7d2 100644 --- a/build-tools/src/main/resources/midpoint-build/checkstyle-suppressions.xml +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -8,16 +8,20 @@ - - - - + + + + - + + + + + - - + + diff --git a/build-tools/src/main/resources/midpoint-build/checkstyle.xml b/config/checkstyle/checkstyle.xml similarity index 100% rename from build-tools/src/main/resources/midpoint-build/checkstyle.xml rename to config/checkstyle/checkstyle.xml diff --git a/gui/admin-gui/pom.xml b/gui/admin-gui/pom.xml index bdc1af0a87c..67c6dbe3ac7 100644 --- a/gui/admin-gui/pom.xml +++ b/gui/admin-gui/pom.xml @@ -691,7 +691,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -816,6 +815,11 @@ 4.1-SNAPSHOT test + + + org.slf4j + slf4j-api + diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java index 095403e416d..75d9ebc7adc 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/DatePanel.java @@ -28,6 +28,7 @@ public DatePanel(String id, IModel model) { super(id); DateInput date = new DateInput(ID_INPUT, new XmlGregorianCalendarModel(model)); + date.setOutputMarkupId(true); add(date); } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java index 51fac38f711..f16800e9121 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/InternalsClockPanel.java @@ -49,9 +49,6 @@ protected void onInitialize() { add(form); DatePanel offset = new DatePanel(ID_OFFSET, getModel()); - for (FormComponent formComponent : offset.getFormComponents()) { - formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); - } form.add(offset); AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("PageInternals.button.changeTime")) { 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 25dad9df661..89e618dfdbf 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 @@ -264,19 +264,25 @@ 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/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java index 34703f4dd6b..67b0533cc02 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/server/PageTask.java @@ -487,7 +487,10 @@ protected Class getRestartResponsePage() { @Override public void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync) { - + if (!isKeepDisplayingResults()) { + showResult(result); + redirectBack(); + } } @Override diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java index 78380a4215a..06178e18898 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestIntegrationObjectWrapperFactory.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest; import com.evolveum.midpoint.web.AdminGuiTestConstants; @@ -123,7 +122,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti PrismObject systemConfig = parseObject(SYSTEM_CONFIGURATION_FILE); -// LOGGER.info("adding system config page"); addObject(systemConfig, ModelExecuteOptions.createOverwrite(), initTask, initResult); } @@ -131,13 +129,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100CreateWrapperUserJack() throws Exception { final String TEST_NAME = "test100CreateWrapperUserJack"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assertLoggedInUserOid(USER_ADMINISTRATOR_OID); PrismObject user = getUser(USER_JACK_OID); @@ -148,7 +145,7 @@ public void test100CreateWrapperUserJack() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -218,11 +215,10 @@ private void assertContainersPaths(PrismObjectWrapper objectWrapper, Collecti @Test public void test110CreateWrapperUserNewEmpty() throws Exception { final String TEST_NAME = "test110CreateWrapperUserNew"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUserDefinition().instantiate(); // WHEN - displayWhen(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -235,7 +231,7 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.ADDED, context); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -289,11 +285,10 @@ public void test110CreateWrapperUserNewEmpty() throws Exception { @Test public void test112CreateWrapperUserNewman() throws Exception { final String TEST_NAME = "test112CreateWrapperUserNewman"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUserDefinition().instantiate(); // WHEN - displayWhen(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -313,7 +308,7 @@ public void test112CreateWrapperUserNewman() throws Exception { WrapperTestUtil.fillInPropertyWrapper(modelServiceLocator, mainContainerValueWrapper, extensionPath(PIRACY_SHIP), USER_NEWMAN_SHIP); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -367,12 +362,11 @@ public void test112CreateWrapperUserNewman() throws Exception { @Test public void test102CreateWrapperUserEmpty() throws Exception { final String TEST_NAME = "test102CreateWrapperUserEmpty"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject user = getUser(USER_EMPTY_OID); PrismObject userOld = user.clone(); // WHEN - displayWhen(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -384,7 +378,7 @@ public void test102CreateWrapperUserEmpty() throws Exception { PrismObjectWrapper objectWrapper = factory.createObjectWrapper(user, ItemStatus.NOT_CHANGED, context); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); @@ -428,14 +422,13 @@ public void test102CreateWrapperUserEmpty() throws Exception { @Test public void test150CreateWrapperShadow() throws Exception { final String TEST_NAME = "test150CreateWrapperShadow"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject shadow = getShadowModel(accountJackOid); shadow.findReference(ShadowType.F_RESOURCE_REF).getValue().setObject(resourceDummy); display("Shadow", shadow); PrismObject shadowOld = shadow.clone(); // WHEN - displayWhen(TEST_NAME); + when(); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -450,7 +443,7 @@ public void test150CreateWrapperShadow() throws Exception { // THEN - displayThen(TEST_NAME); + then(); display("Wrapper after", objectWrapper); WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "shadow description", shadow, shadowOld, ItemStatus.NOT_CHANGED); @@ -512,20 +505,16 @@ private PrismObjectWrapper createObjectWrapper(Task ta @Test public void test160CreateWrapperOrgScummBar() throws Exception { - final String TEST_NAME = "test160CreateWrapperOrgScummBar"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); PrismObject orgOld = org.clone(); // WHEN - displayWhen(TEST_NAME); - - Task task = taskManager.createTaskInstance(TEST_NAME); + when(); + Task task = getTestTask(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, org, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); - + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); WrapperTestUtil.assertWrapper(objectWrapper, getString("prismContainer.mainPanelDisplayName"), "org description", org, orgOld, ItemStatus.NOT_CHANGED); @@ -575,9 +564,8 @@ public void test160CreateWrapperOrgScummBar() throws Exception { @Test public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME); @@ -606,14 +594,14 @@ public void test220AssignRoleLandluberToWally() throws Exception { assertGroupMember(dummyGroup, USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, shadow, ItemStatus.NOT_CHANGED); assertTrue("Wrong wrapper created. Expected ShadowWrapper but was " + objectWrapper.getClass().getSimpleName(), objectWrapper instanceof ShadowWrapper); ShadowWrapper shadowWrapper = (ShadowWrapper) objectWrapper; // THEN - displayThen(TEST_NAME); + then(); display("Wrapper after", shadowWrapper); @@ -658,11 +646,9 @@ public void test220AssignRoleLandluberToWally() throws Exception { @Test public void test240OrgScummBarModifyTransformDescription() throws Exception { - final String TEST_NAME = "test240OrgScummBarModifyTransformDescription"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, org, ItemStatus.NOT_CHANGED); IntegrationTestTools.display("Wrapper before", objectWrapper); @@ -674,11 +660,11 @@ public void test240OrgScummBarModifyTransformDescription() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath ahoyPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM_DESCRIPTION); PrismAsserts.assertPropertyReplace(objectDelta, ahoyPath, "Whatever"); @@ -697,7 +683,6 @@ public void test240OrgScummBarModifyTransformDescription() throws Exception { @Test public void test241OrgScummBarModifyTransformProperties() throws Exception { final String TEST_NAME = "test241OrgScummBarModifyTransformProperties"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -718,11 +703,11 @@ public void test241OrgScummBarModifyTransformProperties() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath ahoyPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM, valueWrapperA.getNewValue().getId(), PIRACY_REPLACEMENT); PrismAsserts.assertPropertyReplace(objectDelta, ahoyPath, "Ahoy"); @@ -741,7 +726,6 @@ public void test241OrgScummBarModifyTransformProperties() throws Exception { @Test public void test242OrgScummBarAddTransform() throws Exception { final String TEST_NAME = "test242OrgScummBarAddTransform"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_SCUMM_BAR_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -766,11 +750,11 @@ public void test242OrgScummBarAddTransform() throws Exception { IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(); display("Delta", objectDelta); ItemPath transformPath = ItemPath.create(ObjectType.F_EXTENSION, PIRACY_TRANSFORM); PrismAsserts.assertModifications(objectDelta, 1); @@ -804,7 +788,6 @@ public void test242OrgScummBarAddTransform() throws Exception { @Test public void test250OrgMinistryOrRumModifyTransformDescription() throws Exception { final String TEST_NAME = "test250OrgMinistryOrRumModifyTransformDescription"; - TestUtil.displayTestTitle(TEST_NAME); PrismObject org = getObject(OrgType.class, ORG_MINISTRY_OF_RUM_OID); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -819,11 +802,11 @@ public void test250OrgMinistryOrRumModifyTransformDescription() throws Exception IntegrationTestTools.display("Wrapper after", objectWrapper); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta objectDelta = objectWrapper.getObjectDelta(); // THEN - displayThen(TEST_NAME); + then(); display("Delta", objectDelta); PrismAsserts.assertModifications(objectDelta, 1); @@ -888,23 +871,21 @@ private void modifyTransformProp(PrismContainerValueWrapper trans @Test public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); PrismObject user = getUser(USER_JACK_OID); display("user before", user); // WHEN - displayWhen(TEST_NAME); + when(); - PrismObjectWrapper objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED); + PrismObjectWrapper objectWrapper = createObjectWrapper(getTestTask(), user, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); @@ -961,23 +942,22 @@ public void test800EditSchemaJackPropReadAllModifySomeUser() throws Exception { @Test public void test802EditSchemaJackPropReadSomeModifySomeUser() throws Exception { final String TEST_NAME = "test800EditSchemaJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject user = getUser(USER_JACK_OID); display("user before", user); // WHEN - displayWhen(TEST_NAME); + when(); PrismObjectWrapper objectWrapper = createObjectWrapper(task, user, ItemStatus.NOT_CHANGED); // THEN - displayThen(TEST_NAME); + then(); IntegrationTestTools.display("Wrapper after", objectWrapper); assertEquals("Wrong object wrapper readOnly", Boolean.FALSE, (Boolean)objectWrapper.isReadOnly()); 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..a699bc67655 --- /dev/null +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestPageRole.java @@ -0,0 +1,148 @@ +/* + * 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.page.admin.users.PageOrgUnit; +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 test001testPageRole() { + renderPage(PageRole.class); + } + + @Test + public void test002testAddNewRole() 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 test003testMembers() 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/gui/TestWrapperDelta.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java index 49836aa40dd..3a5ca945126 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/gui/TestWrapperDelta.java @@ -79,7 +79,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100modifyUserFullname() throws Exception { final String TEST_NAME = "test100CreateWrapperUserJack"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -110,7 +109,6 @@ public void test100modifyUserFullname() throws Exception { @Test public void test101modifyUserWeapon() throws Exception { final String TEST_NAME = "test101modifyUserWeapon"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -146,7 +144,6 @@ public void test101modifyUserWeapon() throws Exception { @Test public void test110modifyUserAddAssignment() throws Exception { final String TEST_NAME = "test110modifyUserAddAssignment"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -181,7 +178,6 @@ public void test110modifyUserAddAssignment() throws Exception { @Test public void test111modifyUserAssignemnt() throws Exception { final String TEST_NAME = "test110modifyUserAddAssignment"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -265,7 +261,6 @@ public void test111modifyUserAssignemnt() throws Exception { @Test public void test200createUser() throws Exception { String TEST_NAME = "test200createUser"; - displayTestTitle(TEST_NAME); Task task = createSimpleTask(TEST_NAME); OperationResult result = task.getResult(); @@ -321,7 +316,6 @@ public void test200createUser() throws Exception { @Test public void test300SaveSystemConfigWithoutChanges() throws Exception { final String TEST_NAME = "test300SaveSystemConfigWithoutChanges"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -339,7 +333,6 @@ public void test300SaveSystemConfigWithoutChanges() throws Exception { @Test public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception { final String TEST_NAME = "test301ModifyProfilingClassLoggerOfSystemConfig"; - TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); 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 fa5772a76b3..f11cea93bab 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 @@ -17,6 +17,11 @@ import java.util.Locale; 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 org.apache.wicket.util.tester.WicketTester; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -310,4 +315,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); + } + } + } + } } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java index 0c7e7327395..c29675aa029 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractGuiUnitTest.java @@ -36,16 +36,12 @@ import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractHigherUnitTest; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; /** * @author lazyman */ public abstract class AbstractGuiUnitTest extends AbstractHigherUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractGuiUnitTest.class); - protected ModelServiceLocator getServiceLocator() { return new ModelServiceLocator() { diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java index 9b1c4cdeeee..02901d3f5d8 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/AbstractInitializedGuiIntegrationTest.java @@ -10,7 +10,6 @@ import static com.evolveum.midpoint.web.AdminGuiTestConstants.*; -import com.evolveum.midpoint.prism.path.ItemName; import org.testng.annotations.Test; import com.evolveum.icf.dummy.resource.DummyResource; @@ -27,16 +26,11 @@ /** * @author semancik - * */ public abstract class AbstractInitializedGuiIntegrationTest extends AbstractGuiIntegrationTest { private static final Trace LOGGER = TraceManager.getTrace(AbstractInitializedGuiIntegrationTest.class); -// protected final static String PIRACY_NS = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; -// protected final static ItemName PIRACY_WEAPON = new ItemName(PIRACY_NS, "weapon"); - - protected DummyResource dummyResource; protected DummyResourceContoller dummyResourceCtl; protected ResourceType resourceDummyType; @@ -71,21 +65,18 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000PreparationAndSanity() throws Exception { - final String TEST_NAME = "test000PreparationAndSanity"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNotNull("No model service", modelService); // WHEN - TestUtil.displayWhen(TEST_NAME); + when("Jack is assigned with account"); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then("One link (account) is created"); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -94,7 +85,5 @@ public void test000PreparationAndSanity() throws Exception { display("User after change execution", userJack); assertUserJack(userJack); accountJackOid = getSingleLinkOid(userJack); - } - } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java index e39bd80413b..c14a3499f5c 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/ObjectWrapperTest.java @@ -7,22 +7,11 @@ package com.evolveum.midpoint.web; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.web.component.prism.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import java.io.File; -import java.lang.reflect.Field; /** * @author lazyman diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java index be944a9953b..5377ad05c26 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/SpringApplicationContextTest.java @@ -7,14 +7,15 @@ package com.evolveum.midpoint.web; -import com.evolveum.midpoint.init.InitialDataImport; -import com.evolveum.midpoint.model.api.ModelService; +import static org.testng.AssertJUnit.assertNotNull; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.Test; -import static org.testng.AssertJUnit.assertNotNull; +import com.evolveum.midpoint.init.InitialDataImport; +import com.evolveum.midpoint.model.api.ModelService; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** * Test of spring application context initialization @@ -34,8 +35,8 @@ "classpath:ctx-security.xml", "classpath:ctx-provisioning.xml", "classpath:ctx-model.xml", - "classpath*:ctx-workflow.xml"}) -public class SpringApplicationContextTest extends AbstractTestNGSpringContextTests { + "classpath*:ctx-workflow.xml" }) +public class SpringApplicationContextTest extends AbstractSpringTest { @Autowired private ModelService modelService; diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java index 1c4921e9c0f..c87225dd5c8 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestCleanStartup.java @@ -8,7 +8,6 @@ import java.util.Collection; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -16,9 +15,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.common.LoggingConfigurationManager; -import com.evolveum.midpoint.init.InfraInitialSetup; -import com.evolveum.midpoint.init.InitialDataImport; -import com.evolveum.midpoint.init.ModelInitialSetup; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; @@ -49,7 +45,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // work in progress @Test public void test001Logfiles() throws Exception { - TestUtil.displayTestTitle("test001Logfiles"); // GIVEN - system startup and initialization that has already happened LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME, false); diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java index 7b0d5a272ed..279c90f81ae 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestDescriptorLoader.java @@ -14,16 +14,12 @@ import java.util.EventListener; import java.util.Map; import java.util.Set; - import javax.servlet.*; import javax.servlet.descriptor.JspConfigDescriptor; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.web.application.DescriptorLoader; import com.evolveum.midpoint.web.security.MidPointApplication; @@ -43,15 +39,11 @@ "classpath:ctx-security.xml", "classpath:ctx-provisioning.xml", "classpath:ctx-model.xml", - "classpath*:ctx-workflow.xml"}) + "classpath*:ctx-workflow.xml" }) public class TestDescriptorLoader extends AbstractGuiUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDescriptorLoader.class); - - @Test(enabled=false) + @Test(enabled = false) public void testDescriptorLoader() { - final String TEST_NAME = "testDescriptorLoader"; - TestUtil.displayTestTitle(TEST_NAME); MidPointApplication midPointApplication = new MidPointApplication(); ServletContext mockServletContext = new ServletContext() { @@ -235,17 +227,17 @@ public void removeAttribute(String arg0) { @Override public void log(String msg, Throwable e) { - LOGGER.error("{}", msg, e); + logger.error("{}", msg, e); } @Override public void log(Exception e, String msg) { - LOGGER.error("{}", msg, e); + logger.error("{}", msg, e); } @Override public void log(String msg) { - LOGGER.trace("{}", msg); + logger.trace("{}", msg); } @Override diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java index e38c70fdb8d..b64cf52be13 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestInitialObjects.java @@ -17,8 +17,6 @@ import com.evolveum.midpoint.schema.validator.ValidationItem; import com.evolveum.midpoint.schema.validator.ValidationResult; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; /** @@ -28,15 +26,10 @@ */ public class TestInitialObjects extends AbstractGuiUnitTest { - private static final Trace LOGGER = TraceManager.getTrace(TestInitialObjects.class); - private static final File DIR_INITIAL_OBJECTS = new File("src/main/resources/initial-objects"); @Test public void testInitialObjects() throws Exception { - final String TEST_NAME = "testInitialObjects"; - displayTestTitle(TEST_NAME); - ObjectValidator validator = new ObjectValidator(getPrismContext()); validator.setAllWarnings(); @@ -48,7 +41,7 @@ public void testInitialObjects() throws Exception { testInitialObject(validator, errorsSb, file); } catch (Throwable e) { String msg = "Error processing file "+file.getName()+": "+e.getMessage(); - LOGGER.error(msg, e); + logger.error(msg, e); display(msg, e); throw e; } diff --git a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java index a9a65824752..98999722901 100644 --- a/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java +++ b/gui/admin-gui/src/test/java/com/evolveum/midpoint/web/TestIntegrationSecurity.java @@ -92,7 +92,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100DecideNoRole() throws Exception { final String TEST_NAME = "test100DecideNoRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject user = getUser(USER_JACK_OID); @@ -102,7 +101,7 @@ public void test100DecideNoRole() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -113,13 +112,12 @@ public void test100DecideNoRole() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(); } @Test public void test110DecideRoleUiAllowAll() throws Exception { final String TEST_NAME = "test110DecideRoleUiAllowAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_ALLOW_ALL_OID); @@ -130,7 +128,7 @@ public void test110DecideRoleUiAllowAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -141,13 +139,12 @@ public void test110DecideRoleUiAllowAll() throws Exception { assertAllow(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(); } @Test public void test120DecideRoleUiDenyAll() throws Exception { final String TEST_NAME = "test120DecideRoleUiDenyAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_DENY_ALL_OID); @@ -158,7 +155,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -169,7 +166,7 @@ public void test120DecideRoleUiDenyAll() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(); } @@ -179,7 +176,6 @@ public void test120DecideRoleUiDenyAll() throws Exception { @Test public void test200DecideRoleUiDenyAllow() throws Exception { final String TEST_NAME = "test200DecideRoleUiDenyAllow"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UI_DENY_ALLOW_OID); @@ -190,7 +186,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { Authentication authentication = createPasswordAuthentication(USER_JACK_USERNAME, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow(authentication, "/login"); assertAllow(authentication, "/"); @@ -201,7 +197,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { assertDeny(authentication, "/admin/config/debugs"); // THEN - displayThen(TEST_NAME); + then(); } @@ -211,7 +207,7 @@ public void test200DecideRoleUiDenyAllow() throws Exception { @Test public void test300ConflictingAuthorizationIds() throws Exception { final String TEST_NAME = "test300ConflictingAuthorizationIds"; - displayTestTitle(TEST_NAME); + // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_AUTHORIZATION_1.oid); @@ -220,11 +216,11 @@ public void test300ConflictingAuthorizationIds() throws Exception { display("user before", user); // WHEN - displayWhen(TEST_NAME); + when("Jack logs in"); login(USER_JACK_USERNAME); // THEN - displayThen(TEST_NAME); + then(); assertLoggedInUsername(USER_JACK_USERNAME); } diff --git a/gui/admin-gui/testng-integration.xml b/gui/admin-gui/testng-integration.xml index 974b7bc2864..5b10ffe9835 100644 --- a/gui/admin-gui/testng-integration.xml +++ b/gui/admin-gui/testng-integration.xml @@ -19,6 +19,7 @@ + diff --git a/infra/common/pom.xml b/infra/common/pom.xml index cd28b157f36..c9a0371983f 100644 --- a/infra/common/pom.xml +++ b/infra/common/pom.xml @@ -139,7 +139,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/AbstractActivationComputerTest.java b/infra/common/src/test/java/com/evolveum/midpoint/common/AbstractActivationComputerTest.java index 6ea8603ece4..b4cb4d89e6f 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/AbstractActivationComputerTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/AbstractActivationComputerTest.java @@ -9,7 +9,6 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; - import javax.xml.datatype.XMLGregorianCalendar; import org.testng.annotations.BeforeSuite; @@ -21,6 +20,7 @@ import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; @@ -28,11 +28,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.LifecycleStateModelType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType; -/** - * @author semancik - * - */ -public abstract class AbstractActivationComputerTest { +public abstract class AbstractActivationComputerTest extends AbstractUnitTest { protected static final XMLGregorianCalendar YEAR_START = XmlTypeConverter.createXMLGregorianCalendar(2013, 1, 1, 0, 0, 0); protected static final XMLGregorianCalendar SPRING_EQUINOX = XmlTypeConverter.createXMLGregorianCalendar(2013, 3, 20, 11, 2, 0); @@ -53,19 +49,20 @@ public void setup() throws SchemaException, SAXException, IOException { PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); } - protected abstract LifecycleStateModelType createLifecycleModel() throws SchemaException, IOException; + protected abstract LifecycleStateModelType createLifecycleModel() + throws SchemaException, IOException; @Test public void testGetAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = + activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus); @@ -73,15 +70,15 @@ public void testGetAdministrativeEnabled() throws Exception { @Test public void testGetAdministrativeDisabled() throws Exception { - System.out.println("\n===[ testGetAdministrativeDisabled ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = + activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -89,15 +86,15 @@ public void testGetAdministrativeDisabled() throws Exception { @Test public void testGetAdministrativeArchived() throws Exception { - System.out.println("\n===[ testGetAdministrativeArchived ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = + activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus); @@ -105,15 +102,15 @@ public void testGetAdministrativeArchived() throws Exception { @Test public void testGetDraftAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetDraftAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -121,31 +118,31 @@ public void testGetDraftAdministrativeEnabled() throws Exception { @Test public void testGetProposedAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetProposedAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); } @Test - public void testGetLimboAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetLimboAdministrativeEnabled ]===\n"); - + public void testGetLimboAdministrativeEnabled() { // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(LIFECYCLE_STATE_LIMBO, activationType, null); + ActivationStatusType effectiveStatus = + activationComputer.getEffectiveStatus(LIFECYCLE_STATE_LIMBO, activationType, null); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -153,15 +150,15 @@ public void testGetLimboAdministrativeEnabled() throws Exception { @Test public void testGetActiveAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetActiveAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus); @@ -169,15 +166,15 @@ public void testGetActiveAdministrativeEnabled() throws Exception { @Test public void testGetActiveAdministrativeDisabled() throws Exception { - System.out.println("\n===[ testGetActiveAdministrativeDisabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -185,15 +182,15 @@ public void testGetActiveAdministrativeDisabled() throws Exception { @Test public void testGetDeprecatedAdministrativeDisabled() throws Exception { - System.out.println("\n===[ testGetDeprecatedAdministrativeDisabled ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DEPRECATED, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_DEPRECATED, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -201,15 +198,15 @@ public void testGetDeprecatedAdministrativeDisabled() throws Exception { @Test public void testGetDeprecatedAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetDeprecatedAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DEPRECATED, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_DEPRECATED, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus); @@ -217,15 +214,15 @@ public void testGetDeprecatedAdministrativeEnabled() throws Exception { @Test public void testGetActiveAdministrativeArchived() throws Exception { - System.out.println("\n===[ testGetAdministrativeArchived ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus); @@ -233,32 +230,30 @@ public void testGetActiveAdministrativeArchived() throws Exception { @Test public void testGetArchivedAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetArchivedAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = createActivationType( + ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_ARCHIVED, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_ARCHIVED, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus); } - @Test public void testGetBeforeValidity() throws Exception { - System.out.println("\n===[ testGetBeforeValidity ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); ActivationType activationType = createActivationType(null, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -266,15 +261,14 @@ public void testGetBeforeValidity() throws Exception { @Test public void testGetInValidity() throws Exception { - System.out.println("\n===[ testGetInValidity ]===\n"); - // GIVEN Clock clock = createClock(SUMMER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); ActivationType activationType = createActivationType(null, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus); @@ -282,15 +276,14 @@ public void testGetInValidity() throws Exception { @Test public void testGetAfterValidity() throws Exception { - System.out.println("\n===[ testGetAfterValidity ]===\n"); - // GIVEN Clock clock = createClock(WINTER_SOLSTICE); ActivationComputer activationComputer = createActivationComputer(clock); ActivationType activationType = createActivationType(null, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(null, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + null, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus); @@ -298,111 +291,137 @@ public void testGetAfterValidity() throws Exception { @Test public void testComputeAdministrativeEnabledBefore() throws Exception { - testCompute("testComputeAdministrativeEnabledBefore", YEAR_START, + testCompute(YEAR_START, ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.ENABLED, TimeIntervalStatusType.BEFORE); } @Test public void testComputeAdministrativeEnabledIn() throws Exception { - testCompute("testComputeAdministrativeEnabledIn", SUMMER_SOLSTICE, + testCompute(SUMMER_SOLSTICE, ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.ENABLED, TimeIntervalStatusType.IN); } @Test public void testComputeAdministrativeEnabledAfter() throws Exception { - testCompute("testComputeAdministrativeEnabledBefore", WINTER_SOLSTICE, + testCompute(WINTER_SOLSTICE, ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.ENABLED, TimeIntervalStatusType.AFTER); } @Test public void testComputeAdministrativeArchivedBefore() throws Exception { - testCompute("testComputeAdministrativeArchivedBefore", YEAR_START, + testCompute(YEAR_START, ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.ARCHIVED, TimeIntervalStatusType.BEFORE); } @Test public void testComputeAdministrativeDisabledIn() throws Exception { - testCompute("testComputeAdministrativeDisabledIn", SUMMER_SOLSTICE, + testCompute(SUMMER_SOLSTICE, ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.DISABLED, TimeIntervalStatusType.IN); } @Test public void testComputeAdministrativeDisabledAfter() throws Exception { - testCompute("testComputeAdministrativeDisabledAfter", WINTER_SOLSTICE, + testCompute(WINTER_SOLSTICE, ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.DISABLED, TimeIntervalStatusType.AFTER); } @Test public void testComputeBefore() throws Exception { - testCompute("testComputeAdministrativeEnabledBefore", YEAR_START, + testCompute(YEAR_START, null, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.DISABLED, TimeIntervalStatusType.BEFORE); } @Test public void testComputeIn() throws Exception { - testCompute("testComputeAdministrativeEnabledIn", SUMMER_SOLSTICE, + testCompute(SUMMER_SOLSTICE, null, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.ENABLED, TimeIntervalStatusType.IN); } @Test public void testComputeAfter() throws Exception { - testCompute("testComputeAdministrativeEnabledBefore", WINTER_SOLSTICE, + testCompute(WINTER_SOLSTICE, null, SPRING_EQUINOX, AUTUMN_EQUINOX, ActivationStatusType.DISABLED, TimeIntervalStatusType.AFTER); } - protected void testCompute(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - System.out.println("\n===[ "+TEST_NAME+" ]===\n"); - - testCompute(TEST_NAME, null, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testComputeDraft(TEST_NAME, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testComputeProposed(TEST_NAME, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_ACTIVE, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_DEPRECATED, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_FAILED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_ARCHIVED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); - testComputeLimbo(TEST_NAME, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testComputeCharmed(TEST_NAME, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - testComputeInhumed(TEST_NAME, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); - } - - protected void testComputeDraft(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_DRAFT, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - } - - protected void testComputeProposed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_PROPOSED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - } - - protected void testComputeLimbo(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, LIFECYCLE_STATE_LIMBO, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - } - - protected void testComputeCharmed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, LIFECYCLE_STATE_CHARMED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - } - - protected void testComputeInhumed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, LIFECYCLE_STATE_INHUMED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); - } - - protected void testCompute(final String TEST_NAME, String lifecycleState, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - + protected void testCompute( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(null, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + testComputeDraft(now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + testComputeProposed(now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + testCompute(SchemaConstants.LIFECYCLE_ACTIVE, now, administrativeStatus, + validFrom, validTo, expectedEffective, expectedValidity); + testCompute(SchemaConstants.LIFECYCLE_DEPRECATED, now, administrativeStatus, + validFrom, validTo, expectedEffective, expectedValidity); + testCompute(SchemaConstants.LIFECYCLE_FAILED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + testCompute(SchemaConstants.LIFECYCLE_ARCHIVED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); + testComputeLimbo(now, administrativeStatus, validFrom, validTo, expectedValidity); + testComputeCharmed(now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + testComputeInhumed(now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + } + + protected void testComputeDraft( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(SchemaConstants.LIFECYCLE_DRAFT, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + } + + protected void testComputeProposed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(SchemaConstants.LIFECYCLE_PROPOSED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + } + + protected void testComputeLimbo( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { + testCompute(LIFECYCLE_STATE_LIMBO, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + } + + protected void testComputeCharmed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(LIFECYCLE_STATE_CHARMED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + } + + protected void testComputeInhumed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(LIFECYCLE_STATE_INHUMED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.DISABLED, expectedValidity); + } + + protected void testCompute(String lifecycleState, + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { // GIVEN Clock clock = createClock(now); ActivationComputer activationComputer = createActivationComputer(clock); @@ -417,8 +436,7 @@ protected void testCompute(final String TEST_NAME, String lifecycleState, XMLGre } protected ActivationComputer createActivationComputer(Clock clock) { - ActivationComputer activationComputer = new ActivationComputer(clock); - return activationComputer; + return new ActivationComputer(clock); } protected Clock createClock(XMLGregorianCalendar date) { @@ -427,14 +445,12 @@ protected Clock createClock(XMLGregorianCalendar date) { return clock; } - protected ActivationType createActivationType(ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo) { + protected ActivationType createActivationType(ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) { ActivationType activationType = new ActivationType(); activationType.setAdministrativeStatus(administrativeStatus); activationType.setValidFrom(validFrom); activationType.setValidTo(validTo); return activationType; } - } - diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/CommonTestConstants.java b/infra/common/src/test/java/com/evolveum/midpoint/common/CommonTestConstants.java deleted file mode 100644 index 4d7bcd079c1..00000000000 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/CommonTestConstants.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2010-2013 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.common; - -import java.io.File; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; - -/** - * @author semancik - * - */ -public class CommonTestConstants { - - public static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; - public static final File USER_JACK_FILE = new File(MidPointTestConstants.OBJECTS_DIR, USER_JACK_OID + ".xml"); - -} diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/LocalizationTest.java b/infra/common/src/test/java/com/evolveum/midpoint/common/LocalizationTest.java index 6fe3e4606ad..46a86c3a4b0 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/LocalizationTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/LocalizationTest.java @@ -8,6 +8,7 @@ package com.evolveum.midpoint.common; import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.LocalizableMessage; import com.evolveum.midpoint.util.LocalizableMessageBuilder; import org.testng.AssertJUnit; @@ -21,7 +22,8 @@ /** * Created by Viliam Repan (lazyman). */ -public class LocalizationTest { +// TODO testing: missing from suite, 1 test failing +public class LocalizationTest extends AbstractUnitTest { private static String midpointHome; @@ -46,7 +48,7 @@ public static void afterClass() { } @Test - public void localization() throws Exception { + public void localization() { assertTranslation(service, "standardKey", "standardKeyCustomValue"); assertTranslation(service, "customMidpointKey", "customMidpointValue"); assertTranslation(service, "otherKey", "otherValue"); @@ -56,7 +58,7 @@ public void localization() throws Exception { } @Test - public void localizationParams2() throws Exception { + public void localizationParams2() { Object[] params = new Object[2]; params[0] = "John"; params[1] = "Couldn't find user with name 'John'"; @@ -68,12 +70,12 @@ public void localizationParams2() throws Exception { } @Test - public void localizationDefaults() throws Exception { + public void localizationDefaults() { assertTranslation(service, "unknownKey", "expectedValues", "expectedValues"); } @Test - public void localizationParams() throws Exception { + public void localizationParams() { Object[] params = new Object[3]; params[0] = 123; params[1] = new LocalizableMessageBuilder().key("someunknownkey").fallbackMessage("fallback").build(); diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerDefault.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerDefault.java index a6b9c519ef0..a88aca51231 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerDefault.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerDefault.java @@ -6,37 +6,12 @@ */ package com.evolveum.midpoint.common; -import static org.testng.AssertJUnit.assertEquals; - -import java.io.IOException; - -import javax.xml.datatype.XMLGregorianCalendar; - -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LifecycleStateModelType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType; -/** - * @author semancik - * - */ public class TestActivationComputerDefault extends AbstractActivationComputerTest { @Override - protected LifecycleStateModelType createLifecycleModel() throws SchemaException, IOException { + protected LifecycleStateModelType createLifecycleModel() { return null; } - } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerLifecycle.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerLifecycle.java index f6b31388a61..9ff46b6c707 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerLifecycle.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestActivationComputerLifecycle.java @@ -11,55 +11,42 @@ import java.io.File; import java.io.IOException; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LifecycleStateModelType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType; - -/** - * @author semancik - * - */ +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + public class TestActivationComputerLifecycle extends AbstractActivationComputerTest { - private static final File SYSTEM_CONFIGURATION_LIFECYCLE_FILE = new File("src/test/resources/system-configuration-lifecycle.xml"); + private static final File SYSTEM_CONFIGURATION_LIFECYCLE_FILE = + new File("src/test/resources/system-configuration-lifecycle.xml"); @Override protected LifecycleStateModelType createLifecycleModel() throws SchemaException, IOException { - PrismObject systemConfig = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_LIFECYCLE_FILE); - List objectPolicyConfigurations = systemConfig.asObjectable().getDefaultObjectPolicyConfiguration(); + PrismObject systemConfig = + PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_LIFECYCLE_FILE); + List objectPolicyConfigurations = + systemConfig.asObjectable().getDefaultObjectPolicyConfiguration(); return objectPolicyConfigurations.get(0).getLifecycleStateModel(); } @Test @Override public void testGetProposedAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetProposedAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = + createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_PROPOSED, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ENABLED, effectiveStatus); @@ -68,42 +55,58 @@ public void testGetProposedAdministrativeEnabled() throws Exception { @Test @Override public void testGetDraftAdministrativeEnabled() throws Exception { - System.out.println("\n===[ testGetDraftAdministrativeEnabled ]===\n"); - // GIVEN Clock clock = createClock(YEAR_START); ActivationComputer activationComputer = createActivationComputer(clock); - ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); + ActivationType activationType = + createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX); // WHEN - ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel()); + ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus( + SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel()); // THEN assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus); } @Override - protected void testComputeDraft(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_DRAFT, now, administrativeStatus, validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); + protected void testComputeDraft( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(SchemaConstants.LIFECYCLE_DRAFT, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); } @Override - protected void testComputeProposed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, SchemaConstants.LIFECYCLE_PROPOSED, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + protected void testComputeProposed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(SchemaConstants.LIFECYCLE_PROPOSED, now, administrativeStatus, + validFrom, validTo, expectedEffective, expectedValidity); } @Override - protected void testComputeCharmed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, LIFECYCLE_STATE_CHARMED, now, administrativeStatus, validFrom, validTo, expectedEffective, expectedValidity); + protected void testComputeCharmed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(LIFECYCLE_STATE_CHARMED, now, administrativeStatus, + validFrom, validTo, expectedEffective, expectedValidity); } @Override - protected void testComputeInhumed(final String TEST_NAME, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, - XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException { - testCompute(TEST_NAME, LIFECYCLE_STATE_INHUMED, now, administrativeStatus, validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); + protected void testComputeInhumed( + XMLGregorianCalendar now, ActivationStatusType administrativeStatus, + XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, + ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) + throws SchemaException, IOException { + testCompute(LIFECYCLE_STATE_INHUMED, now, administrativeStatus, + validFrom, validTo, ActivationStatusType.ARCHIVED, expectedValidity); } } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java index cc26d6eecb8..50facf859c0 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestCryptoUtil.java @@ -6,46 +6,45 @@ */ package com.evolveum.midpoint.common; +import static java.util.Collections.singleton; +import static org.testng.Assert.fail; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.test.util.MidPointTestConstants.TEST_RESOURCES_DIR; +import static com.evolveum.midpoint.test.util.MidPointTestConstants.TEST_RESOURCES_PATH; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.common.crypto.CryptoUtil; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.crypto.KeyStoreBasedProtectorBuilder; +import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ItemDeltaCollectionsUtil; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.test.util.MidPointTestConstants.TEST_RESOURCES_DIR; -import static com.evolveum.midpoint.test.util.MidPointTestConstants.TEST_RESOURCES_PATH; -import static java.util.Collections.singleton; -import static org.testng.Assert.fail; -import static org.testng.AssertJUnit.*; - -/** - * @author mederly - */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) -public class TestCryptoUtil { +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) +public class TestCryptoUtil extends AbstractUnitTest { private static final File TEST_DIR = new File(TEST_RESOURCES_DIR, "crypto"); private static final File FILE_USER_JACK = new File(TEST_DIR, "user-jack.xml"); @@ -69,9 +68,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100CheckEncryptedUser() throws Exception { - final String TEST_NAME = "test100CheckEncryptedUser"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); @@ -82,9 +78,6 @@ public void test100CheckEncryptedUser() throws Exception { @Test public void test110EncryptUser() throws Exception { - final String TEST_NAME = "test110EncryptUser"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); @@ -99,9 +92,6 @@ public void test110EncryptUser() throws Exception { @Test public void test120EncryptBulkActionTask() throws Exception { - final String TEST_NAME = "test120EncryptBulkActionTask"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject task = prismContext.parserFor(FILE_TASK_MODIFY_JACK_PASSWORD).xml().parse(); @@ -119,9 +109,6 @@ public void test120EncryptBulkActionTask() throws Exception { @Test public void test130EncryptUserInDelta() throws Exception { - final String TEST_NAME = "test130EncryptUserInDelta"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject task = prismContext.parserFor(FILE_TASK_ADD_JACK).xml().parse(); @@ -140,9 +127,6 @@ public void test130EncryptUserInDelta() throws Exception { // MID-4941 @Test public void test200CheckEncryptedSystemConfiguration() throws Exception { - final String TEST_NAME = "test200CheckEncryptedSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject config = prismContext.parserFor(FILE_SYSTEM_CONFIGURATION).xml().parse(); @@ -154,9 +138,6 @@ public void test200CheckEncryptedSystemConfiguration() throws Exception { // MID-4941 @Test public void test210EncryptSystemConfiguration() throws Exception { - final String TEST_NAME = "test210EncryptSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject config = prismContext.parserFor(FILE_SYSTEM_CONFIGURATION).xml().parse(); @@ -173,9 +154,6 @@ public void test210EncryptSystemConfiguration() throws Exception { @SuppressWarnings("SimplifiedTestNGAssertion") @Test public void test300Reencryption() throws Exception { - final String TEST_NAME = "test300Reencryption"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); PrismObject jack = prismContext.parserFor(FILE_USER_JACK).xml().parse(); @@ -276,5 +254,4 @@ private Protector createCompromisedProtector() { .encryptionAlgorithm(Protector.XMLSEC_ENCRYPTION_ALGORITHM_AES256_CBC) .initialize(); } - } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java index 1b7988221c6..f5808997c80 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/TestStaticValues.java @@ -6,34 +6,32 @@ */ package com.evolveum.midpoint.common; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.IOException; +import java.util.List; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; - import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.util.List; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; - -import static org.testng.AssertJUnit.*; /** * @author semancik */ -public class TestStaticValues { +public class TestStaticValues extends AbstractUnitTest { private static final QName PROP_NAME = new QName("http://whatever.com/", "foo"); @@ -45,10 +43,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testValueElementsRoundtripString() throws Exception { - final String TEST_NAME = "testValueElementsRoundtripString"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_STRING); propDef.setMaxOccurs(-1); @@ -56,15 +50,11 @@ public void testValueElementsRoundtripString() throws Exception { origProperty.addRealValue("FOO"); origProperty.addRealValue("BAR"); - doRoundtrip(origProperty, propDef, prismContext); + doRoundtrip(origProperty, propDef); } @Test public void testValueElementsRoundtripInt() throws Exception { - final String TEST_NAME = "testValueElementsRoundtripInt"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_INT); propDef.setMaxOccurs(-1); @@ -73,22 +63,22 @@ public void testValueElementsRoundtripInt() throws Exception { origProperty.addRealValue(123); origProperty.addRealValue(321); - doRoundtrip(origProperty, propDef, prismContext); + doRoundtrip(origProperty, propDef); } - private void doRoundtrip(PrismProperty origProperty, ItemDefinition propDef, PrismContext prismContext) throws SchemaException, JAXBException { + private void doRoundtrip(PrismProperty origProperty, ItemDefinition propDef) throws SchemaException { // WHEN List> valueElements = StaticExpressionUtil.serializeValueElements(origProperty, "here somewhere"); - for (Object element: valueElements) { + for (Object element : valueElements) { if (element instanceof JAXBElement) { System.out.println(PrismTestUtil.serializeJaxbElementToString((JAXBElement) element)); } else { - AssertJUnit.fail("Unexpected element type "+element.getClass()); + AssertJUnit.fail("Unexpected element type " + element.getClass()); } } - PrismProperty parsedProperty = (PrismProperty)(Item) StaticExpressionUtil.parseValueElements(valueElements, propDef, "here again"); + PrismProperty parsedProperty = (PrismProperty) (Item) StaticExpressionUtil.parseValueElements(valueElements, propDef, "here again"); // THEN assertEquals("Roundtrip failed", origProperty, parsedProperty); diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java index 09099f0a9b5..e382af2c365 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java @@ -6,10 +6,8 @@ */ package com.evolveum.midpoint.common.refinery; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; import java.io.File; @@ -19,18 +17,8 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.ConsistencyCheckScope; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.query.EqualFilter; -import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.prism.util.PrismTestUtil; - -import com.evolveum.midpoint.schema.RelationRegistry; -import com.evolveum.midpoint.schema.processor.*; import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.annotations.BeforeSuite; @@ -39,39 +27,34 @@ import org.xml.sax.SAXException; import com.evolveum.midpoint.common.ResourceObjectPattern; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.Definition; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.query.EqualFilter; +import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; +import com.evolveum.midpoint.schema.RelationRegistry; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author semancik */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) -public class TestRefinedSchema { +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) +public class TestRefinedSchema extends AbstractUnitTest { public static final String TEST_DIR_NAME = "src/test/resources/refinery"; private static final File RESOURCE_COMPLEX_FILE = new File(TEST_DIR_NAME, "resource-complex.xml"); @@ -80,7 +63,6 @@ public class TestRefinedSchema { private static final String ENTITLEMENT_GROUP_INTENT = "group"; private static final String ENTITLEMENT_LDAP_GROUP_INTENT = "ldapGroup"; - private static final String ENTITLEMENT_UNIX_GROUP_INTENT = "unixGroup"; private static final QName OBJECT_CLASS_INETORGPERSON_QNAME = new QName(MidPointConstants.NS_RI, "inetOrgPerson"); @@ -96,9 +78,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test010ParseFromResourceComplex() throws Exception { - final String TEST_NAME = "test010ParseFromResourceComplex"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -106,11 +85,11 @@ public void test010ParseFromResourceComplex() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNotNull("Refined schema is null", rSchema); System.out.println("Refined schema"); System.out.println(rSchema.debugDump()); @@ -120,7 +99,7 @@ public void test010ParseFromResourceComplex() throws Exception { assertLayerRefinedSchema(resourceType, rSchema, LayerType.MODEL, LayerType.MODEL, true, true); assertLayerRefinedSchema(resourceType, rSchema, LayerType.PRESENTATION, LayerType.PRESENTATION, true, true); - RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); + RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String) null); RefinedAttributeDefinition userPasswordAttribute = rAccount.findAttributeDefinition("userPassword"); assertNotNull("No userPassword attribute", userPasswordAttribute); assertTrue("userPassword not ignored", userPasswordAttribute.isIgnored()); @@ -128,7 +107,7 @@ public void test010ParseFromResourceComplex() throws Exception { private void assertLayerRefinedSchema(ResourceType resourceType, RefinedResourceSchema rSchema, LayerType sourceLayer, LayerType validationLayer, boolean assertEntitlements, boolean assertPasswordPolicy) { - System.out.println("Refined schema: layer="+sourceLayer); + System.out.println("Refined schema: layer=" + sourceLayer); LayerRefinedResourceSchema lrSchema = rSchema.forLayer(sourceLayer); System.out.println(lrSchema.debugDump()); assertRefinedSchema(resourceType, lrSchema, sourceLayer, validationLayer, assertEntitlements, assertPasswordPolicy); @@ -136,9 +115,6 @@ private void assertLayerRefinedSchema(ResourceType resourceType, RefinedResource @Test public void test020ParseFromResourceSimple() throws Exception { - final String TEST_NAME = "test020ParseFromResourceSimple"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -162,15 +138,15 @@ private void assertRefinedSchema(ResourceType resourceType, RefinedResourceSchem assertEquals("Unexpected number of object classes in refined schema", 2, rSchema.getDefinitions().size()); - for (Definition def: rSchema.getDefinitions()) { + for (Definition def : rSchema.getDefinitions()) { if (!(def instanceof RefinedObjectClassDefinition)) { - AssertJUnit.fail("Non-refined definition sneaked into resource schema: "+def); + AssertJUnit.fail("Non-refined definition sneaked into resource schema: " + def); } } assertFalse("No account definitions", rSchema.getRefinedDefinitions(ShadowKindType.ACCOUNT).isEmpty()); - RefinedObjectClassDefinition rAccountDef = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); + RefinedObjectClassDefinition rAccountDef = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String) null); RefinedObjectClassDefinition accountDefByNullObjectclass = rSchema.findRefinedDefinitionByObjectClassQName(ShadowKindType.ACCOUNT, null); assertEquals("findAccountDefinitionByObjectClass(null) returned wrong value", rAccountDef, accountDefByNullObjectclass); @@ -211,10 +187,10 @@ private void assertRefinedSchema(ResourceType resourceType, RefinedResourceSchem if (assertEntitlements) { assertFalse("No entitlement definitions", rSchema.getRefinedDefinitions(ShadowKindType.ENTITLEMENT).isEmpty()); - RefinedObjectClassDefinition rEntDef = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, (String)null); + RefinedObjectClassDefinition rEntDef = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, (String) null); assertNotNull("No entitlement definition for null intent", rEntDef); RefinedObjectClassDefinition rEntDefGroup = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, ENTITLEMENT_GROUP_INTENT); - assertNotNull("No entitlement for intent '"+ENTITLEMENT_GROUP_INTENT+"'", rEntDefGroup); + assertNotNull("No entitlement for intent '" + ENTITLEMENT_GROUP_INTENT + "'", rEntDefGroup); assertEquals("Wrong kind", ShadowKindType.ENTITLEMENT, rEntDef.getKind()); @@ -235,31 +211,31 @@ private void assertRefinedSchema(ResourceType resourceType, RefinedResourceSchem ResourceAttributeContainerDefinition resAttrContainerDef = rAccountDef.toResourceAttributeContainerDefinition(); assertNotNull("No ResourceAttributeContainerDefinition", resAttrContainerDef); - System.out.println("\nResourceAttributeContainerDefinition ("+sourceLayer+")"); + System.out.println("\nResourceAttributeContainerDefinition (" + sourceLayer + ")"); System.out.println(resAttrContainerDef.debugDump()); ObjectClassComplexTypeDefinition rComplexTypeDefinition = resAttrContainerDef.getComplexTypeDefinition(); - System.out.println("\nResourceAttributeContainerDefinition ComplexTypeDefinition ("+sourceLayer+")"); + System.out.println("\nResourceAttributeContainerDefinition ComplexTypeDefinition (" + sourceLayer + ")"); System.out.println(rComplexTypeDefinition.debugDump()); assertRefinedToLayer(rComplexTypeDefinition, sourceLayer); ResourceAttributeDefinition riUidAttrDef = resAttrContainerDef.findAttributeDefinition(new ItemName(resourceType.getNamespace(), "uid")); assertNotNull("No ri:uid def in ResourceAttributeContainerDefinition", riUidAttrDef); - System.out.println("\nri:uid def "+riUidAttrDef.getClass()+" ("+sourceLayer+")"); + System.out.println("\nri:uid def " + riUidAttrDef.getClass() + " (" + sourceLayer + ")"); System.out.println(riUidAttrDef.debugDump()); assertRefinedToLayer(riUidAttrDef, sourceLayer); if (validationLayer == LayerType.PRESENTATION) { - assertFalse("Can update "+riUidAttrDef+" from ResourceAttributeContainerDefinition ("+sourceLayer+")", + assertFalse("Can update " + riUidAttrDef + " from ResourceAttributeContainerDefinition (" + sourceLayer + ")", riUidAttrDef.canModify()); } else { - assertTrue("Cannot update "+riUidAttrDef+" from ResourceAttributeContainerDefinition ("+sourceLayer+")", + assertTrue("Cannot update " + riUidAttrDef + " from ResourceAttributeContainerDefinition (" + sourceLayer + ")", riUidAttrDef.canModify()); } Collection definitionsFromResAttrContainerDef = resAttrContainerDef.getDefinitions(); - for (ResourceAttributeDefinition definitionFromResAttrContainerDef: definitionsFromResAttrContainerDef) { + for (ResourceAttributeDefinition definitionFromResAttrContainerDef : definitionsFromResAttrContainerDef) { assertRefinedToLayer(definitionFromResAttrContainerDef, sourceLayer); } } @@ -272,10 +248,10 @@ private void assertRefinedToLayer( return; } if (!(ocDef instanceof LayerRefinedObjectClassDefinition)) { - AssertJUnit.fail("Expected that definition of objectclass "+ocDef.getTypeName()+" in layer "+expectedLayer - +" will be LayerRefinedObjectClassDefinition, but it is "+ocDef.getClass()+": "+ocDef); + AssertJUnit.fail("Expected that definition of objectclass " + ocDef.getTypeName() + " in layer " + expectedLayer + + " will be LayerRefinedObjectClassDefinition, but it is " + ocDef.getClass() + ": " + ocDef); } - assertEquals("Wrong layer in "+ocDef, expectedLayer, ((LayerRefinedObjectClassDefinition)ocDef).getLayer()); + assertEquals("Wrong layer in " + ocDef, expectedLayer, ((LayerRefinedObjectClassDefinition) ocDef).getLayer()); } private void assertRefinedToLayer(ResourceAttributeDefinition attrDef, LayerType expectedLayer) { @@ -284,17 +260,14 @@ private void assertRefinedToLayer(ResourceAttributeDefinition attrDef, LayerType return; } if (!(attrDef instanceof LayerRefinedAttributeDefinition)) { - AssertJUnit.fail("Expected that definition of attribute "+attrDef.getItemName()+" in layer "+expectedLayer - +" will be LayerRefinedAttributeDefinition, but it is "+attrDef.getClass()+": "+attrDef); + AssertJUnit.fail("Expected that definition of attribute " + attrDef.getItemName() + " in layer " + expectedLayer + + " will be LayerRefinedAttributeDefinition, but it is " + attrDef.getClass() + ": " + attrDef); } - assertEquals("Wrong layer in "+attrDef, expectedLayer, ((LayerRefinedAttributeDefinition)attrDef).getLayer()); + assertEquals("Wrong layer in " + attrDef, expectedLayer, ((LayerRefinedAttributeDefinition) attrDef).getLayer()); } @Test public void test100ParseAccount() throws Exception { - final String TEST_NAME = "test100ParseAccount"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -303,8 +276,7 @@ public void test100ParseAccount() throws Exception { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); RefinedObjectClassDefinition defaultAccountDefinition = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - assertNotNull("No refined default account definition in "+rSchema, defaultAccountDefinition); - + assertNotNull("No refined default account definition in " + rSchema, defaultAccountDefinition); PrismObject accObject = prismContext.parseObject(new File(TEST_DIR_NAME, "account-jack.xml")); @@ -322,14 +294,11 @@ public void test100ParseAccount() throws Exception { System.out.println("Parsed account:"); System.out.println(accObject.debugDump()); - assertAccountShadow(accObject, resource, prismContext); + assertAccountShadow(accObject, resource); } @Test public void test110ApplyAttributeDefinition() throws Exception { - final String TEST_NAME = "test110ApplyAttributeDefinition"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -339,7 +308,7 @@ public void test110ApplyAttributeDefinition() throws Exception { System.out.println("Refined schema:"); System.out.println(rSchema.debugDump(1)); RefinedObjectClassDefinition defaultAccountDefinition = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - assertNotNull("No refined default account definition in "+rSchema, defaultAccountDefinition); + assertNotNull("No refined default account definition in " + rSchema, defaultAccountDefinition); System.out.println("Refined account definition:"); System.out.println(defaultAccountDefinition.debugDump(1)); @@ -349,16 +318,16 @@ public void test110ApplyAttributeDefinition() throws Exception { System.out.println(attributesContainer.debugDump(1)); // WHEN - attributesContainer.applyDefinition((PrismContainerDefinition)defaultAccountDefinition.toResourceAttributeContainerDefinition(), true); + attributesContainer.applyDefinition((PrismContainerDefinition) defaultAccountDefinition.toResourceAttributeContainerDefinition(), true); // THEN System.out.println("Parsed account:"); System.out.println(accObject.debugDump(1)); - assertAccountShadow(accObject, resource, prismContext); + assertAccountShadow(accObject, resource); } - private void assertAccountShadow(PrismObject accObject, PrismObject resource, PrismContext prismContext) throws SchemaException, JAXBException { + private void assertAccountShadow(PrismObject accObject, PrismObject resource) throws SchemaException { ResourceType resourceType = resource.asObjectable(); QName objectClassQName = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass"); PrismAsserts.assertPropertyValue(accObject, ShadowType.F_NAME, createPolyString("jack")); @@ -367,7 +336,7 @@ private void assertAccountShadow(PrismObject accObject, PrismObject< PrismContainer attributes = accObject.findOrCreateContainer(SchemaConstants.C_ATTRIBUTES); assertEquals("Wrong type of definition in account", ResourceAttributeContainerDefinitionImpl.class, attributes.getDefinition().getClass()); - ResourceAttributeContainerDefinition attrDef = (ResourceAttributeContainerDefinition)attributes.getDefinition(); + ResourceAttributeContainerDefinition attrDef = (ResourceAttributeContainerDefinition) attributes.getDefinition(); assertAttributeDefs(attrDef, resourceType, null, LayerType.MODEL); PrismAsserts.assertPropertyValue(attributes, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com"); @@ -393,7 +362,7 @@ private void assertAccountShadow(PrismObject accObject, PrismObject< TestUtil.assertElement(attributeElements, getAttrQName(resource, "uid"), "jack"); String accString = PrismTestUtil.serializeObjectToString(accObjectType.asPrismObject()); - System.out.println("Result of JAXB marshalling:\n"+accString); + System.out.println("Result of JAXB marshalling:\n" + accString); accObject.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH); } @@ -404,9 +373,6 @@ private ItemName getAttrQName(PrismObject resource, String localPa @Test public void test120CreateShadow() throws Exception { - final String TEST_NAME = "test120CreateShadow"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -416,7 +382,7 @@ public void test120CreateShadow() throws Exception { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); assertNotNull("Refined schema is null", rSchema); assertFalse("No account definitions", rSchema.getRefinedDefinitions(ShadowKindType.ACCOUNT).isEmpty()); - RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); + RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String) null); // WHEN PrismObject blankShadow = rAccount.createBlankShadow(); @@ -428,15 +394,12 @@ public void test120CreateShadow() throws Exception { assertNotNull("Blank shadow has no definition", objectDef); PrismContainerDefinition attrDef = objectDef.findContainerDefinition(ShadowType.F_ATTRIBUTES); assertNotNull("Blank shadow has no definition for attributes", attrDef); - assertTrue("Wrong class for attributes definition: "+attrDef.getClass(), attrDef instanceof ResourceAttributeContainerDefinition); + assertTrue("Wrong class for attributes definition: " + attrDef.getClass(), attrDef instanceof ResourceAttributeContainerDefinition); } @Test public void test130ProtectedAccount() throws Exception { - final String TEST_NAME = "test130ProtectedAccount"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); PrismObject resource = prismContext.parseObject(RESOURCE_COMPLEX_FILE); @@ -444,7 +407,7 @@ public void test130ProtectedAccount() throws Exception { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); assertNotNull("Refined schema is null", rSchema); assertFalse("No account definitions", rSchema.getRefinedDefinitions(ShadowKindType.ACCOUNT).isEmpty()); - RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); + RefinedObjectClassDefinition rAccount = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String) null); // WHEN Collection protectedAccounts = rAccount.getProtectedObjectPatterns(); @@ -484,14 +447,14 @@ private void assertRObjectClassDef(RefinedObjectClassDefinition rAccount, Resour sourceLayer, validationLayer); assertAttributeDef(attrs, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn"), DOMUtil.XSD_STRING, - 1, (validationLayer == LayerType.MODEL || validationLayer == LayerType.PRESENTATION) ? 1 : -1, "Common Name", 1, + 1, (validationLayer == LayerType.MODEL || validationLayer == LayerType.PRESENTATION) ? 1 : -1, "Common Name", 1, true, validationLayer == LayerType.PRESENTATION, true, true, true, // Access: create, read, update sourceLayer, validationLayer); assertAttributeDef(attrs, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "uid"), DOMUtil.XSD_STRING, - validationLayer == LayerType.SCHEMA ? 0 : 1 , // minOccurs + validationLayer == LayerType.SCHEMA ? 0 : 1, // minOccurs validationLayer == LayerType.SCHEMA ? -1 : 1, // maxOccurs "Login Name", 2, true, false, @@ -506,23 +469,23 @@ private void assertRObjectClassDef(RefinedObjectClassDefinition rAccount, Resour } private void assertAttributeDef(Collection attrDefs, QName name, - QName typeName, int minOccurs, int maxOccurs, String displayName, Integer displayOrder, - boolean hasOutbound, boolean ignore, boolean canCreate, boolean canRead, boolean canUpdate, - LayerType sourceLayer, LayerType validationLayer) { + QName typeName, int minOccurs, int maxOccurs, String displayName, Integer displayOrder, + boolean hasOutbound, boolean ignore, boolean canCreate, boolean canRead, boolean canUpdate, + LayerType sourceLayer, LayerType validationLayer) { for (RefinedAttributeDefinition def : attrDefs) { if (def.getItemName().equals(name)) { - assertEquals("Attribute " + name + " ("+sourceLayer+") type mismatch", typeName, def.getTypeName()); - assertEquals("Attribute " + name + " ("+sourceLayer+") minOccurs mismatch", minOccurs, def.getMinOccurs()); - assertEquals("Attribute " + name + " ("+sourceLayer+") maxOccurs mismatch", maxOccurs, def.getMaxOccurs()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") type mismatch", typeName, def.getTypeName()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") minOccurs mismatch", minOccurs, def.getMinOccurs()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") maxOccurs mismatch", maxOccurs, def.getMaxOccurs()); if (validationLayer == LayerType.MODEL || validationLayer == LayerType.PRESENTATION) { - assertEquals("Attribute " + name + " ("+sourceLayer+") displayName mismatch", displayName, def.getDisplayName()); - assertEquals("Attribute " + name + " ("+sourceLayer+") displayOrder mismatch", displayOrder, def.getDisplayOrder()); - assertEquals("Attribute " + name + " ("+sourceLayer+") outbound mismatch", hasOutbound, def.getOutboundMappingType() != null); + assertEquals("Attribute " + name + " (" + sourceLayer + ") displayName mismatch", displayName, def.getDisplayName()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") displayOrder mismatch", displayOrder, def.getDisplayOrder()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") outbound mismatch", hasOutbound, def.getOutboundMappingType() != null); } - assertEquals("Attribute " + name + " ("+sourceLayer+") ignored flag mismatch", ignore, def.isIgnored()); - assertEquals("Attribute " + name + " ("+sourceLayer+") canCreate mismatch", canCreate, def.canAdd()); - assertEquals("Attribute " + name + " ("+sourceLayer+") canRead mismatch", canRead, def.canRead()); - assertEquals("Attribute " + name + " ("+sourceLayer+") canUpdate mismatch", canUpdate, def.canModify()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") ignored flag mismatch", ignore, def.isIgnored()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") canCreate mismatch", canCreate, def.canAdd()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") canRead mismatch", canRead, def.canRead()); + assertEquals("Attribute " + name + " (" + sourceLayer + ") canUpdate mismatch", canUpdate, def.canModify()); return; } } @@ -531,24 +494,24 @@ private void assertAttributeDef(Collection private void assertProtectedAccount(String message, ResourceObjectPattern protectedPattern, String identifierValue, RefinedObjectClassDefinition rAccount) throws SchemaException { ObjectFilter filter = protectedPattern.getObjectFilter(); - assertNotNull("Null objectFilter in "+message, filter); - assertTrue("Wrong filter class "+filter.getClass().getSimpleName()+" in "+message, filter instanceof EqualFilter); - assertNotNull("Null filter path in "+message, ((EqualFilter)filter).getPath()); - assertEquals("Wrong filter value in "+message, identifierValue, ((EqualFilter)filter).getValues().iterator().next().getValue()); + assertNotNull("Null objectFilter in " + message, filter); + assertTrue("Wrong filter class " + filter.getClass().getSimpleName() + " in " + message, filter instanceof EqualFilter); + assertNotNull("Null filter path in " + message, ((EqualFilter) filter).getPath()); + assertEquals("Wrong filter value in " + message, identifierValue, ((EqualFilter) filter).getValues().iterator().next().getValue()); // Try matching PrismObject shadow = rAccount.getObjectDefinition().instantiate(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, rAccount); - ResourceAttribute confusingAttr1 = createStringAttribute(new QName("http://whatever.com","confuseMe"), "HowMuchWoodWouldWoodchuckChuckIfWoodchuckCouldChudkWood"); + ResourceAttribute confusingAttr1 = createStringAttribute(new QName("http://whatever.com", "confuseMe"), "HowMuchWoodWouldWoodchuckChuckIfWoodchuckCouldChudkWood"); attributesContainer.add(confusingAttr1); ResourceAttribute nameAttr = createStringAttribute(SchemaTestConstants.ICFS_NAME, identifierValue); attributesContainer.add(nameAttr); - ResourceAttribute confusingAttr2 = createStringAttribute(new QName("http://whatever.com","confuseMeAgain"), "WoodchuckWouldChuckNoWoodAsWoodchuckCannotChuckWood"); + ResourceAttribute confusingAttr2 = createStringAttribute(new QName("http://whatever.com", "confuseMeAgain"), "WoodchuckWouldChuckNoWoodAsWoodchuckCannotChuckWood"); attributesContainer.add(confusingAttr2); - assertTrue("Test attr not matched in "+message, protectedPattern.matches(shadow, matchingRuleRegistry, relationRegistry)); + assertTrue("Test attr not matched in " + message, protectedPattern.matches(shadow, matchingRuleRegistry, relationRegistry)); nameAttr.setRealValue("huhulumululul"); - assertFalse("Test attr nonsense was matched in "+message, protectedPattern.matches(shadow, matchingRuleRegistry, relationRegistry)); + assertFalse("Test attr nonsense was matched in " + message, protectedPattern.matches(shadow, matchingRuleRegistry, relationRegistry)); } private ResourceAttribute createStringAttribute(QName attrName, String value) { @@ -560,9 +523,6 @@ private ResourceAttribute createStringAttribute(QName attrName, String v @Test public void test140ParseFromResourcePosix() throws Exception { - final String TEST_NAME = "test140ParseFromResourcePosix"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -570,11 +530,11 @@ public void test140ParseFromResourcePosix() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext); // THEN - TestUtil.displayThen(TEST_NAME); + when(); assertNotNull("Refined schema is null", rSchema); System.out.println("Refined schema"); System.out.println(rSchema.debugDump()); @@ -583,12 +543,12 @@ public void test140ParseFromResourcePosix() throws Exception { // ### default account objectType - RefinedObjectClassDefinition rAccountDef = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); + RefinedObjectClassDefinition rAccountDef = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String) null); assertNotNull("No default account definition", rAccountDef); RefinedObjectClassDefinition accountDefByIcfAccountObjectclass = rSchema.findRefinedDefinitionByObjectClassQName(ShadowKindType.ACCOUNT, OBJECT_CLASS_INETORGPERSON_QNAME); - assertTrue("findAccountDefinitionByObjectClass("+OBJECT_CLASS_INETORGPERSON_QNAME+") returned wrong value", rAccountDef.equals(accountDefByIcfAccountObjectclass)); + assertTrue("findAccountDefinitionByObjectClass(" + OBJECT_CLASS_INETORGPERSON_QNAME + ") returned wrong value", rAccountDef.equals(accountDefByIcfAccountObjectclass)); assertTrue(rAccountDef.isDefault()); @@ -651,10 +611,10 @@ public void test140ParseFromResourcePosix() throws Exception { assertEquals("Unexpected number of propertyDefinitions", 53, propertyDefinitions.size()); assertFalse("No entitlement definitions", rSchema.getRefinedDefinitions(ShadowKindType.ENTITLEMENT).isEmpty()); - RefinedObjectClassDefinition rEntDef = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, (String)null); + RefinedObjectClassDefinition rEntDef = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, (String) null); assertNotNull("No entitlement definition for null intent", rEntDef); RefinedObjectClassDefinition rEntDefGroup = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, ENTITLEMENT_LDAP_GROUP_INTENT); - assertNotNull("No entitlement for intent '"+ENTITLEMENT_LDAP_GROUP_INTENT+"'", rEntDefGroup); + assertNotNull("No entitlement for intent '" + ENTITLEMENT_LDAP_GROUP_INTENT + "'", rEntDefGroup); assertEquals("Wrong kind", ShadowKindType.ENTITLEMENT, rEntDef.getKind()); @@ -663,7 +623,6 @@ public void test140ParseFromResourcePosix() throws Exception { assertFalse("Empty attributeDefinitions", entAttrDefs.isEmpty()); assertEquals("Unexpected number of attributeDefinitions", 12, entAttrDefs.size()); - RefinedAttributeDefinition entDisplayNameAttributeDef = rEntDef.getDisplayNameAttribute(); assertNotNull("No entitlement displayNameAttribute", entDisplayNameAttributeDef); assertEquals("Wrong entitlement displayNameAttribute", new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "dn"), @@ -682,7 +641,7 @@ public void test140ParseFromResourcePosix() throws Exception { ResourceAttributeDefinition riUidAttrDef = resAttrContainerDef.findAttributeDefinition(new ItemName(resourceType.getNamespace(), "uid")); assertNotNull("No ri:uid def in ResourceAttributeContainerDefinition", riUidAttrDef); - System.out.println("\nri:uid def "+riUidAttrDef.getClass()); + System.out.println("\nri:uid def " + riUidAttrDef.getClass()); System.out.println(riUidAttrDef.debugDump()); } @@ -690,9 +649,6 @@ public void test140ParseFromResourcePosix() throws Exception { // MID-5648 @Test public void test200ParseFromResourceMultithreaded() throws Exception { - final String TEST_NAME = "test200ParseFromResourceMultithreaded"; - TestUtil.displayTestTitle(TEST_NAME); - int THREADS = 50; // GIVEN @@ -702,7 +658,7 @@ public void test200ParseFromResourceMultithreaded() throws Exception { ResourceType resourceType = resource.asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AtomicInteger errors = new AtomicInteger(0); List threads = new ArrayList<>(THREADS); @@ -721,11 +677,10 @@ public void test200ParseFromResourceMultithreaded() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + when(); TestUtil.waitForCompletion(threads, 20000); assertEquals("Wrong # of errors", 0, errors.get()); // TODO some asserts on correct parsing maybe } - } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/test/UtilsTest.java b/infra/common/src/test/java/com/evolveum/midpoint/common/test/UtilsTest.java index 41c27f5a133..a67c5848a3e 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/test/UtilsTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/test/UtilsTest.java @@ -7,23 +7,24 @@ package com.evolveum.midpoint.common.test; -import org.testng.annotations.Test; -import com.evolveum.midpoint.common.Utils; - import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.StandardCharsets; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.common.Utils; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; + /** * Unit tests for Util class * * @author semancik */ -public class UtilsTest { +public class UtilsTest extends AbstractUnitTest { private static final String FILENAME_BAD_UTF = "src/test/resources/bad-utf.txt"; @@ -35,28 +36,23 @@ public UtilsTest() { * The test file contains such characters. */ @Test - public void cleaupUtfTest() throws FileNotFoundException, IOException { - + public void cleanupUtfTest() throws IOException { String badStr; - // The file contains strange chanrs (no-break spaces), so we need to pull + // The file contains strange chars (no-break spaces), so we need to pull // it in exactly as it is. File file = new File(FILENAME_BAD_UTF); - FileInputStream stream = new FileInputStream(file); - try { + try (FileInputStream stream = new FileInputStream(file)) { FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); badStr = StandardCharsets.UTF_8.decode(bb).toString(); } - finally { - stream.close(); - } - System.out.println("Bad: "+badStr); + System.out.println("Bad: " + badStr); String goodStr = Utils.cleanupUtf(badStr); - System.out.println("Good: "+goodStr); + System.out.println("Good: " + goodStr); } } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java index c14e67e46b8..2ba894da3de 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/BasicValidatorTest.java @@ -39,6 +39,7 @@ import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; @@ -48,7 +49,7 @@ * * @author Radovan Semancik */ -public class BasicValidatorTest { +public class BasicValidatorTest extends AbstractUnitTest { public static final String BASE_PATH = "src/test/resources/validator/"; private static final String OBJECT_RESULT_OPERATION_NAME = BasicValidatorTest.class.getName() + ".validateObject"; @@ -64,10 +65,7 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void resource1Valid() throws Exception { - System.out.println("\n===[ resource1Valid ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".resource1Valid"); - EventHandler handler = new EventHandler() { @Override @@ -106,8 +104,6 @@ public void handleGlobalError(OperationResult currentResult) { /* nothing */ } @Test public void handlerTest() throws Exception { - System.out.println("\n===[ handlerTest ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".handlerTest"); final List postMarshallHandledOids = new ArrayList<>(); @@ -151,8 +147,6 @@ public void handleGlobalError(OperationResult currentResult) { @Test public void notWellFormed() throws Exception { - System.out.println("\n===[ notWellFormed ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".notWellFormed"); validateFile("not-well-formed.xml",result); @@ -168,8 +162,6 @@ public void notWellFormed() throws Exception { @Test public void undeclaredPrefix() throws Exception { - System.out.println("\n===[ undeclaredPrefix ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".undeclaredPrefix"); validateFile("undeclared-prefix.xml",result); @@ -185,8 +177,6 @@ public void undeclaredPrefix() throws Exception { @Test public void schemaViolation() throws Exception { - System.out.println("\n===[ schemaViolation ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".schemaViolation"); validateFile("three-users-schema-violation.xml",result); @@ -206,8 +196,6 @@ public void schemaViolation() throws Exception { */ @Test public void testStopOnErrors() throws Exception { - System.out.println("\n===[ testStopOnErrors ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".testStopOnErrors"); LegacyValidator validator = new LegacyValidator(PrismTestUtil.getPrismContext()); @@ -223,8 +211,6 @@ public void testStopOnErrors() throws Exception { @Test public void noName() throws Exception { - System.out.println("\n===[ noName ]====="); - OperationResult result = new OperationResult(this.getClass().getName()+".noName"); validateFile("no-name.xml",result); @@ -250,15 +236,12 @@ private void validateFile(String filename,EventHandler handler, OperationResult } private void validateFile(String filename, LegacyValidator validator, OperationResult result) throws FileNotFoundException { - String filepath = BASE_PATH + filename; System.out.println("Validating " + filename); - FileInputStream fis = null; - File file = new File(filepath); - fis = new FileInputStream(file); + FileInputStream fis = new FileInputStream(file); validator.validate(fis, result, OBJECT_RESULT_OPERATION_NAME); @@ -269,7 +252,5 @@ private void validateFile(String filename, LegacyValidator validator, OperationR System.out.println("No errors"); System.out.println(result.debugDump()); } - } - } diff --git a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeSkipSchemaValidationTest.java b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeSkipSchemaValidationTest.java index 27098bef824..76da331bce2 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeSkipSchemaValidationTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeSkipSchemaValidationTest.java @@ -10,9 +10,9 @@ import com.evolveum.midpoint.common.validator.LegacyValidator; +// TODO testing: missing from suite, 3 tests failing - so what about that annotation? :-) public class UnknownNodeSkipSchemaValidationTest extends UnknownNodeValidationTest { - @Override protected void customizeValidator(LegacyValidator validator) { validator.setValidateSchema(false); diff --git a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeValidationTest.java b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeValidationTest.java index cd2e50f79e6..bf92b0d683d 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeValidationTest.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/validator/test/UnknownNodeValidationTest.java @@ -16,10 +16,12 @@ import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -public class UnknownNodeValidationTest { +// TODO testing: missing from suite, all passing +public class UnknownNodeValidationTest extends AbstractUnitTest { public static final String BASE_PATH = "src/test/resources/validator/unknown/"; private static final String OBJECT_RESULT_OPERATION_NAME = BasicValidatorTest.class.getName() + ".validateObject"; @@ -87,7 +89,6 @@ public void elementInConnector() throws Exception { } protected void validateNodeFailure(String name, String file, String expected) throws Exception { - System.out.println("\n===[ " + name + " ]====="); OperationResult result = new OperationResult(this.getClass().getName()+"." + name); validateFile(file,result); System.out.println(result.debugDump()); diff --git a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java index d735213bd6b..e3d1cf63b89 100644 --- a/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java +++ b/infra/prism-api/src/main/java/com/evolveum/midpoint/prism/util/PrismTestUtil.java @@ -203,6 +203,7 @@ public static PolyStringType createPolyStringType(String orig, String norm) { return new PolyStringType(createPolyString(orig, norm)); } + // TODO inttest: replace with UnitTestMixin (TestUtil?) public static void displayTestTitle(String testName) { System.out.println("\n\n===[ "+testName+" ]===\n"); LOGGER.info("===[ {} ]===",testName); diff --git a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java index eb8cf9fdb34..e6e797d4b97 100644 --- a/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java +++ b/infra/prism-impl/src/main/java/com/evolveum/midpoint/prism/impl/util/JaxbTestUtil.java @@ -6,48 +6,28 @@ */ package com.evolveum.midpoint.prism.impl.util; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; +import java.io.*; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; +import javax.xml.bind.*; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; - -import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.Validate; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; import com.evolveum.midpoint.prism.schema.SchemaDescription; import com.evolveum.midpoint.prism.schema.SchemaRegistry; +import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.DynamicNamespacePrefixMapper; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.JAXBUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; @@ -58,16 +38,15 @@ * (The last drop was the inability to hide RawType from externally-visible model service WSDL. * The solution devised, based on @Raw type, prevents JAXB from correctly parsing any structures that * contain RawType elements.) - * + *

* So, don't use JaxbTestUtil even for testing purposes. Use PrismTestUtil instead. - * - * === + *

* Original description: - * + *

* JAXB testing util. Only for use in tests. DO NOT USE IN PRODUCTION CODE. * This util is used to test the ablility of prism JAXB representation to be used by * native (Sun) JAXB code. - * + *

* Note: this is what used to be PrismJaxbProcessor. Therefore there may be still a lot of junk to clean up. * * @author Radovan Semancik @@ -143,7 +122,7 @@ public boolean isJaxbClass(Class clazz) { // not a JAXB class return false; } - for (Package jaxbPackage: getSchemaRegistry().getCompileTimePackages()) { + for (Package jaxbPackage : getSchemaRegistry().getCompileTimePackages()) { if (jaxbPackage.equals(clazz.getPackage())) { return true; } @@ -246,9 +225,9 @@ public String marshalElementToString(Object element, Map propert if (element instanceof Element) { return DOMUtil.serializeDOMToString((Element) element); } else if (element instanceof JAXBElement) { - return marshalElementToString((JAXBElement)element, properties); + return marshalElementToString((JAXBElement) element, properties); } else { - throw new IllegalArgumentException("Unsupported element type "+element.getClass().getName()); + throw new IllegalArgumentException("Unsupported element type " + element.getClass().getName()); } } @@ -262,7 +241,7 @@ public String marshalElementToString(Object element, QName elementName) throws J if (element instanceof Element) { return DOMUtil.serializeDOMToString((Element) element); } else if (element instanceof JAXBElement) { - return marshalElementToString((JAXBElement)element); + return marshalElementToString((JAXBElement) element); } else { JAXBElement jaxbElement = new JAXBElement<>(elementName, Object.class, element); return marshalElementToString(jaxbElement); @@ -309,7 +288,7 @@ public Element marshalObjectToDom(T jaxbObject, QName elementQName, Document } JAXBElement jaxbElement = new JAXBElement<>(elementQName, (Class) jaxbObject.getClass(), - jaxbObject); + jaxbObject); Element element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); marshalElementToDom(jaxbElement, element); @@ -319,7 +298,7 @@ public Element marshalObjectToDom(T jaxbObject, QName elementQName, Document public void marshalObjectToDom(T jaxbObject, QName elementQName, Element parentElement) throws JAXBException { JAXBElement jaxbElement = new JAXBElement<>(elementQName, (Class) jaxbObject.getClass(), - jaxbObject); + jaxbObject); marshalElementToDom(jaxbElement, parentElement); } @@ -328,7 +307,7 @@ public Element toDomElement(Object element) throws JAXBException { } public Element toDomElement(Object jaxbElement, Document doc) throws JAXBException { - return toDomElement(jaxbElement,doc,false,false,false); + return toDomElement(jaxbElement, doc, false, false, false); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -356,7 +335,6 @@ public Element toDomElement(Object jaxbElement, Document doc, boolean adopt, boo } } - public JAXBElement unmarshalElement(String xmlString, Class type) throws JAXBException, SchemaException { if (xmlString == null) { return null; @@ -439,12 +417,12 @@ public T unmarshalObject(File file, Class type) throws JAXBException, Sch T value = element.getValue(); // adopt not needed, already adopted in unmarshalElement call above if (!type.isAssignableFrom(value.getClass())) { - throw new IllegalArgumentException("Unmarshalled "+value.getClass()+" from file "+file+" while "+type+" was expected"); + throw new IllegalArgumentException("Unmarshalled " + value.getClass() + " from file " + file + " while " + type + " was expected"); } return value; } - public Object unmarshalObjects(File file) throws JAXBException{ + public Object unmarshalObjects(File file) throws JAXBException { return createUnmarshaller().unmarshal(file); } @@ -488,19 +466,18 @@ private PrismContainer unmarshalSingleValueContaine return container; } - public T unmarshalObject(Object domOrJaxbElement, Class type) throws SchemaException { JAXBElement element; if (domOrJaxbElement instanceof JAXBElement) { element = (JAXBElement) domOrJaxbElement; } else if (domOrJaxbElement instanceof Node) { try { - element = unmarshalElement((Node)domOrJaxbElement, type); + element = unmarshalElement((Node) domOrJaxbElement, type); } catch (JAXBException e) { - throw new SchemaException(e.getMessage(),e); + throw new SchemaException(e.getMessage(), e); } } else { - throw new IllegalArgumentException("Unknown element type "+domOrJaxbElement); + throw new IllegalArgumentException("Unknown element type " + domOrJaxbElement); } if (element == null) { return null; @@ -521,7 +498,7 @@ public JAXBElement unmarshalElement(File file, Class type) throws Sche JAXBElement element = (JAXBElement) getUnmarshaller().unmarshal(is); adopt(element); return element; - } catch (RuntimeException ex){ + } catch (RuntimeException ex) { throw new SystemException(ex); } finally { if (is != null) { @@ -627,7 +604,6 @@ private boolean compareElement(Object a, Object b) { return DOMUtil.compareElement(ae, be, true); } - public T fromElement(Object element, Class type) throws SchemaException { if (element == null) { @@ -649,14 +625,14 @@ public T fromElement(Object element, Class type) throws SchemaException { if (element instanceof Element) { try { - JAXBElement unmarshalledElement = unmarshalElement((Element)element, type); + JAXBElement unmarshalledElement = unmarshalElement((Element) element, type); return unmarshalledElement.getValue(); } catch (JAXBException e) { - throw new IllegalArgumentException("Unmarshall failed: " + e.getMessage(),e); + throw new IllegalArgumentException("Unmarshall failed: " + e.getMessage(), e); } } - throw new IllegalArgumentException("Unknown element type "+element.getClass().getName()); + throw new IllegalArgumentException("Unknown element type " + element.getClass().getName()); } private QName determineElementQName(Objectable objectable) { @@ -670,7 +646,7 @@ private QName determineElementQName(Objectable objectable) { return definition.getItemName(); } } - throw new IllegalStateException("Cannot determine element name of "+objectable); + throw new IllegalStateException("Cannot determine element name of " + objectable); } private QName determineElementQName(Containerable containerable) { @@ -690,15 +666,15 @@ private boolean isObjectable(Class type) { private void adopt(T object, Class type) throws SchemaException { if (object instanceof Objectable) { - getPrismContext().adopt(((Objectable)object)); + getPrismContext().adopt(((Objectable) object)); } } private void adopt(Object object) throws SchemaException { if (object instanceof JAXBElement) { - adopt(((JAXBElement)object).getValue()); + adopt(((JAXBElement) object).getValue()); } else if (object instanceof Objectable) { - getPrismContext().adopt(((Objectable)(object))); + getPrismContext().adopt(((Objectable) (object))); } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java index 14eaa8edcff..7ddcaf24f5a 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/AbstractPrismTest.java @@ -6,9 +6,10 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; import static org.testng.AssertJUnit.assertEquals; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; + import java.io.IOException; import java.util.Collection; import java.util.function.Function; @@ -24,6 +25,7 @@ import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -31,9 +33,8 @@ /** * @author semancik - * */ -public class AbstractPrismTest { +public class AbstractPrismTest extends AbstractUnitTest { protected static final String USER_FOO_OID = "01234567"; @@ -43,25 +44,12 @@ public class AbstractPrismTest { protected static final String ASSIGNMENT_ABRAKADABRA_DESCRIPTION = "abra kadabra"; protected static final long ASSIGNMENT_ABRAKADABRA_ID = 222L; - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { + public void initPrismContext() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); } - protected void displayTestTitle(String testName) { - PrismTestUtil.displayTestTitle(testName); - } - - protected void displayWhen(String testName) { - PrismTestUtil.displayWhen(testName); - } - - protected void displayThen(String testName) { - PrismTestUtil.displayThen(testName); - } - protected void display(String title, String value) { PrismTestUtil.display(title, value); } @@ -82,7 +70,7 @@ protected PolyString createPolyString(String orig) { return PrismTestUtil.createPolyString(orig); } - protected PrismContext getPrismContext() { + protected static PrismContext getPrismContext() { return PrismTestUtil.getPrismContext(); } @@ -108,7 +96,7 @@ private void assertAssignmentValueCount(ObjectDelta userDelta, int exp if (expectedValues == 0) { return; } else { - fail("No assignment delta in "+userDelta); + fail("No assignment delta in " + userDelta); } } Collection> values = lambda.apply(assignmentDelta); @@ -116,10 +104,10 @@ private void assertAssignmentValueCount(ObjectDelta userDelta, int exp if (expectedValues == 0) { return; } else { - fail("No values to delete in assignment "+type+" in "+userDelta); + fail("No values to delete in assignment " + type + " in " + userDelta); } } - assertEquals("Wrong number of assignment "+type+" values in "+userDelta, expectedValues, values.size()); + assertEquals("Wrong number of assignment " + type + " values in " + userDelta, expectedValues, values.size()); } protected void assertAssignmentDelete(ObjectDelta userDelta, Long expectedId, String expectedDescription) { @@ -137,18 +125,18 @@ protected void assertAssignmentReplace(ObjectDelta userDelta, Long exp private void assertAssignmentValue(ObjectDelta userDelta, Long expectedId, String expectedDescription, String type, Function, Collection>> lambda) { ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); if (assignmentDelta == null) { - fail("No assignment delta in "+userDelta); + fail("No assignment delta in " + userDelta); } Collection> valuesToDelete = lambda.apply(assignmentDelta); if (valuesToDelete == null) { - fail("No values to "+type+" in assignment delta in "+userDelta); + fail("No values to " + type + " in assignment delta in " + userDelta); } for (PrismContainerValue valueToDelete : valuesToDelete) { if (assignmentMatches(valueToDelete, expectedId, expectedDescription)) { return; } } - fail("Assignment "+expectedId+":"+expectedDescription+" not found in "+userDelta); + fail("Assignment " + expectedId + ":" + expectedDescription + " not found in " + userDelta); } protected boolean assignmentMatches(PrismContainerValue assignmentValue, Long expectedId, String expectedDescription) { @@ -202,5 +190,4 @@ protected PrismObject createUserFoo() throws SchemaException { return user; } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java index 4ce7ee91ada..d5286a82407 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/PrismInternalTestUtil.java @@ -287,10 +287,6 @@ public static void assertPathVisitor(PathVisitable visitable, final ItemPath pat assertEquals("Wrong number of visits for path "+path, expectedVisits, visits.size()); } - public static void displayTestTitle(String testName) { - PrismTestUtil.displayTestTitle(testName); - } - public static void assertUserJack(PrismObject user, boolean expectRawInConstructions, boolean withIncomplete) throws SchemaException { assertUserJack(user, expectRawInConstructions, true, withIncomplete); } @@ -312,9 +308,6 @@ public static void assertUserJack(PrismObject user, boolean expectRawI assertPathVisitor(user, ItemPath.create(UserType.F_ASSIGNMENT, null), false, 2); assertPathVisitor(user, ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED), false, 1); assertPathVisitor(user, UserType.F_EXTENSION, false, 1); -// assertPathVisitor(user, ItemPath.create( -// UserType.F_EXTENSION, -// NameItemPathSegment.WILDCARD), false, 5); } public static void assertUserJackContent(PrismObject user, boolean expectRawInConstructions, @@ -462,7 +455,7 @@ private static void assertLang(Map lang, String key, String expe assertEquals("Wrong lang in polystring for key "+key, expectedValue, lang.get(key)); } - private static void assertUserJackExtension(PrismObject user, boolean withIncomplete) throws SchemaException { + private static void assertUserJackExtension(PrismObject user, boolean withIncomplete) { PrismContext prismContext = user.getPrismContext(); PrismContainer extension = user.getExtension(); assertContainerDefinition(extension, "extension", DOMUtil.XSD_ANY, 0, 1); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java index 142edbfa703..f7a04dd4294 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestCompare.java @@ -37,7 +37,7 @@ public abstract class TestCompare extends AbstractPrismTest { private static final QName REF_QNAME = new QName(NS_FOO, "ref"); - private static final QName REF_TYPE_QNAME = new QName(NS_FOO, "RefType");; + private static final QName REF_TYPE_QNAME = new QName(NS_FOO, "RefType"); protected abstract String getSubdirName(); @@ -56,22 +56,16 @@ protected File getFile(String baseName) { */ @Test public void testCompareJack() throws SchemaException, SAXException, IOException { - final String TEST_NAME="testCompareJack"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); -// Document document = DOMUtil.parseFile(USER_JACK_FILE_XML); -// Element userElement = DOMUtil.getFirstChildElement(document); - PrismObject user1 = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); PrismObject user2 = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); // WHEN, THEN - assertTrue("Users not the same (PrismObject)(1)", user1.equals(user2)); - assertTrue("Users not the same (PrismObject)(2)", user2.equals(user1)); + assertEquals("Users not the same (PrismObject)(1)", user2, user1); + assertEquals("Users not the same (PrismObject)(2)", user1, user2); // Following line won't work here. We don't have proper generated classes here. // It is tested in the "schema" project that has a proper code generation @@ -87,9 +81,6 @@ public void testCompareJack() throws SchemaException, SAXException, IOException */ @Test public void testDiffJack() throws Exception { - final String TEST_NAME="testDiffJack"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -144,9 +135,6 @@ public void testDiffJack() throws Exception { */ @Test public void testDiffJackLiteral() throws Exception { - final String TEST_NAME="testDiffJackLiteral"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -194,9 +182,6 @@ public void testDiffJackLiteral() throws Exception { @Test public void testDiffPatchRoundTrip() throws SchemaException, SAXException, IOException { - final String TEST_NAME="testDiffPatchRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); @@ -206,27 +191,18 @@ public void testDiffPatchRoundTrip() throws SchemaException, SAXException, IOExc ObjectDelta jackDelta = jackOriginal.diff(jackModified); -// System.out.println("jackOriginal:\n" + prismContext.getXnodeProcessor().serializeObject(jackOriginal).debugDump(1)); -// System.out.println("jackModified:\n" + prismContext.getXnodeProcessor().serializeObject(jackModified).debugDump(1)); -// System.out.println("jackDelta:\n" + jackDelta.debugDump()); - jackDelta.assertDefinitions(); jackDelta.checkConsistence(true, true, true); // WHEN jackDelta.applyTo(jackOriginal); -// System.out.println("jackOriginal after applying delta:\n" + prismContext.getXnodeProcessor().serializeObject(jackOriginal).debugDump(1)); - // THEN assertTrue("Roundtrip failed", jackOriginal.equivalent(jackModified)); } @Test public void testEqualsReferenceValues() throws Exception { - final String TEST_NAME="testEqualsReferenceValues"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); PrismReferenceValue val11 = new PrismReferenceValueImpl("oid1"); @@ -270,7 +246,6 @@ public void testEqualsReferenceValues() throws Exception { yetAnotherDifferentUser.setPropertyRealValue(UserType.F_FULL_NAME, "John J Random"); val35.setObject(yetAnotherDifferentUser); - assertTrue("val11 - val11", val11.equals(val11)); assertTrue("val11 - val12", val11.equals(val12)); assertTrue("val12 - val11", val12.equals(val11)); @@ -299,9 +274,6 @@ public void testEqualsReferenceValues() throws Exception { @Test public void testEqualsReferenceValuesSchema() throws Exception { - final String TEST_NAME="testEqualsReferenceValuesSchema"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); MutablePrismReferenceDefinition ref1Def = prismContext.definitionFactory().createReferenceDefinition(REF_QNAME, REF_TYPE_QNAME); @@ -389,21 +361,10 @@ public void testEqualsReferenceValuesSchema() throws Exception { assertFalse("val43 - val21", val43.equals(val21)); assertFalse("val43 - val22", val43.equals(val22)); assertTrue("val43 - val23", val43.equals(val23)); - - -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); -// assertTrue("val11 - val11", val11.equals(val11)); - - } @Test public void testDiffReferences() throws Exception { - final String TEST_NAME="testDiffReferences"; - displayTestTitle(TEST_NAME); - if (!"xml".equals(getFilenameSuffix())) { return; } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java index fcb7ead5e63..60fbcf69145 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDelta.java @@ -6,15 +6,20 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import static org.testng.AssertJUnit.*; -import java.util.Collection; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import java.util.Collection; import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.delta.*; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.foo.ActivationType; +import com.evolveum.midpoint.prism.foo.AssignmentType; +import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceDefinitionImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; @@ -23,12 +28,6 @@ import com.evolveum.midpoint.prism.impl.delta.PropertyDeltaImpl; import com.evolveum.midpoint.prism.impl.delta.ReferenceDeltaImpl; import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.foo.ActivationType; -import com.evolveum.midpoint.prism.foo.AssignmentType; -import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -43,9 +42,6 @@ public class TestDelta extends AbstractPrismTest { @Test public void testDeltaPaths() throws Exception { - final String TEST_NAME="testDeltaPaths"; - displayTestTitle(TEST_NAME); - PrismContext prismContext = getPrismContext(); PrismPropertyDefinition descDefinition = prismContext.definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, @@ -65,8 +61,8 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_PATLAMA_DESCRIPTION, PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); - ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); + UserType.F_ASSIGNMENT, assignmentValue1); + ItemDelta assDelta1 = assObjDelta1.getModifications().iterator().next(); assertPath(assDelta1, UserType.F_ASSIGNMENT); PrismContainerValue assignmentValue2 = prismContext.itemFactory().createContainerValue(); @@ -74,8 +70,8 @@ public void testDeltaPaths() throws Exception { assignmentValue1.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "jamalalicha patlama paprtala", PrismTestUtil.getPrismContext()); ObjectDelta assObjDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue2); - ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); + UserType.F_ASSIGNMENT, assignmentValue2); + ItemDelta assDelta2 = assObjDelta2.getModifications().iterator().next(); assertPath(assDelta2, UserType.F_ASSIGNMENT); PrismPropertyDefinition assDescDefinition = prismContext.definitionFactory().createPropertyDefinition(AssignmentType.F_DESCRIPTION, @@ -90,18 +86,15 @@ public void testDeltaPaths() throws Exception { } - private void assertPath(ItemDelta delta, ItemPath expectedPath) { - PrismAsserts.assertPathEquivalent("Wrong path in "+delta, expectedPath, delta.getPath()); + private void assertPath(ItemDelta delta, ItemPath expectedPath) { + PrismAsserts.assertPathEquivalent("Wrong path in " + delta, expectedPath, delta.getPath()); } @Test - public void testPropertyDeltaMerge01() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge01"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge01() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -122,13 +115,10 @@ public void testPropertyDeltaMerge01() throws Exception { } @Test - public void testPropertyDeltaMerge02() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge02"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge02() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToDelete("del1"); @@ -149,13 +139,10 @@ public void testPropertyDeltaMerge02() throws Exception { } @Test - public void testPropertyDeltaMerge03() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge03"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge03() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -178,13 +165,10 @@ public void testPropertyDeltaMerge03() throws Exception { } @Test - public void testPropertyDeltaMerge04() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge04"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge04() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -207,13 +191,10 @@ public void testPropertyDeltaMerge04() throws Exception { } @Test - public void testPropertyDeltaMerge05() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge05"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge05() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -235,13 +216,10 @@ public void testPropertyDeltaMerge05() throws Exception { } @Test - public void testPropertyDeltaMerge06() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge06"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge06() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); @@ -263,13 +241,10 @@ public void testPropertyDeltaMerge06() throws Exception { } @Test - public void testPropertyDeltaMerge10() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge10"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge10() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -290,13 +265,10 @@ public void testPropertyDeltaMerge10() throws Exception { } @Test - public void testPropertyDeltaMerge11() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge11"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge11() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -318,13 +290,10 @@ public void testPropertyDeltaMerge11() throws Exception { } @Test - public void testPropertyDeltaMerge12() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge12"; - displayTestTitle(TEST_NAME); - + public void testPropertyDeltaMerge12() { // GIVEN - PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, - DOMUtil.XSD_STRING); + PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory() + .createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.setRealValuesToReplace("r1x", "r1y"); @@ -347,9 +316,6 @@ public void testPropertyDeltaMerge12() throws Exception { @Test public void testPropertyDeltaMerge13() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge13"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -374,9 +340,6 @@ public void testPropertyDeltaMerge13() throws Exception { @Test public void testPropertyDeltaMerge20() throws Exception { - final String TEST_NAME="testPropertyDeltaMerge20"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -402,9 +365,6 @@ public void testPropertyDeltaMerge20() throws Exception { @Test public void testPropertyDeltaSwallow01() throws Exception { - final String TEST_NAME="testPropertyDeltaSwallow01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -412,7 +372,7 @@ public void testPropertyDeltaSwallow01() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); ObjectDelta objectDelta = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); @@ -434,9 +394,6 @@ public void testPropertyDeltaSwallow01() throws Exception { @Test public void testSummarize01() throws Exception { - final String TEST_NAME="testSummarize01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -444,13 +401,13 @@ public void testSummarize01() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToAdd("add1"); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToAdd("add2"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -469,9 +426,6 @@ public void testSummarize01() throws Exception { @Test public void testSummarize02() throws Exception { - final String TEST_NAME="testSummarize02"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -479,13 +433,13 @@ public void testSummarize02() throws Exception { PropertyDelta delta1 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta1.addRealValuesToDelete("del1"); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToDelete("del2"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -504,9 +458,6 @@ public void testSummarize02() throws Exception { @Test public void testSummarize05() throws Exception { - final String TEST_NAME="testSummarize05"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -515,14 +466,14 @@ public void testSummarize05() throws Exception { // Let's complicate the things a bit with origin. This should work even though origins do not match. delta1.addValueToAdd(new PrismPropertyValueImpl<>("add1", OriginType.OUTBOUND, null)); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); PropertyDelta delta2 = new PropertyDeltaImpl(propertyDefinition, PrismTestUtil.getPrismContext()); delta2.addRealValuesToAdd("add2"); delta2.addRealValuesToDelete("add1"); ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -541,9 +492,6 @@ public void testSummarize05() throws Exception { @Test public void testSummarize06() throws Exception { - final String TEST_NAME="testSummarize06"; - displayTestTitle(TEST_NAME); - // GIVEN PrismReferenceDefinition referenceDefinition = new PrismReferenceDefinitionImpl(UserType.F_PARENT_ORG_REF, OBJECT_REFERENCE_TYPE_QNAME, PrismTestUtil.getPrismContext()); @@ -551,13 +499,13 @@ public void testSummarize06() throws Exception { ReferenceDelta delta1 = new ReferenceDeltaImpl(referenceDefinition, PrismTestUtil.getPrismContext()); delta1.addValueToAdd(new PrismReferenceValueImpl("oid1")); ObjectDelta objectDelta1 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta1.addModification(delta1); ReferenceDelta delta2 = new ReferenceDeltaImpl(referenceDefinition, PrismTestUtil.getPrismContext()); delta2.addValueToAdd(new PrismReferenceValueImpl("oid1")); // here we add the same value ObjectDelta objectDelta2 = new ObjectDeltaImpl<>(UserType.class, ChangeType.MODIFY, - PrismTestUtil.getPrismContext()); + PrismTestUtil.getPrismContext()); objectDelta2.addModification(delta2); // WHEN @@ -576,10 +524,7 @@ public void testSummarize06() throws Exception { @Test public void testAddPropertyMulti() throws Exception { - final String TEST_NAME="testAddPropertyMulti"; - displayTestTitle(TEST_NAME); // GIVEN - // User PrismObject user = createUserFooPatlama(); @@ -601,10 +546,7 @@ public void testAddPropertyMulti() throws Exception { @Test public void testAddAssignmentSameNullIdApplyToObject() throws Exception { - final String TEST_NAME="testAddAssignmentSameNullIdApplyToObject"; - displayTestTitle(TEST_NAME); // GIVEN - // User PrismObject user = createUserFooPatlama(); @@ -615,7 +557,7 @@ public void testAddAssignmentSameNullIdApplyToObject() throws Exception { ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue); + UserType.F_ASSIGNMENT, assignmentValue); // WHEN userDelta.applyTo(user); @@ -632,8 +574,6 @@ public void testAddAssignmentSameNullIdApplyToObject() throws Exception { @Test public void testAddAssignmentSameNullIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentSameNullIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -643,7 +583,7 @@ public void testAddAssignmentSameNullIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -674,8 +614,6 @@ public void testAddAssignmentSameNullIdSwallow() throws Exception { @Test public void testAddAssignmentDifferentNullIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentNullIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -685,7 +623,7 @@ public void testAddAssignmentDifferentNullIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -708,14 +646,12 @@ public void testAddAssignmentDifferentNullIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentFirstIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -725,7 +661,7 @@ public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -747,14 +683,12 @@ public void testAddAssignmentDifferentFirstIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentSecondIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -764,13 +698,13 @@ public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -786,14 +720,12 @@ public void testAddAssignmentDifferentSecondIdSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentTwoIdsSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -803,13 +735,13 @@ public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -825,14 +757,12 @@ public void testAddAssignmentDifferentTwoIdsSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentDifferentIdSameSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentIdSameSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -842,13 +772,13 @@ public void testAddAssignmentDifferentIdSameSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_1_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_PATLAMA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -864,14 +794,12 @@ public void testAddAssignmentDifferentIdSameSwallow() throws Exception { PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue1+" missing ", valuesToAdd.contains(assignmentValue1)); + assertTrue("Value " + assignmentValue1 + " missing ", valuesToAdd.contains(assignmentValue1)); } // MID-1296 - @Test(enabled=false) + @Test(enabled = false) public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { - final String TEST_NAME="testAddAssignmentDifferentIdConflictSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -881,7 +809,7 @@ public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, assignmentValue1); + UserType.F_ASSIGNMENT, assignmentValue1); //Delta 2 PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); @@ -898,8 +826,6 @@ public void testAddAssignmentDifferentIdConflictSwallow() throws Exception { @Test public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaAddAssignmentDifferentNoIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -910,7 +836,7 @@ public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); // null container ID assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -927,16 +853,14 @@ public void testAddDeltaAddAssignmentDifferentNoIdSwallow() throws Exception { Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 2, valuesToAdd.size()); PrismContainer user1AssignmentCont = user.findContainer(UserType.F_ASSIGNMENT); - for (PrismContainerValue cval: user1AssignmentCont.getValues()) { - assertTrue("Value "+cval+" missing ", valuesToAdd.contains(cval)); + for (PrismContainerValue cval : user1AssignmentCont.getValues()) { + assertTrue("Value " + cval + " missing ", valuesToAdd.contains(cval)); } - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -947,7 +871,7 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws E PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); // null container ID assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -963,13 +887,11 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws E PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exception { - final String TEST_NAME="testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow"; - displayTestTitle(TEST_NAME); // GIVEN //Delta 1 @@ -980,7 +902,7 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exc PrismContainerValue assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); assignmentValue2.setId(USER_ASSIGNMENT_2_ID); assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); - ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); + ContainerDelta containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT, getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN @@ -996,13 +918,11 @@ public void testAddDeltaNoAssignmentAddAssignmentDifferentIdSwallow() throws Exc PrismAsserts.assertNoReplace(containerDeltaAfter); Collection> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); - assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); + assertTrue("Value " + assignmentValue2 + " missing ", valuesToAdd.contains(assignmentValue2)); } @Test public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exception { - final String TEST_NAME="testAddAssignmentActivationDifferentNullIdApplyToObject"; - displayTestTitle(TEST_NAME); // GIVEN // User @@ -1015,10 +935,10 @@ public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exc ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddContainer(UserType.class, USER_FOO_OID, - ItemPath.create(UserType.F_ASSIGNMENT, - // We really need ID here. Otherwise it would not be clear to which assignment to add - 123L, - AssignmentType.F_ACTIVATION), + ItemPath.create(UserType.F_ASSIGNMENT, + // We really need ID here. Otherwise it would not be clear to which assignment to add + 123L, + AssignmentType.F_ACTIVATION), activationValue); // WHEN @@ -1038,14 +958,12 @@ public void testAddAssignmentActivationDifferentNullIdApplyToObject() throws Exc @Test public void testObjectDeltaApplyToAdd() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToAdd"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_LOCALITY, "Caribbean"); + UserType.F_LOCALITY, "Caribbean"); // WHEN userDelta.applyTo(user); @@ -1058,14 +976,12 @@ public void testObjectDeltaApplyToAdd() throws Exception { @Test public void testObjectDeltaApplyToDelete() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToDelete"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationDeleteProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "Jackie"); + UserType.F_ADDITIONAL_NAMES, "Jackie"); // WHEN userDelta.applyTo(user); @@ -1078,14 +994,12 @@ public void testObjectDeltaApplyToDelete() throws Exception { @Test public void testObjectDeltaApplyToReplace() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToReplace"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "Cpt"); + UserType.F_ADDITIONAL_NAMES, "Cpt"); // WHEN userDelta.applyTo(user); @@ -1098,14 +1012,12 @@ public void testObjectDeltaApplyToReplace() throws Exception { @Test public void testObjectDeltaApplyToReplaceEmpty() throws Exception { - final String TEST_NAME="testObjectDeltaApplyToReplaceEmpty"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE_XML); //Delta ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES); + UserType.F_ADDITIONAL_NAMES); // WHEN userDelta.applyTo(user); @@ -1118,8 +1030,6 @@ public void testObjectDeltaApplyToReplaceEmpty() throws Exception { @Test public void testObjectDeltaFindItemDeltaModifyProperty() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyProperty"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); @@ -1131,17 +1041,15 @@ public void testObjectDeltaFindItemDeltaModifyProperty() throws Exception { // THEN PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); PrismAsserts.assertPathEquivalent("paths are different", itemDeltaPath, itemDelta.getPath()); - PrismAsserts.assertPropertyValues("Wrong replace values in "+itemDelta, - ((PropertyDelta)itemDelta).getValuesToReplace(), "Guybrush"); + PrismAsserts.assertPropertyValues("Wrong replace values in " + itemDelta, + ((PropertyDelta) itemDelta).getValuesToReplace(), "Guybrush"); } @Test public void testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED); @@ -1149,20 +1057,18 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInAddedContainer() throws ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); assertEquals(itemDeltaPath, itemDelta.getPath()); - PrismAsserts.assertPropertyValues("Wrong add values in "+itemDelta, - ((PropertyDelta)itemDelta).getValuesToAdd(), Boolean.TRUE); + PrismAsserts.assertPropertyValues("Wrong add values in " + itemDelta, + ((PropertyDelta) itemDelta).getValuesToAdd(), Boolean.TRUE); } @Test public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(false); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALID_TO); // not present in the delta @@ -1170,17 +1076,15 @@ public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInAddedContaine ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); assertNull("Found delta even if it shouldn't", itemDelta); } @Test public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(true); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ENABLED); @@ -1188,7 +1092,7 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() thro ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); PrismAsserts.assertInstanceOf(PropertyDelta.class, itemDelta); assertEquals(itemDeltaPath, itemDelta.getPath()); // TODO @@ -1204,11 +1108,9 @@ public void testObjectDeltaFindItemDeltaModifyPropertyInReplacedContainer() thro @Test // MID-4689 public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedContainer() throws Exception { - final String TEST_NAME="testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedContainer"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta = createDeltaForFindItem(true); - System.out.println("Object delta:\n"+userDelta.debugDump()); + System.out.println("Object delta:\n" + userDelta.debugDump()); ItemPath itemDeltaPath = ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_VALID_TO); // not present in the delta @@ -1216,14 +1118,14 @@ public void testObjectDeltaFindItemDeltaModifyNonExistentPropertyInReplacedConta ItemDelta itemDelta = userDelta.findItemDelta(itemDeltaPath); // THEN - System.out.println("Item delta:\n"+(itemDelta==null?"null":itemDelta.debugDump())); + System.out.println("Item delta:\n" + (itemDelta == null ? "null" : itemDelta.debugDump())); assertNull("Found delta even if it shouldn't", itemDelta); } private ObjectDelta createDeltaForFindItem(boolean containerReplace) throws SchemaException { ObjectDelta userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_LOCALITY, "Caribbean"); + UserType.F_LOCALITY, "Caribbean"); userDelta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, "Guybrush"); ContainerDelta activationDelta = userDelta.createContainerModification(UserType.F_ACTIVATION); @@ -1250,17 +1152,15 @@ private ObjectDelta createDeltaForFindItem(boolean containerReplace) t */ @Test public void testObjectDeltaUnion01Simple() throws Exception { - final String TEST_NAME="testObjectDeltaUnion01Simple"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1274,14 +1174,11 @@ public void testObjectDeltaUnion01Simple() throws Exception { */ @Test public void testObjectDeltaUnion01Metadata() throws Exception { - final String TEST_NAME="testObjectDeltaUnion01Metadata"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); - + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); PropertyDelta fullNameDelta2 = getPrismContext().deltaFactory().property().createDelta(UserType.F_FULL_NAME, UserType.class); PrismPropertyValue fullNameValue2 = new PrismPropertyValueImpl<>(PrismTestUtil.createPolyString("baz")); @@ -1314,17 +1211,15 @@ private void assertUnion01Delta(ObjectDelta userDeltaUnion) { */ @Test public void testObjectDeltaUnion02() throws Exception { - final String TEST_NAME="testObjectDeltaUnion02"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME); + UserType.F_FULL_NAME); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1344,17 +1239,15 @@ public void testObjectDeltaUnion02() throws Exception { */ @Test public void testObjectDeltaUnion03() throws Exception { - final String TEST_NAME="testObjectDeltaUnion03"; - displayTestTitle(TEST_NAME); // GIVEN //Delta ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME); + UserType.F_FULL_NAME); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("baz")); // WHEN ObjectDelta userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2); @@ -1381,16 +1274,14 @@ private PropertyDelta getCheckedPropertyDeltaFromUnion(ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2); @@ -1406,16 +1297,14 @@ public void testObjectDeltaSummarizeModifyAdd() throws Exception { @Test public void testObjectDeltaSummarizeModifyReplace() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeModifyReplace"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("foo")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("bar")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2); @@ -1431,19 +1320,17 @@ public void testObjectDeltaSummarizeModifyReplace() throws Exception { @Test public void testObjectDeltaSummarizeModifyMix() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeModifyMix"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta3 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta1, userDelta2, userDelta3); @@ -1459,21 +1346,19 @@ public void testObjectDeltaSummarizeModifyMix() throws Exception { @Test public void testObjectDeltaSummarizeAddModifyMix() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeAddModifyMix"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user = createUserFooPatlama(); ObjectDelta userDelta0 = DeltaFactory.Object.createAddDelta(user); ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("baz")); ObjectDelta userDelta2 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo")); ObjectDelta userDelta3 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); + UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("bar")); // WHEN ObjectDelta userDeltaSum = ObjectDeltaCollectionsUtil.summarize(userDelta0, userDelta1, userDelta2, userDelta3); @@ -1485,13 +1370,10 @@ public void testObjectDeltaSummarizeAddModifyMix() throws Exception { assert user != userSum : "User was not cloned"; PrismAsserts.assertPropertyValue(userSum, UserType.F_ADDITIONAL_NAMES, PrismTestUtil.createPolyString("foo"), PrismTestUtil.createPolyString("bar")); - // TODO } @Test public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { - final String TEST_NAME="testObjectDeltaSummarizeAddModifySameRefValues"; - displayTestTitle(TEST_NAME); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -1505,7 +1387,7 @@ public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { ObjectDelta userDelta0 = DeltaFactory.Object.createAddDelta(user); ObjectDelta userDelta1 = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddReference(UserType.class, USER_FOO_OID, - UserType.F_PARENT_ORG_REF, + UserType.F_PARENT_ORG_REF, "oid1"); System.out.println("userDelta0 = " + userDelta0.debugDump()); @@ -1523,17 +1405,16 @@ public void testObjectDeltaSummarizeAddModifySameRefValues() throws Exception { assert user != userSum : "User was not cloned"; PrismAsserts.assertReferenceValues(userSum.findOrCreateReference(UserType.F_PARENT_ORG_REF), "oid1"); } + @Test public void testDeltaComplex() throws Exception { - final String TEST_NAME="testDeltaComplex"; - displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = getPrismContext(); ObjectDelta delta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Foo Bar")); + UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Foo Bar")); PrismObjectDefinition userTypeDefinition = getUserTypeDefinition(); @@ -1581,12 +1462,8 @@ public void testDeltaComplex() throws Exception { PrismInternalTestUtil.assertPathVisitor(delta, ItemPath.create(UserType.F_ASSIGNMENT, null), false, 2); } - @Test public void testPropertyDeltaNarrow01() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow01"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1611,9 +1488,6 @@ public void testPropertyDeltaNarrow01() throws Exception { @Test public void testPropertyDeltaNarrow02() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow02"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1639,9 +1513,6 @@ public void testPropertyDeltaNarrow02() throws Exception { @Test public void testPropertyDeltaNarrow03() throws Exception { - final String TEST_NAME="testPropertyDeltaNarrow03"; - displayTestTitle(TEST_NAME); - // GIVEN PrismPropertyDefinition propertyDefinition = getPrismContext().definitionFactory().createPropertyDefinition(UserType.F_DESCRIPTION, DOMUtil.XSD_STRING); @@ -1667,25 +1538,22 @@ public void testPropertyDeltaNarrow03() throws Exception { @Test public void testObjectDeltaNarrow01() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1699,14 +1567,11 @@ public void testObjectDeltaNarrow01() throws Exception { @Test public void testObjectDeltaNarrow02() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow02"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); @@ -1714,11 +1579,11 @@ public void testObjectDeltaNarrow02() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1732,14 +1597,11 @@ public void testObjectDeltaNarrow02() throws Exception { @Test public void testObjectDeltaNarrow03() throws Exception { - final String TEST_NAME="testObjectDeltaNarrow03"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, - UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); + UserType.F_ADDITIONAL_NAMES, "blabla", "bubu"); display("userDelta", userDelta); PrismObject user = createUserFoo(); @@ -1747,11 +1609,11 @@ public void testObjectDeltaNarrow03() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1760,14 +1622,11 @@ public void testObjectDeltaNarrow03() throws Exception { @Test public void testObjectDeltaNarrowAssignmen01() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION)); display("userDelta", userDelta); @@ -1776,11 +1635,11 @@ public void testObjectDeltaNarrowAssignmen01() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1789,14 +1648,11 @@ public void testObjectDeltaNarrowAssignmen01() throws Exception { @Test public void testObjectDeltaNarrowAssignmen02() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen02"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -1805,11 +1661,11 @@ public void testObjectDeltaNarrowAssignmen02() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1818,14 +1674,11 @@ public void testObjectDeltaNarrowAssignmen02() throws Exception { @Test public void testObjectDeltaNarrowAssignmen11() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen11"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION)); display("userDelta", userDelta); @@ -1835,11 +1688,11 @@ public void testObjectDeltaNarrowAssignmen11() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); @@ -1852,14 +1705,11 @@ public void testObjectDeltaNarrowAssignmen11() throws Exception { @Test public void testObjectDeltaNarrowAssignmen12() throws Exception { - final String TEST_NAME="testObjectDeltaNarrowAssignmen12"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -1869,11 +1719,11 @@ public void testObjectDeltaNarrowAssignmen12() throws Exception { display("user", user); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta narrowedDelta = userDelta.narrow(user, false); // THEN - displayThen(TEST_NAME); + then(); display("Narrowed delta", narrowedDelta); PrismAsserts.assertIsModify(narrowedDelta); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java index 33525d65dfc..15832e98ca6 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestDiff.java @@ -6,45 +6,33 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertNull; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.USER_JACK_OID; -import java.io.IOException; import java.util.Collection; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ItemDeltaCollectionsUtil; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestDiff { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestDiff extends AbstractPrismTest { @Test public void testUserSimplePropertyDiffNoChange() throws Exception { - System.out.println("\n\n===[ testUserSimplePropertyDiffNoChange ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -68,7 +56,6 @@ public void testUserSimplePropertyDiffNoChange() throws Exception { @Test public void testPropertySimplePropertyDiffNoChange() throws Exception { - System.out.println("\n\n===[ testPropertySimplePropertyDiffNoChange ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -91,7 +78,6 @@ public void testPropertySimplePropertyDiffNoChange() throws Exception { @Test public void testPropertySimplePropertyDiffNoChangeStatic() throws Exception { - System.out.println("\n\n===[ testPropertySimplePropertyDiffNoChangeStatic ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -114,7 +100,6 @@ public void testPropertySimplePropertyDiffNoChangeStatic() throws Exception { @Test public void testUserSimplePropertyDiffReplace() throws Exception { - System.out.println("\n\n===[ testUserSimplePropertyDiffReplace ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -140,7 +125,6 @@ public void testUserSimplePropertyDiffReplace() throws Exception { @Test public void testPropertyUserSimplePropertyDiffReplace() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimplePropertyDiffReplace ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -166,7 +150,6 @@ public void testPropertyUserSimplePropertyDiffReplace() throws Exception { @Test public void testPropertyUserSimplePropertyDiffReplaceStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimplePropertyDiffReplaceStatic ]===\n"); // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -192,8 +175,6 @@ public void testPropertyUserSimplePropertyDiffReplaceStatic() throws Exception { @Test public void testUserSimpleDiffMultiNoChange() throws Exception { - System.out.println("\n\n===[ testUserSimpleDiffMultiNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -221,8 +202,6 @@ public void testUserSimpleDiffMultiNoChange() throws Exception { @Test public void testPropertyUserSimpleDiffMultiNoChange() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -247,8 +226,6 @@ public void testPropertyUserSimpleDiffMultiNoChange() throws Exception { @Test public void testPropertyUserSimpleDiffMultiNoChangeStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiNoChangeStatic ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -273,8 +250,6 @@ public void testPropertyUserSimpleDiffMultiNoChangeStatic() throws Exception { @Test public void testUserSimpleDiffMultiAdd() throws Exception { - System.out.println("\n\n===[ testUserSimpleDiffMulti ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -305,8 +280,6 @@ public void testUserSimpleDiffMultiAdd() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAdd() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAdd ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -335,8 +308,6 @@ public void testPropertyUserSimpleDiffMultiAdd() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStatic() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStatic ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -365,8 +336,6 @@ public void testPropertyUserSimpleDiffMultiAddStatic() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStaticNull1() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStaticNull1 ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -388,8 +357,6 @@ public void testPropertyUserSimpleDiffMultiAddStaticNull1() throws Exception { @Test public void testPropertyUserSimpleDiffMultiAddStaticNull2() throws Exception { - System.out.println("\n\n===[ testPropertyUserSimpleDiffMultiAddStaticNull2 ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); @@ -411,8 +378,6 @@ public void testPropertyUserSimpleDiffMultiAddStaticNull2() throws Exception { @Test public void testContainerSimpleDiffModificationsNoChange() throws Exception { - System.out.println("\n\n===[ testContainerSimpleDiffModificationsNoChange ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -437,8 +402,6 @@ public void testContainerSimpleDiffModificationsNoChange() throws Exception { @Test public void testContainerDiffModificationsDesciption() throws Exception { - System.out.println("\n\n===[ testContainerDiffModificationsDesciption ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -469,8 +432,6 @@ public void testContainerDiffModificationsDesciption() throws Exception { @Test public void testContainerValueDiffDesciptionNoPath() throws Exception { - System.out.println("\n\n===[ testContainerValueDiffDesciptionNoPath ]===\n"); - // GIVEN PrismObjectDefinition userDef = getUserTypeDefinition(); PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); @@ -496,42 +457,4 @@ public void testContainerValueDiffDesciptionNoPath() throws Exception { "chamalalia patlama paprtala"); ItemDeltaCollectionsUtil.checkConsistence(modifications); } - -// @Test -// public void testContainerValueDiffDesciptionPath() throws Exception { -// System.out.println("\n\n===[ testContainerValueDiffDesciptionPath ]===\n"); -// -// // GIVEN -// PrismObjectDefinition userDef = getUserTypeDefinition(); -// PrismContainerDefinition assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); -// -// PrismContainer ass1 = assignmentContDef.instantiate(); -// PrismContainerValue ass1cval = ass1.createNewValue(); -// ass1cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah"); -// -// PrismContainer ass2 = assignmentContDef.instantiate(); -// PrismContainerValue ass2cval = ass2.createNewValue(); -// ass2cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "chamalalia patlama paprtala"); -// -// ItemPath pathPrefix = ItemPath.create( -// new NameItemPathSegment(UserType.F_ASSIGNMENT), -// new IdItemPathSegment("1")); -// -// // WHEN -// Collection modifications = ass1cval.diff(ass2cval, pathPrefix, true, false); -// -// // THEN -// assertNotNull(modifications); -// System.out.println(DebugUtil.debugDump(modifications)); -// assertEquals("Unexpected number of midifications", 1, modifications.size()); -// PrismAsserts.assertPropertyReplace( -// modifications, -// ItemPath.create( -// new NameItemPathSegment(UserType.F_ASSIGNMENT), -// new IdItemPathSegment("1"), -// new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), -// "chamalalia patlama paprtala"); -// ItemDelta.checkConsistence(modifications); -// } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java index 039bac32526..99e836894bb 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestEquals.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import org.testng.annotations.Test; @@ -17,21 +15,18 @@ import com.evolveum.midpoint.prism.foo.UserType; /** - * @see TestCompare * @author semancik + * @see TestCompare */ public class TestEquals extends AbstractPrismTest { @Test public void testContainsEquivalentValue01() throws Exception { - final String TEST_NAME="testContainsEquivalentValue01"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta userDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(UserType.class, USER_FOO_OID, - UserType.F_ASSIGNMENT, + UserType.F_ASSIGNMENT, createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null)); display("userDelta", userDelta); @@ -43,18 +38,15 @@ public void testContainsEquivalentValue01() throws Exception { PrismContainer assignmentContainer = user.findContainer(UserType.F_ASSIGNMENT); // WHEN, THEN - displayWhen(TEST_NAME); - assertTrue(ASSIGNMENT_PATLAMA_ID+":null", assignmentContainer.containsEquivalentValue(createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null))); - assertTrue("null:"+ASSIGNMENT_PATLAMA_DESCRIPTION, assignmentContainer.containsEquivalentValue(createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION))); + when(); + assertTrue(ASSIGNMENT_PATLAMA_ID + ":null", assignmentContainer.containsEquivalentValue(createAssignmentValue(ASSIGNMENT_PATLAMA_ID, null))); + assertTrue("null:" + ASSIGNMENT_PATLAMA_DESCRIPTION, assignmentContainer.containsEquivalentValue(createAssignmentValue(null, ASSIGNMENT_PATLAMA_DESCRIPTION))); assertFalse("364576:null", assignmentContainer.containsEquivalentValue(createAssignmentValue(364576L, null))); assertFalse("null:never ever never", assignmentContainer.containsEquivalentValue(createAssignmentValue(null, "never ever never"))); } @Test(enabled = false) // normalization no longer removes empty values public void testEqualsBrokenAssignmentActivation() throws Exception { - final String TEST_NAME="testEqualsBrokenAssignmentActivation"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObjectDefinition userDef = PrismInternalTestUtil.getUserTypeDefinition(); PrismContainerDefinition assignmentDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java index b70ae0367d4..495dada9c76 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestExtraSchema.java @@ -7,43 +7,38 @@ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import static org.testng.AssertJUnit.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import java.io.File; import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.Validator; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -public class TestExtraSchema { +public class TestExtraSchema extends AbstractPrismTest { public static final String NS_USER_2_EXT = "http://example.com/xml/ns/user-2-extension"; - private static final ItemName USER_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_EXT,"UserExtensionType"); - private static final ItemName USER_2_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_2_EXT,"User2ExtensionType"); + private static final ItemName USER_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_EXT, "UserExtensionType"); + private static final ItemName USER_2_EXTENSION_TYPE_QNAME = new ItemName(NS_USER_2_EXT, "User2ExtensionType"); private static final ItemName USER_EXT_2_ELEMENT = new ItemName(NS_USER_2_EXT, "ext2"); @@ -53,8 +48,6 @@ public class TestExtraSchema { */ @Test public void testExtraSchema() throws SAXException, IOException, SchemaException { - System.out.println("===[ testExtraSchema ]==="); - Document dataDoc = DOMUtil.parseFile(new File(COMMON_DIR_PATH, "root-foo.xml")); PrismContext context = constructPrismContext(); @@ -67,9 +60,7 @@ public void testExtraSchema() throws SAXException, IOException, SchemaException Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); - validator.validate(new DOMSource(dataDoc),validationResult); -// System.out.println("Validation result:"); -// System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); + validator.validate(new DOMSource(dataDoc), validationResult); } /** @@ -78,8 +69,6 @@ public void testExtraSchema() throws SAXException, IOException, SchemaException */ @Test public void testUserExtensionSchemaLoad() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaLoad ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); @@ -105,7 +94,6 @@ public void testUserExtensionSchemaLoad() throws SAXException, IOException, Sche @Test public void testUserExtensionSchemaParseUser() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaParseUser ]==="); Document dataDoc = DOMUtil.parseFile(USER_JACK_FILE_XML); PrismContext context = constructPrismContext(); @@ -127,16 +115,11 @@ public void testUserExtensionSchemaParseUser() throws SAXException, IOException, assertNotNull(javaxSchema); Validator validator = javaxSchema.newValidator(); DOMResult validationResult = new DOMResult(); - validator.validate(new DOMSource(dataDoc),validationResult); -// System.out.println("Validation result:"); -// System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); - + validator.validate(new DOMSource(dataDoc), validationResult); } @Test public void testUserExtensionSchemaSchemaRegistry() throws SAXException, IOException, SchemaException { - System.out.println("===[ testUserExtensionSchemaAsObjectSchema ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); @@ -163,9 +146,9 @@ private void assertUserDefinition(PrismObjectDefinition userDef) { System.out.println(extDef.debugDump()); assertTrue("Extension is not dynamic", extDef.isRuntimeSchema()); - assertTrue("Wrong extension type "+extDef.getTypeName(), + assertTrue("Wrong extension type " + extDef.getTypeName(), USER_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName()) || USER_2_EXTENSION_TYPE_QNAME.equals(extDef.getTypeName())); - assertEquals("Wrong extension displayOrder", (Integer)1000, extDef.getDisplayOrder()); + assertEquals("Wrong extension displayOrder", (Integer) 1000, extDef.getDisplayOrder()); PrismPropertyDefinition barPropDef = extDef.findPropertyDefinition(USER_EXT_BAR_ELEMENT); assertNotNull("No 'bar' definition in user extension", barPropDef); @@ -197,8 +180,8 @@ private void assertUserDefinition(PrismObjectDefinition userDef) { } private void assertDefinitionOrder(List definitions, QName elementName, int i) { - assertEquals("Wrong definition, expected that "+PrettyPrinter.prettyPrint(elementName)+" definition will be at index " + - i + " but there was a "+definitions.get(i).getItemName()+" instead", elementName, definitions.get(i).getItemName()); + assertEquals("Wrong definition, expected that " + PrettyPrinter.prettyPrint(elementName) + " definition will be at index " + + i + " but there was a " + definitions.get(i).getItemName() + " instead", elementName, definitions.get(i).getItemName()); } /** @@ -207,8 +190,6 @@ private void assertDefinitionOrder(List definitions, Q */ @Test public void testTypeOverride() throws SAXException, IOException, SchemaException { - System.out.println("===[ testTypeOverride ]==="); - PrismContext context = constructPrismContext(); SchemaRegistryImpl reg = (SchemaRegistryImpl) context.getSchemaRegistry(); reg.registerPrismSchemasFromDirectory(EXTRA_SCHEMA_DIR); @@ -218,7 +199,7 @@ public void testTypeOverride() throws SAXException, IOException, SchemaException System.out.println("Parsed root schema:"); System.out.println(schema.debugDump()); - PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT,"root")); + PrismContainerDefinition rootContDef = schema.findContainerDefinitionByElementName(new QName(NS_ROOT, "root")); assertNotNull("Not definition", rootContDef); PrismContainerDefinition extensionContDef = rootContDef.findContainerDefinition(new ItemName(NS_FOO, "extension")); assertNotNull("Not definition", extensionContDef); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java index 3b6466a5e45..a9001b4fe5e 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFind.java @@ -6,43 +6,30 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.foo.AccountConstructionType; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestFind { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestFind extends AbstractPrismTest { @Test - public void testFindString() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindString"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindString() throws SchemaException, IOException { // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_DESCRIPTION; @@ -51,15 +38,12 @@ public void testFindString() throws SchemaException, SAXException, IOException { PrismProperty nameProperty = findProperty(user, path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_DESCRIPTION, nameProperty.getRealValue()); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_DESCRIPTION, nameProperty.getRealValue()); assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_DESCRIPTION)); } @Test - public void testFindPolyString() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyString"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindPolyString() throws SchemaException, IOException { // GIVEN PrismObject user = createUser(); ItemPath path = UserType.F_POLY_NAME; @@ -73,10 +57,7 @@ public void testFindPolyString() throws SchemaException, SAXException, IOExcepti } @Test - public void testFindPolyStringOrig() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyStringOrig"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindPolyStringOrig() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_ORIG); @@ -84,14 +65,11 @@ public void testFindPolyStringOrig() throws SchemaException, SAXException, IOExc Object found = findUser(path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_POLYNAME_ORIG, found); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_POLYNAME_ORIG, found); } @Test - public void testFindPolyStringNorm() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindPolyStringNorm"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindPolyStringNorm() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_NORM); @@ -99,14 +77,11 @@ public void testFindPolyStringNorm() throws SchemaException, SAXException, IOExc Object found = findUser(path); // THEN - assertEquals("Wrong property value (path="+path+")", USER_JACK_POLYNAME_NORM, found); + assertEquals("Wrong property value (path=" + path + ")", USER_JACK_POLYNAME_NORM, found); } @Test - public void testFindExtensionBar() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindExtensionBar"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindExtensionBar() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_EXTENSION, EXTENSION_BAR_ELEMENT); @@ -114,14 +89,11 @@ public void testFindExtensionBar() throws SchemaException, SAXException, IOExcep PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "BAR", property.getAnyRealValue()); + assertEquals("Wrong property value (path=" + path + ")", "BAR", property.getAnyRealValue()); } @Test - public void testFindAssignment1Description() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment1Description"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindAssignment1Description() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_DESCRIPTION); @@ -129,14 +101,11 @@ public void testFindAssignment1Description() throws SchemaException, SAXExceptio PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "Assignment 1", property.getRealValue()); + assertEquals("Wrong property value (path=" + path + ")", "Assignment 1", property.getRealValue()); } @Test - public void testFindAssignment2Construction() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment2ConstructionHowto"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindAssignment2Construction() throws SchemaException, IOException { // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_2_ID, AssignmentType.F_ACCOUNT_CONSTRUCTION); @@ -144,14 +113,11 @@ public void testFindAssignment2Construction() throws SchemaException, SAXExcepti PrismProperty property = findUserProperty(path); // THEN - assertEquals("Wrong property value (path="+path+")", "Just do it", property.getRealValue().getHowto()); + assertEquals("Wrong property value (path=" + path + ")", "Just do it", property.getRealValue().getHowto()); } @Test - public void testFindAssignment() throws SchemaException, SAXException, IOException { - final String TEST_NAME = "testFindAssignment"; - System.out.println("===[ "+TEST_NAME+" ]==="); - + public void testFindAssignment() throws SchemaException, IOException { // GIVEN ItemPath path = UserType.F_ASSIGNMENT; @@ -160,10 +126,10 @@ public void testFindAssignment() throws SchemaException, SAXException, IOExcepti // THEN PrismContainerValue value2 = container.getValue(USER_ASSIGNMENT_2_ID); - assertEquals("Wrong value2 description (path="+path+")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue()); + assertEquals("Wrong value2 description (path=" + path + ")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue()); } - private T findUser(ItemPath path) throws SchemaException, SAXException, IOException { + private T findUser(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return find(user, path); } @@ -181,7 +147,7 @@ private T find(PrismObject user, ItemPath path) { return (T) found; } - private PrismProperty findUserProperty(ItemPath path) throws SchemaException, SAXException, IOException { + private PrismProperty findUserProperty(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return findProperty(user, path); } @@ -199,7 +165,7 @@ private PrismProperty findProperty(PrismObject user, ItemPath p return property; } - private PrismContainer findUserContainer(ItemPath path) throws SchemaException, SAXException, IOException { + private PrismContainer findUserContainer(ItemPath path) throws SchemaException, IOException { PrismObject user = createUser(); return findContainer(user, path); } @@ -217,10 +183,8 @@ private PrismContainer findContainer(PrismObject createUser() throws SchemaException, SAXException, IOException { + public PrismObject createUser() throws SchemaException, IOException { return PrismTestUtil.parseObject(USER_JACK_FILE_XML); } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java index 54b5e605bfe..fecaf227235 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestFundamentals.java @@ -6,41 +6,26 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import static org.testng.AssertJUnit.assertEquals; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; -import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; -import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; +import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; - -import javax.xml.namespace.QName; +import com.evolveum.prism.xml.ns._public.types_3.RawType; /** * @author Radovan Semancik - * */ -public class TestFundamentals { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestFundamentals extends AbstractPrismTest { @Test - public void testPrismValueContainsRealValue() throws Exception { - System.out.println("\n\n===[ testPrismValueContainsRealValue ]===\n"); + public void testPrismValueContainsRealValue() { // GIVEN PrismPropertyValue valFoo1 = new PrismPropertyValueImpl<>("foo"); PrismPropertyValue valBar1 = new PrismPropertyValueImpl<>("bar"); @@ -70,8 +55,7 @@ public void testPrismValueContainsRealValue() throws Exception { } @Test - public void testRawTypeClone() throws Exception { - System.out.println("\n\n===[ testRawTypeClone ]===\n"); + public void testRawTypeClone() { // GIVEN QName typeQName = new QName("abcdef"); MapXNodeImpl mapXNode = new MapXNodeImpl(); @@ -84,5 +68,4 @@ public void testRawTypeClone() throws Exception { // THEN assertEquals("Wrong or missing type QName", typeQName, rawTypeClone.getXnode().getTypeQName()); } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java index dcee348b8f3..27e8abb6530 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPath.java @@ -6,39 +6,28 @@ */ package com.evolveum.midpoint.prism; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.*; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.prism.path.*; /** * @author semancik - * */ -public class TestPath { +public class TestPath extends AbstractPrismTest { private static final String NS = "http://example.com/"; private static Map> creators = new HashMap<>(); + static { creators.put('C', seq -> getPrismContext().path(seq)); creators.put('S', ItemPath::create); @@ -46,16 +35,8 @@ public class TestPath { creators.put('R', seq -> creators.get("CSN".charAt((int) (Math.random() * 3))).apply(seq)); } - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } - @Test public void testPathNormalize() { - System.out.println("\n\n===[ testPathNormalize ]===\n"); - PrismContext prismContext = getPrismContext(); // GIVEN @@ -131,8 +112,6 @@ public void testPathCompareHalf2() { } private void testPathCompare(String source) { - System.out.println("\n\n===[ testPathCompare (" + source + ") ]===\n"); - // GIVEN // /foo @@ -239,9 +218,7 @@ private ItemPath create(String source, int index, Object... components) { } @Test - public void testPathRemainder() throws Exception { - System.out.println("\n\n===[ testPathRemainder ]===\n"); - + public void testPathRemainder() { PrismContext prismContext = getPrismContext(); // GIVEN @@ -251,7 +228,7 @@ public void testPathRemainder() throws Exception { UniformItemPath pathFoo123 = prismContext.path(new QName(NS, "foo"), 123L); UniformItemPath pathFooBar = prismContext.path(new QName(NS, "foo"), new QName(NS, "bar")); UniformItemPath pathFooNullBar = prismContext.path(new QName(NS, "foo"), null, - new QName(NS, "bar")); + new QName(NS, "bar")); // WHEN UniformItemPath remainder1 = pathFooBar.remainder(pathFooNull); @@ -261,20 +238,20 @@ public void testPathRemainder() throws Exception { } private void assertNormalizedPath(UniformItemPath normalized, Object... expected) { - assertEquals("wrong path length",normalized.size(), expected.length); - for(int i=0; i userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java index 9712f6276bf..d9ac4711680 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPolyString.java @@ -36,9 +36,6 @@ public class TestPolyString extends AbstractPrismTest { @Test public void testSimpleAlphaNormalization() { - final String TEST_NAME = "testSimpleAlphaNormalization"; - displayTestTitle(TEST_NAME); - AlphanumericPolyStringNormalizer normalizer = new AlphanumericPolyStringNormalizer(); testNormalization(normalizer, @@ -60,9 +57,6 @@ public void testSimpleAlphaNormalization() { @Test public void testAlphaNormalizationNoNfkd() { - final String TEST_NAME = "testAlphaNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - AlphanumericPolyStringNormalizer normalizer = new AlphanumericPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -87,9 +81,6 @@ public void testAlphaNormalizationNoNfkd() { @Test public void testSimpleAsciiNormalization() { - final String TEST_NAME = "testSimpleAlphaNormalization"; - displayTestTitle(TEST_NAME); - Ascii7PolyStringNormalizer normalizer = new Ascii7PolyStringNormalizer(); testNormalization(normalizer, @@ -111,9 +102,6 @@ public void testSimpleAsciiNormalization() { @Test public void testAsciiNormalizationNoNfkd() { - final String TEST_NAME = "testAsciiNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - Ascii7PolyStringNormalizer normalizer = new Ascii7PolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -138,9 +126,6 @@ public void testAsciiNormalizationNoNfkd() { @Test public void testSimplePassThroughNormalization() { - final String TEST_NAME = "testSimplePassThroughNormalization"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); testNormalization(normalizer, @@ -165,9 +150,6 @@ public void testSimplePassThroughNormalization() { @Test public void testPassThroughNormalizationNoNfkd() { - final String TEST_NAME = "testPassThroughNormalizationNoNfkd"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setNfkd(false); @@ -192,9 +174,6 @@ public void testPassThroughNormalizationNoNfkd() { @Test public void testPassThroughNormalizationAllOff() { - final String TEST_NAME = "testPassThroughNormalizationAllOff"; - displayTestTitle(TEST_NAME); - PassThroughPolyStringNormalizer normalizer = new PassThroughPolyStringNormalizer(); PolyStringNormalizerConfigurationType configuration = new PolyStringNormalizerConfigurationType(); configuration.setTrim(false); @@ -232,9 +211,6 @@ private void testNormalization(PolyStringNormalizer normalizer, String orig, Str @Test public void testRecompute() throws Exception { - final String TEST_NAME = "testRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -246,28 +222,25 @@ public void testRecompute() throws Exception { PrismProperty polyNameProperty = user.findOrCreateProperty(USER_POLYNAME_QNAME); // WHEN - displayWhen(TEST_NAME); + when(); polyNameProperty.setRealValue(polyName); // THEN - displayThen(TEST_NAME); + then(); assertEquals("Changed orig", orig, polyName.getOrig()); assertEquals("Wrong norm", "lala ho papluha", polyName.getNorm()); } @Test - public void testCompareTo() throws Exception { - final String TEST_NAME = "testCompareTo"; - displayTestTitle(TEST_NAME); - + public void testCompareTo() { // GIVEN String orig = "Ľala ho papľuha"; PolyString polyName = new PolyString(orig); // WHEN, THEN - assertTrue(polyName.compareTo("Ľala ho papľuha") == 0); - assertTrue(polyName.compareTo(new PolyString("Ľala ho papľuha")) == 0); + assertEquals(polyName.compareTo("Ľala ho papľuha"), 0); + assertEquals(polyName.compareTo(new PolyString("Ľala ho papľuha")), 0); assertTrue(polyName.compareTo("something different") != 0); assertTrue(polyName.compareTo(new PolyString("something different")) != 0); assertTrue(polyName.compareTo("") != 0); @@ -276,38 +249,29 @@ public void testCompareTo() throws Exception { } @Test - public void testConversion() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversion() { PolyString polyString = new PolyString("Ľala ho papľuha"); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } @Test - public void testConversionWithEmptyLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversionWithEmptyLang() { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } @Test - public void testConversionWithOneLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - + public void testConversionWithOneLang() { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); polyString.getLang().put("sk", "Lalala"); - executeConversionTest(TEST_NAME, polyString); + executeConversionTest(polyString); } - private void executeConversionTest(String TEST_NAME, PolyString polyString) { + private void executeConversionTest(PolyString polyString) { // WHEN - displayWhen(TEST_NAME); + when(); PolyStringType polyStringType = PolyString.toPolyStringType(polyString); PolyString polyString2 = PolyString.toPolyString(polyStringType); PolyStringType polyStringType2 = PolyString.toPolyStringType(polyString2); @@ -318,7 +282,7 @@ private void executeConversionTest(String TEST_NAME, PolyString polyString) { System.out.println("polyStringType2 = " + polyStringType2); // THEN - displayThen(TEST_NAME); + then(); assertEquals("PolyString differs", polyString, polyString2); assertEquals("PolyStringType differs", polyStringType, polyStringType2); assertEquals("PolyString.hashCode differs", polyString.hashCode(), polyString2.hashCode()); @@ -327,23 +291,17 @@ private void executeConversionTest(String TEST_NAME, PolyString polyString) { @Test public void testSerialization() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); PrismObject user = userDefinition.instantiate(); PolyString polyString = new PolyString("Ľala ho papľuha"); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } @Test public void testSerializationWithEmptyLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -351,14 +309,11 @@ public void testSerializationWithEmptyLang() throws Exception { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } @Test public void testSerializationWithOneLang() throws Exception { - final String TEST_NAME = "testConversion"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); @@ -367,16 +322,16 @@ public void testSerializationWithOneLang() throws Exception { PolyString polyString = new PolyString("Ľala ho papľuha"); polyString.setLang(new HashMap<>()); polyString.getLang().put("sk", "Lalala"); - executeSerializationTest(TEST_NAME, ctx, user, polyString); + executeSerializationTest(ctx, user, polyString); } - private void executeSerializationTest(String TEST_NAME, PrismContext ctx, PrismObject user, PolyString polyString) + private void executeSerializationTest(PrismContext ctx, PrismObject user, PolyString polyString) throws com.evolveum.midpoint.util.exception.SchemaException { PrismProperty polyNameProperty = user.findOrCreateProperty(USER_POLYNAME_QNAME); polyNameProperty.setRealValue(polyString); // WHEN - displayWhen(TEST_NAME); + when(); String xml = ctx.xmlSerializer().serialize(user); System.out.println(xml); PrismObject parsed = ctx.parserFor(xml).parse(); @@ -384,7 +339,7 @@ private void executeSerializationTest(String TEST_NAME, PrismContext ctx, PrismO PrismObject parsed2 = ctx.parserFor(xml2).parse(); // THEN - displayThen(TEST_NAME); + then(); assertEquals("original and parsed are different", user, parsed); assertEquals("parsed and parsed2 are different", parsed, parsed2); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismContext.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismContext.java index 9dc1312e1e2..ebee44990a4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismContext.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismContext.java @@ -6,31 +6,24 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertNotNull; import java.io.IOException; -import java.util.Map; - import javax.xml.XMLConstants; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.PrismContextImpl; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; -import com.evolveum.midpoint.prism.foo.AccountConstructionType; import com.evolveum.midpoint.prism.foo.AccountType; -import com.evolveum.midpoint.prism.foo.ActivationType; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.PrismContextImpl; import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.schema.SchemaDescription; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.DynamicNamespacePrefixMapper; @@ -42,9 +35,8 @@ /** * @author semancik - * */ -public class TestPrismContext { +public class TestPrismContext extends AbstractPrismTest { private static final String NS_FOO = "http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd"; @@ -55,8 +47,6 @@ public void setupDebug() { @Test public void testPrefixMapper() throws SchemaException, SAXException, IOException { - System.out.println("===[ testPrefixMapper ]==="); - // WHEN PrismContextImpl prismContext = constructInitializedPrismContext(); @@ -75,14 +65,8 @@ public void testPrefixMapper() throws SchemaException, SAXException, IOException } - private void assertMapping(Map> map, Class clazz, QName typeName) { - assertEquals("Wrong xsdType->class mapping for "+typeName, clazz, map.get(typeName)); - } - @Test public void testBasicSchemas() throws SchemaException, SAXException, IOException { - System.out.println("===[ testBasicSchemas ]==="); - // WHEN PrismContext prismContext = constructInitializedPrismContext(); @@ -100,7 +84,7 @@ public void testBasicSchemas() throws SchemaException, SAXException, IOException System.out.println(fooSchema.debugDump()); // Assert USER definition - PrismObjectDefinition userDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismObjectDefinition userDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "user")); assertNotNull("No user definition", userDefinition); System.out.println("User definition:"); System.out.println(userDefinition.debugDump()); @@ -111,7 +95,7 @@ public void testBasicSchemas() throws SchemaException, SAXException, IOException assertUserDefinition(userDefinition); // Assert ACCOUNT definition - PrismObjectDefinition accountDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"account")); + PrismObjectDefinition accountDefinition = fooSchema.findObjectDefinitionByElementName(new QName(NS_FOO, "account")); assertNotNull("No account definition", accountDefinition); System.out.println("Account definition:"); System.out.println(accountDefinition.debugDump()); @@ -186,8 +170,6 @@ private void assertAccountDefinition(PrismObjectDefinition accountD @Test public void testExtensionSchema() throws SchemaException, SAXException, IOException { - System.out.println("===[ testExtensionSchema ]==="); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); assertNotNull("No prism context", prismContext); @@ -196,19 +178,19 @@ public void testExtensionSchema() throws SchemaException, SAXException, IOExcept PrismPropertyDefinition ignoredTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_IGNORED_TYPE_ELEMENT); PrismAsserts.assertDefinition(ignoredTypeDef, EXTENSION_IGNORED_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); - assertTrue("Element "+EXTENSION_IGNORED_TYPE_ELEMENT+" is NOT ignored", ignoredTypeDef.isIgnored()); + assertTrue("Element " + EXTENSION_IGNORED_TYPE_ELEMENT + " is NOT ignored", ignoredTypeDef.isIgnored()); PrismPropertyDefinition stringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_STRING_TYPE_ELEMENT); PrismAsserts.assertDefinition(stringTypeDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); - assertFalse("Element "+EXTENSION_STRING_TYPE_ELEMENT+" is ignored", stringTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_STRING_TYPE_ELEMENT + " is ignored", stringTypeDef.isIgnored()); PrismPropertyDefinition singleStringTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_SINGLE_STRING_TYPE_ELEMENT); PrismAsserts.assertDefinition(singleStringTypeDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, 1); - assertFalse("Element "+EXTENSION_SINGLE_STRING_TYPE_ELEMENT+" is ignored", singleStringTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_SINGLE_STRING_TYPE_ELEMENT + " is ignored", singleStringTypeDef.isIgnored()); PrismPropertyDefinition intTypeDef = schemaRegistry.findPropertyDefinitionByElementName(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intTypeDef, EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); - assertFalse("Element "+EXTENSION_INT_TYPE_ELEMENT+" is ignored", intTypeDef.isIgnored()); + assertFalse("Element " + EXTENSION_INT_TYPE_ELEMENT + " is ignored", intTypeDef.isIgnored()); PrismContainerDefinition meleeContextDefinition = schemaRegistry.findContainerDefinitionByElementName(EXTENSION_MELEE_CONTEXT_ELEMENT); PrismAsserts.assertDefinition(meleeContextDefinition, EXTENSION_MELEE_CONTEXT_ELEMENT, EXTENSION_MELEE_CONTEXT_TYPE_QNAME, 0, 1); @@ -219,8 +201,6 @@ public void testExtensionSchema() throws SchemaException, SAXException, IOExcept @Test public void testSchemaToDom() throws SchemaException, SAXException, IOException { - System.out.println("===[ testSchemaToDom ]==="); - // GIVEN PrismContext prismContext = constructInitializedPrismContext(); PrismSchema fooSchema = prismContext.getSchemaRegistry().findSchemaByNamespace(NS_FOO); @@ -231,48 +211,4 @@ public void testSchemaToDom() throws SchemaException, SAXException, IOException // THEN assertNotNull("No foo XSD DOM", fooXsd); } - - // This is not supposed to work with foo schema. It container ObjectReferenceType which does - // not survive roundtrip -// @Test -// public void testSchemaParsingRoundTrip() throws SchemaException, SAXException, IOException { -// System.out.println("===[ testSchemaParsingRoundTrip ]==="); -// -// // GIVEN -// PrismContext prismContext = constructInitializedPrismContext(); -// PrismSchema fooSchema = prismContext.getSchemaRegistry().findSchemaByNamespace(NS_FOO); -// -// // WHEN -// Document fooXsd = fooSchema.serializeToXsd(); -// -// // THEN -// assertNotNull("No foo XSD DOM", fooXsd); -// System.out.println("Serialized schema"); -// System.out.println(DOMUtil.serializeDOMToString(fooXsd)); -// -// // WHEN -// PrismSchema parsedSchema = PrismSchema.parse(DOMUtil.getFirstChildElement(fooXsd), prismContext); -// -// // THEN -// assertNotNull("No parsed schema", parsedSchema); -// System.out.println("Parsed schema"); -// System.out.println(parsedSchema.dump()); -// -// // Assert USER definition -// PrismObjectDefinition userDefinition = parsedSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"user")); -// assertNotNull("No user definition", userDefinition); -// System.out.println("User definition:"); -// System.out.println(userDefinition.dump()); -// -// assertUserDefinition(userDefinition); -// -// // Assert ACCOUNT definition -// PrismObjectDefinition accountDefinition = parsedSchema.findObjectDefinitionByElementName(new QName(NS_FOO,"account")); -// assertNotNull("No account definition", accountDefinition); -// System.out.println("Account definition:"); -// System.out.println(accountDefinition.dump()); -// -// assertAccountDefinition(accountDefinition); -// } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java index 529060b677a..8e518c8cae4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismObjectConstruction.java @@ -6,23 +6,18 @@ */ package com.evolveum.midpoint.prism; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.Validator; -import com.evolveum.midpoint.prism.impl.PrismContainerImpl; -import com.evolveum.midpoint.prism.impl.PrismObjectImpl; -import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -30,39 +25,30 @@ import com.evolveum.midpoint.prism.foo.ActivationType; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.PrismContainerImpl; +import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public class TestPrismObjectConstruction { +public class TestPrismObjectConstruction extends AbstractPrismTest { private static final String USER_OID = "1234567890"; private static final String ACCOUNT1_OID = "11100000111"; private static final String ACCOUNT2_OID = "11100000222"; - - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - /** * Construct object with schema. Starts by instantiating a definition and working downwards. * All the items in the object should have proper definition. */ @Test public void testConstructionWithSchema() throws Exception { - final String TEST_NAME = "testConstructionWithSchema"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); // WHEN PrismObject user = userDefinition.instantiate(); @@ -76,73 +62,11 @@ public void testConstructionWithSchema() throws Exception { assertUserDrake(user, true, ctx); } - /** - * Construct object without schema. Starts by creating object "out of the blue" and - * the working downwards. - */ - @Test(enabled = false) // definition-less containers are no longer supported - public void testDefinitionlessConstruction() throws Exception { - final String TEST_NAME = "testDefinitionlessConstruction"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - // No context needed - - // WHEN - PrismObject user = new PrismObjectImpl<>(USER_QNAME, UserType.class); - // Fill-in object values, no schema checking - fillInUserDrake(user, false); - - // THEN - System.out.println("User:"); - System.out.println(user.debugDump()); - // Check if the values are correct, no schema checking - PrismContext ctx = constructInitializedPrismContext(); - assertUserDrake(user, false, ctx); - } - - /** - * Construct object without schema. Starts by creating object "out of the blue" and - * the working downwards. Then apply the schema. Check definitions. - */ -// @Test - public void testDefinitionlessConstructionAndSchemaApplication() throws Exception { - final String TEST_NAME = "testDefinitionlessConstructionAndSchemaApplication"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - // No context needed (yet) - PrismObject user = new PrismObjectImpl<>(USER_QNAME, UserType.class); - // Fill-in object values, no schema checking - fillInUserDrake(user, false); - // Make sure the object is OK - PrismContext ctx = constructInitializedPrismContext(); - assertUserDrake(user, false, ctx); - - - PrismObjectDefinition userDefinition = - getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); - - // WHEN - user.applyDefinition(userDefinition); - - // THEN - System.out.println("User:"); - System.out.println(user.debugDump()); - - // Check schema now - assertUserDrake(user, true, ctx); - - } - @Test public void testClone() throws Exception { - final String TEST_NAME = "testClone"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); PrismObject user = userDefinition.instantiate(); fillInUserDrake(user, true); // precondition @@ -160,12 +84,9 @@ public void testClone() throws Exception { @Test public void testCloneEquals() throws Exception { - final String TEST_NAME = "testCloneEquals"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN - PrismContext ctx = constructInitializedPrismContext(); - PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); + PrismContext ctx = getPrismContext(); + PrismObjectDefinition userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO, "user")); PrismObject user = userDefinition.instantiate(); fillInUserDrake(user, true); PrismObject clone = user.clone(); @@ -175,7 +96,6 @@ public void testCloneEquals() throws Exception { assertTrue("Clone not equivalent", clone.equivalent(user)); } - private void fillInUserDrake(PrismObject user, boolean assertDefinitions) throws SchemaException { user.setOid(USER_OID); @@ -183,7 +103,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty fullNameProperty = user.findOrCreateProperty(USER_FULLNAME_QNAME); assertEquals(USER_FULLNAME_QNAME, fullNameProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); } fullNameProperty.setRealValue("Sir Fancis Drake"); PrismProperty fullNamePropertyAgain = user.findOrCreateProperty(USER_FULLNAME_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again @@ -193,7 +113,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer activationContainer = user.findOrCreateContainer(USER_ACTIVATION_QNAME); assertEquals(USER_ACTIVATION_QNAME, activationContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); } PrismContainer activationContainerAgain = user.findOrCreateContainer(USER_ACTIVATION_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Property not the same", activationContainer == activationContainerAgain); @@ -202,7 +122,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty enabledProperty = user.findOrCreateProperty(USER_ENABLED_PATH); assertEquals(USER_ENABLED_QNAME, enabledProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); } enabledProperty.setRealValue(true); PrismProperty enabledPropertyAgain = activationContainer.findOrCreateProperty(USER_ENABLED_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again @@ -213,7 +133,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer assignmentContainer = user.getValue().findOrCreateContainer(USER_ASSIGNMENT_QNAME); assertEquals(USER_ASSIGNMENT_QNAME, assignmentContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); } PrismContainer assignmentContainerAgain = user.findOrCreateContainer(USER_ASSIGNMENT_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Property not the same", assignmentContainer == assignmentContainerAgain); @@ -246,7 +166,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio // accountRef PrismReference accountRef = user.findOrCreateReference(USER_ACCOUNTREF_QNAME); assertEquals(USER_ACCOUNTREF_QNAME, accountRef.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); } accountRef.add(new PrismReferenceValueImpl(ACCOUNT1_OID)); accountRef.add(new PrismReferenceValueImpl(ACCOUNT2_OID)); PrismReference accountRefAgain = user.findOrCreateReference(USER_ACCOUNTREF_QNAME); @@ -259,7 +179,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismContainer extensionContainer = user.findOrCreateContainer(USER_EXTENSION_QNAME); assertEquals(USER_EXTENSION_QNAME, extensionContainer.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(extensionContainer, DOMUtil.XSD_ANY, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(extensionContainer, DOMUtil.XSD_ANY, 0, 1); } PrismContainer extensionContainerAgain = user.findOrCreateContainer(USER_EXTENSION_QNAME); // The "==" is there by purpose. We really want to make sure that is the same *instance*, that is was not created again assertTrue("Extension not the same", extensionContainer == extensionContainerAgain); @@ -269,7 +189,7 @@ private void fillInUserDrake(PrismObject user, boolean assertDefinitio PrismProperty stringTypeProperty = extensionContainer.findOrCreateProperty(EXTENSION_STRING_TYPE_ELEMENT); assertEquals(EXTENSION_STRING_TYPE_ELEMENT, stringTypeProperty.getElementName()); PrismAsserts.assertParentConsistency(user); - if (assertDefinitions) PrismAsserts.assertDefinition(stringTypeProperty, DOMUtil.XSD_STRING, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(stringTypeProperty, DOMUtil.XSD_STRING, 0, -1); } // TODO @@ -289,42 +209,42 @@ private void assertUserDrake(PrismObject user, boolean assertDefinitio private void assertUserDrakeContent(PrismObject user, boolean assertDefinitions) { // fullName PrismProperty fullNameProperty = user.findProperty(USER_FULLNAME_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(fullNameProperty, DOMUtil.XSD_STRING, 1, 1); } assertEquals("Wrong fullname", "Sir Fancis Drake", fullNameProperty.getValue().getValue()); // activation PrismContainer activationContainer = user.findContainer(USER_ACTIVATION_QNAME); assertEquals(USER_ACTIVATION_QNAME, activationContainer.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(activationContainer, ACTIVATION_TYPE_QNAME, 0, 1); } // activation/enabled PrismProperty enabledProperty = user.findProperty(USER_ENABLED_PATH); assertEquals(USER_ENABLED_QNAME, enabledProperty.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(enabledProperty, DOMUtil.XSD_BOOLEAN, 0, 1); } assertEquals("Wrong enabled", true, enabledProperty.getValue().getValue()); // assignment PrismContainer assignmentContainer = user.findContainer(USER_ASSIGNMENT_QNAME); assertEquals(USER_ASSIGNMENT_QNAME, assignmentContainer.getElementName()); - if (assertDefinitions) PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assignmentContainer, ASSIGNMENT_TYPE_QNAME, 0, -1); } // assignment values List assValues = assignmentContainer.getValues(); assertEquals("Wrong number of assignment values", 3, assValues.size()); // assignment values: blue PrismContainerValue assBlueValue = assValues.get(0); PrismProperty assBlueDescriptionProperty = assBlueValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assBlueDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assBlueDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong blue assignment description", "Assignment created out of the blue", assBlueDescriptionProperty.getValue().getValue()); // assignment values: cyan PrismContainerValue assCyanValue = assValues.get(1); PrismProperty assCyanDescriptionProperty = assCyanValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assCyanDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assCyanDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong cyan assignment description", "Assignment created out of the cyan", assCyanDescriptionProperty.getValue().getValue()); // assignment values: red PrismContainerValue assRedValue = assValues.get(2); PrismProperty assRedDescriptionProperty = assRedValue.findProperty(USER_DESCRIPTION_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(assRedDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); + if (assertDefinitions) { PrismAsserts.assertDefinition(assRedDescriptionProperty, DOMUtil.XSD_STRING, 0, 1); } assertEquals("Wrong red assignment description", "Assignment created out of the red", assRedDescriptionProperty.getValue().getValue()); // accountRef PrismReference accountRef = user.findReference(USER_ACCOUNTREF_QNAME); - if (assertDefinitions) PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); + if (assertDefinitions) { PrismAsserts.assertDefinition(accountRef, OBJECT_REFERENCE_TYPE_QNAME, 0, -1); } PrismAsserts.assertReferenceValue(accountRef, ACCOUNT1_OID); PrismAsserts.assertReferenceValue(accountRef, ACCOUNT2_OID); assertEquals("accountRef size", 2, accountRef.getValues().size()); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java index 1698cc28d4f..b94e3878088 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsing.java @@ -6,11 +6,9 @@ */ package com.evolveum.midpoint.prism; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; @@ -20,33 +18,29 @@ import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; - import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.foo.AccountType; -import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.delta.DiffUtil; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.foo.AccountType; import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ -public abstract class TestPrismParsing { +public abstract class TestPrismParsing extends AbstractPrismTest { protected abstract String getSubdirName(); @@ -57,22 +51,15 @@ protected File getCommonSubdir() { } protected File getFile(String baseName) { - return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix()); - } - - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); + return new File(getCommonSubdir(), baseName + "." + getFilenameSuffix()); } protected abstract String getOutputFormat(); @Test public void test100PrismParseFile() throws Exception { - final String TEST_NAME = "test100PrismParseFile"; - displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); @@ -87,10 +74,8 @@ public void test100PrismParseFile() throws Exception { @Test public void test110PrismParseFileNoNs() throws Exception { - final String TEST_NAME = "test110PrismParseFileNoNs"; - displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_NO_NS_BASENAME)); @@ -105,11 +90,8 @@ public void test110PrismParseFileNoNs() throws Exception { @Test public void test120PrismParseFileObject() throws Exception { - final String TEST_NAME = "test120PrismParseFileObject"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_OBJECT_BASENAME)); @@ -124,11 +106,8 @@ public void test120PrismParseFileObject() throws Exception { @Test public void test130PrismParseFileAdhoc() throws Exception { - final String TEST_NAME = "test130PrismParseFileAdhoc"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_JACK_ADHOC_BASENAME)); @@ -143,32 +122,23 @@ public void test130PrismParseFileAdhoc() throws Exception { @Test public void test200RoundTrip() throws Exception { - final String TEST_NAME = "test200RoundTrip"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_FILE_BASENAME), true, true); } @Test public void test210RoundTripNoNs() throws Exception { - final String TEST_NAME = "test210RoundTripNoNs"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_NO_NS_BASENAME), true, false); } @Test public void test220RoundTripObject() throws Exception { - final String TEST_NAME = "test220RoundTripObject"; - displayTestTitle(TEST_NAME); - roundTrip(getFile(USER_JACK_OBJECT_BASENAME), false, false); } private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomplete) throws SchemaException, SAXException, IOException { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); @@ -187,8 +157,6 @@ private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomp System.out.println(userXml); assertNotNull(userXml); - validateXml(userXml, prismContext); - // WHEN PrismObject parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); @@ -201,23 +169,19 @@ private void roundTrip(File file, boolean expectFullPolyName, boolean withIncomp System.out.println("Diff:"); System.out.println(diff.debugDump()); - assertTrue("Diff: "+diff, diff.isEmpty()); + assertTrue("Diff: " + diff, diff.isEmpty()); - assertTrue("Users not equal", originalUser.equals(parsedUser)); + assertEquals("Users not equal", parsedUser, originalUser); } - @Test public void test230RoundTripAdhoc() throws Exception { - final String TEST_NAME = "test230RoundTripAdhoc"; - displayTestTitle(TEST_NAME); - roundTripAdhoc(getFile(USER_JACK_ADHOC_BASENAME)); } - private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOException { + private void roundTripAdhoc(File file) throws SchemaException, IOException { // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); @@ -236,8 +200,6 @@ private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOE System.out.println(userXml); assertNotNull(userXml); - validateXml(userXml, prismContext); - // WHEN PrismObject parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); @@ -249,14 +211,10 @@ private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOE assertTrue("Users not equal", originalUser.equals(parsedUser)); } - @Test public void test300MeleeContext() throws Exception { - final String TEST_NAME = "test300MeleeContext"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); PrismObject userJack = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); PrismContainer meleeContextContainer = userJack.findOrCreateContainer(ItemPath.create(UserType.F_EXTENSION, EXTENSION_MELEE_CONTEXT_ELEMENT)); @@ -299,7 +257,7 @@ public void test300MeleeContext() throws Exception { // Make the original user jack suitable for comparison. // Some of the accountRef information is (intentionally) lost in re-parsing therefore erase it before comparing PrismReference jackAccountRef = userJack.findReference(UserType.F_ACCOUNT_REF); - for (PrismReferenceValue accRefVal: jackAccountRef.getValues()) { + for (PrismReferenceValue accRefVal : jackAccountRef.getValues()) { String oid = accRefVal.getOid(); QName targetType = accRefVal.getTargetType(); accRefVal.setObject(null); @@ -313,11 +271,8 @@ public void test300MeleeContext() throws Exception { @Test public void test400UserWill() throws Exception { - final String TEST_NAME = "test400UserWill"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); @@ -332,11 +287,8 @@ public void test400UserWill() throws Exception { @Test public void test410UserWillRoundTrip() throws Exception { - final String TEST_NAME = "test410UserWillRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); @@ -370,11 +322,8 @@ public void test410UserWillRoundTrip() throws Exception { @Test public void test500UserElisabethRoundTrip() throws Exception { - final String TEST_NAME = "test500UserElisabethRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parseObject(getFile(USER_ELISABETH_FILE_BASENAME)); @@ -409,11 +358,8 @@ public void test500UserElisabethRoundTrip() throws Exception { // MID-5326 @Test public void test600AccountBarbossa() throws Exception { - final String TEST_NAME = "test600AccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject account = prismContext.parseObject(getFile(ACCOUNT_BARBOSSA_FILE_BASENAME)); @@ -436,7 +382,6 @@ public void test600AccountBarbossa() throws Exception { )), names); } - protected void assertUserAdhoc(PrismObject user, boolean expectRawInConstructions, boolean withIncomplete) throws SchemaException { user.checkConsistence(); assertUserJackContent(user, expectRawInConstructions, true, withIncomplete); @@ -444,7 +389,6 @@ protected void assertUserAdhoc(PrismObject user, boolean expectRawInCo assertVisitor(user, 58); } - private void assertUserExtensionAdhoc(PrismObject user) { PrismContainer extension = user.getExtension(); @@ -454,9 +398,9 @@ private void assertUserExtensionAdhoc(PrismObject user) { assertNull("Extension ID", extensionValue.getId()); PrismAsserts.assertPropertyValue(extension, USER_ADHOC_BOTTLES_ELEMENT, 20); - ItemPath bottlesPath = ItemPath.create(new QName(NS_FOO,"extension"), USER_ADHOC_BOTTLES_ELEMENT); + ItemPath bottlesPath = ItemPath.create(new QName(NS_FOO, "extension"), USER_ADHOC_BOTTLES_ELEMENT); PrismProperty bottlesProperty = user.findProperty(bottlesPath); - assertNotNull("Property "+bottlesPath+" not found", bottlesProperty); + assertNotNull("Property " + bottlesPath + " not found", bottlesProperty); PrismAsserts.assertPropertyValue(bottlesProperty, 20); PrismPropertyDefinition bottlesPropertyDef = bottlesProperty.getDefinition(); assertNotNull("No definition for bottles", bottlesPropertyDef); @@ -548,9 +492,9 @@ private void assertUserWillExtension(PrismObject user) { PrismAsserts.assertDefinition(indexedStringPropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertEquals("'Indexed' attribute on 'singleStringType' property is wrong", Boolean.FALSE, indexedStringPropertyDef.isIndexed()); - ItemPath barPath = ItemPath.create(new QName(NS_FOO,"extension"), EXTENSION_BAR_ELEMENT); + ItemPath barPath = ItemPath.create(new QName(NS_FOO, "extension"), EXTENSION_BAR_ELEMENT); PrismProperty barProperty = user.findProperty(barPath); - assertNotNull("Property "+barPath+" not found", barProperty); + assertNotNull("Property " + barPath + " not found", barProperty); PrismAsserts.assertPropertyValue(barProperty, "BAR"); PrismPropertyDefinition barPropertyDef = barProperty.getDefinition(); assertNotNull("No definition for bar", barPropertyDef); @@ -562,11 +506,10 @@ private void assertUserWillExtension(PrismObject user) { PrismAsserts.assertDefinition(multiPropertyDef, EXTENSION_MULTI_ELEMENT, DOMUtil.XSD_STRING, 1, -1); assertNull("'Indexed' attribute on 'multi' property is not null", multiPropertyDef.isIndexed()); - PrismAsserts.assertPropertyValue(extension, EXTENSION_BAR_ELEMENT, "BAR"); PrismAsserts.assertPropertyValue(extension, EXTENSION_NUM_ELEMENT, 42); Collection> multiPVals = extension.findProperty(EXTENSION_MULTI_ELEMENT).getValues(); - assertEquals("Multi",3,multiPVals.size()); + assertEquals("Multi", 3, multiPVals.size()); } @@ -574,7 +517,6 @@ private void assertUserElisabeth(PrismObject user) throws SchemaExcept user.checkConsistence(); user.assertDefinitions("test"); assertUserElisabethExtension(user); - //assertVisitor(user,55); } private void assertUserElisabethExtension(PrismObject user) { @@ -585,23 +527,10 @@ private void assertUserElisabethExtension(PrismObject user) { assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); -// PrismProperty stringType = extension.findProperty(EXTENSION_STRING_TYPE_ELEMENT); -// PrismAsserts.assertPropertyValue(stringType, "BARbar", "FOObar"); -// PrismPropertyDefinition stringTypePropertyDef = stringType.getDefinition(); -// PrismAsserts.assertDefinition(stringTypePropertyDef, EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); -// assertNull("'Indexed' attribute on 'stringType' property is not null", stringTypePropertyDef.isIndexed()); - PrismProperty secondaryStringType = extension.findProperty(EXTENSION_SECONDARY_SECONDARY_STRING_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(secondaryStringType, "string1"); PrismPropertyDefinition secondaryStringTypePropertyDef = secondaryStringType.getDefinition(); PrismAsserts.assertDefinition(secondaryStringTypePropertyDef, EXTENSION_SINGLE_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); assertNull("'Indexed' attribute on 'secondaryStringType' property is not null", secondaryStringTypePropertyDef.isIndexed()); } - - protected void validateXml(String xmlString, PrismContext prismContext) throws SAXException, IOException { - } - - protected void displayTestTitle(final String TEST_NAME) { - PrismInternalTestUtil.displayTestTitle(TEST_NAME+"("+getSubdirName()+")"); - } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java index 103ea497747..e6079a44141 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismParsingXml.java @@ -41,9 +41,6 @@ protected String getOutputFormat() { @Test public void testPrismParseDom() throws Exception { - final String TEST_NAME = "testPrismParseDom"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); @@ -63,9 +60,6 @@ public void testPrismParseDom() throws Exception { @Test public void testPrismParseDomAdhoc() throws Exception { - final String TEST_NAME = "testPrismParseDomAdhoc"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_ADHOC_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); @@ -85,9 +79,6 @@ public void testPrismParseDomAdhoc() throws Exception { @Test public void testPrismParseXxe() throws Exception { - final String TEST_NAME = "testPrismParseXxe"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - PrismContext prismContext = constructInitializedPrismContext(); try { @@ -104,10 +95,7 @@ public void testPrismParseXxe() throws Exception { } @Test - public void testPrismParseDomXxe() throws Exception { - final String TEST_NAME = "testPrismParseDomXxe"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - + public void testPrismParseDomXxe() { try { // WHEN DOMUtil.parseFile(getFile(USER_JACK_XXE_BASENAME)); @@ -120,13 +108,4 @@ public void testPrismParseDomXxe() throws Exception { } } - - @Override - protected void validateXml(String xmlString, PrismContext prismContext) throws SAXException, IOException { -// Document xmlDocument = DOMUtil.parseDocument(xmlString); -// Schema javaxSchema = prismContext.getSchemaRegistry().getJavaxSchema(); -// Validator validator = javaxSchema.newValidator(); -// validator.setResourceResolver(prismContext.getEntityResolver()); -// validator.validate(new DOMSource(xmlDocument)); - } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java index faacb8c154e..9ee7119f5b4 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPrismSchemaConstruction.java @@ -6,26 +6,24 @@ */ package com.evolveum.midpoint.prism; -import static org.testng.AssertJUnit.assertFalse; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; import java.io.IOException; import java.util.Collection; import java.util.Iterator; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.util.DOMUtil; @@ -34,9 +32,8 @@ /** * @author semancik - * */ -public class TestPrismSchemaConstruction { +public class TestPrismSchemaConstruction extends AbstractPrismTest { private static final String NS_MY_SCHEMA = "http://midpoint.evolveum.com/xml/ns/test/my-1"; private static final String WEAPON_TYPE_LOCAL_NAME = "WeaponType"; @@ -49,7 +46,6 @@ public class TestPrismSchemaConstruction { private static final String WEAPON_PASSWORD_LOCAL_NAME = "password"; private static final String WEAPON_BLADE_LOCAL_NAME = "blade"; - @BeforeSuite public void setupDebug() { PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); @@ -57,8 +53,6 @@ public void setupDebug() { @Test public void testConstructSchema() throws SchemaException, SAXException, IOException { - System.out.println("===[ testConstructSchema ]==="); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); @@ -73,8 +67,6 @@ public void testConstructSchema() throws SchemaException, SAXException, IOExcept @Test public void testSchemaRoundtrip() throws Exception { - System.out.println("===[ testSchemaRoundtrip ]==="); - // GIVEN PrismContext ctx = constructInitializedPrismContext(); @@ -83,29 +75,23 @@ public void testSchemaRoundtrip() throws Exception { @Test public void testSchemaRoundtripLoopShareContext() throws Exception { - System.out.println("===[ testSchemaRoundtripLoopShareContext ]==="); - PrismContext ctx = constructInitializedPrismContext(); - for(int i=0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { - System.out.println("\n--- attempt "+i+"---"); + for (int i = 0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { + System.out.println("\n--- attempt " + i + "---"); schemaRoundtrip(ctx); } } @Test public void testSchemaRoundtripLoopNewContext() throws Exception { - System.out.println("===[ testSchemaRoundtripLoopNewContext ]==="); - - for(int i=0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { - System.out.println("\n--- attempt "+i+"---"); + for (int i = 0; i < SCHEMA_ROUNDTRIP_LOOP_ATTEMPTS; i++) { + System.out.println("\n--- attempt " + i + "---"); PrismContext ctx = constructInitializedPrismContext(); schemaRoundtrip(ctx); } } - - private void schemaRoundtrip(PrismContext ctx) throws SchemaException, SAXException, IOException { - + private void schemaRoundtrip(PrismContext ctx) throws SchemaException { PrismSchema schema = constructSchema(ctx); assertSchema(schema); @@ -155,7 +141,7 @@ private void assertSchema(PrismSchema schema) { assertEquals("Unexpected number of definitions in schema", 2, definitions.size()); Iterator schemaDefIter = definitions.iterator(); - ComplexTypeDefinition weaponTypeDef = (ComplexTypeDefinition)schemaDefIter.next(); + ComplexTypeDefinition weaponTypeDef = (ComplexTypeDefinition) schemaDefIter.next(); assertEquals("Unexpected number of definitions in weaponTypeDef", 5, weaponTypeDef.getDefinitions().size()); Iterator weaponTypeDefIter = weaponTypeDef.getDefinitions().iterator(); PrismPropertyDefinition kindPropertyDef = (PrismPropertyDefinition) weaponTypeDefIter.next(); @@ -180,12 +166,12 @@ private void assertSchema(PrismSchema schema) { assertEquals("Wrong createTimestampPropertyDef displayName", "Create timestamp", createTimestampPropertyDef.getDisplayName()); assertTrue("createTimestampPropertyDef not operational", createTimestampPropertyDef.isOperational()); - PrismContainerDefinition weaponContDef = (PrismContainerDefinition)schemaDefIter.next(); + PrismContainerDefinition weaponContDef = (PrismContainerDefinition) schemaDefIter.next(); assertEquals("Wrong complex type def in weaponContDef", weaponTypeDef, weaponContDef.getComplexTypeDefinition()); } private void assertPrefix(String expectedPrefix, Element element) { - assertEquals("Wrong prefix on element "+DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); + assertEquals("Wrong prefix on element " + DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); } } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java index 295bde68028..caef2815478 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestPropertyArrayList.java @@ -6,24 +6,21 @@ */ package com.evolveum.midpoint.prism; -import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.impl.xjc.PropertyArrayList; -import com.evolveum.midpoint.util.DOMUtil; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; import java.io.File; -import java.io.IOException; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.*; -import static org.testng.AssertJUnit.*; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; -public class TestPropertyArrayList { +import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.prism.impl.xjc.PropertyArrayList; +import com.evolveum.midpoint.util.DOMUtil; - public static final String USER_JACK_XXE_BASENAME = "user-jack-xxe"; +public class TestPropertyArrayList extends AbstractPrismTest { private String getSubdirName() { return "xml"; @@ -38,14 +35,11 @@ private File getCommonSubdir() { } private File getFile(String baseName) { - return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix()); + return new File(getCommonSubdir(), baseName + "." + getFilenameSuffix()); } @Test public void testPrismParseDom() throws Exception { - final String TEST_NAME = "testPrismParseDom"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); - // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); @@ -54,16 +48,16 @@ public void testPrismParseDom() throws Exception { PrismObject user = prismContext.parserFor(userElement).parse(); PrismProperty property = user.findProperty(UserType.F_ADDITIONAL_NAMES); - PropertyArrayList propertyArrayList = new PropertyArrayList(property, user.getValue()); + PropertyArrayList propertyArrayList = new PropertyArrayList<>(property, user.getValue()); // WHEN - System.out.println("Additional names before test: " ); + System.out.println("Additional names before test: "); System.out.println(property.debugDump()); String testName = "test-name"; propertyArrayList.set(1, "test-name"); // THEN - System.out.println("Additional names after test: " ); + System.out.println("Additional names after test: "); System.out.println(property.debugDump()); assertEquals(testName, propertyArrayList.get(1)); } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java index 0aa24a14f30..9ca2a6f0a85 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestTypeConversion.java @@ -17,6 +17,7 @@ import com.evolveum.midpoint.prism.impl.xml.XmlTypeConverterInternal; import com.evolveum.midpoint.prism.util.CloneUtil; import org.testng.AssertJUnit; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Document; @@ -26,6 +27,7 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.prism.xml.XsdTypeMapper; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; @@ -33,19 +35,14 @@ * @author semancik * */ -public class TestTypeConversion { +public class TestTypeConversion extends AbstractPrismTest { private static final String MY_NS = "http://midpoint.evolveum.com/xml/ns/testing/xmlconversion"; private static final String MY_ELEMENT_NAME = "foo"; private static final QName MY_ELEMENT_QNAME = new QName(MY_NS, MY_ELEMENT_NAME); - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - @Test - public void testXmlDateTimeType() throws Exception { + public void testXmlDateTimeType() { assertEquals("Wrong datetime class", XMLGregorianCalendar.class, XsdTypeMapper.toJavaType(DOMUtil.XSD_DATETIME)); assertEquals("Wrong datetime class", DOMUtil.XSD_DATETIME, XsdTypeMapper.toXsdType(XMLGregorianCalendar.class)); } @@ -62,7 +59,7 @@ public void testXmlDateTimeValue() throws Exception { } @Test - public void testJavaStringToXMLGregorianCalendar() throws Exception { + public void testJavaStringToXMLGregorianCalendar() { String stringDate = "1975-05-30T21:30:00.000Z"; // WHEN @@ -74,12 +71,12 @@ public void testJavaStringToXMLGregorianCalendar() throws Exception { } @Test - public void testJavaStringToXMLGregorianCalendarWrongFormat() throws Exception { + public void testJavaStringToXMLGregorianCalendarWrongFormat() { String stringDate = "blah blah blah"; try { // WHEN - XMLGregorianCalendar xmlGregorianCalendar = JavaTypeConverter.convert(XMLGregorianCalendar.class, stringDate); + JavaTypeConverter.convert(XMLGregorianCalendar.class, stringDate); AssertJUnit.fail("Unexpected success"); } catch (IllegalArgumentException e) { @@ -90,7 +87,7 @@ public void testJavaStringToXMLGregorianCalendarWrongFormat() throws Exception { } @Test - public void testJavaXMLGregorianCalendarToString() throws Exception { + public void testJavaXMLGregorianCalendarToString() { XMLGregorianCalendar cal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0); // WHEN @@ -101,7 +98,7 @@ public void testJavaXMLGregorianCalendarToString() throws Exception { } @Test - public void testJavaXMLGregorianCalendarToLong() throws Exception { + public void testJavaXMLGregorianCalendarToLong() { XMLGregorianCalendar cal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0); // WHEN diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java index 5a16a28d565..cd9dee52bdd 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestUnknownItems.java @@ -6,41 +6,33 @@ */ package com.evolveum.midpoint.prism; -import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; import java.io.File; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.constructInitializedPrismContext; -import static org.testng.AssertJUnit.assertNotNull; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.foo.UserType; +import com.evolveum.midpoint.util.exception.SchemaException; /** * See MID-3249. * * @author mederly */ -public class TestUnknownItems { +public class TestUnknownItems extends AbstractPrismTest { public static final String TEST_DIR = "src/test/resources/common/xml"; public static final File WRONG_ITEM_FILE = new File(TEST_DIR + "/user-wrong-item.xml"); public static final File WRONG_NAMESPACE_FILE = new File(TEST_DIR + "/user-wrong-namespace.xml"); - @BeforeSuite - public void setupDebug() { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - } - @Test(expectedExceptions = SchemaException.class) public void test010ParseWrongItemStrict() throws Exception { - final String TEST_NAME = "testParseWrongItemStrict"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN+THEN try { @@ -53,10 +45,8 @@ public void test010ParseWrongItemStrict() throws Exception { @Test public void test020ParseWrongItemCompat() throws Exception { - final String TEST_NAME = "testParseWrongItemCompat"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parserFor(WRONG_ITEM_FILE).compat().parse(); @@ -73,10 +63,8 @@ public void test020ParseWrongItemCompat() throws Exception { // TODO discuss this @Test(enabled = false, expectedExceptions = SchemaException.class) public void test110ParseWrongNamespaceStrict() throws Exception { - final String TEST_NAME = "test110ParseWrongNamespaceStrict"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN+THEN PrismObject user = prismContext.parseObject(WRONG_NAMESPACE_FILE); @@ -87,10 +75,8 @@ public void test110ParseWrongNamespaceStrict() throws Exception { @Test public void test120ParseWrongNamespaceCompat() throws Exception { - final String TEST_NAME = "test120ParseWrongNamespaceCompat"; - PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN - PrismContext prismContext = constructInitializedPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN PrismObject user = prismContext.parserFor(WRONG_NAMESPACE_FILE).compat().parse(); @@ -101,5 +87,4 @@ public void test120ParseWrongNamespaceCompat() throws Exception { assertNotNull(user); } - } diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java index fb734af717e..907918d6078 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/TestXmlSerialization.java @@ -21,7 +21,7 @@ import java.io.IOException; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; + import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; @@ -29,22 +29,12 @@ * @author mederly * */ -public class TestXmlSerialization { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestXmlSerialization extends AbstractPrismTest { @Test public void testHandlingInvalidChars() throws Exception { - final String TEST_NAME = "testHandlingInvalidChars"; - displayTestTitle(TEST_NAME); - // GIVEN - - PrismContext prismContext = PrismTestUtil.getPrismContext(); + PrismContext prismContext = getPrismContext(); // WHEN diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java index 329a635cc19..94e19f8820a 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractJsonLexicalProcessorTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.List; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.fail; @@ -35,10 +34,6 @@ public abstract class AbstractJsonLexicalProcessorTest extends AbstractLexicalPr @Test public void testParseObjectsIteratively_2_Wrong() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_2_Wrong"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -78,10 +73,6 @@ public void testParseObjectsIteratively_2_Wrong() throws Exception { @Test public void testParseObjectsIteratively_2_Wrong_2() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_2_Wrong_2"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java index 1ac3af2b40a..d322a9b3e56 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/AbstractLexicalProcessorTest.java @@ -85,9 +85,6 @@ protected File getFile(String baseName) { @Test public void testParseUserToPrism() throws Exception { - final String TEST_NAME = "testParseUserToPrism"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -116,9 +113,6 @@ ParserSource getFileSource(String basename) { @Test public void testParseUserRoundTrip() throws Exception { - final String TEST_NAME = "testParseUserRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -187,9 +181,6 @@ public void testParseUserRoundTrip() throws Exception { @Test public void testParseResourceRumToPrism() throws Exception { - final String TEST_NAME = "testParseResourceRumToPrism"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -212,9 +203,6 @@ public void testParseResourceRumToPrism() throws Exception { @Test public void testParseResourceRoundTrip() throws Exception { - final String TEST_NAME = "testParseResourceRoundTrip"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -342,9 +330,6 @@ protected void validateResourceSchema(String dataString, PrismContext prismConte // Enable it if that changes. @Test(enabled = false) public void testParseEventHandler() throws Exception { - final String TEST_NAME = "testParseEventHandler"; - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -383,7 +368,6 @@ public void testParseObjectsIteratively_1() throws Exception { } protected List standardTest(String TEST_NAME, String fileName, int expectedCount) throws SchemaException, IOException { - displayTestTitle(TEST_NAME); // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -414,10 +398,6 @@ protected List standardTest(String TEST_NAME, String fileName, in @Test public void testParseObjectsIteratively_1_FirstTwo() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_1_FirstTwo"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -448,10 +428,6 @@ String getFirstElementNS(List nodes, int index) { @Test public void testParseObjectsIteratively_3_NS() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_3_NS"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -486,10 +462,6 @@ public void testParseObjectsIteratively_3_NS() throws Exception { @Test public void testParseObjectsIteratively_4_noRootNs() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_4_noRootNs"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -524,10 +496,6 @@ public void testParseObjectsIteratively_4_noRootNs() throws Exception { @Test public void testParseObjectsIteratively_5_error() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_5_error"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -558,10 +526,6 @@ public void testParseObjectsIteratively_5_error() throws Exception { @Test public void testParseObjectsIteratively_6_single() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_6_single"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); @@ -594,10 +558,6 @@ public void testParseObjectsIteratively_6_single() throws Exception { @Test public void testParseObjectsIteratively_7_single() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_7_single"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java index 0d2e787a537..fdce12b558c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestDomParser.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.prism.lex; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.USER_JACK_FILE_BASENAME; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; @@ -49,9 +48,6 @@ protected DomLexicalProcessor createParser() { @Test public void testParseUserToXNode() throws Exception { - final String TEST_NAME = "testParseUserToXNode"; - displayTestTitle(TEST_NAME); - // GIVEN DomLexicalProcessor parser = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java index 1603ec8466d..ae8f976ee9b 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestProtectedString.java @@ -6,6 +6,7 @@ */ package com.evolveum.midpoint.prism.lex; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.impl.PrismContextImpl; import com.evolveum.midpoint.prism.PrismInternalTestUtil; @@ -23,27 +24,16 @@ import java.io.IOException; import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; /** * @author mederly - * */ -public class TestProtectedString { - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - } +public class TestProtectedString extends AbstractPrismTest { @Test public void testParseProtectedStringEncrypted() throws Exception { - final String TEST_NAME = "testParseProtectedStringEncrypted"; - displayTestTitle(TEST_NAME); - // GIVEN Protector protector = PrismInternalTestUtil.createProtector(Protector.XMLSEC_ENCRYPTION_ALGORITHM_AES256_CBC); ProtectedStringType protectedStringType = protector.encryptString("salalala"); @@ -64,9 +54,6 @@ public void testParseProtectedStringEncrypted() throws Exception { @Test public void testParseProtectedStringHashed() throws Exception { - final String TEST_NAME = "testParseProtectedStringHashed"; - displayTestTitle(TEST_NAME); - // GIVEN ProtectedStringType protectedStringType = new ProtectedStringType(); protectedStringType.setClearValue("blabla"); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java index 132f66ae651..39fac145d7c 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/lex/TestYamlParser.java @@ -17,7 +17,6 @@ import java.util.Iterator; import java.util.List; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.createDefaultParsingContext; import static org.testng.AssertJUnit.assertEquals; @@ -47,10 +46,6 @@ protected String getWhenItemSerialized() { @Test public void testParseObjectsIteratively_8_multiDocument() throws Exception { - final String TEST_NAME = "testParseObjectsIteratively_8_multiDocument"; - - displayTestTitle(TEST_NAME); - // GIVEN LexicalProcessor lexicalProcessor = createParser(); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java index 48f9bf3ea77..edc80b4acbe 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/match/TestMatchingRule.java @@ -6,42 +6,25 @@ */ package com.evolveum.midpoint.prism.match; -import static org.testng.AssertJUnit.assertEquals; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; -import java.io.IOException; +import org.testng.annotations.Test; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author semancik - * */ -public class TestMatchingRule { +public class TestMatchingRule extends AbstractPrismTest { - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } + private static MatchingRuleRegistry matchingRuleRegistry = + MatchingRuleRegistryFactory.createRegistry(); @Test public void testStringDefault() throws Exception { @@ -149,13 +132,12 @@ public void testXml() throws Exception { assertNormalized(rule, "FOO BAR ", "FOO BAR "); } - private void assertMatch(MatchingRule rule, T a, T b) throws SchemaException { - assertTrue("Values '"+a+"' and '"+b+"' does not match; rule: "+rule, rule.match(a, b)); + assertTrue("Values '" + a + "' and '" + b + "' does not match; rule: " + rule, rule.match(a, b)); } private void assertNoMatch(MatchingRule rule, T a, T b) throws SchemaException { - assertFalse("Values '"+a+"' and '"+b+"' DOES match but they should not; rule: "+rule, rule.match(a, b)); + assertFalse("Values '" + a + "' and '" + b + "' DOES match but they should not; rule: " + rule, rule.match(a, b)); } private void assertNormalized(MatchingRule rule, String expected, String original) throws SchemaException { diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java index 2038b521098..416314100f6 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestObjectQuery.java @@ -7,41 +7,28 @@ package com.evolveum.midpoint.prism.query; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.MutablePrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; +import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; - -public class TestObjectQuery { +public class TestObjectQuery extends AbstractPrismTest { - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } + private static MatchingRuleRegistry matchingRuleRegistry = + MatchingRuleRegistryFactory.createRegistry(); @Test public void testMatchAndFilter() throws Exception { @@ -50,12 +37,11 @@ public void testMatchAndFilter() throws Exception { getPrismContext().queryFor(UserType.class) .item(UserType.F_GIVEN_NAME).eq("Jack").matchingCaseIgnore() .and().item(UserType.F_FULL_NAME).contains("arr") - .buildFilter(); + .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); } - @Test public void testMatchOrFilter() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); @@ -125,17 +111,17 @@ public void testMatchEqualEmptyAgainstNonEmptyItem() throws Exception { public void testComplexMatch() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); // System.out.println("user given name" + user.asObjectable().getGivenName()); - System.out.println("definition: " +user.findItem(UserType.F_FAMILY_NAME).getDefinition().debugDump()); + System.out.println("definition: " + user.findItem(UserType.F_FAMILY_NAME).getDefinition().debugDump()); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(UserType.F_FAMILY_NAME).eq("Sparrow") .and().item(UserType.F_FULL_NAME).contains("arr") .and() - .block() - .item(UserType.F_GIVEN_NAME).eq("Jack") - .or().item(UserType.F_GIVEN_NAME).eq("Jackie") - .endBlock() - .buildFilter(); + .block() + .item(UserType.F_GIVEN_NAME).eq("Jack") + .or().item(UserType.F_GIVEN_NAME).eq("Jackie") + .endBlock() + .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); } @@ -167,7 +153,7 @@ public void testExistsNegative() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .item(AssignmentType.F_DESCRIPTION).eq("Assignment NONE") + .item(AssignmentType.F_DESCRIPTION).eq("Assignment NONE") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertFalse("filter matches object, but it should not", match); @@ -178,7 +164,7 @@ public void testExistsPositive() throws Exception { PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .item(AssignmentType.F_DESCRIPTION).eq("Assignment 2") + .item(AssignmentType.F_DESCRIPTION).eq("Assignment 2") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object, but it should", match); diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java index 632c0c2d2e6..19852abbfd1 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryBuilder.java @@ -7,79 +7,61 @@ package com.evolveum.midpoint.prism.query; +import static com.evolveum.midpoint.prism.PrismInternalTestUtil.NS_FOO; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; + +import java.lang.reflect.Method; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.foo.AssignmentType; import com.evolveum.midpoint.prism.foo.UserType; import com.evolveum.midpoint.prism.impl.query.*; -import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; -import com.evolveum.midpoint.prism.impl.match.MatchingRuleRegistryFactory; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.IOException; -import java.lang.reflect.Method; - -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.PrismInternalTestUtil.NS_FOO; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; /** * Here are the most simple tests for Query Builder. * More advanced tests are part of QueryInterpreterTest in repo-sql-impl-test. - * + *

* These tests are strict in the sense they check the exact structure of created queries. * Repo tests check just the HQL outcome. */ -public class TestQueryBuilder { +public class TestQueryBuilder extends AbstractPrismTest { public static final QName USER_TYPE_QNAME = new QName(NS_FOO, "UserType"); public static final QName ASSIGNMENT_TYPE_QNAME = new QName(NS_FOO, "AssignmentType"); - private static MatchingRuleRegistry matchingRuleRegistry; - - @BeforeSuite - public void setupDebug() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(DEFAULT_NAMESPACE_PREFIX); - PrismTestUtil.resetPrismContext(new PrismInternalTestUtil()); - - matchingRuleRegistry = MatchingRuleRegistryFactory.createRegistry(); - } @BeforeMethod - public void beforeMethod(Method method) throws Exception { + public void beforeMethod(Method method) { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); } @Test - public void test100EmptyFilter() throws Exception{ + public void test100EmptyFilter() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); } @Test - public void test110EmptyBlock() throws Exception{ + public void test110EmptyBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); compare(actual, expected); } @Test - public void test112EmptyBlocks() throws Exception{ + public void test112EmptyBlocks() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .block() - .block() - .block() - .endBlock() - .endBlock() + .block() + .block() + .endBlock() + .endBlock() .endBlock() .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery((ObjectFilter) null); @@ -87,7 +69,7 @@ public void test112EmptyBlocks() throws Exception{ } @Test(expectedExceptions = IllegalStateException.class) - public void test113BlocksLeftOpen() throws Exception{ + public void test113BlocksLeftOpen() { getPrismContext().queryFor(UserType.class) .block() .block() @@ -98,7 +80,7 @@ public void test113BlocksLeftOpen() throws Exception{ } @Test(expectedExceptions = IllegalStateException.class) - public void test114NoOpenBlocks() throws Exception{ + public void test114NoOpenBlocks() { getPrismContext().queryFor(UserType.class) .block() .block() @@ -109,28 +91,28 @@ public void test114NoOpenBlocks() throws Exception{ } @Test - public void test120All() throws Exception{ + public void test120All() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).all().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(AllFilterImpl.createAll()); compare(actual, expected); } @Test - public void test122AllInBlock() throws Exception{ + public void test122AllInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).block().all().endBlock().build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(AllFilterImpl.createAll()); compare(actual, expected); } @Test - public void test130SingleEquals() throws Exception{ + public void test130SingleEquals() { ObjectQuery actual = getPrismContext().queryFor(UserType.class).item(UserType.F_LOCALITY).eq("Caribbean").build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery(createEqual(UserType.F_LOCALITY, UserType.class, null, "Caribbean")); compare(actual, expected); } @Test - public void test132SingleAnd() throws Exception{ + public void test132SingleAnd() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .and().item(UserType.F_DESCRIPTION).eq("desc") @@ -145,7 +127,7 @@ public void test132SingleAnd() throws Exception{ } @Test - public void test134SingleOrWithNot() throws Exception{ + public void test134SingleOrWithNot() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .or().not().item(UserType.F_DESCRIPTION).eq("desc") @@ -162,16 +144,16 @@ public void test134SingleOrWithNot() throws Exception{ } @Test - public void test136AndOrNotSequence() throws Exception{ + public void test136AndOrNotSequence() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") .or() - .not().item(UserType.F_DESCRIPTION).eq("desc") - .and().all() - .and().none() + .not().item(UserType.F_DESCRIPTION).eq("desc") + .and().all() + .and().none() .or() - .undefined() - .and().not().none() + .undefined() + .and().not().none() .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery( OrFilterImpl.createOr( @@ -195,7 +177,7 @@ public void test136AndOrNotSequence() throws Exception{ } @Test - public void test140TypeWithEquals() throws Exception{ + public void test140TypeWithEquals() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .item(UserType.F_LOCALITY).eq("Caribbean") @@ -210,7 +192,7 @@ public void test140TypeWithEquals() throws Exception{ } @Test - public void test142TypeWithEqualsInBlock() throws Exception{ + public void test142TypeWithEqualsInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block() @@ -227,7 +209,7 @@ public void test142TypeWithEqualsInBlock() throws Exception{ } @Test - public void test144TypeWithEqualsAndAllInBlock() throws Exception{ + public void test144TypeWithEqualsAndAllInBlock() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block() @@ -248,7 +230,7 @@ public void test144TypeWithEqualsAndAllInBlock() throws Exception{ } @Test - public void test144TypeInTypeInType() throws Exception{ + public void test144TypeInTypeInType() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .type(AssignmentType.class) @@ -271,7 +253,7 @@ public void test144TypeInTypeInType() throws Exception{ } @Test - public void test146TypeAndSomething() throws Exception{ + public void test146TypeAndSomething() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .none() @@ -290,7 +272,7 @@ public void test146TypeAndSomething() throws Exception{ } @Test - public void test148TypeEmpty() throws Exception{ + public void test148TypeEmpty() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block().endBlock() @@ -305,7 +287,7 @@ public void test148TypeEmpty() throws Exception{ } @Test - public void test149TypeEmptyAndAll() throws Exception{ + public void test149TypeEmptyAndAll() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .type(UserType.class) .block().endBlock() @@ -324,7 +306,7 @@ public void test149TypeEmptyAndAll() throws Exception{ } @Test - public void test150ExistsWithEquals() throws Exception{ + public void test150ExistsWithEquals() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .item(AssignmentType.F_DESCRIPTION).startsWith("desc1") @@ -341,12 +323,12 @@ public void test150ExistsWithEquals() throws Exception{ getPrismContext(), null, "desc1", true, false) ) - ); + ); compare(actual, expected); } @Test - public void test151ExistsWithEquals2() throws Exception{ + public void test151ExistsWithEquals2() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .item(AssignmentType.F_NOTE).endsWith("DONE.") @@ -368,11 +350,11 @@ public void test151ExistsWithEquals2() throws Exception{ } @Test - public void test152ExistsWithEqualsInBlock() throws Exception{ + public void test152ExistsWithEqualsInBlock() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .block() - .item(AssignmentType.F_NOTE).endsWith("DONE.") + .item(AssignmentType.F_NOTE).endsWith("DONE.") .endBlock() .build(); ComplexTypeDefinition assCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(AssignmentType.class); @@ -392,12 +374,12 @@ public void test152ExistsWithEqualsInBlock() throws Exception{ } @Test - public void test154ExistsWithEqualsAndAllInBlock() throws Exception{ + public void test154ExistsWithEqualsAndAllInBlock() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) .block() .item(AssignmentType.F_NOTE).endsWith("DONE.") - .and().all() + .and().all() .endBlock() .build(); ComplexTypeDefinition assCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(AssignmentType.class); @@ -421,10 +403,10 @@ public void test154ExistsWithEqualsAndAllInBlock() throws Exception{ } @Test - public void test156ExistsAndSomething() throws Exception{ + public void test156ExistsAndSomething() throws Exception { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .exists(UserType.F_ASSIGNMENT) - .none() + .none() .and().all() .build(); @@ -444,7 +426,7 @@ public void test156ExistsAndSomething() throws Exception{ } @Test - public void test200OrderByName() throws Exception{ + public void test200OrderByName() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .asc(UserType.F_NAME) .build(); @@ -471,7 +453,7 @@ public void test210OrderByNameAndId() { } @Test - public void test300EqualItem() throws Exception { + public void test300EqualItem() { ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY).eq().item(UserType.F_NAME) .build(); @@ -489,14 +471,14 @@ public void test300EqualItem() throws Exception { } @Test - public void test310LessThanItem() throws Exception { + public void test310LessThanItem() { PrismObjectDefinition userDef = getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); PrismPropertyDefinition nameDef = userDef.findPropertyDefinition(UserType.F_NAME); PrismPropertyDefinition localityDef = userDef.findPropertyDefinition(UserType.F_LOCALITY); ObjectQuery actual = getPrismContext().queryFor(UserType.class) .item(UserType.F_LOCALITY, localityDef) - .le() - .item(UserType.F_NAME, nameDef) + .le() + .item(UserType.F_NAME, nameDef) .build(); ObjectQuery expected = ObjectQueryImpl.createObjectQuery( LessFilterImpl.createLess(UserType.F_LOCALITY, localityDef, null, diff --git a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java index 16aa93d1522..3b3e3b42dc0 100644 --- a/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java +++ b/infra/prism-impl/src/test/java/com/evolveum/midpoint/prism/query/TestQueryConverters.java @@ -7,48 +7,40 @@ package com.evolveum.midpoint.prism.query; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.PrismInternalTestUtil.DEFAULT_NAMESPACE_PREFIX; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.createPolyString; import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayQuery; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.displayTestTitle; import static com.evolveum.midpoint.prism.util.PrismTestUtil.getFilterCondition; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.xnode.MapXNode; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.AbstractPrismTest; import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismInternalTestUtil; import com.evolveum.midpoint.prism.foo.UserType; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.impl.xnode.ListXNodeImpl; import com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xnode.MapXNode; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DomAsserts; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -public class TestQueryConverters { - - private static final Trace LOGGER = TraceManager.getTrace(TestQueryConverters.class); +public class TestQueryConverters extends AbstractPrismTest { private static final File TEST_DIR = new File("src/test/resources/query"); @@ -66,8 +58,6 @@ public void setupDebug() throws SchemaException, SAXException, IOException { @Test public void testFilterUserNameJaxb() throws Exception { - displayTestTitle("testFilterUserNameJaxb"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_NAME_FILE); ObjectQuery query = toObjectQuery(UserType.class, filterType); displayQuery(query); @@ -99,8 +89,6 @@ public void testFilterUserNameJaxb() throws Exception { @Test public void testFilterUserAndJaxb() throws Exception { - displayTestTitle("testFilterUserAndJaxb"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_AND_FILE); ObjectQuery query = toObjectQuery(UserType.class, filterType); displayQuery(query); @@ -112,12 +100,12 @@ public void testFilterUserAndJaxb() throws Exception { ObjectFilter first = getFilterCondition(filter, 0); PrismAsserts.assertEqualsFilter(first, UserType.F_GIVEN_NAME, DOMUtil.XSD_STRING, - ItemPath.create(new QName(null,UserType.F_GIVEN_NAME.getLocalPart()))); + ItemPath.create(new QName(null, UserType.F_GIVEN_NAME.getLocalPart()))); PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "Jack"); ObjectFilter second = getFilterCondition(filter, 1); PrismAsserts.assertEqualsFilter(second, UserType.F_LOCALITY, DOMUtil.XSD_STRING, - ItemPath.create(new QName(null,UserType.F_LOCALITY.getLocalPart()))); + ItemPath.create(new QName(null, UserType.F_LOCALITY.getLocalPart()))); PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "Caribbean"); QueryType convertedQueryType = toQueryType(query); @@ -154,9 +142,6 @@ public void testFilterUserAndJaxb() throws Exception { @Test public void testFilterTypeUserNone() throws Exception { - displayTestTitle("testFilterTypeUserNone"); - - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_TYPE_USER_NONE); ObjectQuery query = toObjectQuery(UserType.class, filterType); @@ -175,24 +160,18 @@ public void testFilterTypeUserNone() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); - + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "type")); - - - } @Test public void testFilterNotInOid() throws Exception { - displayTestTitle("testFilterNotInOid"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_IN_OID); ObjectQuery query = toObjectQuery(UserType.class, filterType); @@ -211,12 +190,12 @@ public void testFilterNotInOid() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not")); assertEquals("wrong # of inOid subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "inOid").getLength()); @@ -225,8 +204,6 @@ public void testFilterNotInOid() throws Exception { @Test public void testFilterNotFullText() throws Exception { - displayTestTitle("testFilterNotFullText"); - SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_FULL_TEXT); ObjectQuery query = toObjectQuery(UserType.class, filterType); @@ -245,32 +222,23 @@ public void testFilterNotFullText() throws Exception { System.out.println(convertedQueryType.debugDump()); Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()); - LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); + logger.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump()); System.out.println("Serialized filter (JAXB->DOM)"); String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement); System.out.println(filterAsString); - LOGGER.info(filterAsString); + logger.info(filterAsString); DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not")); assertEquals("wrong # of fullText subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "fullText").getLength()); assertEquals("wrong # of value subfilters", 2, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength()); } - private ObjectQuery toObjectQuery(Class type, QueryType queryType) throws Exception { - ObjectQuery query = getPrismContext().getQueryConverter().createObjectQuery(type, queryType - ); - return query; - } - private ObjectQuery toObjectQuery(Class type, SearchFilterType filterType) throws Exception { - ObjectQuery query = getPrismContext().getQueryConverter().createObjectQuery(type, filterType - ); - return query; + return getPrismContext().getQueryConverter().createObjectQuery(type, filterType); } private QueryType toQueryType(ObjectQuery query) throws Exception { return getPrismContext().getQueryConverter().createQueryType(query); } - } diff --git a/infra/schema/pom.xml b/infra/schema/pom.xml index 0be58ba91c4..ce664fbef9e 100644 --- a/infra/schema/pom.xml +++ b/infra/schema/pom.xml @@ -153,7 +153,6 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT test diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java index a70b7ce6e58..55f2152d672 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/MiscSchemaUtil.java @@ -225,7 +225,7 @@ public static Collection> createCollection(Obj */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static Collection> createCollection(ItemDelta... deltas) { - return (Collection)MiscUtil.createCollection(deltas); + return MiscUtil.createCollection(deltas); } public static Collection> cloneObjectDeltaCollection( diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java index 17ab0077be8..8763f458a3a 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/TestNameHolder.java @@ -9,7 +9,11 @@ /** * Very ugly hack. Assumes single-threaded tests. + * TODO notes: + * - implement TestTracerImpl where this usage is pulled out of production (main) code + * - and (perhaps in a single step) replace it with MidpointTestMethodContext usage */ +@Deprecated public class TestNameHolder { private static String currentTestName; diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java index 0e094501123..b8f8f2fb13e 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/AbstractSchemaTest.java @@ -6,6 +6,8 @@ */ package com.evolveum.midpoint.schema; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; @@ -16,17 +18,15 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; - /** * @author semancik - * */ -public abstract class AbstractSchemaTest { +public abstract class AbstractSchemaTest extends AbstractUnitTest { protected static final File COMMON_DIR = new File("src/test/resources/common"); @@ -52,12 +52,4 @@ public void setup() throws SchemaException, SAXException, IOException { protected PrismObjectDefinition getUserDefinition() { return getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); } - - protected void displayTestTile(String TEST_NAME) { - System.out.println("===[ "+TEST_NAME+" ]===="); - } - -// protected UniformItemPath path(Object... components) { -// return getPrismContext().path(components); -// } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java index 1aed9d8fb8e..44f1151fd17 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestDiffEquals.java @@ -7,6 +7,19 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.LITERAL; +import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.NOT_LITERAL; + +import java.io.File; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ChangeType; import com.evolveum.midpoint.prism.delta.ObjectDelta; @@ -16,37 +29,19 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.PolicyRuleTypeUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -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.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.LITERAL; -import static com.evolveum.midpoint.prism.equivalence.ParameterizedEquivalenceStrategy.NOT_LITERAL; -import static org.testng.AssertJUnit.*; /** * @author lazyman */ -public class TestDiffEquals { +public class TestDiffEquals extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/diff"); private static final File ROLE_COMPARE_FILE = new File(TEST_DIR, "role-compare.xml"); @@ -56,17 +51,8 @@ public class TestDiffEquals { private static final String NS_TEST_RI = "http://midpoint.evolveum.com/xml/ns/test/ri-1"; - private static final Trace LOGGER = TraceManager.getTrace(TestDiffEquals.class); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUserSimplePropertyDiff() throws SchemaException { - System.out.println("\n\n===[ testUserSimplePropertyDiff ]===\n"); UserType userType1 = new UserType(); userType1.setName(PrismTestUtil.createPolyStringType("test name")); UserType userType2 = new UserType(); @@ -87,7 +73,6 @@ public void testUserSimplePropertyDiff() throws SchemaException { @Test public void testUserListSimpleDiff() throws SchemaException { - System.out.println("\n\n===[ testUserListSimpleDiff ]===\n"); UserType u1 = new UserType(); u1.setName(PrismTestUtil.createPolyStringType("test name")); UserType u2 = new UserType(); @@ -108,7 +93,6 @@ public void testUserListSimpleDiff() throws SchemaException { @Test public void testAssignmentEquals1() throws Exception { - System.out.println("\n\n===[ testAssignmentEquals1 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(); @@ -167,9 +151,8 @@ public void testAssignmentEquals1() throws Exception { assertTrue(a1e.equals(a1m)); } - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void testAssignmentEquals2() throws Exception { - System.out.println("\n\n===[ testAssignmentEquals2 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject roleCompare = prismContext.parseObject(ROLE_COMPARE_FILE); @@ -190,8 +173,7 @@ public void testAssignmentEquals2() throws Exception { } @Test - public void testAssignmentEquivalent() throws Exception { - System.out.println("\n\n===[ testAssignmentEquivalent ]===\n"); + public void testAssignmentEquivalent() { PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1 = new AssignmentType(prismContext); @@ -215,7 +197,6 @@ public void testAssignmentEquivalent() throws Exception { @Test public void testContextlessAssignmentEquals() throws Exception { - System.out.println("\n\n===[ testContextlessAssignmentEquals ]===\n"); AssignmentType a1 = new AssignmentType(); // no prismContext here a1.setDescription("descr1"); @@ -238,8 +219,6 @@ public void testContextlessAssignmentEquals() throws Exception { @Test public void testContextlessAssignmentEquals2() throws Exception { - System.out.println("\n\n===[ testContextlessAssignmentEquals2 ]===\n"); - // (1) user without prismContext - the functionality is reduced UserType user = new UserType(); @@ -284,8 +263,6 @@ public void testContextlessAssignmentEquals2() throws Exception { @Test public void testAssignmentHashcode() throws Exception { - LOGGER.info("\n\n===[ testAssignmentHashcode ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(); @@ -347,23 +324,21 @@ public void testAssignmentHashcode() throws Exception { // MID-4251 @Test public void testAssignmentHashcode2() { - LOGGER.info("\n\n===[ testAssignmentHashcode2 ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode2 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(prismContext).id(6L) .beginMetadata() - .createApprovalComment("hi") + .createApprovalComment("hi") .end() .targetRef(new ObjectReferenceType().oid("target").type(OrgType.COMPLEX_TYPE).relation(SchemaConstants.ORG_DEFAULT)) .beginActivation() - .effectiveStatus(ActivationStatusType.ENABLED) - .validTo("2018-01-01T00:00:00.000+01:00") + .effectiveStatus(ActivationStatusType.ENABLED) + .validTo("2018-01-01T00:00:00.000+01:00") .end(); AssignmentType a1b = new AssignmentType(prismContext) .targetRef(new ObjectReferenceType().oid("target").type(OrgType.COMPLEX_TYPE)) .beginActivation() - .validTo("2018-01-01T00:00:00.000+01:00") + .validTo("2018-01-01T00:00:00.000+01:00") .end(); // WHEN @@ -372,14 +347,12 @@ public void testAssignmentHashcode2() { // MID-4251 @Test - public void testAssignmentHashcode3() throws SchemaException { - LOGGER.info("\n\n===[ testAssignmentHashcode3 ]===\n"); - System.out.println("\n\n===[ testAssignmentHashcode3 ]===\n"); + public void testAssignmentHashcode3() { PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(prismContext) .beginActivation() - .validTo("2018-01-01T00:00:00.000+01:00") + .validTo("2018-01-01T00:00:00.000+01:00") .end(); AssignmentType a1b = a1a.clone(); @@ -397,7 +370,6 @@ public void testAssignmentHashcode3() throws SchemaException { @Test public void testDiffShadow() throws Exception { - System.out.println("\n\n===[ testDiffShadow ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject shadow1 = prismContext.getSchemaRegistry() @@ -449,7 +421,7 @@ public void testDiffShadow() throws Exception { } @Test - public void testTriggerCollectionsEqual() throws Exception { + public void testTriggerCollectionsEqual() { EvaluatedPolicyRuleTriggerType trigger1 = new EvaluatedPolicyRuleTriggerType() .triggerId(100) .ruleName("rule100"); @@ -476,7 +448,7 @@ public void testTriggerCollectionsEqual() throws Exception { .ruleName("rule1") .sourceRule(sourceRule2) .sourceRule(sourceRule1) - ); + ); List triggerListC = Arrays.asList( trigger1, trigger2, @@ -485,7 +457,7 @@ public void testTriggerCollectionsEqual() throws Exception { .ruleName("rule123") .sourceRule(sourceRule2) .sourceRule(sourceRule1) - ); + ); assertEquals("Wrong comparison A-A", true, PolicyRuleTypeUtil.triggerCollectionsEqual(triggerListA, triggerListA)); assertEquals("Wrong comparison A-B", true, PolicyRuleTypeUtil.triggerCollectionsEqual(triggerListA, triggerListB)); @@ -505,7 +477,6 @@ public void diffRoles() throws Exception { @Test // MID-4688 public void testDiffWithMetadata() { - System.out.println("\n\n===[ testDiffWithMetadata ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); ProtectedStringType value = new ProtectedStringType(); @@ -513,21 +484,21 @@ public void testDiffWithMetadata() { PrismObject user1 = new UserType(prismContext) .beginCredentials() - .beginPassword() - .value(value.clone()) - .beginMetadata() - .requestorComment("hi") - .end() - .end() + .beginPassword() + .value(value.clone()) + .beginMetadata() + .requestorComment("hi") + .end() + .end() .end() .asPrismObject(); PrismObject user2 = new UserType(prismContext) .beginCredentials() - .beginPassword() - .value(value.clone()) - .beginMetadata() - .end() - .end() + .beginPassword() + .value(value.clone()) + .beginMetadata() + .end() + .end() .end() .asPrismObject(); @@ -546,8 +517,6 @@ public void testDiffWithMetadata() { // MID-5851 @Test public void testRawValuesHashCode() throws SchemaException { - LOGGER.info("\n\n===[ testRawValuesHashCode ]===\n"); - System.out.println("\n\n===[ testRawValuesHashCode ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); QName extensionPropertyName = new QName(NS_TEST_RI, "extensionProperty"); @@ -559,7 +528,7 @@ public void testRawValuesHashCode() throws SchemaException { PrismProperty propertyParsed = extensionPropertyDef.instantiate(); PrismProperty propertyRaw = extensionPropertyDef.instantiate(); propertyParsed.setRealValue("value"); - propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl("value"))); + propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl<>("value"))); PrismObject userParsed = new UserType(prismContext) .name("user") @@ -594,5 +563,4 @@ private void assertHashAndEquals(PrismObject user1, PrismObject assignmentExtensionContainer = parseUserAssignmentContainer(); @@ -64,8 +44,6 @@ public void testAssignmentExtensionContainerProperty() throws Exception { @Test public void testAssignmentExtensionContainerItem() throws Exception { - System.out.println("===[ testAssignmentExtensionContainerItem ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); @@ -81,8 +59,6 @@ public void testAssignmentExtensionContainerItem() throws Exception { @Test public void testAssignmentExtensionValueProperty() throws Exception { - System.out.println("===[ testAssignmentExtensionValueProperty ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); @@ -98,8 +74,6 @@ public void testAssignmentExtensionValueProperty() throws Exception { @Test public void testAssignmentExtensionValueItem() throws Exception { - System.out.println("===[ testAssignmentExtensionValueItem ]==="); - // GIVEN PrismContainer assignmentExtensionContainer = parseUserAssignmentContainer(); PrismContainerValue assignmentExtensionContainerValue = assignmentExtensionContainer.getValue(); @@ -114,9 +88,6 @@ public void testAssignmentExtensionValueItem() throws Exception { PrismAsserts.assertDefinition(assignmentExtensionStringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); } - - - private PrismContainer parseUserAssignmentContainer() throws SchemaException, IOException { PrismContext prismContext = getPrismContext(); PrismObject user = prismContext.parseObject(USER_FILE); @@ -125,5 +96,4 @@ private PrismContainer parseUserAssignmentContainer() throws Sch return user.findContainer(ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_EXTENSION)); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java index ed47f8482ab..735636a1ec3 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestEmptyItems.java @@ -6,40 +6,25 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.apache.commons.collections4.CollectionUtils; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; /** * Tests for mistakenly adding new empty items (PP, PR, PC) into PCVs. * * @author mederly */ -public class TestEmptyItems { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestEmptyItems extends AbstractSchemaTest { @Test - public void testEmptyItemsOnGet() throws Exception { - System.out.println("===[ testEmptyItemsOnGet ]==="); - + public void testEmptyItemsOnGet() { // GIVEN UserType user = new UserType(getPrismContext()); System.out.println("User before:\n" + user.asPrismObject().debugDump()); @@ -57,8 +42,6 @@ public void testEmptyItemsOnGet() throws Exception { @Test public void testEmptyItemsOnParse() throws Exception { - System.out.println("===[ testEmptyItemsOnParse ]==="); - // GIVEN UserType user = new UserType(getPrismContext()); user.setName(PolyStringType.fromOrig("jack")); @@ -75,8 +58,7 @@ public void testEmptyItemsOnParse() throws Exception { } @Test - public void testEmptyItemsOnConstructed() throws Exception { - System.out.println("===[ testEmptyItemsOnConstructed ]==="); + public void testEmptyItemsOnConstructed() { UserType jack = new UserType(getPrismContext()) .oid("00000000-0000-0000-0000-000000000002").version("42") .name("jack") @@ -85,20 +67,20 @@ public void testEmptyItemsOnConstructed() throws Exception { .honorificPrefix("Cpt.") .honorificSuffix("PhD.") .beginAssignment() - .beginActivation() - .administrativeStatus(ActivationStatusType.ENABLED) - .enableTimestamp("2016-12-31T23:59:59+01:00") - .end() - .beginConstruction() - .resourceRef("00000000-1233-4443-3123-943412324212", ResourceType.COMPLEX_TYPE) - .end() + .beginActivation() + .administrativeStatus(ActivationStatusType.ENABLED) + .enableTimestamp("2016-12-31T23:59:59+01:00") + .end() + .beginConstruction() + .resourceRef("00000000-1233-4443-3123-943412324212", ResourceType.COMPLEX_TYPE) + .end() .end() .beginAssignment() - .beginActivation() - .validFrom("2017-01-01T12:00:00+01:00") - .validTo("2017-03-31T00:00:00+01:00") - .end() - .targetRef("83138913-4329-4323-3432-432432143612", RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER) + .beginActivation() + .validFrom("2017-01-01T12:00:00+01:00") + .validTo("2017-03-31T00:00:00+01:00") + .end() + .targetRef("83138913-4329-4323-3432-432432143612", RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER) .end() .employeeType("pirate") .employeeType("captain") @@ -116,5 +98,4 @@ public void testEmptyItemsOnConstructed() throws Exception { System.out.println("User after:\n" + jack.asPrismObject().debugDump()); assertEquals("Wrong # of user sub-items after 'get' operations", 8, jack.asPrismContainerValue().size()); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java index 0902d80e5a7..90e68f28a88 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestExport.java @@ -6,6 +6,15 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.SerializationOptions.createSerializeForExport; + +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -13,36 +22,12 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.SerializationOptions.createSerializeForExport; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; - -/** - * @author mederly - * - */ -public class TestExport { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestExport extends AbstractSchemaTest { @Test public void testExportShadow() throws Exception { - System.out.println("===[ testExportShadow ]==="); - PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow1") diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java index c54aefea06b..cfddb111449 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestFilterSimplifier.java @@ -6,40 +6,23 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -/** - * - */ -public class TestFilterSimplifier { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestFilterSimplifier extends AbstractSchemaTest { @Test public void test010All() { - System.out.println("===[ test010All ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -56,8 +39,6 @@ public void test010All() { @Test public void test020None() { - System.out.println("===[ test020None ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -74,8 +55,6 @@ public void test020None() { @Test public void test030Undefined() { - System.out.println("===[ test030Undefined ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -92,8 +71,6 @@ public void test030Undefined() { @Test public void test100AndLevel1() { - System.out.println("===[ test100AndLevel1 ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -113,8 +90,6 @@ public void test100AndLevel1() { @Test public void test110AndLevel1WithoutNone() { - System.out.println("===[ test110AndLevel1WithoutNone ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -133,8 +108,6 @@ public void test110AndLevel1WithoutNone() { @Test public void test120AndEmpty() { - System.out.println("===[ test120AndEmpty ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -150,8 +123,6 @@ public void test120AndEmpty() { @Test public void test150OrLevel1() { - System.out.println("===[ test150OrLevel1 ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -171,8 +142,6 @@ public void test150OrLevel1() { @Test public void test160OrLevel1WithoutAll() { - System.out.println("===[ test160OrLevel1WithoutAll ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -191,8 +160,6 @@ public void test160OrLevel1WithoutAll() { @Test public void test170OrLevel1Undefined() { - System.out.println("===[ test170OrLevel1Undefined ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -208,8 +175,6 @@ public void test170OrLevel1Undefined() { @Test public void test180OrEmpty() { - System.out.println("===[ test180OrEmpty ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -225,8 +190,6 @@ public void test180OrEmpty() { @Test public void test200AndLevel2() { - System.out.println("===[ test200AndLevel2 ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -235,13 +198,13 @@ public void test200AndLevel2() { .all() .and().undefined() .and() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .and() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); @@ -253,8 +216,6 @@ public void test200AndLevel2() { @Test public void test210OrLevel2() { - System.out.println("===[ test210OrLevel2 ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -263,13 +224,13 @@ public void test210OrLevel2() { .none() .or().undefined() .or() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .or() - .block() - .none().or().none() - .endBlock() + .block() + .none().or().none() + .endBlock() .buildFilter(); System.out.println("Original filter:\n" + filter.debugDump()); @@ -281,8 +242,6 @@ public void test210OrLevel2() { @Test public void test300NotAll() { - System.out.println("===[ test300NotAll ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -300,8 +259,6 @@ public void test300NotAll() { @Test public void test310NotNone() { - System.out.println("===[ test310NotNone ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -319,8 +276,6 @@ public void test310NotNone() { @Test public void test320NotNotAll() { - System.out.println("===[ test320NotNotAll ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -338,8 +293,6 @@ public void test320NotNotAll() { @Test public void test330NotNotNone() { - System.out.println("===[ test330NotNotNone ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -357,8 +310,6 @@ public void test330NotNotNone() { @Test public void test400TypeAll() { - System.out.println("===[ test400TypeAll ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -379,8 +330,6 @@ public void test400TypeAll() { @Test public void test410TypeNone() { - System.out.println("===[ test410TypeNone ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -398,8 +347,6 @@ public void test410TypeNone() { @Test public void test420TypeUndefined() { - System.out.println("===[ test420TypeUndefined ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -420,8 +367,6 @@ public void test420TypeUndefined() { @Test public void test500ExistsAll() { - System.out.println("===[ test500ExistsAll ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -442,8 +387,6 @@ public void test500ExistsAll() { @Test public void test510ExistsNone() { - System.out.println("===[ test510ExistsNone ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -461,8 +404,6 @@ public void test510ExistsNone() { @Test public void test520ExistsUndefined() { - System.out.println("===[ test520ExistsUndefined ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -480,5 +421,4 @@ public void test520ExistsUndefined() { PrismAsserts.assertEquivalent("Wrong simplified filter path", UserType.F_ASSIGNMENT, existsSimplified.getFullPath()); assertTrue("Wrong simplified filter subfilter: " + existsSimplified.getFilter(), ObjectQueryUtil.isAll(existsSimplified.getFilter())); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java index 830e5ec7262..ba11e40ad89 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestImmutable.java @@ -7,45 +7,30 @@ package com.evolveum.midpoint.schema; +import java.util.Date; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.io.IOException; -import java.util.Date; - -import static org.testng.AssertJUnit.assertEquals; /** * @author mederly */ -public class TestImmutable { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestImmutable extends AbstractSchemaTest { @Test - public void test010SimpleProperty() throws Exception { - System.out.println("===[ test010SimpleProperty ]==="); - + public void test010SimpleProperty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -72,9 +57,7 @@ public void test010SimpleProperty() throws Exception { } @Test - public void test020DateProperty() throws Exception { - System.out.println("===[ test020DateProperty ]==="); - + public void test020DateProperty() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -83,7 +66,7 @@ public void test020DateProperty() throws Exception { new QName(SchemaConstants.NS_C, "dateTime"), DOMUtil.XSD_DATETIME); PrismProperty datePP = datePPD.instantiate(); Date now = new Date(); - Date yesterday = new Date(now.getTime()-86400000L); + Date yesterday = new Date(now.getTime() - 86400000L); datePP.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(now)); datePP.freeze(); @@ -111,8 +94,6 @@ public void test020DateProperty() throws Exception { @Test public void test030Reference() throws Exception { - System.out.println("===[ test030Reference ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -140,8 +121,6 @@ public void test030Reference() throws Exception { @Test public void test100Resource() throws Exception { - System.out.println("===[ test100Resource ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -209,5 +188,4 @@ public void test100Resource() throws Exception { // } } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java index 4dec6de8226..cb70afbb2f3 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbConstruction.java @@ -6,73 +6,49 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; import static com.evolveum.midpoint.schema.TestConstants.*; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; - -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.xnode.*; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.w3c.dom.Element; -import org.xml.sax.SAXException; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.prism.xnode.MapXNode; +import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; +import com.evolveum.midpoint.prism.xnode.XNode; +import com.evolveum.midpoint.prism.xnode.XNodeFactory; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; /** * @author semancik - * */ -public class TestJaxbConstruction { +public class TestJaxbConstruction extends AbstractSchemaTest { private static final String FAUX_RESOURCE_OID = "fuuuuuuuuuuu"; private static final String ACCOUNT_NAME = "jack"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test - public void testUserConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testUserConstruction ]===\n"); - + public void testUserConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -93,7 +69,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { // description: setting null value userType.setDescription(null); PrismProperty descriptionProperty = user.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property " + descriptionProperty, descriptionProperty); // description: setting null value userType.setDescription("blah blah"); @@ -103,7 +79,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { // description: resetting null value userType.setDescription(null); descriptionProperty = user.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property (after reset) "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property (after reset) " + descriptionProperty, descriptionProperty); // Extension ExtensionType extension = new ExtensionType(); @@ -112,8 +88,8 @@ public void testUserConstruction() throws JAXBException, SchemaException { user.checkConsistence(); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); AssignmentType assignmentType = new AssignmentType(); userType.getAssignment().add(assignmentType); @@ -127,7 +103,7 @@ public void testUserConstruction() throws JAXBException, SchemaException { user.assertDefinitions(); user.checkConsistence(); - checkExtension(assignmentExtension,"assignment extension after setExtension"); + checkExtension(assignmentExtension, "assignment extension after setExtension"); user.checkConsistence(); user.assertDefinitions(); @@ -178,8 +154,6 @@ public void testUserConstruction() throws JAXBException, SchemaException { @Test public void testUserConstructionBeforeAdopt() throws Exception { - System.out.println("\n\n ===[ testUserConstructionBeforeAdopt ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -193,12 +167,10 @@ public void testUserConstructionBeforeAdopt() throws Exception { AssignmentType assignmentType = new AssignmentType(); userType.getAssignment().add(assignmentType); - // Assignment ExtensionType assignmentExtension = new ExtensionType(); assignmentType.setExtension(assignmentExtension); - // accountRef/account ObjectReferenceType accountRefType = new ObjectReferenceType(); accountRefType.setOid(USER_ACCOUNT_REF_1_OID); @@ -209,7 +181,6 @@ public void testUserConstructionBeforeAdopt() throws Exception { accountRefType.setFilter(filter); userType.getLinkRef().add(accountRefType); - ShadowType accountShadowType = new ShadowType(); prismContext.adopt(accountShadowType); accountShadowType.setOid(USER_ACCOUNT_REF_1_OID); @@ -234,7 +205,6 @@ public void testUserConstructionBeforeAdopt() throws Exception { user.checkConsistence(); user.assertDefinitions(); - PolyString fullName = fullNameProperty.getRealValue(); assertEquals("Wrong fullName orig", "Čučoriedka", fullName.getOrig()); assertEquals("Wrong fullName norm", "cucoriedka", fullName.getNorm()); @@ -243,8 +213,8 @@ public void testUserConstructionBeforeAdopt() throws Exception { assertEquals("Wrong description value", "blah blah", descriptionProperty.getRealValue()); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension"); - checkExtension(extension,"user extension"); + checkExtension(extensionContainer, "user extension"); + checkExtension(extension, "user extension"); PrismReference accountRef = user.findReference(UserType.F_LINK_REF); assertEquals("Wrong accountRef values", 2, accountRef.getValues().size()); @@ -263,22 +233,21 @@ public void testUserConstructionBeforeAdopt() throws Exception { } - private void assertAccountRefs(UserType userType, String... accountOids) { List accountRefs = userType.getLinkRef(); assertEquals("Wrong number of accountRefs", accountOids.length, accountRefs.size()); - for (String expectedAccountOid: accountOids) { + for (String expectedAccountOid : accountOids) { assertAccountRef(accountRefs, expectedAccountOid); } } private void assertAccountRef(List accountRefs, String expectedAccountOid) { - for (ObjectReferenceType accountRef: accountRefs) { + for (ObjectReferenceType accountRef : accountRefs) { if (accountRef.getOid().equals(expectedAccountOid)) { return; } } - AssertJUnit.fail("acountRef for oid "+expectedAccountOid+" was not found"); + AssertJUnit.fail("acountRef for oid " + expectedAccountOid + " was not found"); } /** @@ -286,9 +255,7 @@ private void assertAccountRef(List accountRefs, String expe * e.g. assignment is filled in first then set to the user. */ @Test - public void testUserConstructionReverse() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testUserConstructionReverse ]===\n"); - + public void testUserConstructionReverse() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -304,8 +271,8 @@ public void testUserConstructionReverse() throws JAXBException, SchemaException user.checkConsistence(); PrismContainer extensionContainer = user.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); AssignmentType assignmentType = new AssignmentType(prismContext); @@ -335,12 +302,8 @@ public void testUserConstructionReverse() throws JAXBException, SchemaException user.checkConsistence(); } - - @Test - public void testGenericConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testGenericConstruction ]===\n"); - + public void testGenericConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -358,16 +321,14 @@ public void testGenericConstruction() throws JAXBException, SchemaException { generic.checkConsistence(); PrismContainer extensionContainer = generic.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"user extension after setExtension"); - checkExtension(extension,"user extension after setExtension"); + checkExtension(extensionContainer, "user extension after setExtension"); + checkExtension(extension, "user extension after setExtension"); generic.checkConsistence(); } @Test - public void testAccountConstruction() throws JAXBException, SchemaException { - System.out.println("\n\n ===[ testAccountConstruction ]===\n"); - + public void testAccountConstruction() throws SchemaException { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -411,8 +372,6 @@ public void testAccountConstruction() throws JAXBException, SchemaException { @Test public void testExtensionTypeConstruction() throws Exception { - System.out.println("\n\n ===[ testExtensionTypeConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -435,8 +394,6 @@ public void testExtensionTypeConstruction() throws Exception { @Test public void testResourceConstruction() throws Exception { - System.out.println("\n\n ===[ testResourceConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -456,7 +413,7 @@ public void testResourceConstruction() throws Exception { // description: setting null value resourceType.setDescription(null); PrismProperty descriptionProperty = resource.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property " + descriptionProperty, descriptionProperty); // description: setting null value resourceType.setDescription("blah blah"); @@ -466,7 +423,7 @@ public void testResourceConstruction() throws Exception { // description: resetting null value resourceType.setDescription(null); descriptionProperty = resource.findProperty(UserType.F_DESCRIPTION); - assertNull("Unexpected description property (after reset) "+descriptionProperty, descriptionProperty); + assertNull("Unexpected description property (after reset) " + descriptionProperty, descriptionProperty); // Extension ExtensionType extension = new ExtensionType(); @@ -475,8 +432,8 @@ public void testResourceConstruction() throws Exception { resource.checkConsistence(); PrismContainer extensionContainer = resource.findContainer(GenericObjectType.F_EXTENSION); - checkExtension(extensionContainer,"resource extension after setExtension"); - checkExtension(extension,"resource extension after setExtension"); + checkExtension(extensionContainer, "resource extension after setExtension"); + checkExtension(extension, "resource extension after setExtension"); // Schema XmlSchemaType xmlSchemaType = new XmlSchemaType(); @@ -504,16 +461,16 @@ public void testResourceConstruction() throws Exception { } private void checkExtension(PrismContainer extensionContainer, String sourceDescription) { - assertNotNull("No extension container in "+sourceDescription+" (prism)", extensionContainer); - assertNotNull("No extension definition in "+sourceDescription+" (prism)", extensionContainer.getDefinition()); - assertTrue("Not runtime in definition in "+sourceDescription+" (prism)", extensionContainer.getDefinition().isRuntimeSchema()); + assertNotNull("No extension container in " + sourceDescription + " (prism)", extensionContainer); + assertNotNull("No extension definition in " + sourceDescription + " (prism)", extensionContainer.getDefinition()); + assertTrue("Not runtime in definition in " + sourceDescription + " (prism)", extensionContainer.getDefinition().isRuntimeSchema()); } private void checkExtension(ExtensionType extension, String sourceDescription) throws SchemaException { PrismContainerValue extensionValueFromJaxb = extension.asPrismContainerValue(); - assertNotNull("No extension container in "+sourceDescription+" (jaxb)", extensionValueFromJaxb); - assertNotNull("No extension definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); - assertTrue("Not runtime in definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); + assertNotNull("No extension container in " + sourceDescription + " (jaxb)", extensionValueFromJaxb); + assertNotNull("No extension definition in " + sourceDescription + " (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); + assertTrue("Not runtime in definition in " + sourceDescription + " (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); PrismProperty intProperty = extensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intProperty.getDefinition(), EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java index 4d15d9a4d90..8ca2a2f008e 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbParsing.java @@ -6,68 +6,47 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + import static com.evolveum.midpoint.prism.util.PrismAsserts.assertPropertyValue; +import java.io.File; +import java.io.IOException; +import javax.xml.bind.JAXBElement; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.impl.PrismContextImpl; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; -import com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; +import com.evolveum.prism.xml.ns._public.types_3.*; /** * @author Radovan Semancik */ -public class TestJaxbParsing { +public class TestJaxbParsing extends AbstractSchemaTest { private static final String NS_FOO = "http://www.example.com/foo"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test - public void testParseUserFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - + public void testParseUserFromJaxb() throws SchemaException, IOException { PrismContext prismContext = PrismTestUtil.getPrismContext(); // Try to use the schema to validate Jack - UserType userType = PrismTestUtil.parseObjectable(new File(TestConstants.COMMON_DIR, "user-jack.xml"), UserType.class); + UserType userType = PrismTestUtil.parseObjectable( + new File(TestConstants.COMMON_DIR, "user-jack.xml"), UserType.class); // WHEN @@ -94,22 +73,11 @@ public void testParseUserFromJaxb() throws SchemaException, SAXException, IOExce PrismProperty multi = user.findOrCreateContainer(UserType.F_EXTENSION).findProperty(new ItemName(NS_FOO, "multi")); assertEquals(3, multi.getValues().size()); - // WHEN - -// Node domNode = user.serializeToDom(); -// -// //THEN -// System.out.println("\nSerialized user:"); -// System.out.println(DOMUtil.serializeDOMToString(domNode)); -// -// Element userEl = DOMUtil.getFirstChildElement(domNode); -// assertEquals(SchemaConstants.I_USER, DOMUtil.getQName(userEl)); - // TODO: more asserts } @Test - public void testParseAccountFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { + public void testParseAccountFromJaxb() throws SchemaException, IOException { PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -132,8 +100,7 @@ public void testParseAccountFromJaxb() throws SchemaException, SAXException, IOE } @Test - public void testParseModernRoleFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("\n\n ===[ testParseModernRoleFromJaxb ]===\n"); + public void testParseModernRoleFromJaxb() throws SchemaException, IOException { testParseRoleFromJaxb(new File(TestConstants.COMMON_DIR, "role.xml")); } @@ -141,9 +108,7 @@ public void testParseModernRoleFromJaxb() throws SchemaException, SAXException, * Test of parsing role with elements that were removed in 4.0. */ @Test - public void testParseLegacyRoleFromJaxb() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("\n\n ===[ testParseLegacyRoleFromJaxb ]===\n"); - + public void testParseLegacyRoleFromJaxb() throws SchemaException, IOException { PrismParser parser = PrismTestUtil.getPrismContext() .parserFor(new File(TestConstants.COMMON_DIR, "role-legacy.xml")) .compat(); @@ -159,9 +124,7 @@ public void testParseLegacyRoleFromJaxb() throws SchemaException, SAXException, assertPropertyValue(role, RoleType.F_NAME, PrismTestUtil.createPolyString("r3")); } - public void testParseRoleFromJaxb(File file) throws SchemaException, SAXException, IOException, JAXBException { - - PrismContext prismContext = PrismTestUtil.getPrismContext(); + public void testParseRoleFromJaxb(File file) throws SchemaException, IOException { PrismParser parser = PrismTestUtil.getPrismContext().parserFor(file); // WHEN @@ -177,11 +140,8 @@ public void testParseRoleFromJaxb(File file) throws SchemaException, SAXExceptio // TODO: more asserts? } - @Test public void testParseGenericObjectFromJaxb() throws Exception { - System.out.println("\n\n ===[ testParseGenericObjectFromJaxb ]===\n"); - PrismContext prismContext = PrismTestUtil.getPrismContext(); GenericObjectType object = PrismTestUtil.parseObjectable(new File(TestConstants.COMMON_DIR, "generic-sample-configuration.xml"), @@ -217,9 +177,6 @@ public void testMarshallObjectDeltaType() throws Exception { ItemDeltaType item1 = new ItemDeltaType(); delta.getItemDelta().add(item1); item1.setModificationType(ModificationTypeType.REPLACE); - Document document = DOMUtil.getDocument(); -// Element path = document.createElementNS(SchemaConstantsGenerated.NS_TYPES, "path"); -// path.setTextContent("c:credentials/c:password"); ItemPath path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD); item1.setPath(new ItemPathType(path)); ProtectedStringType protectedString = new ProtectedStringType(); @@ -228,7 +185,7 @@ public void testMarshallObjectDeltaType() throws Exception { item1.getValue().add(value); String xml = PrismTestUtil.serializeJaxbElementToString( - new JAXBElement<>(new QName("http://www.example.com", "custom"), Object.class, delta)); + new JAXBElement<>(new QName("http://www.example.com", "custom"), Object.class, delta)); assertNotNull(xml); } @@ -250,7 +207,6 @@ public void testParseAnyValue() throws Exception { JAXBElement oValue = prismContext.parserFor(dataValue).xml().parseRealValueToJaxbElement(); System.out.println(dumpResult(dataValue, oValue)); - //assertJaxbElement(oValue, SchemaConstantsGenerated.C_VALUE, String.class); assertJaxbElement(oValue, SchemaConstantsGenerated.C_VALUE, RawType.class); } @@ -261,7 +217,7 @@ private void assertJaxbElement(JAXBElement jaxbElement, QName name, Class cla } private String dumpResult(String data, JAXBElement jaxb) { - return "Parsed expression evaluator: " + data + " as " + jaxb + " (name=" + jaxb.getName() + ", declaredType=" + jaxb.getDeclaredType() + ", value=" + jaxb.getValue() + ")"; + return "Parsed expression evaluator: " + data + " as " + jaxb + " (name=" + jaxb.getName() + + ", declaredType=" + jaxb.getDeclaredType() + ", value=" + jaxb.getValue() + ")"; } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java deleted file mode 100644 index 5c56807711c..00000000000 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestJaxbSanity.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2010-2019 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.schema; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.reflect.Method; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; - -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; -import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; - -/** - * @author semancik - * - */ -@Deprecated -public class TestJaxbSanity { - - public static final String TEST_DIR = "src/test/resources/common"; - public static final String USER_BARBOSSA_FILENAME = TEST_DIR + "/user-barbossa.xml"; - public static final String RESOURCE_OPENDJ_FILENAME = TEST_DIR + "/resource-opendj.xml"; - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test - public void testGeneratedEquals() throws JAXBException { - System.out.println("\n\n ===[ testGeneratedEquals ]===\n"); - - assertHasEquals(ObjectType.class); - assertHasEquals(AssignmentType.class); - assertHasEquals(MappingType.class); - assertHasEquals(ProtectedStringType.class); - - assertHasHashCode(ObjectType.class); - assertHasHashCode(AssignmentType.class); - assertHasHashCode(MappingType.class); - assertHasHashCode(ProtectedStringType.class); - } - - private void assertHasEquals(Class clazz) { - try { - Method method = clazz.getDeclaredMethod("equals", Object.class); - assertNotNull("No equals method in "+clazz.getSimpleName(), method); - } catch (SecurityException e) { - AssertJUnit.fail("No equals method in "+clazz.getSimpleName()); - } catch (NoSuchMethodException e) { - AssertJUnit.fail("No equals method in "+clazz.getSimpleName()); - } - } - - private void assertHasHashCode(Class clazz) { - try { - Method method = clazz.getDeclaredMethod("hashCode"); - assertNotNull("No hashCode method in "+clazz.getSimpleName(), method); - } catch (SecurityException e) { - AssertJUnit.fail("No hashCode method in "+clazz.getSimpleName()); - } catch (NoSuchMethodException e) { - AssertJUnit.fail("No hashCode method in "+clazz.getSimpleName()); - } - } - - @Test - public void testUnmarshallAndEqualsUserJaxb() throws Exception { - System.out.println("\n\n ===[ testUnmarshallAndEqualsUserJaxb ]===\n"); - - // GIVEN - JAXBElement userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user1Type = userEl1.getValue(); - assertNotNull(user1Type); - PrismObject user1 = user1Type.asPrismObject(); - - JAXBElement userEl2 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user2Type = userEl2.getValue(); - assertNotNull(user2Type); - PrismObject user2 = user2Type.asPrismObject(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals", ac1.equals(ac2)); - - // WHEN, THEN - ObjectDelta objectDelta = user1.diff(user2); - System.out.println("User delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("User delta is not empty", objectDelta.isEmpty()); - - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("HashCode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("HashCode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsUserPrism() throws Exception { - System.out.println("\n\n ===[testUnmarshallAndEqualsUserPrism]===\n"); - - // GIVEN - PrismObject user1 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user1Type = user1.asObjectable(); - - PrismObject user2 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user2Type = user2.asObjectable(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals (JAXB)", ac1.equals(ac2)); - assertTrue("ConstructionType hashcode does not match (JAXB)", ac1.hashCode() == ac2.hashCode()); - - AssignmentType as1Type = user1Type.getAssignment().get(0); - PrismContainerValue as1ContVal = as1Type.asPrismContainerValue(); - PrismContainer as1Cont = as1ContVal.getContainer(); - AssignmentType as2Type = user2Type.getAssignment().get(0); - PrismContainerValue as2ContVal = as2Type.asPrismContainerValue(); - PrismContainer as2Cont = as2ContVal.getContainer(); - assertTrue("Assignment not equals (ContainerValue)", as1ContVal.equals(as2ContVal)); - assertTrue("Assignment not equals (ContainerValue, ignoreMetadata)", as1ContVal.equals(as2ContVal, EquivalenceStrategy.IGNORE_METADATA)); - assertTrue("Assignment not equals (ContainerValue, not ignoreMetadata)", as1ContVal.equals(as2ContVal, EquivalenceStrategy.NOT_LITERAL)); - assertTrue("Assignment not equivalent (ContainerValue)", as1ContVal.equivalent(as2ContVal)); - assertTrue("Assignment not equals (Container)", as1Cont.equals(as2Cont)); - assertTrue("Assignment not equivalent (Container)", as1Cont.equivalent(as2Cont)); - assertTrue("AssignmentType not equals (JAXB)", as1Type.equals(as2Type)); - assertTrue("Assignment hashcode does not match (Container)", as1Cont.hashCode() == as2Cont.hashCode()); - assertTrue("Assignment hashcode does not match (Objectable)", as1Type.hashCode() == as2Type.hashCode()); - - // Compare object inner value - assertTrue("User prism values do not match", user1.getValue().equals(user2.getValue())); - - // WHEN, THEN - ObjectDelta objectDelta = user1.diff(user1); - System.out.println("User delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("User delta is not empty", objectDelta.isEmpty()); - - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("User hashcode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("User hashcode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsUserMixed() throws Exception { - System.out.println("\n\n ===[testUnmarshallAndEqualsUserMixed]===\n"); - - // GIVEN - PrismObject user1 = PrismTestUtil.parseObject(new File(USER_BARBOSSA_FILENAME)); - UserType user1Type = user1.asObjectable(); - - JAXBElement userEl2 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME),UserType.class); - UserType user2Type = userEl2.getValue(); - assertNotNull(user2Type); - PrismObject user2 = user2Type.asPrismObject(); - - // Compare plain JAXB objects (not backed by containers) - ConstructionType ac1 = user1Type.getAssignment().get(0).getConstruction(); - ConstructionType ac2 = user2Type.getAssignment().get(0).getConstruction(); - assertTrue("ConstructionType not equals", ac1.equals(ac2)); - System.out.println(user1.debugDump()); - System.out.println(user2.debugDump()); - // WHEN, THEN - assertTrue("User not equals (PrismObject)", user1.equals(user2)); - assertTrue("User not equivalent (PrismObject)", user1.equivalent(user2)); - assertTrue("User not equals (Objectable)", user1Type.equals(user2Type)); - - assertTrue("HashCode does not match (PrismObject)", user1.hashCode() == user2.hashCode()); - assertTrue("HashCode does not match (Objectable)", user1Type.hashCode() == user2Type.hashCode()); - } - - - @Test - public void testUnmarshallAndEqualsResourceSchema() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testUnmarshallAndEqualsResourceSchema]===\n"); - - // GIVEN - ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource1Type); - SchemaDefinitionType schemaDefinition1 = resource1Type.getSchema().getDefinition(); - - ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource2Type); - SchemaDefinitionType schemaDefinition2 = resource2Type.getSchema().getDefinition(); - - // WHEN - boolean equals = schemaDefinition1.equals(schemaDefinition2); - - // THEN - assertTrue("Schema definition not equal", equals); - - assertEquals("Hashcode does not match", schemaDefinition1.hashCode(), schemaDefinition2.hashCode()); - } - - @Test - public void testUnmarshallAndEqualsResource() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testUnmarshallAndEqualsResource]===\n"); - - // GIVEN - ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource1Type); - System.out.println("Resource1 " + resource1Type.asPrismObject().debugDump()); - PrismObject resource1 = resource1Type.asPrismObject(); - - ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class); - assertNotNull(resource2Type); - System.out.println("Resource2 " + resource2Type.asPrismObject().debugDump()); - PrismObject resource2 = resource2Type.asPrismObject(); - - // WHEN, THEN - ObjectDelta objectDelta = resource1.diff(resource2); - System.out.println("Resource delta:"); - System.out.println(objectDelta.debugDump()); - assertTrue("Resource delta is not empty", objectDelta.isEmpty()); - - assertTrue("Resource not equal", resource1Type.equals(resource2Type)); - - System.out.println("HASH"); - System.out.println(resource1Type.hashCode()); - System.out.println(resource2Type.hashCode()); - assertTrue("Resource hashcode does not match", resource1Type.hashCode() == resource2Type.hashCode()); - - PrismPropertyValue pv1 = getPrismContext().itemFactory().createPropertyValue(resource1Type.getConnectorConfiguration()); - PrismPropertyValue pv2 = getPrismContext().itemFactory().createPropertyValue(resource2Type.getConnectorConfiguration()); - - assertTrue("Real property values not equal",pv1.equals(pv2, EquivalenceStrategy.REAL_VALUE)); - } - - @Test - public void testAssignmentEquals() throws JAXBException, SchemaException, FileNotFoundException { - System.out.println("\n\n ===[testAssnignmentEquals]===\n"); - - // GIVEN - JAXBElement userEl1 = JaxbTestUtil.getInstance().unmarshalElement(new File(USER_BARBOSSA_FILENAME), UserType.class); - UserType user = userEl1.getValue(); - assertNotNull(user); - - AssignmentType userAssignmentType = user.getAssignment().get(0); - assertNotNull(userAssignmentType); - - System.out.println("\n*** user assignment"); - System.out.println(PrismTestUtil.serializeAnyDataWrapped(userAssignmentType)); - - JAXBElement modEl = JaxbTestUtil.getInstance().unmarshalElement(new File(TEST_DIR, "user-barbossa-modify-delete-assignment-account-opendj-attr.xml"),ObjectModificationType.class); - ObjectModificationType mod = modEl.getValue(); - assertNotNull(mod); - - //FIXME : modification value -> rawType... - RawType rawType = mod.getItemDelta().get(0).getValue().get(0); - ItemDefinition assignmentDefinition = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class); - assertNotNull(assignmentDefinition); - AssignmentType assignmentType = ((PrismContainerValue) rawType.getParsedValue(assignmentDefinition, null)).getValue(); -// was: (JAXBElement) mod.getItemDelta().get(0).getValue().get(0).getContent().get(0); - assertNotNull(assignmentType); - - System.out.println("\n*** assignment"); - System.out.println(PrismTestUtil.serializeAnyDataWrapped(assignmentType)); - - // WHEN, THEN - - assertTrue("Assignment not equals", userAssignmentType.equals(assignmentType)); - - assertTrue("HashCode does not match", userAssignmentType.hashCode() == assignmentType.hashCode()); - } - - @Test - public void testObjectReferenceNullSet() throws Exception { - System.out.println("\n\n ===[testObjectReferenceNullSet]===\n"); - - //GIVEN - SystemConfigurationType config = new SystemConfigurationType(); - getPrismContext().adopt(config); - - //WHEN - config.setGlobalSecurityPolicyRef(null); - - //THEN - SystemConfigurationType configNew = new SystemConfigurationType(); - - ObjectReferenceType ref = new ObjectReferenceType(); - ref.setOid("1234"); - ref.setType(ValuePolicyType.COMPLEX_TYPE); - - configNew.setGlobalSecurityPolicyRef(ref); - configNew.setGlobalSecurityPolicyRef(null); - - getPrismContext().adopt(configNew); - - assertTrue(config.equals(configNew)); - } -} diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java index 88cf685de53..b11640268d1 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestLazyDumpPerformance.java @@ -7,61 +7,44 @@ package com.evolveum.midpoint.schema; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; /** * @author mederly */ -public class TestLazyDumpPerformance { - - private static final Trace LOGGER = TraceManager.getTrace(TestLazyDumpPerformance.class); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestLazyDumpPerformance extends AbstractSchemaTest { private static final long ITERATIONS = 4000000; @Test public void toShortStringLazyPerformance() { - UserType user = new UserType(PrismTestUtil.getPrismContext()).name("jack"); for (long i = 0; i < 100000; i++) { // warm-up - LOGGER.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); + logger.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); } long startLazy = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); + logger.trace("{}", ObjectTypeUtil.toShortStringLazy(user)); } long lazy = System.currentTimeMillis() - startLazy; System.out.println("Lazy: " + lazy + " ms = " + (lazy * 1000000) / ITERATIONS + " ns per iteration"); long startNormal = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", user); + logger.trace("{}", user); } long normal = System.currentTimeMillis() - startNormal; System.out.println("Normal: " + normal + " ms = " + (normal * 1000000) / ITERATIONS + " ns per iteration"); long startOptimized = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("{}", ObjectTypeUtil.toShortString(user)); + if (logger.isTraceEnabled()) { + logger.trace("{}", ObjectTypeUtil.toShortString(user)); } } long optimized = System.currentTimeMillis() - startOptimized; @@ -69,7 +52,7 @@ public void toShortStringLazyPerformance() { long startNaive = System.currentTimeMillis(); for (long i = 0; i < ITERATIONS; i++) { - LOGGER.trace("{}", ObjectTypeUtil.toShortString(user)); + logger.trace("{}", ObjectTypeUtil.toShortString(user)); } long naive = System.currentTimeMillis() - startNaive; System.out.println("Naive: " + naive + " ms = " + (naive * 1000000) / ITERATIONS + " ns per iteration"); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java index 579269cac52..6fd16d4fa40 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestMiscellaneous.java @@ -6,49 +6,34 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import java.io.File; -import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.fail; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author mederly - * */ -public class TestMiscellaneous { +public class TestMiscellaneous extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/misc"); private static final File FILE_ROLE_REMOVE_ITEMS = new File(TEST_DIR, "role-remove-items.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void singleValuedItems() throws Exception { - System.out.println("===[ singleValuedItems ]==="); - UserType userBean = getPrismContext().createObjectable(UserType.class) .beginAssignment() - .id(1L) - .targetRef(new ObjectReferenceType().oid("123456").type(RoleType.COMPLEX_TYPE)) + .id(1L) + .targetRef(new ObjectReferenceType().oid("123456").type(RoleType.COMPLEX_TYPE)) .end(); //noinspection unchecked @@ -69,7 +54,6 @@ public void singleValuedItems() throws Exception { @Test public void removeOperationalItems() throws Exception { - System.out.println("===[ removeOperationalItems ]==="); PrismObject role = getPrismContext().parseObject(FILE_ROLE_REMOVE_ITEMS); AtomicInteger propertyValuesBefore = new AtomicInteger(0); @@ -99,7 +83,7 @@ public void removeOperationalItems() throws Exception { assertNull("assignment[1]/activation/effectiveStatus present", role.findProperty(ItemPath.create(RoleType.F_ASSIGNMENT, 1L, AssignmentType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS))); - assertEquals("Wrong property values after", propertyValuesBefore.intValue()-6, propertyValuesAfter.intValue()); + assertEquals("Wrong property values after", propertyValuesBefore.intValue() - 6, propertyValuesAfter.intValue()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java index 4c66f4f64f4..7876874cd19 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestObjectConstruction.java @@ -6,42 +6,25 @@ */ package com.evolveum.midpoint.schema; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; +import static org.testng.AssertJUnit.*; -import java.io.IOException; - -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * @author semancik - * */ -public class TestObjectConstruction { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestObjectConstruction extends AbstractSchemaTest { @Test public void testUserConstruction() throws Exception { - System.out.println("\n\n ===[ testUserConstruction ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -54,23 +37,18 @@ public void testUserConstruction() throws Exception { } @Test - public void testObjectTypeConstruction() throws Exception { - System.out.println("\n\n ===[ testObjectTypeConstruction ]===\n"); - + public void testObjectTypeConstruction() { // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); try { // WHEN - PrismObject object = prismContext.createObject(ObjectType.class); + prismContext.createObject(ObjectType.class); fail("unexpected success"); } catch (SchemaException e) { // This is expected, abstract object types cannot be instantiated assertTrue(e.getMessage().contains("abstract")); } - } - - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java index 6bed0333698..a64175a6fa4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestOperationResult.java @@ -6,48 +6,34 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultImportanceType.MAJOR; + +import java.util.Arrays; +import java.util.List; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultHandlingStrategyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultImportanceType.MAJOR; -import static org.testng.AssertJUnit.assertEquals; /** * @author mederly - * */ -public class TestOperationResult { +public class TestOperationResult extends AbstractSchemaTest { private static final String LOCAL_1 = "local1"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testCleanup() throws Exception { - System.out.println("===[ testCleanup ]==="); - - // GIVEN (checks also conversions during result construction) - + given("checks also conversions during result construction"); OperationResult root = new OperationResult("dummy"); checkResultConversion(root, true); @@ -67,14 +53,14 @@ public void testCleanup() throws Exception { sub13.recordSuccess(); checkResultConversion(root, true); - // WHEN + when(); System.out.println("Before cleanup:\n" + root.debugDump()); sub1.computeStatus(); sub1.cleanupResult(); root.computeStatus(); root.cleanupResult(); - // THEN + then(); System.out.println("After cleanup (normal):\n" + root.debugDump()); assertEquals("Wrong overall status", OperationResultStatus.FATAL_ERROR, root.getStatus()); // because of sub2 assertEquals("Wrong status of sub1", OperationResultStatus.WARNING, sub1.getStatus()); // because of sub12 @@ -104,10 +90,7 @@ public void testCleanup() throws Exception { @Test public void testSummarizeByHiding() throws Exception { - System.out.println("===[ testSummarizeByHiding ]==="); - // GIVEN - OperationResult root = new OperationResult("dummy"); OperationResult level1 = root.createSubresult("level1"); for (int i = 1; i <= 30; i++) { @@ -137,8 +120,6 @@ public void testSummarizeByHiding() throws Exception { @Test public void testExplicitSummarization() throws Exception { - System.out.println("===[ testExplicitSummarization ]==="); - // GIVEN OperationResult root = new OperationResult("dummy"); @@ -172,8 +153,6 @@ public void testExplicitSummarization() throws Exception { @Test public void testIncrementalSummarization() throws Exception { - System.out.println("===[ testIncrementalSummarization ]==="); - OperationResult root = new OperationResult("dummy"); int b = 0; for (int a = 1; a <= 30; a++) { @@ -215,8 +194,8 @@ public void testIncrementalSummarization() throws Exception { assertEquals("Wrong operation in summary for B", "operationB", sumB.getOperation()); assertEquals("Wrong status in summary for A", OperationResultStatus.SUCCESS, sumA.getStatus()); assertEquals("Wrong status in summary for B", OperationResultStatus.WARNING, sumB.getStatus()); - assertEquals("Wrong hidden records count in summary for A", a-expectedA, sumA.getHiddenRecordsCount()); - assertEquals("Wrong hidden records count in summary for B", b-expectedB, sumB.getHiddenRecordsCount()); + assertEquals("Wrong hidden records count in summary for A", a - expectedA, sumA.getHiddenRecordsCount()); + assertEquals("Wrong hidden records count in summary for B", b - expectedB, sumB.getHiddenRecordsCount()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java index 3deb03d73cc..c930120e94f 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseDiffPatch.java @@ -6,45 +6,38 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.*; import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.prism.xnode.RootXNode; import com.evolveum.midpoint.prism.xnode.XNode; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -52,9 +45,8 @@ /** * @author semancik - * */ -public class TestParseDiffPatch { +public class TestParseDiffPatch extends AbstractSchemaTest { private static final String TEST_DIR = "src/test/resources/diff/"; @@ -70,16 +62,8 @@ public class TestParseDiffPatch { private static final File SYSTEM_CONFIGURATION_BEFORE_FILE = new File(TEST_DIR, "system-configuration-before.xml"); private static final File SYSTEM_CONFIGURATION_AFTER_FILE = new File(TEST_DIR, "system-configuration-after.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUserCredentialsDiff() throws Exception { - System.out.println("===[ testUserCredentialsDiff ]==="); - PrismObject userBefore = PrismTestUtil.parseObject(USER_BEFORE_FILE); userBefore.checkConsistence(); PrismObject userAfter = PrismTestUtil.parseObject(USER_AFTER_FILE); @@ -100,14 +84,13 @@ public void testUserCredentialsDiff() throws Exception { path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); PropertyDelta propertyDelta = userDelta.findPropertyDelta(path); - assertNotNull("Property delta for "+path+" not found",propertyDelta); + assertNotNull("Property delta for " + path + " not found", propertyDelta); assertEquals(1, propertyDelta.getValuesToAdd().size()); } - //@Test + // was commented from 2014 to 2020, but it seem to work - now what? + @Test public void testAssignmentActivationDiff() throws Exception { - System.out.println("===[ testUserCredentialsDiff ]==="); - PrismObject userBefore = PrismTestUtil.parseObject(USER_BEFORE_FILE); PrismObject userAfter = userBefore.clone(); AssignmentType assignmentBefore = new AssignmentType(); @@ -122,84 +105,49 @@ public void testAssignmentActivationDiff() throws Exception { assignmentAfter.setActivation(activation); userAfter.asObjectable().getAssignment().add(assignmentAfter); + Collection userDeltas = + assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); - Collection userDelta = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - ItemDelta assignmentDelta = userDelta.iterator().next(); + ItemDelta assignmentDelta = userDeltas.iterator().next(); System.out.println("Assignment delta: " + assignmentDelta); System.out.println("Assignment delta: " + assignmentDelta.debugDump()); ItemPath path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - PropertyDelta propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); - assertNotNull("Property delta for "+path+" not found",propertyDelta); -// assertEquals(1, propertyDelta.getValuesToAdd().size()); + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); assignmentAfter = new AssignmentType(); activation = new ActivationType(); activation.setAdministrativeStatus(null); assignmentAfter.setActivation(activation); - userDelta = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - assignmentDelta = userDelta.iterator().next(); - System.out.println("Assignment delta: " + assignmentDelta); - System.out.println("Assignment delta: " + assignmentDelta.debugDump()); - - path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, - AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); - - - - userDelta = assignmentAfter.asPrismContainerValue().diff(assignmentBefore.asPrismContainerValue()); -// ObjectDelta userDelta = userBefore.diff(userAfter); - System.out.println("DELTA:"); -// System.out.println(userDelta.debugDump()); - -// userBefore.checkConsistence(); -// userAfter.checkConsistence(); -// userDelta.checkConsistence(); -// userDelta.assertDefinitions(); - - assignmentDelta = userDelta.iterator().next(); - System.out.println("Assignment delta: " + assignmentDelta); - System.out.println("Assignment delta: " + assignmentDelta.debugDump()); - - path = ItemPath.create(SchemaConstantsGenerated.C_ASSIGNMENT, - AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS); -// PrismAsserts.assertPropertyAdd(assignmentDelta, path, 1); -// path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, -// CredentialsType.F_PASSWORD, PasswordType.F_FAILED_LOGINS); - propertyDelta = ItemDeltaCollectionsUtil.findPropertyDelta(userDelta, path); + userDeltas = assignmentBefore.asPrismContainerValue().diff(assignmentAfter.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); + assignmentDelta = userDeltas.iterator().next(); + System.out.println("Assignment delta: " + assignmentDelta); + System.out.println("Assignment delta: " + assignmentDelta.debugDump()); + + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); + + userDeltas = assignmentAfter.asPrismContainerValue().diff(assignmentBefore.asPrismContainerValue()); + userBefore.checkConsistence(); + userAfter.checkConsistence(); + + assignmentDelta = userDeltas.iterator().next(); + System.out.println("Assignment delta: " + assignmentDelta); + System.out.println("Assignment delta: " + assignmentDelta.debugDump()); + + assertNotNull("Property delta for " + path + " not found", + ItemDeltaCollectionsUtil.findPropertyDelta(userDeltas, path)); } @Test - public void testUser() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testUser ]==="); - + public void testUser() throws SchemaException, IOException { PrismObject userBefore = PrismTestUtil.parseObject(new File(TEST_DIR, "user-jack-before.xml")); userBefore.checkConsistence(); PrismObject userAfter = PrismTestUtil.parseObject(new File(TEST_DIR, "user-jack-after.xml")); @@ -226,11 +174,11 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx assertEquals("Wrong change type", ChangeType.MODIFY, userDelta.getChangeType()); Collection modifications = userDelta.getModifications(); assertEquals("Unexpected number of modifications", 3, modifications.size()); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"fullName"), + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "fullName"), new PolyString("Cpt. Jack Sparrow", "cpt jack sparrow")); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"honorificPrefix"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "honorificPrefix"), new PolyString("Cpt.", "cpt")); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"locality"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "locality"), new PolyString("Tortuga", "tortuga")); ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(userDelta); @@ -242,15 +190,15 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx PolyStringType polyString = new PolyStringType(); polyString.setOrig("Cpt. Jack Sparrow"); polyString.setNorm("cpt jack sparrow"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"fullName"), ModificationTypeType.REPLACE, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "fullName"), ModificationTypeType.REPLACE, polyString); polyString = new PolyStringType(); polyString.setOrig("Cpt."); polyString.setNorm("cpt"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"honorificPrefix"), ModificationTypeType.ADD, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "honorificPrefix"), ModificationTypeType.ADD, polyString); polyString = new PolyStringType(); polyString.setOrig("Tortuga"); polyString.setNorm("tortuga"); - assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C,"locality"), ModificationTypeType.ADD, polyString); + assertXmlPolyMod(objectModificationType, new ItemName(SchemaConstants.NS_C, "locality"), ModificationTypeType.ADD, polyString); userBefore.checkConsistence(); userAfter.checkConsistence(); @@ -265,19 +213,17 @@ public void testUser() throws SchemaException, SAXException, IOException, JAXBEx //assertEquals("Round trip failed", userAfter, userBefore); - assertTrue("Not equivalent",userBefore.equivalent(userAfter)); + assertTrue("Not equivalent", userBefore.equivalent(userAfter)); ObjectDelta roundTripDelta = DiffUtil.diff(userBefore, userAfter); System.out.println("roundtrip DELTA:"); System.out.println(roundTripDelta.debugDump()); - assertTrue("Roundtrip delta is not empty",roundTripDelta.isEmpty()); + assertTrue("Roundtrip delta is not empty", roundTripDelta.isEmpty()); } @Test - public void testUserReal() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testUserReal ]==="); - + public void testUserReal() throws SchemaException, IOException { String userBeforeXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-before.xml")); String userAfterXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-after.xml")); @@ -295,20 +241,18 @@ public void testUserReal() throws SchemaException, SAXException, IOException, JA assertEquals("Wrong change type", ChangeType.MODIFY, userDelta.getChangeType()); Collection modifications = userDelta.getModifications(); assertEquals("Unexpected number of modifications", 4, modifications.size()); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"emailAddress"), "jack@blackpearl.com"); - PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C,"locality"), + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "emailAddress"), "jack@blackpearl.com"); + PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "locality"), new PolyString("World's End", "worlds end")); PrismAsserts.assertPropertyReplace(userDelta, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); - PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C,"organizationalUnit"), + PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "organizationalUnit"), new PolyString("Brethren of the Coast", "brethren of the coast")); } @Test - public void testAddDelta() throws SchemaException, SAXException, IOException { - System.out.println("===[ testAddDelta ]==="); - + public void testAddDelta() throws SchemaException, IOException { // WHEN - ObjectDelta userDelta = DiffUtil.diff(null,new File(TEST_DIR, "user-jack-after.xml"), UserType.class, getPrismContext()); + ObjectDelta userDelta = DiffUtil.diff(null, new File(TEST_DIR, "user-jack-after.xml"), UserType.class, getPrismContext()); //THEN System.out.println("DELTA:"); @@ -322,9 +266,7 @@ public void testAddDelta() throws SchemaException, SAXException, IOException { } @Test - public void testTask() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testTask ]==="); - + public void testTask() throws SchemaException, IOException { // WHEN ObjectDelta diffDelta = DiffUtil.diff(TASK_BEFORE_FILE, @@ -347,7 +289,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx // Convert to XML form. This should include xsi:type to pass the type information - ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(diffDelta); + ObjectModificationType objectModificationType = DeltaConvertor.toObjectModificationType(diffDelta); System.out.println("Modification XML:"); System.out.println(PrismTestUtil.serializeAnyDataWrapped(objectModificationType)); @@ -376,7 +318,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx PrismObject taskAfter = PrismTestUtil.parseObject(TASK_AFTER_FILE); taskAfter.checkConsistence(); - assertTrue("Not equivalent",taskPatch.equivalent(taskAfter)); + assertTrue("Not equivalent", taskPatch.equivalent(taskAfter)); diffDelta.checkConsistence(); taskPatch.checkConsistence(); @@ -386,7 +328,7 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx System.out.println("roundtrip DELTA:"); System.out.println(roundTripDelta.debugDump()); - assertTrue("Roundtrip delta is not empty",roundTripDelta.isEmpty()); + assertTrue("Roundtrip delta is not empty", roundTripDelta.isEmpty()); roundTripDelta.checkConsistence(); diffDelta.checkConsistence(); @@ -396,8 +338,6 @@ public void testTask() throws SchemaException, SAXException, IOException, JAXBEx @Test public void testResource() throws Exception { - System.out.println("===[ testResource ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_FILE); @@ -443,8 +383,6 @@ public void testResource() throws Exception { @Test public void testResourceConst() throws Exception { - System.out.println("===[ testResourceConst ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_CONST_FILE); @@ -482,8 +420,6 @@ public void testResourceConst() throws Exception { @Test public void testResourceConstLiteral() throws Exception { - System.out.println("===[ testResourceConstLiteral ]==="); - PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_CONST_FILE); @@ -516,7 +452,7 @@ public void testResourceConstLiteral() throws Exception { private void assertConfigurationPropertyChange(ObjectDelta resourceDelta, String propName) { resourceDelta.checkConsistence(); PropertyDelta propertyDelta = resourceDelta.findPropertyDelta(pathConfigProperties(propName)); - assertNotNull("No delta for configuration property "+propName, propertyDelta); + assertNotNull("No delta for configuration property " + propName, propertyDelta); // TODO resourceDelta.checkConsistence(); } @@ -532,9 +468,7 @@ private ItemPath pathTimeouts(String last) { } @Test - public void testResourceRoundTrip() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceRoundTrip ]==="); - + public void testResourceRoundTrip() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_FILE); @@ -600,9 +534,7 @@ public void testResourceRoundTrip() throws SchemaException, SAXException, IOExce } @Test - public void testResourceNsChange() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsChange ]==="); - + public void testResourceNsChange() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_NS_CHANGE_FILE); @@ -624,7 +556,7 @@ public void testResourceNsChange() throws SchemaException, SAXException, IOExcep resourceAfter.checkConsistence(); if (!resourceDelta.isEmpty()) { - AssertJUnit.fail("The delta is not empty; it is "+resourceDelta); + AssertJUnit.fail("The delta is not empty; it is " + resourceDelta); } // "post" sanity @@ -633,9 +565,7 @@ public void testResourceNsChange() throws SchemaException, SAXException, IOExcep } @Test - public void testResourceNsChangeLiteral() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsChangeLiteral ]==="); - + public void testResourceNsChangeLiteral() throws SchemaException, IOException { PrismObject resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE); PrismObject resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_NS_CHANGE_FILE); @@ -660,9 +590,7 @@ public void testResourceNsChangeLiteral() throws SchemaException, SAXException, } @Test - public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testResourceNsFixUndeclaredPrefixes ]==="); - + public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, IOException { boolean orig = QNameUtil.isTolerateUndeclaredPrefixes(); try { QNameUtil.setTolerateUndeclaredPrefixes(true); @@ -707,23 +635,17 @@ public void testResourceNsFixUndeclaredPrefixes() throws SchemaException, SAXExc QNameUtil.setTolerateUndeclaredPrefixes(orig); } - - } - - protected PrismObject getRawShadowBefore(PrismContext prismContext) throws SchemaException, IOException { - PrismObject oldObject = prismContext.parseObject(new File(TEST_DIR, "shadow-before.xml")); - return oldObject; } private void assertXmlPolyMod(ObjectModificationType objectModificationType, QName propertyName, ModificationTypeType modType, PolyStringType... expectedValues) throws SchemaException { //FIXME: for (ItemDeltaType mod : objectModificationType.getItemDelta()) { - if (!propertyName.equals(mod.getPath().getItemPath().last())) { - continue; - } - assertEquals(modType, mod.getModificationType()); - for (RawType val : mod.getValue()){ + if (!propertyName.equals(mod.getPath().getItemPath().last())) { + continue; + } + assertEquals(modType, mod.getModificationType()); + for (RawType val : mod.getValue()) { assertModificationPolyStringValue(val, expectedValues); } } @@ -736,7 +658,7 @@ private void assertModificationPolyStringValue(RawType value, PolyStringType... RootXNode rootNode = pc.xnodeFactory().root(new ItemName("dummy"), xnode); PolyStringType valueAsPoly = pc.parserFor(rootNode).parseRealValue(PolyStringType.class); boolean found = false; - for (PolyStringType expectedValue: expectedValues) { + for (PolyStringType expectedValue : expectedValues) { if (expectedValue.getOrig().equals(valueAsPoly.getOrig()) && expectedValue.getNorm().equals(valueAsPoly.getNorm())) { found = true; } @@ -744,51 +666,10 @@ private void assertModificationPolyStringValue(RawType value, PolyStringType... assertTrue(found); } - private boolean equal(String value, Element element) { - if (value == null && element == null) { - return true; - } - - if ((value == null && element != null) || (value != null && element == null)) { - return false; - } - - return value.equals(element.getTextContent()); - } - -// private void assertXmlMod(ObjectModificationType objectModificationType, QName propertyName, -// ModificationTypeType modType, String... expectedValues) { -// for (ItemDeltaType mod: objectModificationType.getItemDelta()) { -// assertEquals(modType, mod.getModificationType()); -// for (RawType val : mod.getValue()){ -// List elements = val.getContent(); -// assertFalse(elements.isEmpty()); -// Object first = elements.get(0); -//// QName elementQName = JAXBUtil.getElementQName(first); -// if (propertyName.equals(mod.getPath().getItemPath().last())) { -// -// assertEquals(expectedValues.length, elements.size()); -// for (Object element: elements) { -// boolean found = false; -// for (String expectedValue: expectedValues) { -// Element domElement = (Element)element; -// if (expectedValue.equals(domElement.getTextContent())) { -// found = true; -// } -// } -// assertTrue(found); -// } -// } -// } -// } -// } - // this is a simple test of applying delta (don't know where to put it) // MID-3828 @Test - public void testCampaign() throws SchemaException, SAXException, IOException, JAXBException { - System.out.println("===[ testCampaign ]==="); - + public void testCampaign() throws SchemaException, IOException { PrismObject campaign = PrismTestUtil.parseObject(new File(TEST_DIR, "campaign-1.xml")); campaign.checkConsistence(); assertEquals("Wrong # of triggers", 2, campaign.asObjectable().getTrigger().size()); @@ -799,11 +680,11 @@ public void testCampaign() throws SchemaException, SAXException, IOException, JA triggerToDelete.setTimestamp(XmlTypeConverter.createXMLGregorianCalendar("2017-03-17T23:43:49.705+01:00")); triggerToDelete.setHandlerUri("http://midpoint.evolveum.com/xml/ns/public/certification/trigger/close-stage/handler-3"); - @SuppressWarnings({"unchecked", "raw"}) + @SuppressWarnings({ "raw" }) ObjectDelta delta = getPrismContext().deltaFor(AccessCertificationCampaignType.class) - .item(AccessCertificationCampaignType.F_TRIGGER).delete(triggerToDelete) - .asObjectDelta(campaign.getOid()); + .item(AccessCertificationCampaignType.F_TRIGGER).delete(triggerToDelete) + .asObjectDelta(campaign.getOid()); // THEN delta.applyTo(campaign); @@ -851,8 +732,6 @@ public void testDiffSameValues() throws Exception { */ @Test public void testSystemConfigurationDiff() throws Exception { - System.out.println("===[ testSystemConfigurationDiff ]==="); - PrismObject before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); before.checkConsistence(); PrismObject after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE); @@ -877,8 +756,6 @@ public void testSystemConfigurationDiff() throws Exception { */ @Test public void testSystemConfigurationDiffPlusNarrow() throws Exception { - System.out.println("===[ testSystemConfigurationDiffPlusNarrow ]==="); - PrismObject before = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); before.checkConsistence(); PrismObject after = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_AFTER_FILE); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java index 15594694924..e2ac9735d4f 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseFilter.java @@ -6,43 +6,25 @@ */ package com.evolveum.midpoint.schema; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; +import static org.testng.AssertJUnit.assertEquals; +import java.io.File; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import static org.testng.AssertJUnit.assertEquals; - -/** - * @author mederly - * - */ -public class TestParseFilter { +import org.testng.annotations.Test; - public static final File FILTER_FILE = new File(TestConstants.COMMON_DIR, "filter.xml"); +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestParseFilter extends AbstractSchemaTest { + public static final File FILTER_FILE = new File(TestConstants.COMMON_DIR, "filter.xml"); @Test public void testParseFilterFile() throws Exception { - System.out.println("===[ testParseFilterFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -54,8 +36,8 @@ public void testParseFilterFile() throws Exception { System.out.println(filter.debugDump()); String serialized = PrismTestUtil.serializeJaxbElementToString(new JAXBElement<>( - new QName(SchemaConstants.NS_QUERY, "filter"), SearchFilterType.class, filter)); - System.out.println("JAXB serialization result:\n"+serialized); + new QName(SchemaConstants.NS_QUERY, "filter"), SearchFilterType.class, filter)); + System.out.println("JAXB serialization result:\n" + serialized); // WHEN2 @@ -68,5 +50,4 @@ public void testParseFilterFile() throws Exception { assertEquals("Parsed and serialized+parsed filters do not match", filter, filter2); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java index d9ebaf93c91..25ae9ada1f4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseGenericObject.java @@ -6,64 +6,45 @@ */ package com.evolveum.midpoint.schema; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ExtensionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - /** * @author semancik - * */ -public class TestParseGenericObject { +public class TestParseGenericObject extends AbstractSchemaTest { public static final File GENERIC_FILE = new File("src/test/resources/common/generic-sample-configuration.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParseGenericFile() throws Exception { - System.out.println("===[ testParseGenericFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -79,8 +60,6 @@ public void testParseGenericFile() throws Exception { @Test public void testParseGenericDom() throws SchemaException, DatatypeConfigurationException { - System.out.println("===[ testParseGenericDom ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -99,11 +78,9 @@ public void testParseGenericDom() throws SchemaException, DatatypeConfigurationE @Deprecated @Test(enabled = false) - public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxb ]==="); - + public void testPrismParseJaxb() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -114,17 +91,14 @@ public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXExcep } /** - * The definition should be set properly even if the declared type is ObjectType. The Prism should determine - * the actual type. - * @throws DatatypeConfigurationException + * The definition should be set properly even if the declared type is ObjectType. + * The Prism should determine the actual type. */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbObjectType ]==="); - + public void testPrismParseJaxbObjectType() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -135,16 +109,13 @@ public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException } /** - * Parsing in form of JAXBELement - * @throws DatatypeConfigurationException + * Parsing in form of JAXBElement. */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbElement ]==="); - + public void testPrismParseJaxbElement() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -157,15 +128,12 @@ public void testPrismParseJaxbElement() throws JAXBException, SchemaException, S /** * Parsing in form of JAXBELement, with declared ObjectType - * @throws DatatypeConfigurationException */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException, DatatypeConfigurationException { - System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); - + public void testPrismParseJaxbElementObjectType() + throws JAXBException, SchemaException, IOException, DatatypeConfigurationException { // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -176,11 +144,8 @@ public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaEx assertGenericObject(genericType.asPrismObject()); } - @Test public void testParseGenericRoundtrip() throws Exception { - System.out.println("===[ testParseGenericRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -213,19 +178,12 @@ public void testParseGenericRoundtrip() throws Exception { assertTrue("Delta is not empty", objectDelta.isEmpty()); PrismAsserts.assertEquivalent("generic object re-parsed quivalence", generic, reparsedGeneric); - -// // Compare schema container -// -// PrismContainer originalSchemaContainer = resource.findContainer(ResourceType.F_SCHEMA); -// PrismContainer reparsedSchemaContainer = reparsedResource.findContainer(ResourceType.F_SCHEMA); } private void assertGenericObject(PrismObject generic) throws DatatypeConfigurationException { - generic.checkConsistence(); assertEquals("Wrong oid", "c0c010c0-d34d-b33f-f00d-999111111111", generic.getOid()); -// assertEquals("Wrong version", "42", resource.getVersion()); PrismObjectDefinition resourceDefinition = generic.getDefinition(); assertNotNull("No resource definition", resourceDefinition); PrismAsserts.assertObjectDefinition(resourceDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "genericObject"), @@ -245,22 +203,9 @@ private void assertGenericObject(PrismObject generic) throws PrismContainerDefinition extensionContainerDefinition = extensionContainer.getDefinition(); assertTrue("Extension container definition is NOT dynamic", extensionContainerDefinition.isDynamic()); PrismContainerValue extensionContainerValue = extensionContainer.getValue(); - Collection> extensionItems = extensionContainerValue.getItems(); + Collection> extensionItems = extensionContainerValue.getItems(); assertEquals("Wrong number of extension items", 5, extensionItems.size()); - // COMPLEX RUN TIME PROPERTIES...NOT SUPPORTED WITH NEW PARSERS.. -// Item locationsItem = extensionContainerValue.findItem(SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT); -// if (!(locationsItem instanceof PrismProperty)) { -// AssertJUnit.fail("Expected the extension item to be of type "+PrismProperty.class+ -// "but it was of type "+locationsItem.getClass()); -// } -// PrismProperty locationsProperty = (PrismProperty)locationsItem; -// assertEquals("Wrong name of ", SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, locationsProperty.getElementName()); -// PrismPropertyDefinition locationsDefinition = locationsProperty.getDefinition(); -// assertNotNull("No definition for ", locationsDefinition); -// PrismAsserts.assertDefinition(locationsDefinition, SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, -// SchemaTestConstants.EXTENSION_LOCATIONS_TYPE, 0, -1); - PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT, "X marks the spot"); PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234); PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D); @@ -281,10 +226,9 @@ public static void assertPropertyValue(PrismContainer container, String propN PrismAsserts.assertPropertyValue(container, propQName, propValue); } - private void assertContainerDefinition(PrismContainer container, String contName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertContainerDefinition(PrismContainer container, + String contName, QName xsdType, int minOccurs, int maxOccurs) { QName qName = new QName(SchemaConstantsGenerated.NS_COMMON, contName); PrismAsserts.assertDefinition(container.getDefinition(), qName, xsdType, minOccurs, maxOccurs); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java index 21d1ad10677..5e358669e46 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseLookupTable.java @@ -6,6 +6,14 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismContext; @@ -14,43 +22,21 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; /** * @author Viliam Repan (lazyman) */ -public class TestParseLookupTable { +public class TestParseLookupTable extends AbstractSchemaTest { public static final File LOOKUP_TABLE_FILE = new File("src/test/resources/common/lookup-table.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParseTableFileRoundTrip() throws Exception { - System.out.println("===[ testParseTableFileRoundTrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -81,7 +67,6 @@ public void testParseTableFileRoundTrip() throws Exception { PrismAsserts.assertEquals(table.asObjectable(), reparsedObject.asObjectable()); } - private void assertTable(PrismObject table) { table.checkConsistence(); @@ -113,7 +98,7 @@ private void assertRow(PrismContainerValue tableContainerVal } private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + int maxOccurs) { QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java index 59a166c9cd4..ac15c9923d6 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseMisc.java @@ -10,53 +10,34 @@ import static org.testng.AssertJUnit.assertNotNull; import java.io.File; -import java.io.IOException; import java.util.List; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * @author semancik - * */ -public class TestParseMisc { +public class TestParseMisc extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/misc"); protected static final File ROLE_FILTERS_FILE = new File(TEST_DIR, "role-filters.xml"); protected static final String ROLE_FILTERS_OID = "aad19b9a-d511-11e7-8bf7-cfecde275e59"; - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - SchemaDebugUtil.initialize(); // Make sure the pretty printer is activated - } - - @Test public void testParseRoleFilters() throws Exception { - System.out.println("\n\n===[ testParseRoleFilters ]===\n"); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -85,9 +66,8 @@ public void testParseRoleFilters() throws Exception { assertEquals("Wrong number of inducements", 2, inducements.size()); } - - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition(PrismContainer container, + String propName, QName xsdType, int minOccurs, int maxOccurs) { QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } @@ -96,11 +76,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - - public static void assertPropertyValues(PrismContainer container, String propName, T... expectedValues) { - ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); - PrismAsserts.assertPropertyValue(container, propQName, expectedValues); - } - - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java deleted file mode 100644 index 7f296cfa31c..00000000000 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseModelContext.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2010-2013 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.schema; - -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType; - -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; - -/** - * @author semancik - * @author mederly - * - */ -public class TestParseModelContext { - - public static final File MODEL_CONTEXT_FILE = new File("src/test/resources/common/model-context-1.xml"); - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - - @Test - public void testParseModelContextPrism() throws Exception { - System.out.println("===[ testParseModelContextPrism ]==="); - - // GIVEN - PrismContext prismContext = PrismTestUtil.getPrismContext(); - - // WHEN - LensContextType lensContextType = prismContext.parserFor(MODEL_CONTEXT_FILE).xml().parseRealValue(LensContextType.class); - - // THEN - System.out.println("Parsed LensContextType: " + lensContextType); - } - -// @Test -// public void testParseTaskDom() throws SchemaException { -// System.out.println("===[ testParseTaskDom ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// -// Document document = DOMUtil.parseFile(MODEL_CONTEXT_FILE); -// Element taskElement = DOMUtil.getFirstChildElement(document); -// -// // WHEN -// PrismObject task = prismContext.parseObject(taskElement); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(task.dump()); -// -// assertTask(task); -// } -// -// @Test -// public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxb ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// TaskType taskType = jaxbProcessor.unmarshalObject(MODEL_CONTEXT_FILE, TaskType.class); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * The definition should be set properly even if the declared type is ObjectType. The Prism should determine -// * the actual type. -// */ -// @Test -// public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbObjectType ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// ObjectType taskType = jaxbProcessor.unmarshalObject(MODEL_CONTEXT_FILE, ObjectType.class); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * Parsing in form of JAXBELement -// */ -// @Test -// public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbElement ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// JAXBElement jaxbElement = jaxbProcessor.unmarshalElement(MODEL_CONTEXT_FILE, TaskType.class); -// TaskType taskType = jaxbElement.getValue(); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// /** -// * Parsing in form of JAXBELement, with declared ObjectType -// */ -// @Test -// public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException { -// System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); -// -// // GIVEN -// PrismContext prismContext = PrismTestUtil.getPrismContext(); -// PrismJaxbProcessor jaxbProcessor = prismContext.getPrismJaxbProcessor(); -// -// // WHEN -// JAXBElement jaxbElement = jaxbProcessor.unmarshalElement(MODEL_CONTEXT_FILE, ObjectType.class); -// ObjectType taskType = jaxbElement.getValue(); -// -// // THEN -// System.out.println("Parsed task:"); -// System.out.println(taskType.asPrismObject().dump()); -// -// assertTask(taskType.asPrismObject()); -// } -// -// -// private void assertTask(PrismObject task) { -// -// task.checkConsistence(); -// -// assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); -//// assertEquals("Wrong version", "42", user.getVersion()); -// PrismObjectDefinition usedDefinition = task.getDefinition(); -// assertNotNull("No task definition", usedDefinition); -// PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), -// TaskType.COMPLEX_TYPE, TaskType.class); -// assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); -// TaskType taskType = task.asObjectable(); -// assertNotNull("asObjectable resulted in null", taskType); -// -// assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Example Task")); -// assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); -// -// assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); -// assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); -// -// assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); -// PrismProperty executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); -// PrismPropertyValue executionStatusValue = executionStatusProperty.getValue(); -// TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); -// assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); -// -// // TODO: more tests -// -//// PrismContainer extension = user.getExtension(); -//// assertContainerDefinition(extension, "extension", DOMUtil.XSD_ANY, 0, 1); -//// PrismContainerValue extensionValue = extension.getValue(); -//// assertTrue("Extension parent", extensionValue.getParent() == extension); -//// assertNull("Extension ID", extensionValue.getId()); -// -//// PropertyPath enabledPath = new PropertyPath(UserType.F_ACTIVATION, ActivationType.F_ENABLED); -//// PrismProperty enabledProperty1 = task.findProperty(enabledPath); -//// PrismAsserts.assertDefinition(enabledProperty1.getDefinition(), ActivationType.F_ENABLED, DOMUtil.XSD_BOOLEAN, 0, 1); -//// assertNotNull("Property "+enabledPath+" not found", enabledProperty1); -//// PrismAsserts.assertPropertyValue(enabledProperty1, true); -// -//// PrismProperty validFromProperty = user.findProperty(new PropertyPath(UserType.F_ACTIVATION, ActivationType.F_VALID_FROM)); -//// assertNotNull("Property "+ActivationType.F_VALID_FROM+" not found", validFromProperty); -//// PrismAsserts.assertPropertyValue(validFromProperty, USER_JACK_VALID_FROM); -// -//// PrismReference accountRef = task.findReference(UserType.F_ACCOUNT_REF); -//// assertEquals("Wrong number of accountRef values", 3, accountRef.getValues().size()); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000001111"); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000002222"); -//// PrismAsserts.assertReferenceValue(accountRef, "2f9b9299-6f45-498f-aaaa-000000003333"); -// } -// -// private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, -// int maxOccurs) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); -// } -// -// public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyValue(container, propQName, propValue); -// } - -} diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java index c1da02efd70..2fc8f784339 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseObjectTemplate.java @@ -6,69 +6,52 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.query.EqualFilter; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.*; - -/** - * @author semancik - * - */ -public class TestParseObjectTemplate { +public class TestParseObjectTemplate extends AbstractSchemaTest { public static final File TEST_DIR = new File("src/test/resources/object-template"); private static final File OBJECT_TEMPLATE_FILE = new File(TEST_DIR, "object-template.xml"); private static final File USER_TEMPLATE_FILE = new File(TEST_DIR, "user-template.xml"); private static final File WRONG_TEMPLATE_FILE = new File(TEST_DIR, "wrong-template.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - SchemaDebugUtil.initialize(); // Make sure the pretty printer is activated - System.out.println("Pretty printers:\n"+PrettyPrinter.getPrettyPrinters()); - } - - @Test public void testParseObjectTemplateFileSingle() throws Exception { - single("testParseObjectTemplateFileSingle", OBJECT_TEMPLATE_FILE, + single(OBJECT_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseUserTemplateFileSingle() throws Exception { - single("testParseUserTemplateFileSingle", USER_TEMPLATE_FILE, + single(USER_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseObjectTemplateFileRoundTrip() throws Exception { - roundTrip("testParseObjectTemplateFileRoundTrip", OBJECT_TEMPLATE_FILE, + roundTrip(OBJECT_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @@ -122,17 +105,14 @@ public void testAccessObjectTemplateMultithreaded() throws Exception { @Test public void testParseUserTemplateFileRoundTrip() throws Exception { - roundTrip("testParseUserTemplateFileRoundTrip", USER_TEMPLATE_FILE, + roundTrip(USER_TEMPLATE_FILE, new QName(SchemaConstantsGenerated.NS_COMMON, "objectTemplate")); } @Test public void testParseWrongTemplateFile() throws Exception { - final String TEST_NAME = "testParseWrongTemplateFile"; File file = WRONG_TEMPLATE_FILE; - System.out.println("===[ "+TEST_NAME+" ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -149,9 +129,7 @@ public void testParseWrongTemplateFile() throws Exception { } } - private void single(final String TEST_NAME, File file, QName elementName) throws Exception { - System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); - + private void single(File file, QName elementName) throws Exception { // GIVEN PrismContext prismContext = getPrismContext(); @@ -163,12 +141,10 @@ private void single(final String TEST_NAME, File file, QName elementName) throws System.out.println(object.debugDump()); assertObjectTemplate(object, elementName); - assertObjectTemplateInternals(object, elementName); + assertObjectTemplateInternals(object); } - private void roundTrip(final String TEST_NAME, File file, QName elementName) throws Exception { - System.out.println("\n\n===[ "+TEST_NAME+" ]===\n"); - + private void roundTrip(File file, QName elementName) throws Exception { // GIVEN PrismContext prismContext = getPrismContext(); @@ -190,7 +166,7 @@ private void roundTrip(final String TEST_NAME, File file, QName elementName) thr System.out.println("Serialized object:"); System.out.println(xml); - assertSerializedObject(xml, elementName); + // TODO // WHEN PrismObject reparsedObject = prismContext.parseObject(xml); @@ -200,7 +176,7 @@ private void roundTrip(final String TEST_NAME, File file, QName elementName) thr System.out.println(reparsedObject.debugDump()); assertObjectTemplate(reparsedObject, elementName); - assertObjectTemplateInternals(reparsedObject, elementName); + assertObjectTemplateInternals(reparsedObject); } private void assertObjectTemplate(PrismObject object, QName elementName) { @@ -227,7 +203,7 @@ private void assertObjectTemplatePrism(PrismObject object, Q // checks raw values of mappings // should be called only on reparsed values in order to catch some raw-data-related serialization issues (MID-2196) - private void assertObjectTemplateInternals(PrismObject object, QName elementName) throws SchemaException { + private void assertObjectTemplateInternals(PrismObject object) throws SchemaException { int assignmentValuesFound = 0; for (ObjectTemplateMappingType mappingType : object.asObjectable().getMapping()) { if (mappingType.getExpression() != null) { @@ -253,13 +229,6 @@ private void assertObjectTemplateInternals(PrismObject objec assertEquals("wrong # of assignment values found in mapping", 2, assignmentValuesFound); } - - private void assertSerializedObject(String xml, QName elementName) { - // TODO - } - - - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); @@ -271,11 +240,6 @@ public static void assertPropertyValue(PrismContainer container, String propN PrismAsserts.assertPropertyValue(container, propQName, propValue); } - public static void assertPropertyValues(PrismContainer container, String propName, T... expectedValues) { - ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); - PrismAsserts.assertPropertyValue(container, propQName, expectedValues); - } - // todo deduplicate with TestUtil private static void waitForCompletion(List threads, long timeout) throws InterruptedException { long start = System.currentTimeMillis(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java index 36aef28594e..f9427730896 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParsePasswordPolicy.java @@ -7,6 +7,13 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -15,43 +22,19 @@ import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; /** * @author semancik * @author mederly - * */ -public class TestParsePasswordPolicy { +public class TestParsePasswordPolicy extends AbstractSchemaTest { public static final File FILE = new File("src/test/resources/common/password-policy.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test public void testParsePasswordPolicyFile() throws Exception { - System.out.println("===[ testParsePasswordPolicyFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -67,8 +50,6 @@ public void testParsePasswordPolicyFile() throws Exception { @Test public void testParsePolicyRoundtrip() throws Exception { - System.out.println("===[ testParsePolicyRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -105,7 +86,6 @@ public void testParsePolicyRoundtrip() throws Exception { } private void assertPolicy(PrismObject policy) { - policy.checkConsistence(); assertEquals("Wrong oid", "00000000-0000-0000-0000-000000000003", policy.getOid()); @@ -123,8 +103,8 @@ private void assertPolicy(PrismObject policy) { // TODO... } - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition(PrismContainer container, + String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } @@ -133,5 +113,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java index 4a23d2970cf..093293d2de7 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTask.java @@ -6,59 +6,45 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; + +import java.io.File; +import java.io.IOException; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.impl.util.JaxbTestUtil; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getSchemaRegistry; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - /** * @author semancik - * */ -public class TestParseTask { +public class TestParseTask extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-1.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - - @Test(enabled = false) public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -78,8 +64,6 @@ public void testParseTaskFile() throws Exception { @Test(enabled = false) public void testParseTaskDom() throws SchemaException { - System.out.println("===[ testParseTaskDom ]==="); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -98,11 +82,8 @@ public void testParseTaskDom() throws SchemaException { @Deprecated @Test(enabled = false) - public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxb ]==="); - + public void testPrismParseJaxb() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -121,11 +102,8 @@ public void testPrismParseJaxb() throws JAXBException, SchemaException, SAXExcep */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbObjectType ]==="); - + public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -143,11 +121,8 @@ public void testPrismParseJaxbObjectType() throws JAXBException, SchemaException */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElement() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbElement ]==="); - + public void testPrismParseJaxbElement() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -166,11 +141,8 @@ public void testPrismParseJaxbElement() throws JAXBException, SchemaException, S */ @Deprecated @Test(enabled = false) - public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("===[ testPrismParseJaxbElementObjectType ]==="); - + public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaException, IOException { // GIVEN - PrismContext prismContext = getPrismContext(); JaxbTestUtil jaxbProcessor = JaxbTestUtil.getInstance(); // WHEN @@ -184,7 +156,6 @@ public void testPrismParseJaxbElementObjectType() throws JAXBException, SchemaEx assertTask(taskType.asPrismObject()); } - private void assertTask(PrismObject task) { task.checkConsistence(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java index e2cd8c59bed..bae6d9805c7 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction.java @@ -7,51 +7,34 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; /** * @author semancik - * */ -public class TestParseTaskBulkAction { +public class TestParseTaskBulkAction extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-bulk-action-1.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseTaskFileToXNode() throws Exception { - System.out.println("===[ testParseTaskFileToXNode ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -68,8 +51,6 @@ public void testParseTaskFileToXNode() throws Exception { @Test public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -85,8 +66,6 @@ public void testParseTaskFile() throws Exception { @Test public void testParseTaskRoundtrip() throws Exception { - System.out.println("===[ testParseTaskRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -128,9 +107,7 @@ public void testParseTaskRoundtrip() throws Exception { PrismAsserts.assertEquivalent("Task re-parsed equivalence", task, reparsedTask); } - private void assertTask(PrismObject task) { - task.checkConsistence(); assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); @@ -161,13 +138,14 @@ private void assertTask(PrismObject task) { } - private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, - int maxOccurs) { + private void assertPropertyDefinition( + PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); } - public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { + public static void assertPropertyValue( + PrismContainer container, String propName, Object propValue) { ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java index 142e2db8647..5ff3388ef86 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestParseTaskBulkAction2.java @@ -7,6 +7,13 @@ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -14,40 +21,16 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xnode.RootXNode; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertTrue; - -/** - * @author semancik - * - */ -public class TestParseTaskBulkAction2 { +public class TestParseTaskBulkAction2 extends AbstractSchemaTest { public static final File TASK_FILE = new File("src/test/resources/common/task-bulk-action-2.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseTaskFileToXNode() throws Exception { - System.out.println("===[ testParseTaskFileToXNode ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -64,8 +47,6 @@ public void testParseTaskFileToXNode() throws Exception { @Test public void testParseTaskFile() throws Exception { - System.out.println("===[ testParseTaskFile ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -76,7 +57,7 @@ public void testParseTaskFile() throws Exception { System.out.println("Parsed task:"); System.out.println(task.debugDump()); - assertTask(task); + task.checkConsistence(); Item executeScriptItem = task.findExtensionItem(new QName("executeScript")); ExecuteScriptType executeScript = (ExecuteScriptType) executeScriptItem.getRealValue(); @@ -87,8 +68,6 @@ public void testParseTaskFile() throws Exception { @Test public void testParseTaskRoundtrip() throws Exception { - System.out.println("===[ testParseTaskRoundtrip ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -97,7 +76,7 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println("Parsed task:"); System.out.println(task.debugDump()); - assertTask(task); + task.checkConsistence(); // SERIALIZE @@ -120,7 +99,7 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println(reparsedTask.debugDump()); // Cannot assert here. It will cause parsing of some of the raw values and diff will fail - assertTask(reparsedTask); + reparsedTask.checkConsistence(); ObjectDelta objectDelta = task.diff(reparsedTask); System.out.println("Delta:"); @@ -135,49 +114,4 @@ public void testParseTaskRoundtrip() throws Exception { System.out.println(o); assertTrue("Raw value is not parsed", o instanceof RawType && ((RawType) o).getAlreadyParsedValue() != null); } - - - private void assertTask(PrismObject task) { - - task.checkConsistence(); - -// assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); -// PrismObjectDefinition usedDefinition = task.getDefinition(); -// assertNotNull("No task definition", usedDefinition); -// PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), -// TaskType.COMPLEX_TYPE, TaskType.class); -// assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); -// TaskType taskType = task.asObjectable(); -// assertNotNull("asObjectable resulted in null", taskType); -// -// assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2")); -// assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); -// -// assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); -// assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); -// -// assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); -// PrismProperty executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); -// PrismPropertyValue executionStatusValue = executionStatusProperty.getValue(); -// TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); -// assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); -// -// PrismContainer extension = task.getExtension(); -// PrismContainerValue extensionValue = extension.getValue(); -// assertTrue("Extension parent", extensionValue.getParent() == extension); -// assertNull("Extension ID", extensionValue.getId()); - - } - -// private void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, -// int maxOccurs) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs); -// } - -// public static void assertPropertyValue(PrismContainer container, String propName, Object propValue) { -// QName propQName = new QName(SchemaConstantsGenerated.NS_COMMON, propName); -// PrismAsserts.assertPropertyValue(container, propQName, propValue); -// } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java index f098567f29b..776d155bb27 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestQueryConverter.java @@ -19,6 +19,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DomAsserts; import com.evolveum.midpoint.util.PrettyPrinter; @@ -41,13 +42,14 @@ import javax.xml.namespace.QName; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType.F_OWNER_REF; import static org.testng.AssertJUnit.*; -public class TestQueryConverter { +public class TestQueryConverter extends AbstractUnitTest { private static final Trace LOGGER = TraceManager.getTrace(TestQueryConverter.class); @@ -62,8 +64,6 @@ public class TestQueryConverter { private static final QName fooBlaDefinition = new QName(NS_BLA, "foo"); private static final QName ICF_NAME = new QName(NS_ICFS, "name"); - private static final QName TAG_QNAME = new QName(SchemaConstantsGenerated.NS_COMMON, "tag"); - private static final File FILTER_AND_GENERIC_FILE = new File(TEST_DIR, "filter-and-generic.xml"); private static final File FILTER_ACCOUNT_FILE = new File(TEST_DIR, "filter-account.xml"); private static final File FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_FILE = new File(TEST_DIR, @@ -82,8 +82,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testAccountFilter() throws Exception { - displayTestTitle("testAccountFilter"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -135,8 +133,6 @@ public void testAccountFilter() throws Exception { @Test public void testAccountQueryAttributesAndResource() throws Exception { - displayTestTitle("testAccountQueryAttributesAndResource"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -157,14 +153,10 @@ public void testAccountQueryAttributesAndResource() throws Exception { QueryType convertedQueryType = toQueryType(query); LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test public void testAccountQueryAttributesAndResourceNoNs() throws Exception { - displayTestTitle("testAccountQueryAttributesAndResourceNoNs"); - SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_NO_NS_FILE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -185,14 +177,10 @@ public void testAccountQueryAttributesAndResourceNoNs() throws Exception { QueryType convertedQueryType = toQueryType(query); System.out.println(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test public void testAccountQueryCompositeOr() throws Exception { - displayTestTitle("testAccountQueryCompositeOr"); - SearchFilterType filterType = unmarshalFilter(FILTER_OR_COMPOSITE); ObjectQuery query = toObjectQuery(ShadowType.class, filterType); displayQuery(query); @@ -223,13 +211,10 @@ public void testAccountQueryCompositeOr() throws Exception { QueryType convertedQueryType = toQueryType(query); LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext()))); - - // TODO: add some asserts } @Test public void testConnectorQuery() throws Exception { - displayTestTitle("testConnectorQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_CONNECTOR_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { @@ -257,7 +242,6 @@ private PrismObjectDefinition getUserDefinition(){ @Test public void testTypeFilterQuery() throws Exception { - displayTestTitle("testConnectorQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { @@ -275,9 +259,6 @@ public void testTypeFilterQuery() throws Exception { PrismPropertyDefinition ppd = getUserDefinition().findPropertyDefinition(namePath); PrismAsserts.assertEqualsFilter(typeFilter.getFilter(), ppd.getItemName(), ppd.getTypeName(), namePath); PrismAsserts.assertEqualsFilterValue((EqualFilter) typeFilter.getFilter(), PrismTestUtil.createPolyString("some name identificator")); -// PrismAsserts.assertEqualsFilter(query.getFilter(), ConnectorType.F_CONNECTOR_TYPE, DOMUtil.XSD_STRING, -// prismContext.path(ConnectorType.F_CONNECTOR_TYPE)); -// PrismAsserts.assertEqualsFilterValue((EqualsFilter) filter, "org.identityconnectors.ldap.LdapConnector"); QueryType convertedQueryType = toQueryType(query); displayQueryType(convertedQueryType); @@ -290,7 +271,6 @@ public void testTypeFilterQuery() throws Exception { @Test public void testShadowKindTypeQuery() throws Exception { - displayTestTitle("testShadowKindTypeQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { @@ -324,8 +304,6 @@ private void assertRefFilterValue(RefFilter filter, String oid) { PrismReferenceValue val = (PrismReferenceValue) values.get(0); assertEquals(oid, val.getOid()); - // TODO: maybe some more asserts for type, relation and other reference - // values } private ObjectQuery toObjectQuery(Class type, QueryType queryType) throws Exception { @@ -360,8 +338,6 @@ private String toXml(QueryType q1jaxb) throws SchemaException { @Test public void testGenericQuery() throws Exception { - displayTestTitle("testGenericQuery"); - SearchFilterType queryType = unmarshalFilter(FILTER_AND_GENERIC_FILE); ObjectQuery query = toObjectQuery(GenericObjectType.class, queryType); @@ -390,8 +366,6 @@ public void testGenericQuery() throws Exception { @Test public void testUserQuery() throws Exception { - displayTestTitle("testUserQuery"); - File[] userQueriesToTest = new File[] { new File(TEST_DIR, "filter-user-by-fullName.xml"), new File(TEST_DIR, "filter-user-by-name.xml"), new File(TEST_DIR, "filter-user-substring-fullName.xml"), @@ -467,100 +441,81 @@ private void checkQueryRoundtrip(Class objectClass, Obj checkQuery(objectClass, q2object, q1xml); } - private void checkQueryRoundtripFile(Class objectClass, ObjectQuery query, String testName) throws Exception { - String fileName = TEST_DIR + "/" + testName + ".xml"; - checkQueryRoundtrip(objectClass, query, FileUtils.readFileToString(new File(fileName))); + private void checkQueryRoundtripFile(Class objectClass, ObjectQuery query) throws Exception { + String fileName = TEST_DIR + "/" + getTestNameShort() + ".xml"; + checkQueryRoundtrip(objectClass, query, + FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); } @Test public void test100All() throws Exception { - final String TEST_NAME = "test100All"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).all().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test110None() throws Exception { - final String TEST_NAME = "test110None"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).none().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test120Undefined() throws Exception { - final String TEST_NAME = "test120Undefined"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class).undefined().build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test200Equal() throws Exception { - final String TEST_NAME = "test200Equal"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).eqPoly("some-name", "somename").matchingOrig() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test210EqualMultiple() throws Exception { - final String TEST_NAME = "test210EqualMultiple"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).eq("STD", "TEMP") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test220EqualRightHandItem() throws Exception { - final String TEST_NAME = "test220EqualRightHandItem"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_NUMBER).eq().item(UserType.F_COST_CENTER) .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test300Greater() throws Exception { - final String TEST_NAME = "test300Greater"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).gt("100000") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test305GreaterLesserMatchingNorm() throws Exception { - final String TEST_NAME = "test305GreaterLesserMatchingNorm"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_NAME).ge(new PolyString("00", "00")).matchingNorm() .and().item(UserType.F_NAME).lt(new PolyString("0a", "0a")).matchingNorm() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test305GreaterOrEqual() throws Exception { - final String TEST_NAME = "test305GreaterOrEqual"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).ge("100000") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test310AllComparisons() throws Exception { - final String TEST_NAME = "test310AllComparisons"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_COST_CENTER).gt("100000") .and().item(UserType.F_COST_CENTER).lt("999999") @@ -568,27 +523,22 @@ public void test310AllComparisons() throws Exception { .item(UserType.F_COST_CENTER).ge("X100") .and().item(UserType.F_COST_CENTER).le("X999") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test350Substring() throws Exception { - final String TEST_NAME = "test350Substring"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE).contains("A") .or().item(UserType.F_EMPLOYEE_TYPE).startsWith("B") .or().item(UserType.F_EMPLOYEE_TYPE).endsWith("C") .or().item(UserType.F_NAME).startsWithPoly("john", "john").matchingOrig() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test360Ref() throws Exception { - final String TEST_NAME = "test360Ref"; - displayTestTitle(TEST_NAME); - // we test only parsing here, as there are more serialized forms used here ObjectQuery q1object = getPrismContext().queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref("oid1") @@ -598,7 +548,9 @@ public void test360Ref() throws Exception { .build(); q1object.getFilter().checkConsistence(true); - String q2xml = FileUtils.readFileToString(new File(TEST_DIR + "/" + TEST_NAME + ".xml")); + String q2xml = FileUtils.readFileToString( + new File(TEST_DIR + "/" + getTestNameShort() + ".xml"), + StandardCharsets.UTF_8); displayQueryXml(q2xml); QueryType q2jaxb = toQueryType(q2xml); displayQueryType(q2jaxb); @@ -616,8 +568,6 @@ public void test360Ref() throws Exception { @Test public void test365RefTwoWay() throws Exception { - final String TEST_NAME = "test365RefTwoWay"; - displayTestTitle(TEST_NAME); PrismReferenceValue reference3 = getPrismContext().itemFactory().createReferenceValue("oid3", ResourceType.COMPLEX_TYPE).relation(new QName("test")); PrismReferenceValue reference4 = getPrismContext().itemFactory().createReferenceValue("oid4", ResourceType.COMPLEX_TYPE).relation(new QName("test")); ObjectQuery q = getPrismContext().queryFor(ShadowType.class) @@ -625,38 +575,29 @@ public void test365RefTwoWay() throws Exception { .or().item(ShadowType.F_RESOURCE_REF).ref("oid2", ResourceType.COMPLEX_TYPE) .or().item(ShadowType.F_RESOURCE_REF).ref(reference3, reference4) .build(); - checkQueryRoundtripFile(ShadowType.class, q, TEST_NAME); + checkQueryRoundtripFile(ShadowType.class, q); } @Test public void test400OrgFilterRoot() throws Exception { - final String TEST_NAME = "test400OrgFilterRoot"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isRoot().build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test410OrgFilterSubtree() throws Exception { - final String TEST_NAME = "test410OrgFilterSubtree"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isChildOf("111").build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test420OrgFilterDirect() throws Exception { - final String TEST_NAME = "test420OrgFilterDirect"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(OrgType.class).isDirectChildOf("222").build(); - checkQueryRoundtripFile(OrgType.class, q, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, q); } @Test public void test430OrgFilterDefaultScope() throws Exception { - final String TEST_NAME = "test430OrgFilterDefaultScope"; - displayTestTitle(TEST_NAME); - // default scope is SUBTREE String queryXml = "\n" + " \n" + @@ -672,44 +613,36 @@ public void test430OrgFilterDefaultScope() throws Exception { assertEquals("Parsed query is wrong", expectedQuery.toString(), query.toString()); // primitive way of comparing queries // now reserialize the parsed query and compare with XML - the XML contains explicit scope=SUBTREE (as this is set when parsing original queryXml) - checkQueryRoundtripFile(OrgType.class, query, TEST_NAME); + checkQueryRoundtripFile(OrgType.class, query); } @Test public void test500InOid() throws Exception { - final String TEST_NAME = "test500InOid"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id("oid1", "oid2", "oid3") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test505InOidEmpty() throws Exception { - final String TEST_NAME = "test505InOidEmpty"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id(new String[0]) .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test510InOidContainer() throws Exception { - final String TEST_NAME = "test510InOidContainer"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .id(1, 2, 3) .and().ownerId("oid4") .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test590Logicals() throws Exception { - final String TEST_NAME = "test590Logicals"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .block() .all() @@ -724,13 +657,11 @@ public void test590Logicals() throws Exception { .and().undefined() .endBlock() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test595Logicals2() throws Exception { - final String TEST_NAME = "test595Logicals2"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(UserType.class) .item(UserType.F_DESCRIPTION).eq("A") .and().item(UserType.F_DESCRIPTION).eq("B") @@ -744,24 +675,20 @@ public void test595Logicals2() throws Exception { .endBlock() .build(); - checkQueryRoundtripFile(UserType.class, q, TEST_NAME); + checkQueryRoundtripFile(UserType.class, q); } @Test public void test600Type() throws Exception { - final String TEST_NAME = "test600Type"; - displayTestTitle(TEST_NAME); ObjectQuery q = getPrismContext().queryFor(ObjectType.class) .type(UserType.class) .item(UserType.F_NAME).eqPoly("somename", "somename") .build(); - checkQueryRoundtripFile(ObjectType.class, q, TEST_NAME); + checkQueryRoundtripFile(ObjectType.class, q); } @Test public void test700Exists() throws Exception { - final String TEST_NAME = "test700Exists"; - displayTestTitle(TEST_NAME); PrismReferenceValue ownerRef = ObjectTypeUtil.createObjectRef("1234567890", ObjectTypes.USER).asReferenceValue(); ObjectQuery q = getPrismContext().queryFor(AccessCertificationCaseType.class) .exists(new ParentPathSegment()) // if using T_PARENT then toString representation of paths is different @@ -772,7 +699,7 @@ public void test700Exists() throws Exception { .and().exists(AccessCertificationCaseType.F_WORK_ITEM) .item(AccessCertificationWorkItemType.F_STAGE_NUMBER).eq(3) .build(); - checkQueryRoundtripFile(AccessCertificationCaseType.class, q, TEST_NAME); + checkQueryRoundtripFile(AccessCertificationCaseType.class, q); } @Test @@ -780,7 +707,7 @@ public void test900TypeWrong() throws Exception { final String TEST_NAME = "test900TypeWrong"; String fileName = TEST_DIR + "/" + TEST_NAME + ".xml"; try { - toQueryType(FileUtils.readFileToString(new File(fileName))); + toQueryType(FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); fail("Unexpected success!"); } catch (SchemaException e) { System.out.println("Got expected exception: " + e.getMessage()); @@ -791,7 +718,8 @@ public void test900TypeWrong() throws Exception { public void test910TypeWrongCompat() throws Exception { final String TEST_NAME = "test900TypeWrong"; String fileName = TEST_DIR + "/" + TEST_NAME + ".xml"; - QueryType jaxb = toQueryTypeCompat(FileUtils.readFileToString(new File(fileName))); + QueryType jaxb = toQueryTypeCompat( + FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)); displayQueryType(jaxb); try { ObjectQuery query = toObjectQuery(ObjectType.class, jaxb); @@ -806,7 +734,6 @@ public void test910TypeWrongCompat() throws Exception { @Test public void test920QueryTypeEquals() throws Exception { - final String TEST_NAME = "test920QueryTypeEquals"; ObjectQuery query1 = getPrismContext().queryFor(ShadowType.class) .id("8657eccf-c60d-4b5c-bbd4-4c73ecfd6436") .and().item(ShadowType.F_RESOURCE_REF).ref("aeff994e-381a-4fb3-af3b-f0f5dcdc9653") diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java index adc7bc7bc24..8f1fb352996 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaDelta.java @@ -40,7 +40,6 @@ public class TestSchemaDelta extends AbstractSchemaTest { @Test public void testAssignmentNullIdApplyToObject() throws Exception { final String TEST_NAME = "testAssignmentNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -67,7 +66,6 @@ public void testAssignmentNullIdApplyToObject() throws Exception { @Test public void testAddInducementNullIdApplyToObject() throws Exception { final String TEST_NAME = "testAddInducementNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -94,7 +92,6 @@ public void testAddInducementNullIdApplyToObject() throws Exception { @Test public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdSameValueApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -126,7 +123,6 @@ public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception @Test public void testDeleteInducementValidIdEmptyValueApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -153,7 +149,6 @@ public void testDeleteInducementValidIdEmptyValueApplyToObject() throws Exceptio @Test public void testDeleteInducementValidIdEmptyValueApplyToObjectStatic() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObjectStatic"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -182,7 +177,6 @@ public void testDeleteInducementValidIdEmptyValueApplyToObjectStatic() throws Ex @Test public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementConstructionSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -221,7 +215,6 @@ public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exc @Test public void testDeleteInducementActivationSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementActivationSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); @@ -256,7 +249,6 @@ public void testDeleteInducementActivationSameNullIdApplyToObject() throws Excep @Test public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws Exception { final String TEST_NAME = "testDeleteUserAssignmentActivationSameNullIdApplyToObject"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -295,7 +287,6 @@ public void testDeleteUserAssignmentActivationSameNullIdApplyToObject() throws E @Test public void testAddAssignmentSameOidDifferentTargetType() throws Exception { final String TEST_NAME = "testAddAssignmentSameOidDifferentTargetType"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = new UserType(getPrismContext()) @@ -325,7 +316,6 @@ public void testAddAssignmentSameOidDifferentTargetType() throws Exception { @Test public void testSubtractAssignmentFromAddDelta() throws Exception { final String TEST_NAME = "testSubtractAssignmentFromAddDelta"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -359,7 +349,6 @@ public void testSubtractAssignmentFromAddDelta() throws Exception { @Test public void testSubtractAssignmentFromModifyDelta() throws Exception { final String TEST_NAME = "testSubtractAssignmentFromModifyDelta"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -400,7 +389,6 @@ public void testSubtractAssignmentFromModifyDelta() throws Exception { @Test public void testFactorAddDeltaForItem() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItem"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -434,7 +422,6 @@ private void assertDeltaOid(ObjectDelta delta, String expectedOid) { @Test public void testFactorAddDeltaForItems() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItems"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -462,7 +449,6 @@ public void testFactorAddDeltaForItems() throws Exception { @Test public void testFactorAddDeltaForItemValues() throws Exception { final String TEST_NAME = "testFactorAddDeltaForItemValues"; - displayTestTile(TEST_NAME); // GIVEN PrismObject user = PrismTestUtil.parseObject(USER_BILL_FILE); @@ -492,7 +478,6 @@ public void testFactorAddDeltaForItemValues() throws Exception { @Test public void testFactorModifyDeltaForItem() throws Exception { final String TEST_NAME = "testFactorModifyDeltaForItem"; - displayTestTile(TEST_NAME); // GIVEN String OID = "oid1"; @@ -524,7 +509,6 @@ public void testFactorModifyDeltaForItem() throws Exception { @Test public void testFactorModifyDeltaForItemValues() throws Exception { final String TEST_NAME = "testFactorModifyDeltaForItemValues"; - displayTestTile(TEST_NAME); // GIVEN String OID = "oid1"; @@ -573,7 +557,6 @@ public void testFactorModifyDeltaForItemValues() throws Exception { @Test // MID-4690 public void testObjectDeltaUnion() throws Exception { final String TEST_NAME="testObjectDeltaUnion"; - displayTestTile(TEST_NAME); // GIVEN ProtectedStringType value = new ProtectedStringType(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java index 8292d34c983..f284a2b5497 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaImmutability.java @@ -6,43 +6,29 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; - -import static org.testng.AssertJUnit.assertNotNull; /** * Various tests related to schema immutability, definition cloning, etc. - * */ -public class TestSchemaImmutability { +public class TestSchemaImmutability extends AbstractSchemaTest { private static final File TEST_DIR = new File("src/test/resources/schema-immutability"); private static final File RESOURCE_DUMMY_VAULT_FILE = new File(TEST_DIR, "resource-dummy-vault.xml"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testUltraDeepCloning() throws Exception { - System.out.println("===[ testUltraDeepCloning ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); PrismObject resource = prismContext.parseObject(RESOURCE_DUMMY_VAULT_FILE); @@ -55,7 +41,7 @@ public void testUltraDeepCloning() throws Exception { System.out.println("schemaHandling definition:\n" + schemaHandling.getDefinition().debugDump()); PrismAsserts.assertImmutable(schemaHandling.getDefinition()); - Item testConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); + Item testConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); assertNotNull("No testConnection capability", testConnection); assertNotNull("No testConnection capability definition", testConnection.getDefinition()); System.out.println("testConnection capability definition:\n" + testConnection.getDefinition().debugDump()); @@ -77,7 +63,7 @@ public void testUltraDeepCloning() throws Exception { System.out.println("Updated schemaHandling definition:\n" + updatedSchemaHandling.getDefinition().debugDump()); PrismAsserts.assertMutable(updatedSchemaHandling.getDefinition()); - Item updatedTestConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); + Item updatedTestConnection = resource.findItem(ItemPath.create(ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, "testConnection")); assertNotNull("No updated testConnection capability", updatedTestConnection); assertNotNull("No updated testConnection capability definition", updatedTestConnection.getDefinition()); System.out.println("Updated testConnection capability definition:\n" + updatedTestConnection.getDefinition().debugDump()); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java index 3b3a8cfed19..194b5c23ec4 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaRegistry.java @@ -6,47 +6,33 @@ */ package com.evolveum.midpoint.schema; +import static org.testng.AssertJUnit.*; + +import java.io.IOException; +import java.util.List; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.Validator; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.impl.schema.SchemaRegistryImpl; -import com.evolveum.midpoint.schema.constants.SchemaConstants; - import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; - -import java.io.IOException; -import java.util.List; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -/** - * @author Radovan Semancik - */ -public class TestSchemaRegistry { +public class TestSchemaRegistry extends AbstractUnitTest { @SuppressWarnings("unused") // for the future private static final String FOO_NAMESPACE = "http://example.com/xml/ns/foo"; @@ -78,7 +64,6 @@ public void testBasic() throws SAXException, IOException, SchemaException { // System.out.println(DOMUtil.serializeDOMToString(validationResult.getNode())); } - @Test public void testCommonSchema() throws SchemaException, SAXException, IOException { @@ -118,8 +103,6 @@ public void testReferenceInExtension() throws SchemaException, SAXException, IOE @Test public void testUserType() throws Exception { - System.out.println("===[ testUserType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -159,8 +142,6 @@ public void testUserType() throws Exception { @Test public void testRoleType() throws Exception { - System.out.println("\n\n===[ testRoleType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -195,8 +176,6 @@ public void testRoleType() throws Exception { @Test public void testAbstractRoleType() throws Exception { - System.out.println("\n\n===[ testAbstractRoleType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -233,8 +212,6 @@ public void testAbstractRoleType() throws Exception { @Test public void testCommonSchemaShadowType() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testCommonSchemaShadowType ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -257,21 +234,19 @@ public void testCommonSchemaShadowType() throws SchemaException, SAXException, I assertTrue("'attributes' definition is not marked as runtime", attributesDef.isRuntimeSchema()); List schemaMigrations = shadowDef.getSchemaMigrations(); - System.out.println("\nshadow schema migrations ("+schemaMigrations.size()+"):"); + System.out.println("\nshadow schema migrations (" + schemaMigrations.size() + "):"); System.out.println(DebugUtil.debugDump(schemaMigrations)); assertEquals("Wrong number of schema migrations in shadow definition", 1, schemaMigrations.size()); ComplexTypeDefinition shadowTypeDef = shadowDef.getComplexTypeDefinition(); List shadowTypeSchemaMigrations = shadowTypeDef.getSchemaMigrations(); - System.out.println("\nShadowType schema migrations ("+shadowTypeSchemaMigrations.size()+"):"); + System.out.println("\nShadowType schema migrations (" + shadowTypeSchemaMigrations.size() + "):"); System.out.println(DebugUtil.debugDump(shadowTypeSchemaMigrations)); assertEquals("Wrong number of schema migrations in ShadowType definition", 4, shadowTypeSchemaMigrations.size()); } @Test public void testCommonSchemaLegacyAccount() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testCommonSchemaLegacyAccount ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); @@ -280,15 +255,13 @@ public void testCommonSchemaLegacyAccount() throws SchemaException, SAXException assertNotNull("No definition for legacy account", accountDef); System.out.println("\naccount definition:"); System.out.println(accountDef.debugDump(1)); - assertTrue("Expected object definition for legacy account, but got "+accountDef, accountDef instanceof PrismObjectDefinition); + assertTrue("Expected object definition for legacy account, but got " + accountDef, accountDef instanceof PrismObjectDefinition); assertEquals("Unexpected element name in legacy account definition", SchemaConstants.C_SHADOW, accountDef.getItemName()); } @Test public void testAuditTimestampDocumentation() throws SchemaException, SAXException, IOException { - System.out.println("\n\n===[ testAuditTimestampDocumentation ]==="); - MidPointPrismContextFactory factory = getContextFactory(); PrismContext context = factory.createInitializedPrismContext(); SchemaRegistry schemaRegistry = context.getSchemaRegistry(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java index 6d153fd6837..b5ca82e3199 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSchemaSanity.java @@ -6,32 +6,16 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.EXTENSION_LOCATIONS_TYPE; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES_TYPE; -import static com.evolveum.midpoint.schema.util.SchemaTestConstants.NS_ICFC; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.schema.util.SchemaTestConstants.*; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import com.evolveum.midpoint.prism.ComplexTypeDefinition; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; + +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -42,37 +26,17 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.SchemaTestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAttributesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType; /** * @author semancik - * */ -public class TestSchemaSanity { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestSchemaSanity extends AbstractSchemaTest { @Test public void testPrefixMappings() { - System.out.println("===[ testPrefixMappings ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); assertNotNull("No prism context", prismContext); @@ -95,31 +59,27 @@ public void testPrefixMappings() { assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "", cBarQNameWithPrefix); QName cBarQNameWithPrefixExplixit = prefixMapper.setQNamePrefixExplicit(cBarQName); assertQName("common namespace implicit", SchemaConstantsGenerated.NS_COMMON, "bar", "c", cBarQNameWithPrefixExplixit); - } private void assertQName(String message, String expectedNamespace, String expectedLocalName, String expectedPrefix, QName actual) { - assertEquals("Wrong qname namespace in "+message, expectedNamespace, actual.getNamespaceURI()); - assertEquals("Wrong qname local part in "+message, expectedLocalName, actual.getLocalPart()); - assertEquals("Wrong qname prefix in "+message, expectedPrefix, actual.getPrefix()); - + assertEquals("Wrong qname namespace in " + message, expectedNamespace, actual.getNamespaceURI()); + assertEquals("Wrong qname local part in " + message, expectedLocalName, actual.getLocalPart()); + assertEquals("Wrong qname prefix in " + message, expectedPrefix, actual.getPrefix()); } private void assertMapping(DynamicNamespacePrefixMapper prefixMapper, String namespace, String prefix) { - assertEquals("Wrong prefix mapping for namespace "+namespace, prefix, prefixMapper.getPrefix(namespace)); + assertEquals("Wrong prefix mapping for namespace " + namespace, prefix, prefixMapper.getPrefix(namespace)); } @Test public void testUserDefinition() { - System.out.println("===[ testUserDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); // WHEN - PrismObjectDefinition userDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON,"user")); + PrismObjectDefinition userDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "user")); // THEN assertNotNull("No user definition", userDefinition); @@ -134,8 +94,6 @@ public void testUserDefinition() { @Test public void testAccountDefinition() { - System.out.println("===[ testAccountDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -148,7 +106,7 @@ public void testAccountDefinition() { System.out.println(accountDefinition.debugDump()); PrismObjectDefinition accountDefinitionByClass = - schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class); + schemaRegistry.findObjectDefinitionByCompileTimeClass(ShadowType.class); assertTrue("Different account def", accountDefinition == accountDefinitionByClass); assertEquals("Wrong compile-time class in account definition", ShadowType.class, accountDefinition.getCompileTimeClass()); @@ -162,11 +120,8 @@ public void testAccountDefinition() { assertEquals("Wrong attributes compile-time class", ShadowAttributesType.class, attributesContainer.getCompileTimeClass()); } - @Test public void testResourceDefinition() { - System.out.println("===[ testResourceDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -179,7 +134,7 @@ public void testResourceDefinition() { System.out.println(resourceDefinition.debugDump()); PrismObjectDefinition resourceDefinitionByClass = - schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class); + schemaRegistry.findObjectDefinitionByCompileTimeClass(ResourceType.class); assertTrue("Different user def", resourceDefinition == resourceDefinitionByClass); assertEquals("Wrong compile-time class in resource definition", ResourceType.class, resourceDefinition.getCompileTimeClass()); @@ -190,7 +145,6 @@ public void testResourceDefinition() { PrismContainerDefinition connectorConfContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION); PrismAsserts.assertDefinition(connectorConfContainerDef, ResourceType.F_CONNECTOR_CONFIGURATION, ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); assertTrue(" is NOT dynamic", connectorConfContainerDef.isDynamic()); -// assertFalse(" is runtime", connectorConfContainerDef.isRuntimeSchema()); assertEquals("Wrong compile-time class for in resource definition", ConnectorConfigurationType.class, connectorConfContainerDef.getCompileTimeClass()); PrismContainerDefinition schemaContainerDef = resourceDefinition.findContainerDefinition(ResourceType.F_SCHEMA); @@ -203,13 +157,10 @@ public void testResourceDefinition() { PrismAsserts.assertPropertyDefinition(schemaContainerDef, XmlSchemaType.F_DEFINITION, SchemaDefinitionType.COMPLEX_TYPE, 0, 1); PrismPropertyDefinition definitionPropertyDef = schemaContainerDef.findPropertyDefinition(XmlSchemaType.F_DEFINITION); assertNotNull("Null definition", definitionPropertyDef); -// assertFalse("schema/definition is NOT runtime", definitionPropertyDef.isRuntimeSchema()); } @Test public void testResourceConfigurationDefinition() { - System.out.println("===[ testResourceConfigurationDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -222,23 +173,16 @@ public void testResourceConfigurationDefinition() { System.out.println(configurationPropertiesDefinition.debugDump()); assertTrue("configurationProperties definition is NOT marked as runtime", configurationPropertiesDefinition.isRuntimeSchema()); -// assertNull("Unexpected compile-time class in configurationProperties definition", configurationPropertiesDefinition.getCompileTimeClass()); - -// assertTrue("configurationProperties definition is NOT marked as wildcard", configurationPropertiesDefinition.isWildcard()); - - // TODO } @Test public void testRoleDefinition() { - System.out.println("===[ testRoleDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); // WHEN - PrismObjectDefinition roleDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON,"role")); + PrismObjectDefinition roleDefinition = schemaRegistry.findObjectDefinitionByElementName(new QName(SchemaConstantsGenerated.NS_COMMON, "role")); // THEN assertNotNull("No role definition", roleDefinition); @@ -260,8 +204,6 @@ public void testRoleDefinition() { @Test public void testFocusDefinition() { - System.out.println("===[ testFocusDefinition ]==="); - // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry(); @@ -279,8 +221,6 @@ public void testFocusDefinition() { @Test public void testIcfSchema() { - System.out.println("===[ testIcfSchema ]==="); - // WHEN // The context should have parsed common schema and also other midPoint schemas PrismContext prismContext = PrismTestUtil.getPrismContext(); @@ -296,12 +236,10 @@ public void testIcfSchema() { System.out.println("ICF schema:"); System.out.println(icfSchema.debugDump()); - PrismContainerDefinition configurationPropertiesContainerDef = icfSchema.findContainerDefinitionByElementName(ICFC_CONFIGURATION_PROPERTIES); PrismAsserts.assertDefinition(configurationPropertiesContainerDef, ICFC_CONFIGURATION_PROPERTIES, ICFC_CONFIGURATION_PROPERTIES_TYPE, 0, 1); assertTrue("configurationPropertiesContainer definition is NOT marked as runtime", configurationPropertiesContainerDef.isRuntimeSchema()); assertTrue("configurationPropertiesContainer definition is NOT marked as dynamic", configurationPropertiesContainerDef.isDynamic()); - } /** @@ -309,8 +247,6 @@ public void testIcfSchema() { */ @Test public void testExtensionSchema() { - System.out.println("===[ testExtensionSchema ]==="); - // WHEN PrismContext prismContext = PrismTestUtil.getPrismContext(); assertNotNull("No prism context", prismContext); @@ -322,7 +258,6 @@ public void testExtensionSchema() { System.out.println("Extension schema:"); System.out.println(extensionSchema.debugDump()); - PrismPropertyDefinition locationsProperty = extensionSchema.findPropertyDefinitionByElementName(EXTENSION_LOCATIONS_ELEMENT); PrismAsserts.assertDefinition(locationsProperty, EXTENSION_LOCATIONS_ELEMENT, EXTENSION_LOCATIONS_TYPE, 0, -1); } @@ -331,5 +266,4 @@ public static void assertPropertyValue(PrismContainer container, String propN ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName); PrismAsserts.assertPropertyValue(container, propQName, propValue); } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java index 2d6a7b0bb49..622a631c7a6 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/TestSerialization.java @@ -6,50 +6,34 @@ */ package com.evolveum.midpoint.schema; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.impl.DefaultReferencableImpl; import com.evolveum.midpoint.prism.impl.PrismReferenceValueImpl; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.LocalizationUtil; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.SerializationUtil; import com.evolveum.midpoint.util.SingleLocalizableMessage; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteCredentialResetResponseType; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - import com.evolveum.prism.xml.ns._public.types_3.DeltaSetTripleType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; - /** * @author semancik - * */ -public class TestSerialization { - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } +public class TestSerialization extends AbstractSchemaTest { @Test public void testSerializeTrace() throws Exception { - System.out.println("===[ testSerializeTrace ]==="); - PrismContext prismContext = getPrismContext(); ValueTransformationTraceType trace = new ValueTransformationTraceType(prismContext); NamedValueType input1 = new NamedValueType(); @@ -63,8 +47,6 @@ public void testSerializeTrace() throws Exception { @Test public void testSerializeDeltaSetTripleType() throws Exception { - System.out.println("===[ testSerializeDeltaSetTripleType ]==="); - PrismContext prismContext = getPrismContext(); PrismReferenceValue refValue = new PrismReferenceValueImpl("123456"); @@ -79,8 +61,6 @@ public void testSerializeDeltaSetTripleType() throws Exception { @Test public void testSerializeNamedReference() throws Exception { - System.out.println("===[ testSerializeNamedReference ]==="); - PrismContext prismContext = getPrismContext(); ObjectReferenceType reference = new ObjectReferenceType() .oid("66662a3b-76eb-4465-8374-742f6e2f54b4") @@ -93,8 +73,6 @@ public void testSerializeNamedReference() throws Exception { @Test public void testSerializeFullReference() throws Exception { - System.out.println("===[ testSerializeFullReference ]==="); - PrismContext prismContext = getPrismContext(); QName fakeQName = new QName(PrismConstants.NS_TYPES, "ref"); @@ -115,8 +93,6 @@ public void testSerializeFullReference() throws Exception { @Test public void testSerializeMessage() throws Exception { - System.out.println("===[ testSerializeMessage ]==="); - PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); LocalizableMessageType localizableMessageBean = LocalizationUtil.createLocalizableMessageType(localizableMessage); @@ -127,8 +103,6 @@ public void testSerializeMessage() throws Exception { @Test public void testSerializeExecuteCredentialResetResponseType() throws Exception { - System.out.println("===[ testSerializeExecuteCredentialResetResponseType ]==="); - PrismContext prismContext = getPrismContext(); SingleLocalizableMessage localizableMessage = new SingleLocalizableMessage("execute.reset.credential.bad.request", null, "Failed to execute reset password. Bad request."); @@ -145,22 +119,16 @@ public void testSerializeExecuteCredentialResetResponseType() throws Exception { @Test public void testSerializeResource() throws Exception { - System.out.println("===[ testSerializeResource ]==="); - serializationRoundTrip(TestConstants.RESOURCE_FILE); } @Test public void testSerializeUser() throws Exception { - System.out.println("===[ testSerializeUser ]==="); - serializationRoundTrip(TestConstants.USER_FILE); } @Test public void testSerializeRole() throws Exception { - System.out.println("===[ testSerializeRole ]==="); - PrismContext prismContext = getPrismContext(); PrismObject parsedObject = prismContext.parseObject(TestConstants.ROLE_FILE); @@ -205,7 +173,7 @@ private void serializationRoundTripPrismObject(PrismObjec deserializedObject.revive(getPrismContext()); ObjectDelta diff = parsedObject.diff(deserializedObject); - assertTrue("Something changed in serialization of "+parsedObject+" (PrismObject): "+diff, diff.isEmpty()); + assertTrue("Something changed in serialization of " + parsedObject + " (PrismObject): " + diff, diff.isEmpty()); ItemDefinition nameDef = deserializedObject.getDefinition().findLocalItemDefinition(ObjectType.F_NAME); assertNotNull("No 'name' definition in deserialized object", nameDef); @@ -225,7 +193,7 @@ private void serializationRoundTripObjectType(O parsedObj System.out.println(deserializedObject.asPrismObject().debugDump()); ObjectDelta diff = parsedObject.asPrismObject().diff((PrismObject) deserializedObject.asPrismObject()); - assertTrue("Something changed in serializetion of "+parsedObject+" (ObjectType): "+diff, diff.isEmpty()); + assertTrue("Something changed in serializetion of " + parsedObject + " (ObjectType): " + diff, diff.isEmpty()); } } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java index ef83789c563..87ee870b134 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/parser/TestParseResource.java @@ -212,9 +212,6 @@ public void testSchemaRoundtrip() throws Exception { @Test public void testParseResourceFileExpression() throws Exception { - final String TEST_NAME = "testParseResourceFileExpression"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); @@ -637,9 +634,6 @@ public void testParseResourceDom() throws Exception { if (!"xml".equals(language)) { return; } - final String TEST_NAME = "testParseResourceDom"; - displayTestTitle(TEST_NAME); - // GIVEN PrismContext prismContext = getPrismContext(); diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java index f2e139bf1ba..77a3861be84 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/processor/TestResourceSchema.java @@ -11,26 +11,27 @@ */ package com.evolveum.midpoint.schema.processor; +import static org.testng.AssertJUnit.*; + import java.io.File; -import java.io.IOException; import java.util.Collection; import java.util.List; +import javax.xml.namespace.QName; + +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.AbstractSchemaTest; import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; @@ -40,21 +41,7 @@ import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.LiveSyncCapabilityType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBException; -import javax.xml.namespace.QName; - -import static org.testng.AssertJUnit.*; - -/** - * @author semancik - */ -public class TestResourceSchema { +public class TestResourceSchema extends AbstractSchemaTest { private static final String TEST_DIR = "src/test/resources/processor/"; @@ -63,18 +50,8 @@ public class TestResourceSchema { private static final String SCHEMA_NAMESPACE = "http://schema.foo.com/bar"; - public TestResourceSchema() { - } - - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testParseSchema() throws Exception { - System.out.println("===[ testParseSchema ]==="); // GIVEN Document schemaDom = DOMUtil.parseFile(RESOURCE_SCHEMA_SIMPLE_FILENAME); @@ -90,7 +67,6 @@ public void testParseSchema() throws Exception { @Test public void testParseSchemaDeprecated() throws Exception { - System.out.println("===[ testParseSchemaDeprecated ]==="); // GIVEN Document schemaDom = DOMUtil.parseFile(RESOURCE_SCHEMA_SIMPLE_DEPRECATED_FILENAME); @@ -137,9 +113,8 @@ private void assertSimpleSchema(ResourceSchema schema, String filename) { } // The support for the xsd:any properties is missing in JAXB generator. Otherwise this test should work. - @Test(enabled=false) - public void testResourceSchemaJaxbRoundTrip() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaJaxbRoundTrip ]====="); + @Test(enabled = false) + public void testResourceSchemaJaxbRoundTrip() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -179,7 +154,6 @@ public void testResourceSchemaJaxbRoundTrip() throws SchemaException, JAXBExcept @Test public void testResourceSchemaPrismRoundTrip() throws SchemaException { - System.out.println("\n===[ testResourceSchemaPrismRoundTrip ]====="); // GIVEN ResourceSchema schema = createResourceSchema(); @@ -227,26 +201,21 @@ public void testResourceSchemaPrismRoundTrip() throws SchemaException { private void assertResourceSchema(ResourceSchema unSchema) { ObjectClassComplexTypeDefinition objectClassDef = unSchema.findObjectClassDefinition(new ItemName(SCHEMA_NAMESPACE, "AccountObjectClass")); assertNotNull("No object class def", objectClassDef); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"AccountObjectClass"),objectClassDef.getTypeName()); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "AccountObjectClass"), objectClassDef.getTypeName()); assertEquals("AccountObjectClass class not an account", ShadowKindType.ACCOUNT, objectClassDef.getKind()); assertTrue("AccountObjectClass class not a DEFAULT account", objectClassDef.isDefaultInAKind()); - PrismPropertyDefinition loginDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE,"login")); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"login"), loginDef.getItemName()); + PrismPropertyDefinition loginDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE, "login")); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "login"), loginDef.getItemName()); assertEquals(DOMUtil.XSD_STRING, loginDef.getTypeName()); - PrismPropertyDefinition passwdDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE,"password")); - assertEquals(new ItemName(SCHEMA_NAMESPACE,"password"), passwdDef.getItemName()); + PrismPropertyDefinition passwdDef = objectClassDef.findPropertyDefinition(new ItemName(SCHEMA_NAMESPACE, "password")); + assertEquals(new ItemName(SCHEMA_NAMESPACE, "password"), passwdDef.getItemName()); assertEquals(ProtectedStringType.COMPLEX_TYPE, passwdDef.getTypeName()); - -// PrismContainerDefinition credDef = objectClassDef.findContainerDefinition(new SingleNamePath(SchemaConstants.NS_C,"credentials")); -// assertEquals(new SingleNamePath(SchemaConstants.NS_C,"credentials"), credDef.getName()); -// assertEquals(new SingleNamePath(SchemaConstants.NS_C,"CredentialsType"), credDef.getTypeName()); } @Test - public void testResourceSchemaSerializationDom() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaSerializationDom ]====="); + public void testResourceSchemaSerializationDom() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -261,8 +230,7 @@ public void testResourceSchemaSerializationDom() throws SchemaException, JAXBExc } @Test - public void testResourceSchemaSerializationInResource() throws SchemaException, JAXBException { - System.out.println("\n===[ testResourceSchemaSerializationInResource ]====="); + public void testResourceSchemaSerializationInResource() throws SchemaException { // GIVEN ResourceSchema schema = createResourceSchema(); @@ -290,10 +258,9 @@ public void testResourceSchemaSerializationInResource() throws SchemaException, assertDomSchema(reparsedXsdElement); } - private PrismObject wrapInResource(Element xsdElement) throws SchemaException { PrismObjectDefinition resourceDefinition = - PrismTestUtil.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); + PrismTestUtil.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); PrismObject resource = resourceDefinition.instantiate(); ResourceTypeUtil.setResourceXsdSchema(resource, xsdElement); return resource; @@ -332,7 +299,7 @@ private ResourceSchema createResourceSchema() { // ... in it ordinary attribute - an identifier ResourceAttributeDefinition icfUidDef = containerDefinition.createAttributeDefinition( SchemaTestConstants.ICFS_UID, DOMUtil.XSD_STRING); - ((Collection)containerDefinition.getPrimaryIdentifiers()).add(icfUidDef); + ((Collection) containerDefinition.getPrimaryIdentifiers()).add(icfUidDef); ResourceAttributeDefinitionImpl xloginDef = containerDefinition.createAttributeDefinition("login", DOMUtil.XSD_STRING); xloginDef.setNativeAttributeName("LOGIN"); containerDefinition.setDisplayNameAttribute(xloginDef.getItemName()); @@ -347,12 +314,11 @@ private ResourceSchema createResourceSchema() { } private void assertPrefix(String expectedPrefix, Element element) { - assertEquals("Wrong prefix on element "+DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); + assertEquals("Wrong prefix on element " + DOMUtil.getQName(element), expectedPrefix, element.getPrefix()); } @Test public void testParseResource() throws Exception { - System.out.println("===[ testParseResource ]==="); // WHEN PrismObject resource = PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")); @@ -362,7 +328,6 @@ public void testParseResource() throws Exception { @Test public void testUnmarshallResource() throws Exception { - System.out.println("===[ testUnmarshallResource ]==="); // WHEN ResourceType resourceType = (ResourceType) PrismTestUtil.parseObject(new File("src/test/resources/common/xml/ns/resource-opendj.xml")).asObjectable(); @@ -370,25 +335,24 @@ public void testUnmarshallResource() throws Exception { assertCapabilities(resourceType); } - private void assertCapabilities(ResourceType resourceType) throws SchemaException { if (resourceType.getCapabilities() != null) { if (resourceType.getCapabilities().getNative() != null) { for (Object capability : resourceType.getCapabilities().getNative().getAny()) { - System.out.println("Native Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } if (resourceType.getCapabilities().getConfigured() != null) { for (Object capability : resourceType.getCapabilities().getConfigured().getAny()) { - System.out.println("Configured Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } } List effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resourceType); for (Object capability : effectiveCapabilities) { - System.out.println("Efective Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } assertNotNull("null native capabilities", resourceType.getCapabilities().getNative()); @@ -399,7 +363,7 @@ private void assertCapabilities(ResourceType resourceType) throws SchemaExceptio assertFalse("empty configured capabilities", resourceType.getCapabilities().getConfigured().getAny().isEmpty()); assertEquals("Unexepected number of configured capabilities", 2, resourceType.getCapabilities().getConfigured().getAny().size()); - assertEquals("Unexepected number of effective capabilities", 3,effectiveCapabilities.size()); + assertEquals("Unexepected number of effective capabilities", 3, effectiveCapabilities.size()); assertNotNull("No credentials effective capability", ResourceTypeUtil.getEffectiveCapability(resourceType, CredentialsCapabilityType.class)); assertNotNull("No activation effective capability", @@ -409,5 +373,4 @@ private void assertCapabilities(ResourceType resourceType) throws SchemaExceptio } - } diff --git a/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java b/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java index be612404261..5e8c981d17b 100644 --- a/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java +++ b/infra/schema/src/test/java/com/evolveum/midpoint/schema/validator/TestObjectValidator.java @@ -42,7 +42,6 @@ public class TestObjectValidator extends AbstractSchemaTest { @Test public void testValidateRoleOneDefault() throws Exception { final String TEST_NAME = "testValidateRoleOneDefault"; - displayTestTile(TEST_NAME); // GIVEN @@ -65,7 +64,6 @@ public void testValidateRoleOneDefault() throws Exception { @Test public void testValidateRoleOneDeprecated() throws Exception { final String TEST_NAME = "testValidateRoleOneDeprecated"; - displayTestTile(TEST_NAME); // GIVEN @@ -93,7 +91,6 @@ public void testValidateRoleOneDeprecated() throws Exception { @Test public void testValidateRoleOneLegacyCompat() throws Exception { final String TEST_NAME = "testValidateRoleOneLegacyCompat"; - displayTestTile(TEST_NAME); // GIVEN @@ -124,7 +121,6 @@ public void testValidateRoleOneLegacyCompat() throws Exception { @Test public void testValidateRoleOneLegacyStrict() throws Exception { final String TEST_NAME = "testValidateRoleOneLegacyStrict"; - displayTestTile(TEST_NAME); // GIVEN diff --git a/infra/schema/src/test/resources/common/filter.xml b/infra/schema/src/test/resources/common/filter.xml index c94276c9575..fb581089734 100644 --- a/infra/schema/src/test/resources/common/filter.xml +++ b/infra/schema/src/test/resources/common/filter.xml @@ -6,13 +6,10 @@ ~ and European Union Public License. See LICENSE file for details. --> - - + ...a filter description... connectorType - - org.identityconnectors.ldap.LdapConnector - + org.identityconnectors.ldap.LdapConnector diff --git a/infra/schema/testng-unit.xml b/infra/schema/testng-unit.xml index 2473cbbde2f..c689f939e08 100644 --- a/infra/schema/testng-unit.xml +++ b/infra/schema/testng-unit.xml @@ -107,7 +107,7 @@ - + @@ -138,6 +138,7 @@ + diff --git a/infra/test-util/pom.xml b/infra/test-util/pom.xml index 24007fc05a2..2a5be4ca36d 100644 --- a/infra/test-util/pom.xml +++ b/infra/test-util/pom.xml @@ -18,7 +18,7 @@ test-util jar - midPoint Infrastructure - testing mock utils + midPoint Infrastructure - testing utils (lvl 2) @@ -61,6 +61,11 @@ org.springframework spring-context + + org.springframework + spring-test + + org.apache.felix @@ -100,8 +105,10 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT - test + + + org.slf4j + slf4j-api org.apache.qpid diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java new file mode 100644 index 00000000000..e2c0f904d23 --- /dev/null +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/AbstractSpringTest.java @@ -0,0 +1,105 @@ +/* + * 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.test.util; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +import org.jetbrains.annotations.Nullable; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.ITestResult; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import com.evolveum.midpoint.tools.testng.MidpointTestContext; +import com.evolveum.midpoint.tools.testng.MidpointTestMixin; +import com.evolveum.midpoint.tools.testng.SimpleMidpointTestContext; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +/** + * Base test class for tests integrated with Spring providing {@link MidpointTestMixin} implementation. + * Can be extended by any unit test class that would otherwise extend + * {@link AbstractTestNGSpringContextTests}. + */ +public abstract class AbstractSpringTest extends AbstractTestNGSpringContextTests + implements MidpointTestMixin { + + /** + * Hides parent's logger, but that one is from commons-logging and we don't want that. + */ + protected final Trace logger = TraceManager.getTrace(getClass()); + + @BeforeMethod + public void startTestContext(ITestResult testResult) { + SimpleMidpointTestContext context = SimpleMidpointTestContext.create(testResult); + displayTestTitle(context.getTestName()); + } + + @AfterMethod + public void finishTestContext(ITestResult testResult) { + SimpleMidpointTestContext context = SimpleMidpointTestContext.get(); + SimpleMidpointTestContext.destroy(); + displayDefaultTestFooter(context.getTestName(), testResult); + } + + @Override + public Trace logger() { + return logger; + } + + @Override + @Nullable + public MidpointTestContext getTestContext() { + return SimpleMidpointTestContext.get(); + } + + /** + * This method null all fields which are not static, final or primitive type. + *

+ * All this is just to make GC work during DirtiesContext after every test class, + * because test class instances are not GCed immediately. + * If they hold autowired fields like sessionFactory (for example + * through SqlRepositoryService impl), their memory footprint is getting big. + *

+ * Note that this does not work for components injected through constructor into + * final fields - if we need this cleanup, make the field non-final. + */ + @AfterClass(alwaysRun = true) + protected void clearClassFields() throws Exception { + logger.trace("Clearing all fields for test class {}", getClass().getName()); + clearClassFields(this, getClass()); + } + + private void clearClassFields(Object object, Class forClass) throws Exception { + if (forClass.getSuperclass() != null) { + clearClassFields(object, forClass.getSuperclass()); + } + + for (Field field : forClass.getDeclaredFields()) { + if (Modifier.isFinal(field.getModifiers()) + || Modifier.isStatic(field.getModifiers()) + || field.getType().isPrimitive()) { + continue; + } + + nullField(object, field); + } + } + + private void nullField(Object obj, Field field) throws Exception { + logger.info("Setting {} to null on {}.", field.getName(), obj.getClass().getSimpleName()); + boolean accessible = field.isAccessible(); +// boolean accessible = field.canAccess(obj); // TODO: after ditching JDK 8 + if (!accessible) { + field.setAccessible(true); + } + field.set(obj, null); + field.setAccessible(accessible); + } +} diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index 910393c8532..e69df1ea4bc 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -7,32 +7,12 @@ package com.evolveum.midpoint.test.util; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrimitiveType; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ObjectFactory; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.TestNameHolder; -import com.evolveum.midpoint.util.JAXBUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.fail; import java.io.BufferedReader; import java.io.File; @@ -41,17 +21,9 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermission; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.GregorianCalendar; -import java.util.HashSet; -import java.util.List; -import java.util.Random; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; @@ -64,12 +36,21 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ObjectFactory; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.util.JAXBUtil; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * Unit test utilities. @@ -80,10 +61,6 @@ public class TestUtil { public static final int MAX_EXCEPTION_MESSAGE_LENGTH = 500; - public static final String TEST_LOG_PREFIX = "=====[ "; - public static final String TEST_LOG_SUFFIX = " ]======================================"; - public static final String TEST_OUT_PREFIX = "\n\n=====[ "; - public static final String TEST_OUT_SUFFIX = " ]======================================\n"; public static final String TEST_OUT_SECTION_PREFIX = "\n\n----- "; public static final String TEST_OUT_SECTION_SUFFIX = " --------------------------------------\n"; public static final String TEST_LOG_SECTION_PREFIX = "----- "; @@ -124,7 +101,7 @@ public static void assertSetEquals(String message, Collection actual, T.. } public static void assertSetEquals(String message, T[] actual, T[] expected) { - assertTrue(message+"expected "+Arrays.toString(expected)+", was "+Arrays.toString(actual), + assertTrue(message + "expected " + Arrays.toString(expected) + ", was " + Arrays.toString(actual), MiscUtil.unorderedArrayEquals(actual, expected)); } @@ -132,7 +109,7 @@ public static String getNodeOid(Node node) { Node oidNode = null; if ((null == node.getAttributes()) || (null == (oidNode = node.getAttributes().getNamedItem( - SchemaConstants.C_OID_ATTRIBUTE.getLocalPart()))) + SchemaConstants.C_OID_ATTRIBUTE.getLocalPart()))) || (StringUtils.isEmpty(oidNode.getNodeValue()))) { return null; } @@ -150,22 +127,22 @@ public static void setAttribute(PrismObject account, QName attrName, } public static void assertElement(List elements, QName elementQName, String value) { - for (Object element: elements) { + for (Object element : elements) { QName thisElementQName = JAXBUtil.getElementQName(element); if (elementQName.equals(thisElementQName)) { if (element instanceof Element) { - String thisElementContent = ((Element)element).getTextContent(); + String thisElementContent = ((Element) element).getTextContent(); if (value.equals(thisElementContent)) { return; } else { - AssertJUnit.fail("Wrong value for element with name "+elementQName+"; expected "+value+"; was "+thisElementContent); + AssertJUnit.fail("Wrong value for element with name " + elementQName + "; expected " + value + "; was " + thisElementContent); } } else { - throw new IllegalArgumentException("Unexpected type of element "+elementQName+": "+element.getClass()); + throw new IllegalArgumentException("Unexpected type of element " + elementQName + ": " + element.getClass()); } } } - AssertJUnit.fail("No element with name "+elementQName); + AssertJUnit.fail("No element with name " + elementQName); } public static void assertExceptionSanity(ObjectAlreadyExistsException e) { @@ -174,40 +151,7 @@ public static void assertExceptionSanity(ObjectAlreadyExistsException e) { System.out.println(ExceptionUtils.getFullStackTrace(e)); assert !e.getMessage().isEmpty() : "Empty exception message"; assert e.getMessage().length() < MAX_EXCEPTION_MESSAGE_LENGTH : "Exception message too long (" - +e.getMessage().length()+" characters): "+e.getMessage(); - } - - public static void displayTestTitle(String testName) { - System.out.println(TEST_OUT_PREFIX + testName + TEST_OUT_SUFFIX); - LOGGER.info(TEST_LOG_PREFIX + testName + TEST_LOG_SUFFIX); - TestNameHolder.setCurrentTestName(testName); - } - - public static void displayTestTitle(Object testCase, String testName) { - String qualifiedTestName = testCase.getClass().getSimpleName() + "." + testName; - System.out.println(TEST_OUT_PREFIX + qualifiedTestName + TEST_OUT_SUFFIX); - LOGGER.info(TEST_LOG_PREFIX + qualifiedTestName + TEST_LOG_SUFFIX); - TestNameHolder.setCurrentTestName(qualifiedTestName); - } - - public static void displayWhen(String testName) { - System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + testName + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + testName + TEST_LOG_SECTION_SUFFIX); - } - - public static void displayWhen(String testName, String part) { - System.out.println(TEST_OUT_SECTION_PREFIX + " WHEN " + testName + " (" + part + ")" + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " WHEN " + testName + " (" + part + ")" + TEST_LOG_SECTION_SUFFIX); - } - - public static void displayThen(String testName) { - System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + TEST_LOG_SECTION_SUFFIX); - } - - public static void displayThen(String testName, String part) { - System.out.println(TEST_OUT_SECTION_PREFIX + " THEN " + testName + " (" + part + ")" + TEST_OUT_SECTION_SUFFIX); - LOGGER.info(TEST_LOG_SECTION_PREFIX + " THEN " + testName + " (" + part + ")" + TEST_LOG_SECTION_SUFFIX); + + e.getMessage().length() + " characters): " + e.getMessage(); } public static void displayCleanup(String testName) { @@ -230,7 +174,7 @@ public static void assertSuccess(String message, OperationResult result, Operati return; } if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) { - String logmsg = message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation(); + String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation(); LOGGER.error(logmsg); LOGGER.trace(logmsg + "\n" + originalResult.debugDump()); System.out.println(logmsg + "\n" + originalResult.debugDump()); @@ -276,7 +220,7 @@ public static void assertSuccess(String message, OperationResult result, int lev } public static void assertSuccess(String message, OperationResult result) { - assertSuccess(message, result,-1); + assertSuccess(message, result, -1); } public static void assertSuccess(OperationResultType result) { @@ -289,23 +233,23 @@ public static void assertSuccess(String message, OperationResultType result) { } assertNotNull(message + ": null result", result); // Ignore top-level if the operation name is not set - if (result.getOperation()!=null) { + if (result.getOperation() != null) { if (result.getStatus() == null || result.getStatus() == OperationResultStatusType.UNKNOWN) { - fail(message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation()); + fail(message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation()); } if (result.getStatus() != OperationResultStatusType.SUCCESS && result.getStatus() != OperationResultStatusType.NOT_APPLICABLE && result.getStatus() != OperationResultStatusType.HANDLED_ERROR) { - fail(message + ": " + result.getMessage() + " ("+result.getStatus()+")"); + fail(message + ": " + result.getMessage() + " (" + result.getStatus() + ")"); } } List partialResults = result.getPartialResults(); for (OperationResultType subResult : partialResults) { - if (subResult==null) { - fail(message+": null subresult under operation "+result.getOperation()); + if (subResult == null) { + fail(message + ": null subresult under operation " + result.getOperation()); } - if (subResult.getOperation()==null) { - fail(message+": null subresult operation under operation "+result.getOperation()); + if (subResult.getOperation() == null) { + fail(message + ": null subresult operation under operation " + result.getOperation()); } assertSuccess(message, subResult); } @@ -313,51 +257,51 @@ public static void assertSuccess(String message, OperationResultType result) { public static void assertInProgressOrSuccess(OperationResult result) { if (!result.isInProgress()) { - assertSuccess("Operation "+result.getOperation()+" result", result); + assertSuccess("Operation " + result.getOperation() + " result", result); } } public static void assertSuccess(OperationResult result) { - assertSuccess("Operation "+result.getOperation()+" result", result); + assertSuccess("Operation " + result.getOperation() + " result", result); } public static void assertSuccess(OperationResult result, int depth) { - assertSuccess("Operation "+result.getOperation()+" result", result, depth); + assertSuccess("Operation " + result.getOperation() + " result", result, depth); } public static void assertStatus(OperationResult result, OperationResultStatus expectedStatus) { - assertEquals("Operation "+result.getOperation()+" result", expectedStatus, result.getStatus()); + assertEquals("Operation " + result.getOperation() + " result", expectedStatus, result.getStatus()); } public static void assertStatus(OperationResultType result, OperationResultStatusType expectedStatus) { - assertEquals("Operation "+result.getOperation()+" result", expectedStatus, result.getStatus()); + assertEquals("Operation " + result.getOperation() + " result", expectedStatus, result.getStatus()); } public static boolean hasWarningAssertSuccess(String message, OperationResultType result) { boolean hasWarning = false; // Ignore top-level if the operation name is not set - if (result.getOperation()!=null) { + if (result.getOperation() != null) { if (result.getStatus() == OperationResultStatusType.WARNING) { // Do not descent into warnings. There may be lions inside. Or errors. return true; } else { if (result.getStatus() == null || result.getStatus() == OperationResultStatusType.UNKNOWN) { - fail(message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation()); + fail(message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation()); } if (result.getStatus() != OperationResultStatusType.SUCCESS && result.getStatus() != OperationResultStatusType.NOT_APPLICABLE && result.getStatus() != OperationResultStatusType.HANDLED_ERROR) { - fail(message + ": " + result.getMessage() + " ("+result.getStatus()+")"); + fail(message + ": " + result.getMessage() + " (" + result.getStatus() + ")"); } } } List partialResults = result.getPartialResults(); for (OperationResultType subResult : partialResults) { - if (subResult==null) { - fail(message+": null subresult under operation "+result.getOperation()); + if (subResult == null) { + fail(message + ": null subresult under operation " + result.getOperation()); } - if (subResult.getOperation()==null) { - fail(message+": null subresult operation under operation "+result.getOperation()); + if (subResult.getOperation() == null) { + fail(message + ": null subresult operation under operation " + result.getOperation()); } if (hasWarningAssertSuccess(message, subResult)) { hasWarning = true; @@ -380,23 +324,23 @@ public static void assertFailure(String message, OperationResult result) { public static void assertFailure(OperationResult result) { if (!result.isError()) { - String message = "Expected that operation "+result.getOperation()+" fails, but the result was "+result.getStatus(); + String message = "Expected that operation " + result.getOperation() + " fails, but the result was " + result.getStatus(); System.out.println(message); System.out.println(result.debugDump()); - LOGGER.error("{}",message); - LOGGER.error("{}",result.debugDump()); + LOGGER.error("{}", message); + LOGGER.error("{}", result.debugDump()); AssertJUnit.fail(message); } assertNoUnknown(result); } public static void assertPartialError(OperationResult result) { - assertTrue("Expected that operation "+result.getOperation()+" fails partially, but the result was "+result.getStatus(), result.getStatus() == OperationResultStatus.PARTIAL_ERROR); + assertTrue("Expected that operation " + result.getOperation() + " fails partially, but the result was " + result.getStatus(), result.getStatus() == OperationResultStatus.PARTIAL_ERROR); assertNoUnknown(result); } public static void assertResultStatus(OperationResult result, OperationResultStatus expectedStatus) { - assertTrue("Expected that operation "+result.getOperation()+" will result with "+expectedStatus+", but the result was "+result.getStatus(), result.getStatus() == expectedStatus); + assertTrue("Expected that operation " + result.getOperation() + " will result with " + expectedStatus + ", but the result was " + result.getStatus(), result.getStatus() == expectedStatus); assertNoUnknown(result); } @@ -406,26 +350,26 @@ public static void assertFailure(OperationResultType result) { public static void assertFailure(String message, OperationResultType result) { assertTrue((message == null ? "" : message + ": ") + - "Expected that operation "+result.getOperation()+" fails, but the result was "+result.getStatus(), + "Expected that operation " + result.getOperation() + " fails, but the result was " + result.getStatus(), OperationResultStatusType.FATAL_ERROR == result.getStatus() || - OperationResultStatusType.PARTIAL_ERROR == result.getStatus()) ; + OperationResultStatusType.PARTIAL_ERROR == result.getStatus()); assertNoUnknown(result); } public static void assertNoUnknown(OperationResult result) { if (result.isUnknown()) { - AssertJUnit.fail("Unkwnown status for operation "+result.getOperation()); + AssertJUnit.fail("Unkwnown status for operation " + result.getOperation()); } - for (OperationResult subresult: result.getSubresults()) { + for (OperationResult subresult : result.getSubresults()) { assertNoUnknown(subresult); } } public static void assertNoUnknown(OperationResultType result) { if (result.getStatus() == OperationResultStatusType.UNKNOWN) { - AssertJUnit.fail("Unkwnown status for operation "+result.getOperation()); + AssertJUnit.fail("Unkwnown status for operation " + result.getOperation()); } - for (OperationResultType subresult: result.getPartialResults()) { + for (OperationResultType subresult : result.getPartialResults()) { assertNoUnknown(subresult); } } @@ -444,7 +388,7 @@ public static void assertWarning(String message, OperationResult result) { public static boolean hasWarningAssertSuccess(String message, OperationResult result, OperationResult originalResult, int stopLevel, int currentLevel) { if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) { - String logmsg = message + ": undefined status ("+result.getStatus()+") on operation "+result.getOperation(); + String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation(); LOGGER.error(logmsg); LOGGER.trace(logmsg + "\n" + originalResult.debugDump()); System.out.println(logmsg + "\n" + originalResult.debugDump()); @@ -487,7 +431,7 @@ public static void assertWarning(String message, OperationResult result, int sto } public static void assertInProgress(String message, OperationResult result) { - assertTrue("Expected result IN_PROGRESS but it was "+result.getStatus()+" in "+message, + assertTrue("Expected result IN_PROGRESS but it was " + result.getStatus() + " in " + message, result.getStatus() == OperationResultStatus.IN_PROGRESS); } @@ -495,7 +439,7 @@ public static String getErrorMessage(OperationResult result) { if (result.isError()) { return result.getMessage(); } - for (OperationResult subresult: result.getSubresults()) { + for (OperationResult subresult : result.getSubresults()) { String message = getErrorMessage(subresult); if (message != null) { return message; @@ -543,9 +487,9 @@ public static String execSystemCommand(String command, boolean ignoreExitCode) t } reader.close(); String outstring = output.toString(); - LOGGER.debug("Command output:\n{}",outstring); + LOGGER.debug("Command output:\n{}", outstring); if (!ignoreExitCode && exitCode != 0) { - String msg = "Execution of command '"+command+"' failed with exit code "+exitCode; + String msg = "Execution of command '" + command + "' failed with exit code " + exitCode; LOGGER.error("{}", msg); throw new IOException(msg); } @@ -556,12 +500,12 @@ public static void assertBetween(String message, XMLGregorianCalendar start, XML XMLGregorianCalendar actual) { assertNotNull(message + " is null", actual); if (start != null) { - assertTrue(message+": expected time to be after "+start+" but it was "+actual, - actual.compare(start) == DatatypeConstants.GREATER || actual.compare(start) == DatatypeConstants.EQUAL); + assertTrue(message + ": expected time to be after " + start + " but it was " + actual, + actual.compare(start) == DatatypeConstants.GREATER || actual.compare(start) == DatatypeConstants.EQUAL); } if (end != null) { - assertTrue(message+": expected time to be before "+end+" but it was "+actual, - actual.compare(end) == DatatypeConstants.LESSER || actual.compare(end) == DatatypeConstants.EQUAL); + assertTrue(message + ": expected time to be before " + end + " but it was " + actual, + actual.compare(end) == DatatypeConstants.LESSER || actual.compare(end) == DatatypeConstants.EQUAL); } } @@ -569,23 +513,23 @@ public static void assertBetween(String message, Long start, Long end, Long actual) { assertNotNull(message + " is null", actual); if (start != null) { - assertTrue(message+": expected time to be after "+start+" but it was "+actual, actual >= start); + assertTrue(message + ": expected time to be after " + start + " but it was " + actual, actual >= start); } if (end != null) { - assertTrue(message+": expected time to be before "+end+" but it was "+actual, actual <= end); + assertTrue(message + ": expected time to be before " + end + " but it was " + actual, actual <= end); } } public static void assertEqualsTimestamp(String message, XMLGregorianCalendar expected, XMLGregorianCalendar actual) { - assertNotNull(message+"; expected "+expected, actual); - assertTrue(message+"; expected "+expected+" but was "+actual, expected.compare(actual) == 0); + assertNotNull(message + "; expected " + expected, actual); + assertTrue(message + "; expected " + expected + " but was " + actual, expected.compare(actual) == 0); } public static void assertCreateTimestamp(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { MetadataType metadata = object.asObjectable().getMetadata(); - assertNotNull("No metadata in "+object, metadata); - assertBetween("createTimestamp in "+object, start, end, metadata.getCreateTimestamp()); + assertNotNull("No metadata in " + object, metadata); + assertBetween("createTimestamp in " + object, start, end, metadata.getCreateTimestamp()); } public static void assertModifyTimestamp(PrismObject object, XMLGregorianCalendar start, @@ -596,8 +540,8 @@ public static void assertModifyTimestamp(PrismObject objec public static void assertModifyTimestamp(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end, String channel) { MetadataType metadata = object.asObjectable().getMetadata(); - assertNotNull("No metadata in "+object, metadata); - assertBetween("modifyTimestamp in "+object, start, end, metadata.getModifyTimestamp()); + assertNotNull("No metadata in " + object, metadata); + assertBetween("modifyTimestamp in " + object, start, end, metadata.getModifyTimestamp()); if (channel != null) { assertEquals("Wrong channel", channel, metadata.getModifyChannel()); } @@ -627,13 +571,13 @@ public static int getJavaMajorVersion() { if (matcher.matches()) { return Integer.parseInt(matcher.group(1)); } else { - throw new IllegalStateException("Cannot match java version string '"+javaVersionString+"'"); + throw new IllegalStateException("Cannot match java version string '" + javaVersionString + "'"); } } public static void assertMessageContains(String message, String expectedSubstring) { - assertTrue("Expected that message will contain substring '"+expectedSubstring+"', but it did not. Message: "+message, + assertTrue("Expected that message will contain substring '" + expectedSubstring + "', but it did not. Message: " + message, message.contains(expectedSubstring)); } @@ -660,16 +604,18 @@ public static void assertPrivateFilePermissions(File f) throws IOException { } } - private static void assertPermission(File f, Set permissions, PosixFilePermission permission) { - assertTrue(permissions.contains(permission), f.getPath() + ": missing permission "+permission); + private static void assertPermission(File f, Set permissions, PosixFilePermission permission) { + assertTrue(permissions.contains(permission), f.getPath() + ": missing permission " + permission); } private static void assertNoPermission(File f, Set permissions, PosixFilePermission permission) { - assertFalse(permissions.contains(permission), f.getPath() + ": unexpected permission "+permission); + assertFalse(permissions.contains(permission), f.getPath() + ": unexpected permission " + permission); } - public static ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { + public static ParallelTestThread[] multithread( + MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { ParallelTestThread[] threads = new ParallelTestThread[numberOfThreads]; + System.out.println("Going to create " + numberOfThreads + " threads..."); for (int i = 0; i < numberOfThreads; i++) { threads[i] = new ParallelTestThread(i, (ii) -> { @@ -677,7 +623,7 @@ public static ParallelTestThread[] multithread(final String TEST_NAME, Multithre LOGGER.info("{} starting", Thread.currentThread().getName()); lambda.run(ii); }); - threads[i].setName("Thread " + (i+1) + " of " + numberOfThreads); + threads[i].setName("Thread " + (i + 1) + " of " + numberOfThreads); threads[i].start(); } return threads; @@ -702,7 +648,7 @@ public static void waitForThreads(ParallelTestThread[] threads, long timeout) th } Throwable threadException = threads[i].getException(); if (threadException != null) { - throw new AssertionError("Test thread "+i+" failed: "+threadException.getMessage(), threadException); + throw new AssertionError("Test thread " + i + " failed: " + threadException.getMessage(), threadException); } } } diff --git a/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java b/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java index f3393da61a5..72fd94ecb11 100644 --- a/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java +++ b/infra/util/src/main/java/com/evolveum/midpoint/util/PrettyPrinter.java @@ -9,14 +9,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; - import javax.xml.XMLConstants; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -28,7 +22,6 @@ /** * @author semancik - * */ public class PrettyPrinter { @@ -53,7 +46,7 @@ static String prettyPrintElementAsProperty(Object element) { sb.append(prettyPrint(elementName)); sb.append(">"); if (element instanceof Element) { - Element domElement = (Element)element; + Element domElement = (Element) element; // TODO: this is too simplistic, expand later sb.append(domElement.getTextContent()); } else { @@ -94,9 +87,9 @@ public static String prettyPrint(QName qname) { } if (qname.getNamespaceURI() != null) { if (qname.getNamespaceURI().equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) { - return "{"+DOMUtil.NS_W3C_XML_SCHEMA_PREFIX+":}"+qname.getLocalPart(); + return "{" + DOMUtil.NS_W3C_XML_SCHEMA_PREFIX + ":}" + qname.getLocalPart(); } else if (defaultNamespacePrefix != null && qname.getNamespaceURI().startsWith(defaultNamespacePrefix)) { - return "{..."+qname.getNamespaceURI().substring(defaultNamespacePrefix.length())+"}"+qname.getLocalPart(); + return "{..." + qname.getNamespaceURI().substring(defaultNamespacePrefix.length()) + "}" + qname.getLocalPart(); } } return qnameToString(qname); // avoiding qname.toString because recursive call to prettyPrint from ItemName.toString @@ -216,7 +209,6 @@ public static String prettyPrint(Element element, boolean displayTag) { return sb.toString(); } - public static String prettyPrint(Date date) { if (date == null) { return "null"; @@ -235,7 +227,7 @@ public static String prettyPrint(byte[] value) { if (printlen > BYTE_ARRAY_MAX_LEN) { printlen = BYTE_ARRAY_MAX_LEN; } - for(int i=0; i < printlen; i++) { + for (int i = 0; i < printlen; i++) { sb.append(String.format("%02x", value[i] & 0xff)); } if (value.length > BYTE_ARRAY_MAX_LEN) { @@ -252,10 +244,10 @@ public static String prettyPrint(Object value) { return "null"; } if (value instanceof JAXBElement) { - Object elementValue = ((JAXBElement)value).getValue(); + Object elementValue = ((JAXBElement) value).getValue(); String attempt = tryPrettyPrint(elementValue); if (attempt != null) { - return ("JAXBElement("+((JAXBElement)value).getName()+","+attempt+")"); + return ("JAXBElement(" + ((JAXBElement) value).getName() + "," + attempt + ")"); } } String attempt = tryPrettyPrint(value); @@ -268,32 +260,32 @@ public static String prettyPrint(Object value) { private static String tryPrettyPrint(Object value) { if (value instanceof Class) { - Class c = (Class)value; + Class c = (Class) value; if (c.getPackage().getName().equals("com.evolveum.midpoint.xml.ns._public.common.common_3")) { return c.getSimpleName(); } return c.getName(); } if (value instanceof Collection) { - return PrettyPrinter.prettyPrint((Collection)value); + return PrettyPrinter.prettyPrint((Collection) value); } if (value.getClass().isArray()) { Class cclass = value.getClass().getComponentType(); if (cclass.isPrimitive()) { if (cclass == byte.class) { - return PrettyPrinter.prettyPrint((byte[])value); + return PrettyPrinter.prettyPrint((byte[]) value); } else { // TODO: something better } } else { - return PrettyPrinter.prettyPrint((Object[])value); + return PrettyPrinter.prettyPrint((Object[]) value); } } if (value instanceof Node) { // This is interface, won't catch it using reflection - return PrettyPrinter.prettyPrint((Node)value); + return PrettyPrinter.prettyPrint((Node) value); } - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { String printerValue = tryPrettyPrint(value, prettyPrinterClass); if (printerValue != null) { return printerValue; @@ -309,15 +301,15 @@ private static String tryPrettyPrint(Object value, Class prettyPrinterClass) Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(value.getClass())) { try { - return (String)method.invoke(null, value); + return (String) method.invoke(null, value); } catch (IllegalArgumentException e) { - return "###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (IllegalAccessException e) { - return "###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (InvocationTargetException e) { - return "###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; prettyPrint method for value " + value; } catch (Throwable e) { - return "###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; prettyPrint method for value "+value; + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; prettyPrint method for value " + value; } } } @@ -331,10 +323,10 @@ public static String debugDump(Object value, int indent) { } String out = null; if (value instanceof DebugDumpable) { - return ((DebugDumpable)value).debugDump(indent); + return ((DebugDumpable) value).debugDump(indent); } if (value instanceof Collection) { - return DebugUtil.debugDump((Collection)value, indent); + return DebugUtil.debugDump((Collection) value, indent); } out = tryDebugDumpMethod(value, indent); if (out != null) { @@ -346,7 +338,7 @@ public static String debugDump(Object value, int indent) { } private static String tryDebugDumpMethod(Object value, int indent) { - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { String printerValue = tryDebugDumpMethod(value, indent, prettyPrinterClass); if (printerValue != null) { return printerValue; @@ -362,15 +354,15 @@ private static String tryDebugDumpMethod(Object value, int indent, Class pret Class[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length == 2 && parameterTypes[0].equals(value.getClass())) { try { - return (String)method.invoke(null, value, indent); + return (String) method.invoke(null, value, indent); } catch (IllegalArgumentException e) { - return "###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; debugDump method for value " + value; } catch (IllegalAccessException e) { - return "###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; debugDump method for value " + value; } catch (InvocationTargetException e) { - return "###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; debugDump method for value " + value; } catch (Throwable e) { - return "###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; debugDump method for value "+value; + return "###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; debugDump method for value " + value; } } } @@ -384,11 +376,11 @@ public static void shortDump(StringBuilder sb, Object value) { return; } if (value instanceof ShortDumpable) { - ((ShortDumpable)value).shortDump(sb); + ((ShortDumpable) value).shortDump(sb); return; } if (value instanceof Collection) { - DebugUtil.shortDump(sb, (Collection)value); + DebugUtil.shortDump(sb, (Collection) value); return; } if (tryShortDumpMethod(sb, value)) { @@ -398,7 +390,7 @@ public static void shortDump(StringBuilder sb, Object value) { } private static boolean tryShortDumpMethod(StringBuilder sb, Object value) { - for (Class prettyPrinterClass: prettyPrinters) { + for (Class prettyPrinterClass : prettyPrinters) { if (tryShortDumpMethod(sb, value, prettyPrinterClass)) { return true; } @@ -416,13 +408,13 @@ private static boolean tryShortDumpMethod(StringBuilder sb, Object value, Class< method.invoke(null, sb, value); return true; } catch (IllegalArgumentException e) { - sb.append("###INTERNAL#ERROR### Illegal argument: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal argument: " + e.getMessage() + "; shortDump method for value " + value); } catch (IllegalAccessException e) { - sb.append("###INTERNAL#ERROR### Illegal access: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal access: " + e.getMessage() + "; shortDump method for value " + value); } catch (InvocationTargetException e) { - sb.append("###INTERNAL#ERROR### Illegal target: "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### Illegal target: " + e.getMessage() + "; shortDump method for value " + value); } catch (Throwable e) { - sb.append("###INTERNAL#ERROR### "+e.getClass().getName()+": "+e.getMessage() + "; shortDump method for value "+value); + sb.append("###INTERNAL#ERROR### " + e.getClass().getName() + ": " + e.getMessage() + "; shortDump method for value " + value); } } } diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java index 6b275a4a43b..c82d7e0edf0 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestMiscUtil.java @@ -8,6 +8,7 @@ import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertEquals; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -16,15 +17,12 @@ import org.testng.annotations.Test; -/** - * @author semancik - * - */ -public class TestMiscUtil { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; + +public class TestMiscUtil extends AbstractUnitTest { @Test public void testUnion() { - System.out.println("===[ testUnion ]==="); Collection a = new HashSet<>(); a.add("A1"); a.add("X"); @@ -54,7 +52,6 @@ public void testUnion() { @Test public void testUglyXsiHack1() { - System.out.println("===[ testUglyXsiHack1 ]==="); String in = " "; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals(" ", out); @@ -62,7 +59,6 @@ public void testUglyXsiHack1() { @Test public void testUglyXsiHack2() { - System.out.println("===[ testUglyXsiHack2 ]==="); String in = ""; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals("", out); @@ -70,7 +66,6 @@ public void testUglyXsiHack2() { @Test public void testUglyXsiHack3() { - System.out.println("===[ testUglyXsiHack3 ]==="); String in = ""; String out = UglyHacks.forceXsiNsDeclaration(in); assertEquals(in, out); @@ -78,8 +73,6 @@ public void testUglyXsiHack3() { @Test public void testCarthesian() { - System.out.println("===[ testCarthesian ]==="); - // GIVEN Collection> dimensions = new ArrayList<>(); Collection dim1 = new ArrayList<>(); diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java index 527e990f544..aa678cf7cf4 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestReflectionUtil.java @@ -15,11 +15,9 @@ import org.testng.annotations.Test; -/** - * @author semancik - * - */ -public class TestReflectionUtil { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; + +public class TestReflectionUtil extends AbstractUnitTest { @Test public void testFindMethodByArity3() throws Exception { @@ -87,7 +85,7 @@ public void testFindMethodByArglistVararg() throws Exception { // THEN assertNotNull("No method", method); - method.invoke(library, new Object[] { new String[] {"foo", "bar", "baz"}}); + method.invoke(library, new Object[] { new String[] { "foo", "bar", "baz" } }); assertCalled(library, "v:3"); } @@ -155,9 +153,7 @@ public void testInvokeMethodByArglistCollection() throws Exception { assertCalled(library, "lc"); } - private void assertCalled(ReflectionTestFunctionLibrary library, String methodId) { - assertTrue("The method "+methodId+" was not called. Called: "+library.getCalledIds(), library.wasCalled(methodId)); + assertTrue("The method " + methodId + " was not called. Called: " + library.getCalledIds(), library.wasCalled(methodId)); } - } diff --git a/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java b/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java index e6c96c1ee54..590620ca180 100644 --- a/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java +++ b/infra/util/src/test/java/com/evolveum/midpoint/util/TestStringSubstitutorUtil.java @@ -6,6 +6,7 @@ */ package com.evolveum.midpoint.util; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.template.*; import org.testng.annotations.Test; @@ -13,11 +14,10 @@ import static org.testng.AssertJUnit.*; -public class TestStringSubstitutorUtil { +public class TestStringSubstitutorUtil extends AbstractUnitTest { @Test public void testSimpleExpand() { - System.out.println("===[ testSimpleExpand ]==="); Map map = new HashMap<>(); map.put("t1", "TEST1"); map.put("t2", "TEST2"); diff --git a/model/certification-impl/pom.xml b/model/certification-impl/pom.xml index aa0f718526a..66cdf67cc5f 100644 --- a/model/certification-impl/pom.xml +++ b/model/certification-impl/pom.xml @@ -156,7 +156,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java index 930df67ede9..ceb14258121 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestAdHocCertification.java @@ -64,20 +64,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010HireIndigo() throws Exception { - final String TEST_NAME = "test010HireIndigo"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestAdHocCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -94,16 +91,13 @@ public void test010HireIndigo() throws Exception { @Test public void test020ModifyIndigo() throws Exception { - final String TEST_NAME = "test020ModifyIndigo"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestAdHocCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_DESCRIPTION).replace("new description") @@ -112,7 +106,7 @@ public void test020ModifyIndigo() throws Exception { executeChanges(delta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java index ab0075df339..a3c2fd7bba4 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCertificationBasic.java @@ -7,6 +7,26 @@ package com.evolveum.midpoint.certification.test; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.CLOSED; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.IN_REMEDIATION; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_ACTIVATION; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.*; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_ADMINISTRATIVE_STATUS; + +import java.io.File; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -21,24 +41,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import static com.evolveum.midpoint.prism.PrismConstants.T_PARENT; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.CLOSED; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType.IN_REMEDIATION; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_ACTIVATION; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.*; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_ADMINISTRATIVE_STATUS; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.*; /** * Very simple certification test. @@ -46,7 +48,7 @@ * * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-certification-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-certification-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestCertificationBasic extends AbstractCertificationTest { @@ -75,23 +77,20 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test001CreateForeignCampaign() throws Exception { - final String TEST_NAME = "test001CreateForeignCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); roleInducementCertDefinition = repoAddObjectFromFile(ROLE_INDUCEMENT_CERT_DEF_FILE, AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(roleInducementCertDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -107,20 +106,17 @@ public void test001CreateForeignCampaign() throws Exception { @Test public void test002OpenFirstForeignStage() throws Exception { - final String TEST_NAME = "test002OpenFirstForeignStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(roleInducementCampaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -131,16 +127,13 @@ public void test002OpenFirstForeignStage() throws Exception { @Test public void test005CreateCampaignDenied() throws Exception { - final String TEST_NAME = "test005CreateCampaignDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - login(getUserFromRepo(USER_ELAINE_OID)); // elaine is a reviewer, not authorized to create campaigns + login(getUserFromRepo(USER_ELAINE_OID)); // elaine is a reviewer, not authorized to create campaigns // WHEN/THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.createCampaign(certificationDefinition.getOid(), task, result); fail("Unexpected success"); @@ -151,16 +144,13 @@ public void test005CreateCampaignDenied() throws Exception { @Test public void test006CreateCampaignDeniedBobWrongDeputy() throws Exception { - final String TEST_NAME = "test006CreateCampaignDeniedBobWrongDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_DEPUTY_NO_ASSIGNMENTS_OID)); // this is a deputy with limitation blocking all assignments // WHEN/THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.createCampaign(certificationDefinition.getOid(), task, result); fail("Unexpected success"); @@ -171,21 +161,18 @@ public void test006CreateCampaignDeniedBobWrongDeputy() throws Exception { @Test public void test010CreateCampaignAllowedForDeputy() throws Exception { - final String TEST_NAME = "test010CreateCampaignAllowedForDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_DEPUTY_FULL_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,21 +193,18 @@ public void test010CreateCampaignAllowedForDeputy() throws Exception { @Test public void test011CreateCampaignAllowed() throws Exception { - final String TEST_NAME = "test010CreateCampaignAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -237,35 +221,31 @@ public void test011CreateCampaignAllowed() throws Exception { @Test public void test012SearchAllCasesDenied() throws Exception { - final String TEST_NAME = "test012SearchAllCasesDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test013SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test013SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } - private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { + private void searchWithNoCasesExpected() throws Exception { // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -273,19 +253,15 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { assertEquals("Unexpected cases in caseList", 0, caseList.size()); } - @Test public void test020OpenFirstStageDenied() throws Exception { - final String TEST_NAME = "test020OpenFirstStageDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_ELAINE_OID)); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.openNextStage(campaignOid, task, result); fail("Unexpected success"); @@ -298,21 +274,18 @@ public void test020OpenFirstStageDenied() throws Exception { @Test public void test021OpenFirstStageAllowed() throws Exception { - final String TEST_NAME = "test021OpenFirstStageAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); task.setOwner(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -320,7 +293,7 @@ public void test021OpenFirstStageAllowed() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7); - checkAllCasesSanity(campaign.getCase(), campaignOid); + checkAllCasesSanity(campaign.getCase()); List caseList = campaign.getCase(); // no responses -> NO_RESPONSE in all cases assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, NO_RESPONSE, NO_RESPONSE, null); @@ -336,82 +309,72 @@ public void test021OpenFirstStageAllowed() throws Exception { @Test public void test030SearchAllCasesDenied() throws Exception { - final String TEST_NAME = "test030SearchCasesDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test031SearchAllCasesDeniedLimitedDeputy() throws Exception { - final String TEST_NAME = "test031SearchAllCasesDeniedLimitedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_DEPUTY_NO_ASSIGNMENTS_OID)); - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @Test public void test032SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test032SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); } @Test(enabled = false) public void test034SearchAllCasesAllowedDeputy() throws Exception { - final String TEST_NAME = "test034SearchAllCasesAllowedDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_DEPUTY_FULL_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); } @Test public void test040SearchCasesFilteredSortedPaged() throws Exception { - final String TEST_NAME = "test040SearchCasesFilteredSortedPaged"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Collection> resolveNames = SelectorOptions.createCollection(GetOperationOptions.createResolveNames()); ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) @@ -429,7 +392,7 @@ public void test040SearchCasesFilteredSortedPaged() throws Exception { // - COO // - CEO // so paging (2, 2) should return the last two - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -443,23 +406,21 @@ public void test040SearchCasesFilteredSortedPaged() throws Exception { @Test public void test050SearchWorkItemsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchWorkItemsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -470,21 +431,19 @@ public void test050SearchWorkItemsAdministrator() throws Exception { @Test public void test052SearchWorkItemsByTenantRef() throws Exception { - final String TEST_NAME = "test052SearchWorkItemsByTenantRef"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(AccessCertificationCaseType.F_TENANT_REF).ref(ORG_GOVERNOR_OFFICE_OID) - .and().ownerId(campaignOid) + .item(AccessCertificationCaseType.F_TENANT_REF).ref(ORG_GOVERNOR_OFFICE_OID) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = @@ -492,7 +451,7 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -503,28 +462,26 @@ public void test052SearchWorkItemsByTenantRef() throws Exception { @Test public void test054SearchDecisionsByOrgRef() throws Exception { - final String TEST_NAME = "test054SearchDecisionsByOrgRef"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(AccessCertificationCaseType.F_ORG_REF).ref(ORG_SCUMM_BAR_OID) - .and().ownerId(campaignOid) + .item(AccessCertificationCaseType.F_ORG_REF).ref(ORG_SCUMM_BAR_OID) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = certificationService.searchOpenWorkItems(query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -535,28 +492,26 @@ public void test054SearchDecisionsByOrgRef() throws Exception { @Test public void test056SearchDecisionsByAdminStatus() throws Exception { - final String TEST_NAME = "test056SearchDecisionsByAdminStatus"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() - .item(F_ACTIVATION, F_ADMINISTRATIVE_STATUS).eq(ENABLED) - .and().ownerId(campaignOid) + .item(F_ACTIVATION, F_ADMINISTRATIVE_STATUS).eq(ENABLED) + .and().ownerId(campaignOid) .endBlock() .build(); List workItems = certificationService.searchOpenWorkItems(query, false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -567,22 +522,20 @@ public void test056SearchDecisionsByAdminStatus() throws Exception { @Test public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { - final String TEST_NAME = "test060SearchOpenWorkItemsDeputyDenied"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_DEPUTY_NONE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems(CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -592,22 +545,20 @@ public void test060SearchOpenWorkItemsDeputyDenied() throws Exception { @Test public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { - final String TEST_NAME = "test062SearchOpenWorkItemsDeputyAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_DEPUTY_NO_ASSIGNMENTS_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems(CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -618,107 +569,101 @@ public void test062SearchOpenWorkItemsDeputyAllowed() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); assertEquals("changed case ID", Long.valueOf(id), superuserCase.asPrismContainerValue().getId()); assertSingleDecision(superuserCase, ACCEPT, "no comment", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test105RecordAcceptJackCeo() throws Exception { - final String TEST_NAME = "test105RecordAcceptJackCeo"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ADMINISTRATOR_OID); // reviewerRef will be taken from the current user long id = ceoCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "ok", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); assertEquals("changed case ID", Long.valueOf(id), ceoCase.asPrismContainerValue().getId()); assertSingleDecision(ceoCase, ACCEPT, "ok", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test110RecordRevokeJackCeo() throws Exception { - final String TEST_NAME = "test110RecordRevokeJackCeo"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); // reviewerRef will be taken from the current user long id = ceoCase.asPrismContainerValue().getId(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ADMINISTRATOR_OID); certificationService.recordDecision(campaignOid, id, workItem.getId(), REVOKE, "no way", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case", ceoCase.asPrismContainerValue()); @@ -726,12 +671,12 @@ public void test110RecordRevokeJackCeo() throws Exception { assertSingleDecision(ceoCase, REVOKE, "no way", 1, 1, USER_ADMINISTRATOR_OID, REVOKE, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @SuppressWarnings("Duplicates") - private void checkAllCasesSanity(Collection caseList, String campaignOid) { + private void checkAllCasesSanity(Collection caseList) { assertEquals("Wrong number of certification cases", 7, caseList.size()); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, userAdministrator); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, userAdministrator); @@ -754,16 +699,14 @@ private void checkAllWorkItemsSanity(Collection @Test public void test150CloseFirstStageDeny() throws Exception { - final String TEST_NAME = "test150CloseFirstStageDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.closeCurrentStage(campaignOid, task, result); fail("Unexpected success"); @@ -774,16 +717,14 @@ public void test150CloseFirstStageDeny() throws Exception { @Test public void test151CloseCampaignDeny() throws Exception { - final String TEST_NAME = "test151CloseCampaignDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.closeCampaign(campaignOid, task, result); fail("Unexpected success"); @@ -794,21 +735,19 @@ public void test151CloseCampaignDeny() throws Exception { @Test public void test152CloseFirstStageAllow() throws Exception { - final String TEST_NAME = "test152CloseFirstStageAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUserFromRepo(USER_BOB_OID)); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -816,7 +755,7 @@ public void test152CloseFirstStageAllow() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterStageClose(campaign, certificationDefinition, 1); List caseList = campaign.getCase(); - checkAllCasesSanity(caseList, campaignOid); + checkAllCasesSanity(caseList); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, ACCEPT, ACCEPT, 1); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, NO_RESPONSE, NO_RESPONSE, 1); assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, NO_RESPONSE, NO_RESPONSE, 1); @@ -824,23 +763,21 @@ public void test152CloseFirstStageAllow() throws Exception { assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, REVOKE, REVOKE, 1); assertCaseOutcome(caseList, USER_JACK_OID, ORG_EROOT_OID, NO_RESPONSE, NO_RESPONSE, 1); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test200StartRemediationDeny() throws Exception { - final String TEST_NAME = "test200StartRemediationDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); try { certificationService.startRemediation(campaignOid, task, result); } catch (SecurityViolationException e) { @@ -850,21 +787,19 @@ public void test200StartRemediationDeny() throws Exception { @Test public void test205StartRemediationAllow() throws Exception { - final String TEST_NAME = "test205StartRemediationAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -896,18 +831,16 @@ public void test205StartRemediationAllow() throws Exception { assertEquals("wrong # of jack's assignments", 4, userJack.getAssignment().size()); assertEquals("wrong target OID", ORG_EROOT_OID, userJack.getAssignment().get(0).getTargetRef().getOid()); - assertPercentCompleteAll(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) - assertPercentCompleteCurrent(campaign, Math.round(200.0f/7.0f), Math.round(200.0f/7.0f), Math.round(200.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteCurrent(campaign, Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f), Math.round(200.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test210CheckAfterClose() throws Exception { - final String TEST_NAME = "test210CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -923,17 +856,15 @@ public void test210CheckAfterClose() throws Exception { @Test public void test900CleanupCampaignsDeny() throws Exception { - final String TEST_NAME = "test900CleanupCampaignsDeny"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ELAINE_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxRecords(0); certificationService.cleanupCampaigns(policy, task, result); display("result", result); @@ -944,17 +875,15 @@ public void test900CleanupCampaignsDeny() throws Exception { @Test public void test910CleanupCampaignsAllow() throws Exception { - final String TEST_NAME = "test910CleanupCampaignsAllow"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxRecords(0); certificationService.cleanupCampaigns(policy, task, result); result.computeStatus(); @@ -980,12 +909,10 @@ public void test910CleanupCampaignsAllow() throws Exception { @Test public void test920CleanupCampaignsByAge() throws Exception { - final String TEST_NAME = "test920CleanupCampaignsByAge"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -1013,7 +940,7 @@ public void test920CleanupCampaignsByAge() throws Exception { display("campaigns", getAllCampaigns(result)); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); + when(); CleanupPolicyType policy = new CleanupPolicyType().maxAge(XmlTypeConverter.createDuration("P1D")); certificationService.cleanupCampaigns(policy, task, result); result.computeStatus(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java index fec47a54481..c847c47e963 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestCriticalRolesCertification.java @@ -61,11 +61,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(CERT_DEF_FILE, @@ -73,12 +70,12 @@ public void test010CreateCampaign() throws Exception { dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -113,21 +110,18 @@ public void test010CreateCampaign() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -177,17 +171,14 @@ public void test020OpenFirstStage() throws Exception { @Test public void test100RecordDecisions1() throws Exception { - final String TEST_NAME = "test100RecordDecisions1"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertEquals("unexpected # of cases", 6, caseList.size()); AccessCertificationCaseType guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID); @@ -195,7 +186,7 @@ public void test100RecordDecisions1() throws Exception { recordDecision(campaignOid, guybrushCooCase, ACCEPT, null, USER_CHEESE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -220,21 +211,18 @@ public void test100RecordDecisions1() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -262,21 +250,18 @@ public void test150CloseFirstStage() throws Exception { @Test public void test200OpenSecondStage() throws Exception { - final String TEST_NAME = "test200OpenSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -336,20 +321,17 @@ public void test200OpenSecondStage() throws Exception { @Test public void test220StatisticsAllStages() throws Exception { - final String TEST_NAME = "test220StatisticsAllStages"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -365,17 +347,14 @@ public void test220StatisticsAllStages() throws Exception { @Test public void test250RecordDecisionsSecondStage() throws Exception { - final String TEST_NAME = "test250RecordDecisionsSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Stage2: allMustAccept, default: accept, advance on: accept (target owner) @@ -408,7 +387,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { // jackCto: no reviewers // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -452,20 +431,17 @@ public void test250RecordDecisionsSecondStage() throws Exception { @Test public void test260Statistics() throws Exception { - final String TEST_NAME = "test260Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -481,21 +457,18 @@ public void test260Statistics() throws Exception { @Test public void test290CloseSecondStage() throws Exception { - final String TEST_NAME = "test290CloseSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,21 +500,18 @@ public void test290CloseSecondStage() throws Exception { @Test public void test300OpenThirdStage() throws Exception { - final String TEST_NAME = "test300OpenThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -604,18 +574,15 @@ public void test300OpenThirdStage() throws Exception { @Test public void test330RecordDecisionsThirdStage() throws Exception { - final String TEST_NAME = "test330RecordDecisionsThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Case Stage1 Stage2 Stage3 @@ -643,7 +610,7 @@ public void test330RecordDecisionsThirdStage() throws Exception { // no response for jackCto // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -711,21 +678,18 @@ public void test330RecordDecisionsThirdStage() throws Exception { @Test public void test390CloseThirdStage() throws Exception { - final String TEST_NAME = "test390CloseThirdStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -777,21 +741,18 @@ public void test390CloseThirdStage() throws Exception { @Test public void test400OpenFourthStage() throws Exception { - final String TEST_NAME = "test400OpenFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -853,17 +814,14 @@ public void test400OpenFourthStage() throws Exception { @Test public void test430RecordDecisionsFourthStage() throws Exception { - final String TEST_NAME = "test430RecordDecisionsFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); /* Stage4: allMustAccept @@ -892,7 +850,7 @@ public void test430RecordDecisionsFourthStage() throws Exception { recordDecision(campaignOid, administratorCeoCase, ACCEPT, null, USER_CHEESE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -958,21 +916,18 @@ public void test430RecordDecisionsFourthStage() throws Exception { @Test public void test490CloseFourthStage() throws Exception { - final String TEST_NAME = "test490CloseFourthStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1026,20 +981,17 @@ public void test490CloseFourthStage() throws Exception { @Test public void test495StartRemediation() throws Exception { - final String TEST_NAME = "test900StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -1079,20 +1031,17 @@ public void test495StartRemediation() throws Exception { @Test public void test497Statistics() throws Exception { - final String TEST_NAME = "test910Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1111,12 +1060,10 @@ public void test497Statistics() throws Exception { @Test public void test499CheckAfterClose() throws Exception { - final String TEST_NAME = "test920CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); @@ -1133,25 +1080,23 @@ public void test499CheckAfterClose() throws Exception { @Test public void test500Reiterate() throws Exception { - final String TEST_NAME = "test500Reiterate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); //certificationManager.closeCampaign(campaignOid, true, task, result); certificationManager.reiterateCampaign(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1227,21 +1172,18 @@ public void test500Reiterate() throws Exception { @Test public void test510OpenNextStage() throws Exception { // next stage is 2 (because the first one has no work items) - final String TEST_NAME = "test510OpenNextStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1311,69 +1253,4 @@ Out of them, completed (for stage 2) are: elaine->CEO, guybrush->COO, administra assertCasesCount(campaignOid, 6); display("dummy transport", dummyTransport); } - -// @Test -// public void test520CloseFirstStage() throws Exception { -// final String TEST_NAME = "test520CloseFirstStage"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// certificationManager.closeCurrentStage(campaignOid, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); -// display("campaign in stage 1", campaign); -// -// assertSanityAfterStageClose(campaign, certificationDefinition, 1); -// -// List caseList = queryHelper.searchCases(campaignOid, null, null, result); -// assertEquals("unexpected # of cases", 6, caseList.size()); -// -// assertCaseOutcome(caseList, USER_ELAINE_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1); -// assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CTO_OID, ACCEPT, ACCEPT, 1); -// -// assertPercentComplete(campaignOid, 100, 100, 100); -// assertCasesCount(campaignOid, 6); -// } - -// @Test -// public void test530OpenSecondStage() throws Exception { -// final String TEST_NAME = "test530OpenSecondStage"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// certificationManager.openNextStage(campaignOid, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); -// display("campaign in stage 2", campaign); -// assertSanityAfterStageOpen(campaign, certificationDefinition, 2, 2, 6); -// -// List caseList = queryHelper.searchCases(campaignOid, null, null, result); -// } - } diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java index 5790aae10ca..d4d68489ca6 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestEscalation.java @@ -60,20 +60,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -89,26 +86,23 @@ public void test010CreateCampaign() throws Exception { @Test public void test013SearchAllCases() throws Exception { - final String TEST_NAME = "test013SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - - searchWithNoCasesExpected(TEST_NAME); + searchWithNoCasesExpected(); } @SuppressWarnings("SameParameterValue") - private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { + private void searchWithNoCasesExpected() throws Exception { // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -118,20 +112,17 @@ private void searchWithNoCasesExpected(String TEST_NAME) throws Exception { @Test public void test021OpenFirstStage() throws Exception { - final String TEST_NAME = "test021OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -157,20 +148,17 @@ public void test021OpenFirstStage() throws Exception { @Test public void test032SearchAllCases() throws Exception { - final String TEST_NAME = "test032SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -180,22 +168,19 @@ public void test032SearchAllCases() throws Exception { @Test public void test050SearchWorkItems() throws Exception { - final String TEST_NAME = "test050SearchWorkItems"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,24 +191,21 @@ public void test050SearchWorkItems() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -242,25 +224,23 @@ public void test100RecordDecision() throws Exception { @Test public void test110Escalate() throws Exception { - final String TEST_NAME = "test110Escalate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P2D"); // first escalation is at P1D waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -309,25 +289,23 @@ public void test110Escalate() throws Exception { @Test public void test120EscalateAgain() throws Exception { - final String TEST_NAME = "test120EscalateAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P4D"); // second escalation is at P3D waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -378,25 +356,23 @@ public void test120EscalateAgain() throws Exception { @Test public void test130Remediation() throws Exception { - final String TEST_NAME = "test130Remediation"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P15D"); // stage ends at P14D waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -407,26 +383,24 @@ public void test130Remediation() throws Exception { @Test public void test140Close() throws Exception { - final String TEST_NAME = "test140Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P16D"); certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -438,26 +412,24 @@ public void test140Close() throws Exception { @Test public void test200AutomaticReiteration() throws Exception { - final String TEST_NAME = "test200AutomaticReiteration"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P18D"); // campaign ends at P16D, reiteration scheduled to P17D waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -496,26 +468,24 @@ public void test200AutomaticReiteration() throws Exception { @Test public void test300Close() throws Exception { - final String TEST_NAME = "test300Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P19D"); // +1 day relative to previous test certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,26 +497,24 @@ public void test300Close() throws Exception { @Test public void test310ManualReiteration() throws Exception { - final String TEST_NAME = "test310ManualReiteration"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P20D"); // +1 day relative to previous test certificationManager.reiterateCampaign(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -575,20 +543,17 @@ public void test310ManualReiteration() throws Exception { @Test public void test320OpenFirstStage() throws Exception { - final String TEST_NAME = "test320OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -627,26 +592,24 @@ public void test320OpenFirstStage() throws Exception { @Test public void test400Close() throws Exception { - final String TEST_NAME = "test300Close"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P21D"); // +1 day relative to previous test certificationManager.closeCampaign(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -658,19 +621,17 @@ public void test400Close() throws Exception { @Test public void test410ManualReiterationUnavailable() throws Exception { - final String TEST_NAME = "test410ManualReiterationUnavailable"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); dummyTransport.clearMessages(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.resetOverride(); clock.overrideDuration("P22D"); // +1 day relative to previous test diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java index 6da245eb852..db718359252 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestManualEscalation.java @@ -7,6 +7,21 @@ package com.evolveum.midpoint.certification.test; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.ACCEPT; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.NO_RESPONSE; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -15,19 +30,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.ACCEPT; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType.NO_RESPONSE; -import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType.ENABLED; -import static org.testng.AssertJUnit.*; /** * Very simple certification test. @@ -35,12 +37,12 @@ * * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-certification-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-certification-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestManualEscalation extends AbstractCertificationTest { - protected static final File CERT_DEF_USER_ASSIGNMENT_BASIC_FILE = new File(COMMON_DIR, "certification-of-eroot-user-assignments.xml"); - protected static final String CERT_DEF_USER_ASSIGNMENT_BASIC_OID = "33333333-0000-0000-0000-000000000001"; + protected static final File CERT_DEF_USER_ASSIGNMENT_BASIC_FILE = + new File(COMMON_DIR, "certification-of-eroot-user-assignments.xml"); protected AccessCertificationDefinitionType certificationDefinition; @@ -61,21 +63,18 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationService.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -91,26 +90,20 @@ public void test010CreateCampaign() throws Exception { @Test public void test013SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test013SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); - searchWithNoCasesExpected(TEST_NAME); - } - - protected void searchWithNoCasesExpected(String TEST_NAME) throws Exception { // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, CertCampaignTypeUtil.createCasesForCampaignQuery(campaignOid, prismContext), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -120,20 +113,17 @@ protected void searchWithNoCasesExpected(String TEST_NAME) throws Exception { @Test public void test021OpenFirstStageAllowed() throws Exception { - final String TEST_NAME = "test021OpenFirstStageAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); login(getUserFromRepo(USER_BOB_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationService.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -141,7 +131,7 @@ public void test021OpenFirstStageAllowed() throws Exception { display("campaign in stage 1", campaign); assertSanityAfterCampaignStart(campaign, certificationDefinition, 7); - checkAllCases(campaign.getCase(), campaignOid); + checkAllCases(campaign.getCase()); List caseList = campaign.getCase(); // no responses -> NO_RESPONSE in all cases assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, NO_RESPONSE, NO_RESPONSE, null); @@ -156,47 +146,43 @@ public void test021OpenFirstStageAllowed() throws Exception { @Test public void test032SearchAllCasesAllowed() throws Exception { - final String TEST_NAME = "test032SearchAllCasesAllowed"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_BOB_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = modelService.searchContainers( AccessCertificationCaseType.class, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); } @Test public void test050SearchWorkItemsAsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchWorkItemsAsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = certificationService.searchOpenWorkItems( CertCampaignTypeUtil.createWorkItemsForCampaignQuery(campaignOid, prismContext), false, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -207,52 +193,48 @@ public void test050SearchWorkItemsAsAdministrator() throws Exception { @Test public void test100RecordDecision() throws Exception { - final String TEST_NAME = "test100RecordDecision"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); AccessCertificationCaseType superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(superuserCase, 1, 1, USER_ADMINISTRATOR_OID); long id = superuserCase.asPrismContainerValue().getId(); certificationService.recordDecision(campaignOid, id, workItem.getId(), ACCEPT, "no comment", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); superuserCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID); assertEquals("changed case ID", Long.valueOf(id), superuserCase.asPrismContainerValue().getId()); assertSingleDecision(superuserCase, ACCEPT, "no comment", 1, 1, USER_ADMINISTRATOR_OID, ACCEPT, false); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); // 1 reviewer per case (always administrator) + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); // 1 reviewer per case (always administrator) } @Test public void test110Escalate() throws Exception { - final String TEST_NAME = "test110Escalate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); EscalateWorkItemActionType action = new EscalateWorkItemActionType() .approverRef(USER_JACK_OID, UserType.COMPLEX_TYPE) .delegationMethod(WorkItemDelegationMethodType.ADD_ASSIGNEES) @@ -260,13 +242,13 @@ public void test110Escalate() throws Exception { operationsHelper.escalateCampaign(campaignOid, action, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); List caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -287,34 +269,32 @@ public void test110Escalate() throws Exception { assertEquals("Wrong new escalation level", NEW_ESCALATION_LEVEL, event.getNewEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } @Test public void test120EscalateAgain() throws Exception { - final String TEST_NAME = "test120EscalateAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); EscalateWorkItemActionType action = new EscalateWorkItemActionType() .approverRef(USER_ELAINE_OID, UserType.COMPLEX_TYPE) .escalationLevelName("ESC-2"); operationsHelper.escalateCampaign(campaignOid, action, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); List caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -337,17 +317,15 @@ public void test120EscalateAgain() throws Exception { assertEquals("Wrong new escalation level", NEW_ESCALATION_LEVEL, event.getNewEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } @Test public void test130Delegate() throws Exception { - final String TEST_NAME = "test130Delegate"; - TestUtil.displayTestTitle(this, TEST_NAME); login(getUserFromRepo(USER_ADMINISTRATOR_OID)); // GIVEN - Task task = taskManager.createTaskInstance(TestManualEscalation.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); @@ -355,7 +333,7 @@ public void test130Delegate() throws Exception { display("CEO case", ceoCase); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(ceoCase, 1, 1, USER_ELAINE_OID); long id = ceoCase.asPrismContainerValue().getId(); DelegateWorkItemActionType action = new DelegateWorkItemActionType() @@ -364,13 +342,13 @@ public void test130Delegate() throws Exception { certificationManager.delegateWorkItems(campaignOid, Collections.singletonList(workItem), action, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); caseList = queryHelper.searchCases(campaignOid, null, null, result); display("caseList", caseList); - checkAllCases(caseList, campaignOid); + checkAllCases(caseList); ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID); display("CEO case after escalation", ceoCase); @@ -393,10 +371,10 @@ public void test130Delegate() throws Exception { assertEquals("Wrong old escalation level", OLD_ESCALATION_LEVEL, event.getEscalationLevel()); AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid); - assertPercentCompleteAll(campaign, Math.round(100.0f/7.0f), Math.round(100.0f/7.0f), Math.round(100.0f/7.0f)); + assertPercentCompleteAll(campaign, Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f), Math.round(100.0f / 7.0f)); } - protected void checkAllCases(Collection caseList, String campaignOid) { + protected void checkAllCases(Collection caseList) { assertEquals("Wrong number of certification cases", 7, caseList.size()); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_SUPERUSER_OID, userAdministrator); checkCaseSanity(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, userAdministrator); @@ -416,5 +394,4 @@ protected void checkAllWorkItems(Collection wor checkWorkItemSanity(workItems, USER_JACK_OID, ORG_EROOT_OID, userJack); } - } diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java index 2f4a5b92fda..68960a14648 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestRoleInducementCertification.java @@ -44,23 +44,20 @@ public class TestRoleInducementCertification extends AbstractCertificationTest { @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(ROLE_INDUCEMENT_CERT_DEF_FILE, AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -77,19 +74,16 @@ public void test010CreateCampaign() throws Exception { @Test public void test012SearchAllCases() throws Exception { - final String TEST_NAME = "test012SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -99,20 +93,17 @@ public void test012SearchAllCases() throws Exception { @Test public void test014Statistics() throws Exception { - final String TEST_NAME = "test014Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -128,20 +119,17 @@ public void test014Statistics() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -176,20 +164,17 @@ protected void checkAllCasesSanity(Collection caseL @Test public void test024Statistics() throws Exception { - final String TEST_NAME = "test024Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,19 +191,16 @@ public void test024Statistics() throws Exception { @Test public void test030SearchAllCases() throws Exception { - final String TEST_NAME = "test030SearchCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -230,16 +212,13 @@ public void test030SearchAllCases() throws Exception { @Test public void test050SearchDecisionsAdministrator() throws Exception { - final String TEST_NAME = "test050SearchDecisionsAdministrator"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userAdministrator.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); @@ -251,7 +230,7 @@ public void test050SearchDecisionsAdministrator() throws Exception { */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -264,16 +243,13 @@ public void test050SearchDecisionsAdministrator() throws Exception { @Test public void test051SearchDecisionsElaine() throws Exception { - final String TEST_NAME = "test051SearchDecisionsElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userElaine.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); @@ -283,7 +259,7 @@ public void test051SearchDecisionsElaine() throws Exception { */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -294,23 +270,20 @@ public void test051SearchDecisionsElaine() throws Exception { @Test public void test052SearchDecisionsJack() throws Exception { - final String TEST_NAME = "test052SearchDecisionsJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userJack.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List workItems = queryHelper.searchOpenWorkItems(null, SecurityUtil.getPrincipal(), false, null, result); /* Expected cases - phase 1: NONE */ // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -331,18 +304,15 @@ public void test052SearchDecisionsJack() throws Exception { @Test public void test100RecordDecisions() throws Exception { - final String TEST_NAME = "test100RecordDecisions"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN login(userAdministrator.asPrismObject()); - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType ceoDummyCase = findCase(caseList, ROLE_CEO_OID, RESOURCE_DUMMY_OID); AccessCertificationCaseType cooDummyCase = findCase(caseList, ROLE_COO_OID, RESOURCE_DUMMY_OID); @@ -355,7 +325,7 @@ public void test100RecordDecisions() throws Exception { recordDecision(campaignOid, cooSuperuserCase, NOT_DECIDED, "I'm so procrastinative...", null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -390,20 +360,17 @@ public void test100RecordDecisions() throws Exception { @Test public void test110Statistics() throws Exception { - final String TEST_NAME = "test110Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -420,20 +387,17 @@ public void test110Statistics() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -468,20 +432,17 @@ public void test150CloseFirstStage() throws Exception { @Test public void test160Statistics() throws Exception { - final String TEST_NAME = "test160Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -497,20 +458,17 @@ public void test160Statistics() throws Exception { @Test public void test200OpenSecondStage() throws Exception { - final String TEST_NAME = "test200OpenSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -557,20 +515,17 @@ public void test200OpenSecondStage() throws Exception { @Test public void test210Statistics() throws Exception { - final String TEST_NAME = "test210Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -586,20 +541,17 @@ public void test210Statistics() throws Exception { @Test public void test220StatisticsAllStages() throws Exception { - final String TEST_NAME = "test220StatisticsAllStages"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -615,17 +567,14 @@ public void test220StatisticsAllStages() throws Exception { @Test public void test250RecordDecisionsSecondStage() throws Exception { - final String TEST_NAME = "test250RecordDecisionsSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType cooDummyBlackCase = findCase(caseList, ROLE_COO_OID, RESOURCE_DUMMY_BLACK_OID); AccessCertificationCaseType cooSuperuserCase = findCase(caseList, ROLE_COO_OID, ROLE_SUPERUSER_OID); @@ -637,7 +586,7 @@ public void test250RecordDecisionsSecondStage() throws Exception { recordDecision(campaignOid, superuserDummyCase, ACCEPT, null, USER_JACK_OID, task, result); // decision of administrator is missing here // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -702,20 +651,17 @@ public void test250RecordDecisionsSecondStage() throws Exception { @Test public void test260Statistics() throws Exception { - final String TEST_NAME = "test260Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -731,20 +677,17 @@ public void test260Statistics() throws Exception { @Test public void test290CloseSecondStage() throws Exception { - final String TEST_NAME = "test290CloseSecondStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,20 +735,17 @@ public void test290CloseSecondStage() throws Exception { @Test public void test300StartRemediation() throws Exception { - final String TEST_NAME = "test300StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -866,20 +806,17 @@ public void test300StartRemediation() throws Exception { @Test public void test310Statistics() throws Exception { - final String TEST_NAME = "test310Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestRoleInducementCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, false, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -895,12 +832,10 @@ public void test310Statistics() throws Exception { @Test public void test320CheckAfterClose() throws Exception { - final String TEST_NAME = "test320CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java index b3c3a13c2b1..0f5c0f26fdf 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/TestSoDCertification.java @@ -94,9 +94,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001Triggers() throws Exception { - final String TEST_NAME = "test001Triggers"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN, WHEN PrismObject jack = getUser(USER_JACK_OID); display("jack", jack); @@ -153,23 +150,20 @@ private void assertTriggers(AssignmentType assignment, int exclusionExpected, in @Test public void test010CreateCampaign() throws Exception { - final String TEST_NAME = "test010CreateCampaign"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); certificationDefinition = repoAddObjectFromFile(SOD_CERTIFICATION_DEF_FILE, AccessCertificationDefinitionType.class, result).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCampaignType campaign = certificationManager.createCampaign(certificationDefinition.getOid(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -185,19 +179,16 @@ public void test010CreateCampaign() throws Exception { @Test public void test012SearchAllCases() throws Exception { - final String TEST_NAME = "test012SearchAllCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -207,20 +198,17 @@ public void test012SearchAllCases() throws Exception { @Test public void test014Statistics() throws Exception { - final String TEST_NAME = "test014Statistics"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCasesStatisticsType stat = certificationManager.getCampaignStatistics(campaignOid, true, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -236,22 +224,19 @@ public void test014Statistics() throws Exception { @Test public void test020OpenFirstStage() throws Exception { - final String TEST_NAME = "test020OpenFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); display("jack", getUser(USER_JACK_OID)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.openNextStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -283,19 +268,16 @@ protected void checkAllCases(Collection caseList) @Test public void test030SearchAllCases() throws Exception { - final String TEST_NAME = "test030SearchCases"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -308,17 +290,14 @@ public void test030SearchAllCases() throws Exception { @Test public void test100RecordDecisions() throws Exception { - final String TEST_NAME = "test100RecordDecisions"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List caseList = queryHelper.searchCases(campaignOid, null, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); AccessCertificationCaseType test2aCase = findCase(caseList, USER_JACK_OID, roleATest2aOid); AccessCertificationCaseType test2bCase = findCase(caseList, USER_JACK_OID, roleATest2bOid); @@ -333,7 +312,7 @@ public void test100RecordDecisions() throws Exception { recordDecision(campaignOid, test3bCase, NOT_DECIDED, "dunno", USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -365,20 +344,17 @@ public void test100RecordDecisions() throws Exception { @Test public void test150CloseFirstStage() throws Exception { - final String TEST_NAME = "test150CloseFirstStage"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.closeCurrentStage(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -411,20 +387,17 @@ public void test150CloseFirstStage() throws Exception { @Test public void test200StartRemediation() throws Exception { - final String TEST_NAME = "test200StartRemediation"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestSoDCertification.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); certificationManager.startRemediation(campaignOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); @@ -464,12 +437,10 @@ public void test200StartRemediation() throws Exception { @Test public void test210CheckAfterClose() throws Exception { - final String TEST_NAME = "test210CheckAfterClose"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator.asPrismObject()); // GIVEN - Task task = taskManager.createTaskInstance(TestCertificationBasic.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); diff --git a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java index ac8e1b27d4b..f5ed0c18e3e 100644 --- a/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java +++ b/model/certification-impl/src/test/java/com/evolveum/midpoint/certification/test/complex/TestPolicyDrivenRoleLifecycle.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.Holder; import com.evolveum.midpoint.util.exception.*; @@ -111,17 +110,14 @@ protected File getSystemConfigurationFile() { @Test public void test010AttemptToActivateIncompleteRoleC1345() throws Exception { - final String TEST_NAME = "test010AttemptToActivateIncompleteRoleC1345"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); - TestUtil.displayThen(TEST_NAME); + when(); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleEmptyOid, contextHolder, result, task); @@ -146,17 +142,14 @@ private void activateRoleAssertFailure(String roleOid, Holder> co @Test public void test020AttemptToActivateIncompleteRoleC234() throws Exception { - final String TEST_NAME = "test020AttemptToActivateIncompleteRoleC234"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); - TestUtil.displayThen(TEST_NAME); + when(); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleHighRiskEmptyOid, contextHolder, result, task); @@ -169,17 +162,14 @@ public void test020AttemptToActivateIncompleteRoleC234() throws Exception { @Test public void test030AttemptToActivateCorrectRoleC34() throws Exception { - final String TEST_NAME = "test030AttemptToActivateCorrectRoleC34"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); - TestUtil.displayThen(TEST_NAME); + when(); + then(); Holder> contextHolder = new Holder<>(); activateRoleAssertFailure(roleCorrectOid, contextHolder, result, task); @@ -196,17 +186,14 @@ private void dumpRules(Holder> contextHolder) { @Test public void test040AssignOwnerAndApproverToCorrectRole() throws Exception { - final String TEST_NAME = "test040AssignOwnerAndApproverToCorrectRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); - TestUtil.displayThen(TEST_NAME); + when(); + then(); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); assignRole(USER_ADMINISTRATOR_OID, roleCorrectOid, SchemaConstants.ORG_OWNER, noApprovals, task, result); @@ -217,21 +204,18 @@ public void test040AssignOwnerAndApproverToCorrectRole() throws Exception { @Test public void test050ActivateCorrectRole() throws Exception { - final String TEST_NAME = "test050ActivateCorrectRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Holder> contextHolder = new Holder<>(); activateRole(roleCorrectOid, contextHolder, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject roleAfter = getRole(roleCorrectOid); display("role after", roleAfter); @@ -276,17 +260,14 @@ public void test050ActivateCorrectRole() throws Exception { @Test public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exception { - final String TEST_NAME = "test060AssignOwnerAndApproverToCorrectHighRiskRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN+THEN - TestUtil.displayWhen(TEST_NAME); - TestUtil.displayThen(TEST_NAME); + when(); + then(); ModelExecuteOptions noApprovals = createPartialProcessing(new PartialProcessingOptionsType().approvals(SKIP)); assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); assignRole(userJackOid, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result); @@ -298,21 +279,18 @@ public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exceptio @Test public void test070ActivateCorrectHighRiskRole() throws Exception { - final String TEST_NAME = "test070ActivateCorrectHighRiskRole"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(userAdministrator.asPrismObject()); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Holder> contextHolder = new Holder<>(); activateRole(roleCorrectHighRiskOid, contextHolder, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject roleAfter = getRole(roleCorrectHighRiskOid); display("role after", roleAfter); @@ -377,73 +355,4 @@ private void activateRole(String oid, Holder> contextHolder, Task } } } - -// @Test -// public void test010HireIndigo() throws Exception { -// final String TEST_NAME = "test010HireIndigo"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// assignOrg(USER_INDIGO_OID, ORG_LABORATORY_OID, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// SearchResultList> campaigns = repositoryService -// .searchObjects(AccessCertificationCampaignType.class, null, null, result); -// assertEquals("Wrong # of campaigns", 1, campaigns.size()); -// AccessCertificationCampaignType campaign = campaigns.get(0).asObjectable(); -// -// campaign = getCampaignWithCases(campaign.getOid()); -// display("campaign", campaign); -// assertSanityAfterCampaignStart(campaign, assignmentCertificationDefinition, 1); // beware, maybe not all details would match (in the future) - then adapt this test -// assertPercentComplete(campaign, 0, 0, 0); // no cases, no problems -// assertCasesCount(campaign.getOid(), 1); -// } -// -// @Test -// public void test020ModifyIndigo() throws Exception { -// final String TEST_NAME = "test020ModifyIndigo"; -// TestUtil.displayTestTitle(this, TEST_NAME); -// -// // GIVEN -// Task task = taskManager.createTaskInstance(TestPolicyDrivenRoleLifecycle.class.getName() + "." + TEST_NAME); -// task.setOwner(userAdministrator.asPrismObject()); -// OperationResult result = task.getResult(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// @SuppressWarnings({ "unchecked", "raw" }) -// ObjectDelta delta = (ObjectDelta) DeltaBuilder.deltaFor(UserType.class, prismContext) -// .item(UserType.F_DESCRIPTION).replace("new description") -// .item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED) -// .asObjectDelta(USER_INDIGO_OID); -// executeChanges(delta, null, task, result); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// result.computeStatus(); -// TestUtil.assertSuccess(result); -// -// SearchResultList> campaigns = repositoryService -// .searchObjects(AccessCertificationCampaignType.class, null, null, result); -// assertEquals("Wrong # of campaigns", 2, campaigns.size()); -// AccessCertificationCampaignType campaign = campaigns.stream() -// .filter(c -> MODIFICATION_CERT_DEF_OID.equals(c.asObjectable().getDefinitionRef().getOid())) -// .findFirst() -// .orElseThrow(() -> new AssertionError("No modification-triggered campaign")).asObjectable(); -// -// campaign = getCampaignWithCases(campaign.getOid()); -// display("campaign", campaign); -// assertSanityAfterCampaignStart(campaign, modificationCertificationDefinition, 1); // beware, maybe not all details would match (in the future) - then adapt this test -// assertPercentComplete(campaign, 0, 0, 0); // no cases, no problems -// } } diff --git a/model/model-common/pom.xml b/model/model-common/pom.xml index 3f4dd147999..9099d5cf774 100644 --- a/model/model-common/pom.xml +++ b/model/model-common/pom.xml @@ -170,7 +170,11 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT + test + + + com.evolveum.midpoint.tools + test-ng test diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java index 93f493b96cc..27fb55044ed 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/script/ScriptExpressionFactory.java @@ -7,19 +7,20 @@ package com.evolveum.midpoint.model.common.expression.script; import java.util.*; - import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.jetbrains.annotations.NotNull; + import com.evolveum.midpoint.CacheInvalidationContext; import com.evolveum.midpoint.model.common.expression.functions.CustomFunctions; import com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.crypto.Protector; +import com.evolveum.midpoint.repo.api.Cacheable; import com.evolveum.midpoint.repo.api.RepositoryService; import com.evolveum.midpoint.repo.cache.CacheRegistry; -import com.evolveum.midpoint.repo.api.Cacheable; import com.evolveum.midpoint.repo.common.ObjectResolver; import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; import com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException; @@ -41,12 +42,9 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.FunctionLibraryType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType; -import org.jetbrains.annotations.NotNull; /** - * * @author Radovan Semancik - * */ public class ScriptExpressionFactory implements Cacheable { @@ -54,7 +52,7 @@ public class ScriptExpressionFactory implements Cacheable { public static final String DEFAULT_LANGUAGE = "http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy"; - private Map evaluatorMap = new HashMap<>(); + private Map evaluatorMap = new HashMap<>(); private ObjectResolver objectResolver; private final PrismContext prismContext; private Collection functions; @@ -90,7 +88,7 @@ public void setObjectResolver(ObjectResolver objectResolver) { } public void setEvaluators(Collection evaluators) { - for (ScriptEvaluator evaluator: evaluators) { + for (ScriptEvaluator evaluator : evaluators) { registerEvaluator(evaluator.getLanguageUrl(), evaluator); } } @@ -115,9 +113,11 @@ public void setCacheRegistry(CacheRegistry registry) { this.cacheRegistry = registry; } - public ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, - ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult result) - throws ExpressionSyntaxException, SecurityViolationException { + public ScriptExpression createScriptExpression( + ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, + ExpressionProfile expressionProfile, ExpressionFactory expressionFactory, + String shortDesc, Task task, OperationResult result) + throws ExpressionSyntaxException, SecurityViolationException { initializeCustomFunctionsLibraryCache(expressionFactory, task, result); //cache cleanup method @@ -152,7 +152,7 @@ private ScriptExpressionProfile processScriptExpressionProfile(ExpressionProfile return null; } else { throw new SecurityViolationException("Access to script expression evaluator " + - " not allowed (expression profile: "+expressionProfile.getIdentifier()+") in "+shortDesc); + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc); } } ScriptExpressionProfile scriptProfile = evaluatorProfile.getScriptExpressionProfile(language); @@ -161,7 +161,7 @@ private ScriptExpressionProfile processScriptExpressionProfile(ExpressionProfile return null; } else { throw new SecurityViolationException("Access to script language " + language + - " not allowed (expression profile: "+expressionProfile.getIdentifier()+") in "+shortDesc); + " not allowed (expression profile: " + expressionProfile.getIdentifier() + ") in " + shortDesc); } } return scriptProfile; @@ -205,15 +205,15 @@ private synchronized void initializeCustomFunctionsLibraryCache(ExpressionFactor public void registerEvaluator(String language, ScriptEvaluator evaluator) { if (evaluatorMap.containsKey(language)) { - throw new IllegalArgumentException("Evaluator for language "+language+" already registered"); + throw new IllegalArgumentException("Evaluator for language " + language + " already registered"); } - evaluatorMap.put(language,evaluator); + evaluatorMap.put(language, evaluator); } private ScriptEvaluator getEvaluator(String language, String shortDesc) throws ExpressionSyntaxException { ScriptEvaluator evaluator = evaluatorMap.get(language); if (evaluator == null) { - throw new ExpressionSyntaxException("Unsupported language "+language+" used in script in "+shortDesc); + throw new ExpressionSyntaxException("Unsupported language " + language + " used in script in " + shortDesc); } return evaluator; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java index 96f92eb4f56..db701349071 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/mapping/MappingImpl.java @@ -6,6 +6,14 @@ */ package com.evolveum.midpoint.model.common.mapping; +import java.util.*; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.jetbrains.annotations.NotNull; + import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.model.api.context.Mapping; import com.evolveum.midpoint.prism.*; @@ -35,25 +43,17 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.DeltaSetTripleType; import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import org.jetbrains.annotations.NotNull; - -import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; -import java.util.*; /** - * * Mapping is non-recyclable single-use object. Once evaluated it should not be evaluated again. It will retain its original * inputs and outputs that can be read again and again. But these should not be changed after evaluation. - * + *

* Configuration properties are unmodifiable. They are to be set via Mapping.Builder. * * @author Radovan Semancik - * */ -public class MappingImpl implements Mapping, DebugDumpable, PrismValueDeltaSetTripleProducer { +public class MappingImpl + implements Mapping, DebugDumpable, PrismValueDeltaSetTripleProducer { private static final String OP_EVALUATE_PREPARED = MappingImpl.class.getName() + ".evaluatePrepared"; private static final String OP_EVALUATE = MappingImpl.class.getName() + ".evaluate"; @@ -67,8 +67,8 @@ public class MappingImpl implemen private final ObjectDeltaObject sourceContext; private TypedValue> typedSourceContext; // cached - private final Collection> sources; - private final Source defaultSource; + private final Collection> sources; + private final Source defaultSource; private final PrismObjectDefinition targetContext; private final ItemPath defaultTargetPath; @@ -89,7 +89,7 @@ public class MappingImpl implemen private final String contextDescription; private final QName mappingQName; // This is sometimes used to identify the element that mapping produces - // if it is different from itemName. E.g. this happens with associations. + // if it is different from itemName. E.g. this happens with associations. private final RefinedObjectClassDefinition refinedObjectClassDefinition; // working and output properties @@ -121,15 +121,15 @@ public class MappingImpl implemen // This is single-use only. Once evaluated it is not used any more // it is remembered only for tracing purposes. - private Expression expression; + private Expression expression; // Mapping state properties that are exposed to the expressions. They can be used by the expressions to "communicate". // E.g. one expression seting the property and other expression checking the property. - private Map stateProperties; + private Map stateProperties; private static final Trace LOGGER = TraceManager.getTrace(MappingImpl.class); - private MappingImpl(Builder builder) { + private MappingImpl(Builder builder) { prismContext = builder.prismContext; expressionFactory = builder.expressionFactory; variables = builder.variables; @@ -179,7 +179,7 @@ public ObjectType getOriginObject() { return originObject; } - public Source getDefaultSource() { + public Source getDefaultSource() { return defaultSource; } @@ -223,7 +223,7 @@ public String getMappingContextDescription() { } sb.append("in "); sb.append(contextDescription); - mappingContextDescription = sb.toString(); + mappingContextDescription = sb.toString(); } return mappingContextDescription; } @@ -316,7 +316,7 @@ public boolean isApplicableToChannel(String channelUri) { public static boolean isApplicableToChannel(MappingType mappingType, String channelUri) { List exceptChannel = mappingType.getExceptChannel(); - if (exceptChannel != null && !exceptChannel.isEmpty()){ + if (exceptChannel != null && !exceptChannel.isEmpty()) { return !exceptChannel.contains(channelUri); } List applicableChannels = mappingType.getChannel(); @@ -387,7 +387,7 @@ public T setStateProperty(String propertyName, T value) { stateProperties = new HashMap<>(); } //noinspection unchecked - return (T)stateProperties.put(propertyName, value); + return (T) stateProperties.put(propertyName, value); } // TODO: rename to evaluateAll @@ -446,7 +446,7 @@ public void prepare(Task task, OperationResult parentResult) parseTarget(); if (outputPath != null && outputDefinition == null) { - throw new IllegalArgumentException("No output definition, cannot evaluate "+getMappingContextDescription()); + throw new IllegalArgumentException("No output definition, cannot evaluate " + getMappingContextDescription()); } } catch (ExpressionEvaluationException | ObjectNotFoundException | RuntimeException | SchemaException | @@ -510,10 +510,10 @@ private void evaluateBody(Task task, OperationResult parentResult) throws Expres evaluateCondition(task, result); - boolean conditionOutputOld = computeConditionResult(conditionOutputTriple==null ? null : conditionOutputTriple.getNonPositiveValues()); + boolean conditionOutputOld = computeConditionResult(conditionOutputTriple == null ? null : conditionOutputTriple.getNonPositiveValues()); boolean conditionResultOld = conditionOutputOld && conditionMaskOld; - boolean conditionOutputNew = computeConditionResult(conditionOutputTriple==null ? null : conditionOutputTriple.getNonNegativeValues()); + boolean conditionOutputNew = computeConditionResult(conditionOutputTriple == null ? null : conditionOutputTriple.getNonNegativeValues()); boolean conditionResultNew = conditionOutputNew && conditionMaskNew; if (trace != null) { @@ -594,7 +594,7 @@ private void checkRangeTarget(Task task, OperationResult result) throw new IllegalStateException("Couldn't check range for mapping in " + contextDescription + ", as original target values are not known."); } ValueSetDefinitionType rangetSetDefType = mappingType.getTarget().getSet(); - ValueSetDefinition setDef = new ValueSetDefinition<>(rangetSetDefType, outputDefinition, expressionProfile, name, "range of "+name+" in "+getMappingContextDescription(), task, result); + ValueSetDefinition setDef = new ValueSetDefinition<>(rangetSetDefType, outputDefinition, expressionProfile, name, "range of " + name + " in " + getMappingContextDescription(), task, result); setDef.init(expressionFactory); setDef.setAdditionalVariables(variables); for (V originalValue : originalTargetValues) { @@ -615,7 +615,7 @@ private void addToMinusIfNecessary(V originalValue) { outputTriple = getPrismContext().deltaFactory().createPrismValueDeltaSetTriple(); } LOGGER.trace("Original value is in the mapping range (while not in mapping result), adding it to minus set: {}", originalValue); - outputTriple.addToMinusSet((V)originalValue.clone()); + outputTriple.addToMinusSet((V) originalValue.clone()); } @SuppressWarnings("unused") // todo is this externally used? @@ -764,7 +764,7 @@ private void appendTraceHeader(StringBuilder sb) { if (!isAuthoritative()) { sb.append("\nNot authoritative"); } - for (Source source: sources) { + for (Source source : sources) { sb.append("\n"); source.mediumDump(sb); } @@ -858,7 +858,7 @@ private XMLGregorianCalendar parseTime(MappingTimeDeclarationType timeType, Task if (referenceTimeType == null) { if (defaultReferenceTime == null) { if (expressionType == null) { - throw new SchemaException("No reference time specified, there is also no default and no expression; in time specification in "+getMappingContextDescription()); + throw new SchemaException("No reference time specified, there is also no default and no expression; in time specification in " + getMappingContextDescription()); } else { referenceTime = null; } @@ -885,7 +885,7 @@ private XMLGregorianCalendar parseTime(MappingTimeDeclarationType timeType, Task timeVariables.addVariableDefinitions(variables); timeVariables.addVariableDefinition(ExpressionConstants.VAR_REFERENCE_TIME, referenceTime, timeDefinition); - PrismPropertyValue timePropVal = ExpressionUtil.evaluateExpression(sources, timeVariables, timeDefinition, expressionType, expressionProfile, expressionFactory, "time expression in "+contextDescription, task, result); + PrismPropertyValue timePropVal = ExpressionUtil.evaluateExpression(sources, timeVariables, timeDefinition, expressionType, expressionProfile, expressionFactory, "time expression in " + contextDescription, task, result); if (timePropVal == null) { return null; @@ -905,19 +905,19 @@ private XMLGregorianCalendar parseTimeSource(VariableBindingDefinitionType sourc SecurityViolationException, ExpressionEvaluationException { ItemPath path = getSourcePath(source); - Object sourceObject = ExpressionUtil.resolvePathGetValue(path, variables, false, getTypedSourceContext(), objectResolver, getPrismContext(), "reference time definition in "+getMappingContextDescription(), task, result); + Object sourceObject = ExpressionUtil.resolvePathGetValue(path, variables, false, getTypedSourceContext(), objectResolver, getPrismContext(), "reference time definition in " + getMappingContextDescription(), task, result); if (sourceObject == null) { return null; } PrismProperty timeProperty; - if (sourceObject instanceof ItemDeltaItem) { + if (sourceObject instanceof ItemDeltaItem) { //noinspection unchecked - timeProperty = (PrismProperty) ((ItemDeltaItem)sourceObject).getItemNew(); - } else if (sourceObject instanceof Item) { + timeProperty = (PrismProperty) ((ItemDeltaItem) sourceObject).getItemNew(); + } else if (sourceObject instanceof Item) { //noinspection unchecked timeProperty = (PrismProperty) sourceObject; } else { - throw new IllegalStateException("Unknown resolve result "+sourceObject); + throw new IllegalStateException("Unknown resolve result " + sourceObject); } return timeProperty != null ? timeProperty.getRealValue() : null; } @@ -932,8 +932,8 @@ private void parseSources(Task task, OperationResult result) defaultSource.recompute(); } if (sourceDefinitions != null) { - for (VariableBindingDefinitionType sourceDefinition: sourceDefinitions) { - Source source = parseSource(sourceDefinition, task, result); + for (VariableBindingDefinitionType sourceDefinition : sourceDefinitions) { + Source source = parseSource(sourceDefinition, task, result); source.recompute(); // Override existing sources (e.g. default source) @@ -943,7 +943,7 @@ private void parseSources(Task task, OperationResult result) } } - private Source parseSource(VariableBindingDefinitionType sourceDefinition, + private Source parseSource(VariableBindingDefinitionType sourceDefinition, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { @@ -953,48 +953,48 @@ private Source parseSo TypedValue typedSourceObject = ExpressionUtil.resolvePathGetTypedValue(path, variables, true, getTypedSourceContext(), objectResolver, getPrismContext(), - "source definition in "+getMappingContextDescription(), task, result); + "source definition in " + getMappingContextDescription(), task, result); Object sourceObject = typedSourceObject != null ? typedSourceObject.getValue() : null; - Item itemOld = null; - ItemDelta delta = null; - Item itemNew = null; + Item itemOld = null; + ItemDelta delta = null; + Item itemNew = null; ItemPath resolvePath = path; ItemPath residualPath = null; - Collection> subItemDeltas = null; + Collection> subItemDeltas = null; if (sourceObject != null) { - if (sourceObject instanceof ItemDeltaItem) { + if (sourceObject instanceof ItemDeltaItem) { //noinspection unchecked - itemOld = ((ItemDeltaItem)sourceObject).getItemOld(); + itemOld = ((ItemDeltaItem) sourceObject).getItemOld(); //noinspection unchecked - delta = ((ItemDeltaItem)sourceObject).getDelta(); + delta = ((ItemDeltaItem) sourceObject).getDelta(); //noinspection unchecked - itemNew = ((ItemDeltaItem)sourceObject).getItemNew(); + itemNew = ((ItemDeltaItem) sourceObject).getItemNew(); //noinspection unchecked - residualPath = ((ItemDeltaItem)sourceObject).getResidualPath(); + residualPath = ((ItemDeltaItem) sourceObject).getResidualPath(); //noinspection unchecked - resolvePath = ((ItemDeltaItem)sourceObject).getResolvePath(); + resolvePath = ((ItemDeltaItem) sourceObject).getResolvePath(); //noinspection unchecked - subItemDeltas = ((ItemDeltaItem)sourceObject).getSubItemDeltas(); - } else if (sourceObject instanceof Item) { + subItemDeltas = ((ItemDeltaItem) sourceObject).getSubItemDeltas(); + } else if (sourceObject instanceof Item) { //noinspection unchecked - itemOld = (Item) sourceObject; + itemOld = (Item) sourceObject; //noinspection unchecked - itemNew = (Item) sourceObject; + itemNew = (Item) sourceObject; } else { - throw new IllegalStateException("Unknown resolve result "+sourceObject); + throw new IllegalStateException("Unknown resolve result " + sourceObject); } } // TODO what if typedSourceObject is null? //noinspection unchecked - ID sourceItemDefinition = (ID)typedSourceObject.getDefinition(); + ID sourceItemDefinition = (ID) typedSourceObject.getDefinition(); // apply domain ValueSetDefinitionType domainSetType = sourceDefinition.getSet(); if (domainSetType != null) { - ValueSetDefinition setDef = new ValueSetDefinition<>(domainSetType, sourceItemDefinition, expressionProfile, variableName, "domain of "+variableName+" in "+getMappingContextDescription(), task, result); + ValueSetDefinition setDef = new ValueSetDefinition<>(domainSetType, sourceItemDefinition, expressionProfile, variableName, "domain of " + variableName + " in " + getMappingContextDescription(), task, result); setDef.init(expressionFactory); setDef.setAdditionalVariables(variables); try { @@ -1034,7 +1034,7 @@ private Source parseSo } } - Source source = new Source<>(itemOld, delta, itemNew, sourceQName, sourceItemDefinition); + Source source = new Source<>(itemOld, delta, itemNew, sourceQName, sourceItemDefinition); source.setResidualPath(residualPath); source.setResolvePath(resolvePath); source.setSubItemDeltas(subItemDeltas); @@ -1055,7 +1055,7 @@ private ItemPath getSourcePath(VariableBindingDefinitionType sourceType) throws } private boolean sourcesChanged() { - for (Source source: sources) { + for (Source source : sources) { if (source.getDelta() != null) { return true; } @@ -1075,9 +1075,9 @@ private void parseTarget() throws SchemaException { outputPath = defaultTargetPath; } else { ItemPath path = itemPathType.getItemPath(); - outputDefinition = ExpressionUtil.resolveDefinitionPath(path, variables, targetContext, "target definition in "+getMappingContextDescription()); + outputDefinition = ExpressionUtil.resolveDefinitionPath(path, variables, targetContext, "target definition in " + getMappingContextDescription()); if (outputDefinition == null) { - throw new SchemaException("No target item that would conform to the path "+path+" in "+getMappingContextDescription()); + throw new SchemaException("No target item that would conform to the path " + path + " in " + getMappingContextDescription()); } outputPath = path.stripVariableSegment(); } @@ -1120,7 +1120,7 @@ private void recomputeValues() { } Visitor visitor = visitable -> { if (visitable instanceof PrismValue) { - ((PrismValue)visitable).recompute(getPrismContext()); + ((PrismValue) visitable).recompute(getPrismContext()); } }; outputTriple.accept(visitor); @@ -1146,11 +1146,11 @@ private void evaluateCondition(Task task, OperationResult result) throws SchemaE conditionOutputTriple.addToZeroSet(getPrismContext().itemFactory().createPropertyValue(Boolean.TRUE)); return; } - Expression,PrismPropertyDefinition> expression = + Expression, PrismPropertyDefinition> expression = ExpressionUtil.createCondition(conditionExpressionType, expressionProfile, expressionFactory, - "condition in "+getMappingContextDescription(), task, result); + "condition in " + getMappingContextDescription(), task, result); ExpressionEvaluationContext context = new ExpressionEvaluationContext(sources, variables, - "condition in "+getMappingContextDescription(), task); + "condition in " + getMappingContextDescription(), task); context.setValuePolicyResolver(stringPolicyResolver); context.setExpressionFactory(expressionFactory); context.setDefaultSource(defaultSource); @@ -1161,16 +1161,15 @@ private void evaluateCondition(Task task, OperationResult result) throws SchemaE conditionOutputTriple = expression.evaluate(context, result); } - private void evaluateExpression(Task task, OperationResult result, boolean conditionResultOld, boolean conditionResultNew) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { ExpressionType expressionType = null; if (mappingType != null) { expressionType = mappingType.getExpression(); } expression = expressionFactory.makeExpression(expressionType, outputDefinition, expressionProfile, - "expression in "+getMappingContextDescription(), task, result); + "expression in " + getMappingContextDescription(), task, result); ExpressionEvaluationContext context = new ExpressionEvaluationContext(sources, variables, - "expression in "+getMappingContextDescription(), task); + "expression in " + getMappingContextDescription(), task); context.setDefaultSource(defaultSource); context.setSkipEvaluationMinus(!conditionResultOld); context.setSkipEvaluationPlus(!conditionResultNew); @@ -1231,17 +1230,17 @@ public PrismValueDeltaSetTriple getOutputTriple() { return outputTriple; } - public Item getOutput() throws SchemaException { + public Item getOutput() throws SchemaException { if (outputTriple == null) { return null; } //noinspection unchecked - Item output = outputDefinition.instantiate(); + Item output = outputDefinition.instantiate(); output.addAll(PrismValueCollectionsUtil.cloneCollection(outputTriple.getNonNegativeValues())); return output; } - public ItemDelta createEmptyDelta(ItemPath path) { + public ItemDelta createEmptyDelta(ItemPath path) { //noinspection unchecked return outputDefinition.createEmptyDelta(path); } @@ -1252,7 +1251,7 @@ private void transitionState(MappingEvaluationState newState) { private void assertState(MappingEvaluationState expectedState) { if (state != expectedState) { - throw new IllegalArgumentException("Expected mapping state "+expectedState+", but was "+state); + throw new IllegalArgumentException("Expected mapping state " + expectedState + ", but was " + state); } } @@ -1319,94 +1318,58 @@ public int hashCode() { @SuppressWarnings("RedundantIfStatement") @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; + if (this == obj) { return true; } + if (obj == null) { return false; } + if (getClass() != obj.getClass()) { return false; } MappingImpl other = (MappingImpl) obj; - if (conditionMaskNew != other.conditionMaskNew) - return false; - if (conditionMaskOld != other.conditionMaskOld) - return false; + if (conditionMaskNew != other.conditionMaskNew) { return false; } + if (conditionMaskOld != other.conditionMaskOld) { return false; } if (conditionOutputTriple == null) { - if (other.conditionOutputTriple != null) - return false; - } else if (!conditionOutputTriple.equals(other.conditionOutputTriple)) - return false; + if (other.conditionOutputTriple != null) { return false; } + } else if (!conditionOutputTriple.equals(other.conditionOutputTriple)) { return false; } if (defaultSource == null) { - if (other.defaultSource != null) - return false; - } else if (!defaultSource.equals(other.defaultSource)) - return false; + if (other.defaultSource != null) { return false; } + } else if (!defaultSource.equals(other.defaultSource)) { return false; } if (defaultTargetDefinition == null) { - if (other.defaultTargetDefinition != null) - return false; - } else if (!defaultTargetDefinition.equals(other.defaultTargetDefinition)) - return false; + if (other.defaultTargetDefinition != null) { return false; } + } else if (!defaultTargetDefinition.equals(other.defaultTargetDefinition)) { return false; } if (expressionProfile == null) { - if (other.expressionProfile != null) - return false; - } else if (!expressionProfile.equals(other.expressionProfile)) - return false; + if (other.expressionProfile != null) { return false; } + } else if (!expressionProfile.equals(other.expressionProfile)) { return false; } if (expressionFactory == null) { - if (other.expressionFactory != null) - return false; - } else if (!expressionFactory.equals(other.expressionFactory)) - return false; + if (other.expressionFactory != null) { return false; } + } else if (!expressionFactory.equals(other.expressionFactory)) { return false; } if (mappingType == null) { - if (other.mappingType != null) - return false; - } else if (!mappingType.equals(other.mappingType)) - return false; + if (other.mappingType != null) { return false; } + } else if (!mappingType.equals(other.mappingType)) { return false; } if (objectResolver == null) { - if (other.objectResolver != null) - return false; - } else if (!objectResolver.equals(other.objectResolver)) - return false; + if (other.objectResolver != null) { return false; } + } else if (!objectResolver.equals(other.objectResolver)) { return false; } if (originObject == null) { - if (other.originObject != null) - return false; - } else if (!originObject.equals(other.originObject)) - return false; - if (originType != other.originType) - return false; + if (other.originObject != null) { return false; } + } else if (!originObject.equals(other.originObject)) { return false; } + if (originType != other.originType) { return false; } if (outputDefinition == null) { - if (other.outputDefinition != null) - return false; - } else if (!outputDefinition.equals(other.outputDefinition)) - return false; + if (other.outputDefinition != null) { return false; } + } else if (!outputDefinition.equals(other.outputDefinition)) { return false; } if (outputTriple == null) { - if (other.outputTriple != null) - return false; - } else if (!outputTriple.equals(other.outputTriple)) - return false; + if (other.outputTriple != null) { return false; } + } else if (!outputTriple.equals(other.outputTriple)) { return false; } if (contextDescription == null) { - if (other.contextDescription != null) - return false; - } else if (!contextDescription.equals(other.contextDescription)) - return false; + if (other.contextDescription != null) { return false; } + } else if (!contextDescription.equals(other.contextDescription)) { return false; } if (sourceContext == null) { - if (other.sourceContext != null) - return false; - } else if (!sourceContext.equals(other.sourceContext)) - return false; + if (other.sourceContext != null) { return false; } + } else if (!sourceContext.equals(other.sourceContext)) { return false; } if (sources == null) { - if (other.sources != null) - return false; - } else if (!sources.equals(other.sources)) - return false; + if (other.sources != null) { return false; } + } else if (!sources.equals(other.sources)) { return false; } if (targetContext == null) { - if (other.targetContext != null) - return false; - } else if (!targetContext.equals(other.targetContext)) - return false; + if (other.targetContext != null) { return false; } + } else if (!targetContext.equals(other.targetContext)) { return false; } if (variables == null) { - if (other.variables != null) - return false; - } else if (!variables.equals(other.variables)) - return false; + if (other.variables != null) { return false; } + } else if (!variables.equals(other.variables)) { return false; } return true; } @@ -1421,7 +1384,7 @@ public String debugDump(int indent) { @Override public String toString() { if (mappingType != null && mappingType.getName() != null) { - return "M(" + mappingType.getName()+ ": "+ getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; + return "M(" + mappingType.getName() + ": " + getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; } else { return "M(" + getMappingDisplayName() + " = " + outputTriple + toStringStrength() + ")"; } @@ -1439,9 +1402,12 @@ private String getMappingDisplayName() { private String toStringStrength() { switch (getStrength()) { - case NORMAL: return ""; - case WEAK: return ", weak"; - case STRONG: return ", strong"; + case NORMAL: + return ""; + case WEAK: + return ", weak"; + case STRONG: + return ", strong"; } return null; } @@ -1467,16 +1433,14 @@ public String toHumanReadableDescription() { return sb.toString(); } - - /** * Builder is used to construct a configuration of Mapping object, which - after building - becomes * immutable. - * + *

* In order to provide backward-compatibility with existing use of Mapping object, the builder has * also traditional setter methods. Both setters and "builder-style" methods MODIFY existing Builder * object (i.e. they do not create a new one). - * + *

* TODO decide on which style of setters to keep (setters vs builder-style). */ @SuppressWarnings({ "unused", "BooleanMethodIsAlwaysInverted", "UnusedReturnValue" }) @@ -1486,14 +1450,14 @@ public static final class Builder defaultSource; + private Source defaultSource; private D defaultTargetDefinition; private ExpressionProfile expressionProfile; private ItemPath defaultTargetPath; private Collection originalTargetValues; private ObjectDeltaObject sourceContext; private PrismObjectDefinition targetContext; - private Collection> sources = new ArrayList<>(); + private Collection> sources = new ArrayList<>(); private OriginType originType; private ObjectType originObject; private ValuePolicyResolver valuePolicyResolver; @@ -1509,58 +1473,57 @@ public static final class Builder expressionFactory(ExpressionFactory val) { + public Builder expressionFactory(ExpressionFactory val) { expressionFactory = val; return this; } - public Builder variables(ExpressionVariables val) { + public Builder variables(ExpressionVariables val) { variables = val; return this; } - public Builder mappingType(MappingType val) { + public Builder mappingType(MappingType val) { mappingType = val; return this; } - public Builder objectResolver(ObjectResolver val) { + public Builder objectResolver(ObjectResolver val) { objectResolver = val; return this; } - public Builder securityContextManager(SecurityContextManager val) { + public Builder securityContextManager(SecurityContextManager val) { securityContextManager = val; return this; } - public Builder defaultSource(Source val) { + public Builder defaultSource(Source val) { defaultSource = val; return this; } - public Builder defaultTargetDefinition(D val) { + public Builder defaultTargetDefinition(D val) { defaultTargetDefinition = val; return this; } - public Builder expressionProfile(ExpressionProfile val) { + public Builder expressionProfile(ExpressionProfile val) { expressionProfile = val; return this; } - public Builder defaultTargetPath(ItemPath val) { + public Builder defaultTargetPath(ItemPath val) { defaultTargetPath = val; return this; } - public Builder originalTargetValues(Collection values) { + public Builder originalTargetValues(Collection values) { originalTargetValues = values; return this; } - public Builder sourceContext(ObjectDeltaObject val) { + public Builder sourceContext(ObjectDeltaObject val) { if (val.getDefinition() == null) { throw new IllegalArgumentException("Attempt to set mapping source context without a definition"); } @@ -1568,87 +1531,87 @@ public Builder sourceContext(ObjectDeltaObject val) { return this; } - public Builder targetContext(PrismObjectDefinition val) { + public Builder targetContext(PrismObjectDefinition val) { targetContext = val; return this; } - public Builder sources(Collection> val) { + public Builder sources(Collection> val) { sources = val; return this; } - public Builder originType(OriginType val) { + public Builder originType(OriginType val) { originType = val; return this; } - public Builder originObject(ObjectType val) { + public Builder originObject(ObjectType val) { originObject = val; return this; } - public Builder valuePolicyResolver(ValuePolicyResolver val) { + public Builder valuePolicyResolver(ValuePolicyResolver val) { valuePolicyResolver = val; return this; } - public Builder variableResolver(VariableProducer variableProducer) { + public Builder variableResolver(VariableProducer variableProducer) { this.variableProducer = variableProducer; return this; } - public Builder mappingPreExpression(MappingPreExpression mappingPreExpression) { + public Builder mappingPreExpression(MappingPreExpression mappingPreExpression) { this.mappingPreExpression = mappingPreExpression; return this; } - public Builder conditionMaskOld(boolean val) { + public Builder conditionMaskOld(boolean val) { conditionMaskOld = val; return this; } - public Builder conditionMaskNew(boolean val) { + public Builder conditionMaskNew(boolean val) { conditionMaskNew = val; return this; } - public Builder now(XMLGregorianCalendar val) { + public Builder now(XMLGregorianCalendar val) { now = val; return this; } - public Builder defaultReferenceTime(XMLGregorianCalendar val) { + public Builder defaultReferenceTime(XMLGregorianCalendar val) { defaultReferenceTime = val; return this; } - public Builder profiling(boolean val) { + public Builder profiling(boolean val) { profiling = val; return this; } - public Builder contextDescription(String val) { + public Builder contextDescription(String val) { contextDescription = val; return this; } - public Builder mappingQName(QName val) { + public Builder mappingQName(QName val) { mappingQName = val; return this; } - public Builder refinedObjectClassDefinition(RefinedObjectClassDefinition val) { + public Builder refinedObjectClassDefinition(RefinedObjectClassDefinition val) { refinedObjectClassDefinition = val; return this; } - public Builder prismContext(PrismContext val) { + public Builder prismContext(PrismContext val) { prismContext = val; return this; } - public MappingImpl build() { + public MappingImpl build() { return new MappingImpl<>(this); } @@ -1830,7 +1793,7 @@ public Builder addVariableDefinition(String name, PrismValue value) { public Builder addVariableDefinition(String name, ObjectDeltaObject value) { PrismObjectDefinition definition = value.getDefinition(); if (definition == null) { - throw new IllegalArgumentException("Attempt to set variable '"+name+"' as ODO without a definition: "+value); + throw new IllegalArgumentException("Attempt to set variable '" + name + "' as ODO without a definition: " + value); } return addVariableDefinition(name, value, definition); } @@ -1863,7 +1826,7 @@ public boolean isApplicableToChannel(String channel) { return MappingImpl.isApplicableToChannel(mappingType, channel); } - public Builder addSource(Source source) { + public Builder addSource(Source source) { sources.add(source); return this; } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java index ca11d7a866e..a7a13e48e83 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/AbstractModelCommonTest.java @@ -10,31 +10,18 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.test.NullTaskImpl; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; /** * @author semancik - * */ -public class AbstractModelCommonTest { +public class AbstractModelCommonTest extends AbstractUnitTest { protected static final File COMMON_DIR = new File("src/test/resources/common"); protected static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); protected static final String EXPRESSION_PROFILE_SAFE_NAME = "safe"; - protected void displayTestTitle(final String TEST_NAME) { - TestUtil.displayTestTitle(this, TEST_NAME); - } - - protected void displayWhen(final String TEST_NAME) { - TestUtil.displayWhen(TEST_NAME); - } - - protected void displayThen(final String TEST_NAME) { - TestUtil.displayThen(TEST_NAME); - } - protected Task createTask() { return new NullTaskImpl(); } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java index 5c4094aad8b..1cf8bba5cdb 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpression.java @@ -6,15 +6,12 @@ */ package com.evolveum.midpoint.model.common.expression; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; - import javax.xml.namespace.QName; import org.testng.AssertJUnit; @@ -25,27 +22,13 @@ import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.model.common.AbstractModelCommonTest; import com.evolveum.midpoint.model.common.ConstantsManager; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrimitiveType; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismPropertyValue; -import com.evolveum.midpoint.prism.PrismValue; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver; import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.Expression; -import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; -import com.evolveum.midpoint.repo.common.expression.ExpressionFactory; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.repo.common.expression.Source; +import com.evolveum.midpoint.repo.common.expression.*; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -59,19 +42,10 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +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.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationExpressionsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author Radovan Semancik @@ -109,8 +83,6 @@ public class TestExpression extends AbstractModelCommonTest { private static final Trace LOGGER = TraceManager.getTrace(TestExpression.class); - - protected PrismContext prismContext; protected ExpressionFactory expressionFactory; protected ConstantsManager constantsManager; @@ -140,27 +112,24 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100AsIs() throws Exception { - final String TEST_NAME = "test100AsIs"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_ASIS_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, result); // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(INPUT_VALUE); assertScriptExecutionIncrement(0); @@ -168,18 +137,15 @@ public void test100AsIs() throws Exception { @Test public void test110Path() throws Exception { - final String TEST_NAME = "test110Path"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_PATH_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, @@ -187,9 +153,9 @@ public void test110Path() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(USER_JACK_NAME); assertScriptExecutionIncrement(0); @@ -197,18 +163,15 @@ public void test110Path() throws Exception { @Test public void test120Value() throws Exception { - final String TEST_NAME = "test120Value"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_VALUE_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -216,9 +179,9 @@ public void test120Value() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(EXPRESSION_VALUE_OUTPUT); assertScriptExecutionIncrement(0); @@ -226,18 +189,15 @@ public void test120Value() throws Exception { @Test public void test130Const() throws Exception { - final String TEST_NAME = "test130Const"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_CONST_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -245,9 +205,9 @@ public void test130Const() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(ExpressionTestUtil.CONST_FOO_VALUE); assertScriptExecutionIncrement(0); @@ -255,18 +215,15 @@ public void test130Const() throws Exception { @Test public void test150ScriptGroovySimple() throws Exception { - final String TEST_NAME = "test150ScriptGroovySimple"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SIMPLE_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -274,9 +231,9 @@ public void test150ScriptGroovySimple() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(VAR_FOO_VALUE + VAR_BAR_VALUE); assertScriptExecutionIncrement(1); @@ -284,18 +241,15 @@ public void test150ScriptGroovySimple() throws Exception { @Test public void test152ScriptGroovySystemAllow() throws Exception { - final String TEST_NAME = "test152ScriptGroovySystemAllow"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_ALLOW_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -303,9 +257,9 @@ public void test152ScriptGroovySystemAllow() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(GROOVY_SCRIPT_OUTPUT_SUCCESS); assertScriptExecutionIncrement(1); @@ -313,18 +267,15 @@ public void test152ScriptGroovySystemAllow() throws Exception { @Test public void test154ScriptGroovySystemDeny() throws Exception { - final String TEST_NAME = "test154ScriptGroovySystemDeny"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_DENY_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -332,9 +283,9 @@ public void test154ScriptGroovySystemDeny() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(GROOVY_SCRIPT_OUTPUT_SUCCESS); assertScriptExecutionIncrement(1); @@ -342,18 +293,15 @@ public void test154ScriptGroovySystemDeny() throws Exception { @Test public void test160ScriptJavaScript() throws Exception { - final String TEST_NAME = "test160ScriptJavaScript"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_JAVASCRIPT_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -361,9 +309,9 @@ public void test160ScriptJavaScript() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(VAR_FOO_VALUE + VAR_BAR_VALUE); assertScriptExecutionIncrement(1); @@ -371,11 +319,8 @@ public void test160ScriptJavaScript() throws Exception { @Test public void test200IterationCondition() throws Exception { - final String TEST_NAME = "test200IterationCondition"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); @@ -397,7 +342,7 @@ public void test200IterationCondition() throws Exception { variables.put(ExpressionConstants.VAR_ITERATION_TOKEN, "001", TestUtil.createPrimitivePropertyDefinition(prismContext, ExpressionConstants.VAR_ITERATION_TOKEN, PrimitiveType.STRING)); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null , variables, TEST_NAME, createTask()); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(null, variables, getTestNameShort(), createTask()); // WHEN PrismValueDeltaSetTriple> outputTriple = @@ -405,9 +350,9 @@ public void test200IterationCondition() throws Exception { // THEN assertOutputTriple(outputTriple) - .assertEmptyMinus() - .assertEmptyPlus() - .zeroSet() + .assertEmptyMinus() + .assertEmptyPlus() + .zeroSet() .assertSinglePropertyValue(Boolean.TRUE); // Make sure that the script is executed only once. There is no delta in the variables, no need to do it twice. @@ -418,7 +363,7 @@ protected ExpressionType parseExpression(File file) throws SchemaException, IOEx return PrismTestUtil.parseAtomicValue(file, ExpressionType.COMPLEX_TYPE); } - protected Source,PrismPropertyDefinition> prepareStringSource(String value) throws SchemaException { + protected Source, PrismPropertyDefinition> prepareStringSource() throws SchemaException { PrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.VAR_INPUT_QNAME, PrimitiveType.STRING.getQname()); PrismProperty inputProp = prismContext.itemFactory().createProperty(ExpressionConstants.VAR_INPUT_QNAME, propDef); PrismPropertyValue pval = prismContext.itemFactory().createPropertyValue(INPUT_VALUE); @@ -426,9 +371,9 @@ protected Source,PrismPropertyDefinition> pre return new Source<>(inputProp, null, inputProp, ExpressionConstants.VAR_INPUT_QNAME, propDef); } - protected Collection> prepareStringSources(String value) throws SchemaException { + protected Collection> prepareStringSources() throws SchemaException { Collection> sources = new ArrayList<>(); - sources.add(prepareStringSource(value)); + sources.add(prepareStringSource()); return sources; } @@ -444,8 +389,8 @@ protected ExpressionVariables prepareBasicVariables() throws SchemaException, IO protected PrismValueDeltaSetTriple evaluateExpression( ExpressionType expressionType, D outputDefinition, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Expression expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Expression expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), expressionContext.getContextDescription(), expressionContext.getTask(), result); LOGGER.debug("Starting evaluation of expression: {}", expression); return expression.evaluate(expressionContext, result); @@ -453,7 +398,7 @@ protected PrismValueDeltaSetTri protected PrismValueDeltaSetTriple> evaluatePropertyExpression( ExpressionType expressionType, QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, outputType); return evaluateExpression(expressionType, outputDefinition, expressionContext, result); @@ -462,19 +407,19 @@ protected PrismValueDeltaSetTriple> evaluatePropertyEx protected PrismValueDeltaSetTriple> evaluatePropertyExpression( ExpressionType expressionType, PrimitiveType outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { return evaluatePropertyExpression(expressionType, outputType.getQname(), expressionContext, result); } protected void evaluateExpressionRestricted( - ExpressionType expressionType, D outputDefinition, ExpressionEvaluationContext expressionContext, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Expression expression; + ExpressionType expressionType, D outputDefinition, + ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Expression expression; try { - expression = expressionFactory.makeExpression(expressionType, outputDefinition , getExpressionProfile(), - expressionContext.getContextDescription(), expressionContext.getTask(), result); + expression = expressionFactory.makeExpression(expressionType, outputDefinition, getExpressionProfile(), + expressionContext.getContextDescription(), expressionContext.getTask(), result); } catch (SecurityViolationException e) { // Exception may happen here, or it may happen later. @@ -496,22 +441,24 @@ protected void evaluateExpressi LOGGER.debug("Expected exception", e); assertTrue("Wrong exception message: " + e.getMessage(), e.getMessage().contains("Access to expression evaluator") - || e.getMessage().contains("Access to Groovy method")); + || e.getMessage().contains("Access to Groovy method")); } } - protected void evaluatePropertyExpressionRestricted( - ExpressionType expressionType, QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + protected void evaluatePropertyExpressionRestricted(ExpressionType expressionType, + QName outputType, ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException { PrismPropertyDefinition outputDefinition = prismContext.definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, outputType); evaluateExpressionRestricted(expressionType, outputDefinition, expressionContext, result); } protected void evaluatePropertyExpressionRestricted( - ExpressionType expressionType, PrimitiveType outputType, ExpressionEvaluationContext expressionContext, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + ExpressionType expressionType, PrimitiveType outputType, + ExpressionEvaluationContext expressionContext, OperationResult result) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException { evaluatePropertyExpressionRestricted(expressionType, outputType.getQname(), expressionContext, result); } @@ -522,7 +469,7 @@ protected void rememberScriptExecutionCount() { protected void assertScriptExecutionIncrement(int expectedIncrement) { long currentScriptExecutionCount = InternalMonitor.getCount(InternalCounters.SCRIPT_EXECUTION_COUNT); long actualIncrement = currentScriptExecutionCount - lastScriptExecutionCount; - assertEquals("Unexpected increment in script execution count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in script execution count", (long) expectedIncrement, actualIncrement); lastScriptExecutionCount = currentScriptExecutionCount; } @@ -548,7 +495,7 @@ protected ExpressionProfile compileExpressionProfile(String profileName) throws ExpressionProfiles profiles = compiler.compile(expressions); ExpressionProfile profile = profiles.getProfile(profileName); if (profile == null) { - throw new SchemaException("Profile '"+profile+"' not found in system config"); + throw new SchemaException("Profile '" + profile + "' not found in system config"); } return profile; } @@ -557,10 +504,10 @@ protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } - protected PrismValueDeltaSetTripleAsserter assertOutputTriple(PrismValueDeltaSetTriple triple) { + protected PrismValueDeltaSetTripleAsserter assertOutputTriple(PrismValueDeltaSetTriple triple) { assertNotNull(triple); triple.checkConsistence(); - PrismValueDeltaSetTripleAsserter asserter = new PrismValueDeltaSetTripleAsserter<>(triple, "expression output triple"); + PrismValueDeltaSetTripleAsserter asserter = new PrismValueDeltaSetTripleAsserter<>(triple, "expression output triple"); asserter.setPrismContext(prismContext); asserter.display(); return asserter; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java index 4abafcfd88a..faa8c7ed01f 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionProfileSafe.java @@ -8,13 +8,12 @@ import java.util.Collection; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.PrimitiveType; import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext; import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.repo.common.expression.Source; -import com.evolveum.midpoint.prism.*; - -import org.testng.annotations.Test; - import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; @@ -31,18 +30,15 @@ protected String getExpressionProfileName() { @Test @Override public void test130Const() throws Exception { - final String TEST_NAME = "test130Const"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_CONST_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); @@ -55,18 +51,15 @@ public void test130Const() throws Exception { @Test @Override public void test154ScriptGroovySystemDeny() throws Exception { - final String TEST_NAME = "test154ScriptGroovySystemDeny"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_GROOVY_SYSTEM_DENY_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); @@ -79,18 +72,15 @@ public void test154ScriptGroovySystemDeny() throws Exception { @Test @Override public void test160ScriptJavaScript() throws Exception { - final String TEST_NAME = "test160ScriptJavaScript"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestExpression.class.getName()+"."+TEST_NAME); + OperationResult result = new OperationResult(contextName()); rememberScriptExecutionCount(); ExpressionType expressionType = parseExpression(EXPRESSION_SCRIPT_JAVASCRIPT_FILE); - Collection> sources = prepareStringSources(INPUT_VALUE); + Collection> sources = prepareStringSources(); ExpressionVariables variables = prepareBasicVariables(); - ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources , variables, TEST_NAME, null); + ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null); // WHEN evaluatePropertyExpressionRestricted(expressionType, PrimitiveType.STRING, expressionContext, result); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java index 39012203f3f..36b89d383f5 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/TestExpressionUtil.java @@ -73,13 +73,10 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testResolvePathStringProperty() throws Exception { - final String TEST_NAME = "testResolvePathStringProperty"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - PrismProperty resolvedProperty = resolvePath("$user/description", TEST_NAME); + PrismProperty resolvedProperty = resolvePath("$user/description", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "jack", resolvedProperty.getRealValue()); @@ -87,13 +84,10 @@ public void testResolvePathStringProperty() throws Exception { @Test public void testResolvePathPolyStringProperty() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringProperty"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - PrismProperty resolvedProperty = resolvePath("$user/fullName", TEST_NAME); + PrismProperty resolvedProperty = resolvePath("$user/fullName", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -102,13 +96,10 @@ public void testResolvePathPolyStringProperty() throws Exception { @Test public void testResolvePathPolyStringOrig() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOrig"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - String resolved = resolvePath("$user/fullName/t:orig", TEST_NAME); + String resolved = resolvePath("$user/fullName/t:orig", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "Jack Sparrow", resolved); @@ -116,13 +107,10 @@ public void testResolvePathPolyStringOrig() throws Exception { @Test public void testResolvePathPolyStringNorm() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringNorm"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - String resolved = resolvePath("$user/fullName/t:norm", TEST_NAME); + String resolved = resolvePath("$user/fullName/t:norm", getTestNameShort()); // THEN assertEquals("Wrong resolved property value", "jack sparrow", resolved); @@ -130,13 +118,10 @@ public void testResolvePathPolyStringNorm() throws Exception { @Test public void testResolvePathPolyStringOdo() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdo"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -151,13 +136,10 @@ public void testResolvePathPolyStringOdo() throws Exception { @Test public void testResolvePathPolyStringOdoOrig() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdoOrig"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:orig", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:orig", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), @@ -170,13 +152,10 @@ public void testResolvePathPolyStringOdoOrig() throws Exception { @Test public void testResolvePathPolyStringOdoNorm() throws Exception { - final String TEST_NAME = "testResolvePathPolyStringOdoNorm"; - displayTestTitle(TEST_NAME); - // GIVEN // WHEN - ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:norm", TEST_NAME); + ItemDeltaItem,PrismPropertyDefinition> idi = resolvePathOdo("$user/fullName/t:norm", getTestNameShort()); // THEN assertEquals("Wrong resolved idi old value", PrismTestUtil.createPolyString("Jack Sparrow"), diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java index b417127b496..691e9b72752 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/AbstractScriptTest.java @@ -145,7 +145,7 @@ public void testExpressionStringVariablesParallel() throws Exception { // WHEN - ParallelTestThread[] threads = TestUtil.multithread(TEST_NAME, + ParallelTestThread[] threads = TestUtil.multithread( (threadIndex) -> { String foo = "FOO"+threadIndex; @@ -399,7 +399,6 @@ protected void evaluateAndAssertBooleanScalarExpresssion(String fileName, String } private List> evaluateStringExpresssion(String fileName, String testName, ExpressionVariables variables, boolean scalar) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - displayTestTitle(testName); ScriptExpressionEvaluatorType scriptType = parseScriptType(fileName); OperationResult opResult = new OperationResult(testName); @@ -407,22 +406,13 @@ private List> evaluateStringExpresssion(String fileNa } private List> evaluateBooleanExpresssion(String fileName, String testName, ExpressionVariables variables, boolean scalar) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - displayTestTitle(testName); ScriptExpressionEvaluatorType scriptType = parseScriptType(fileName); OperationResult opResult = new OperationResult(testName); - return evaluateExpression(scriptType, DOMUtil.XSD_BOOLEAN, true, variables, testName, opResult); } - - private void displayTestTitle(String testName) { - System.out.println("===[ "+evaluator.getLanguageName()+": "+testName+" ]==========================="); - LOGGER.info("===[ "+evaluator.getLanguageName()+": "+testName+" ]==========================="); - } - protected ExpressionVariables createVariables(Object... params) { return ExpressionVariables.create(prismContext, params); } - } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java index 2d89123b983..54dbfacf4cc 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestExpressionFunctions.java @@ -19,6 +19,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; @@ -47,7 +48,7 @@ /** * @author semancik */ -public class TestExpressionFunctions { +public class TestExpressionFunctions extends AbstractUnitTest { public static final File TEST_DIR = new File("src/test/resources/expression/functions"); public static final File USER_JACK_FILE = new File(TEST_DIR, "user-jack.xml"); @@ -73,9 +74,6 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void testGetExtensionPropertyValue() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -90,9 +88,6 @@ public void testGetExtensionPropertyValue() throws Exception { @Test public void testGetExtensionPropertyValueParts() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -108,9 +103,6 @@ public void testGetExtensionPropertyValueParts() throws Exception { @Test public void testGetExtensionPropertyValueNotPresent() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueNotPresent"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject userJack = PrismTestUtil.parseObject(USER_JACK_FILE); @@ -125,9 +117,6 @@ public void testGetExtensionPropertyValueNotPresent() throws Exception { @Test public void testGetExtensionPropertyValueNullObject() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValueNullObject"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); @@ -141,9 +130,6 @@ public void testGetExtensionPropertyValueNullObject() throws Exception { @Test public void testGetAttributeValueParts() throws Exception { - final String TEST_NAME = "testGetAttributeValueParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -159,9 +145,6 @@ public void testGetAttributeValueParts() throws Exception { @Test public void testGetAttributeValueDefaultRi() throws Exception { - final String TEST_NAME = "testGetAttributeValueDefaultRi"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -176,9 +159,6 @@ public void testGetAttributeValueDefaultRi() throws Exception { @Test public void testGetAttributeValuesParts() throws Exception { - final String TEST_NAME = "testGetAttributeValuesParts"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -194,9 +174,6 @@ public void testGetAttributeValuesParts() throws Exception { @Test public void testGetAttributeValuesDefaultRi() throws Exception { - final String TEST_NAME = "testGetAttributeValuesDefaultRi"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE); @@ -211,9 +188,6 @@ public void testGetAttributeValuesDefaultRi() throws Exception { @Test public void testgetResourceIcfConfigurationPropertyValueStringHost() throws Exception { - final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringHost"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); @@ -227,9 +201,6 @@ public void testgetResourceIcfConfigurationPropertyValueStringHost() throws Exce @Test public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exception { - final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringPort"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); @@ -243,9 +214,6 @@ public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exce @Test public void testDetermineLdapSingleAttributeValue01() throws Exception { - final String TEST_NAME = "testDetermineLdapSingleAttributeValue01"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); String dn = "uid=foo, ou=People, dc=example,dc=com"; @@ -363,9 +331,6 @@ public void testFormatDateTime() throws Exception { @Test public void testParseDateTime() throws Exception { - final String TEST_NAME = "testParseDateTime"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN BasicExpressionFunctions f = createBasicFunctions(); @@ -389,8 +354,6 @@ private BasicExpressionFunctions createBasicFunctions() throws SchemaException, @Test public void testStringify() throws Exception { - final String TEST_NAME = "testStringifyString"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo", basic.stringify("foo")); assertEquals("foo", basic.stringify(poly("foo"))); @@ -402,8 +365,6 @@ public void testStringify() throws Exception { @Test public void testConcatName() throws Exception { - final String TEST_NAME = "testConcatName"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo bar", basic.concatName("foo","bar")); assertEquals("foo bar", basic.concatName(poly("foo"),"bar")); @@ -425,8 +386,6 @@ private PolyString poly(String s) { @Test public void testToAscii() throws Exception { - final String TEST_NAME = "testToAscii"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("foo", basic.toAscii("foo")); assertEquals("foo", basic.toAscii(poly("foo"))); @@ -434,14 +393,12 @@ public void testToAscii() throws Exception { assertEquals("Cortuv hrad, tam Strasa!", basic.toAscii("Čórtův hrád, tam Strašá!")); assertEquals("hrabe Teleke z Toloko", basic.toAscii(poly("hrabě Teleke z Tölökö"))); assertEquals("Vedeckotechnicka revoluce neni zadna idyla!", basic.toAscii(PrismTestUtil.createPolyStringType("Vědeckotechnická revoluce není žádná idyla!"))); - assertEquals(null, basic.toAscii(null)); + assertNull(basic.toAscii(null)); assertEquals("", basic.toAscii("")); } @Test public void testComposeDn() throws Exception { - final String TEST_NAME = "testComposeDn"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("cn=foo,o=bar", basic.composeDn("cn","foo","o","bar")); @@ -462,8 +419,6 @@ public void testComposeDn() throws Exception { @Test public void testComposeDnWithSuffix() throws Exception { - final String TEST_NAME = "testComposeDnWithSuffix"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix(new Rdn("cn","foo"),"ou=baz,o=bar")); @@ -490,8 +445,6 @@ public void testComposeDnWithSuffix() throws Exception { @Test public void testParseFullName() throws Exception { - final String TEST_NAME = "testParseFullName"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); assertEquals(null, basic.parseGivenName(null)); @@ -523,8 +476,6 @@ public void testParseFullName() throws Exception { */ @Test public void testHashLdapPasswordSsha() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSsha"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); // WHEN @@ -544,8 +495,6 @@ public void testHashLdapPasswordSsha() throws Exception { */ @Test public void testHashLdapPasswordSshaProtectedStringClear() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSshaProtectedStringClear"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); ProtectedStringType protectedString = new ProtectedStringType(); @@ -568,8 +517,6 @@ public void testHashLdapPasswordSshaProtectedStringClear() throws Exception { */ @Test public void testHashLdapPasswordSshaProtectedStringEncrypted() throws Exception { - final String TEST_NAME = "testHashLdapPasswordSshaProtectedStringEncrypted"; - TestUtil.displayTestTitle(TEST_NAME); BasicExpressionFunctions basic = createBasicFunctions(); ProtectedStringType protectedString = new ProtectedStringType(); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java index 815748b9418..cbe540afa1a 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/expression/script/TestScriptCaching.java @@ -16,7 +16,6 @@ import java.util.Collection; import java.util.List; -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import com.evolveum.midpoint.common.Clock; @@ -39,14 +38,13 @@ import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver; import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.ExpressionSyntaxException; import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommunicationException; @@ -60,13 +58,12 @@ /** * @author semancik */ -public class TestScriptCaching { +public class TestScriptCaching extends AbstractUnitTest { private static final File TEST_DIR = new File("src/test/resources/expression/groovy"); protected static final File OBJECTS_DIR = new File("src/test/resources/objects"); private static final QName PROPERTY_NAME = new QName(MidPointConstants.NS_MIDPOINT_TEST_PREFIX, "whatever"); - private static final String NS_WHATEVER = "http://whatever/xml/ns"; protected ScriptExpressionFactory scriptExpressionfactory; protected ScriptEvaluator evaluator; @@ -96,9 +93,6 @@ public void setupFactory() { @Test public void testGetExtensionPropertyValue() throws Exception { - final String TEST_NAME = "testGetExtensionPropertyValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN InternalMonitor.reset(); @@ -136,13 +130,13 @@ private void assertScriptMonitor(int expCompilations, int expExecutions, String assertEquals("Unexpected number of script executions after "+desc, expExecutions, InternalMonitor.getCount(InternalCounters.SCRIPT_EXECUTION_COUNT)); } - private long executeScript(String filname, String expectedResult, String desc) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + private long executeScript(String filname, String expectedResult, String desc) throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { // GIVEN OperationResult result = new OperationResult(desc); ScriptExpressionEvaluatorType scriptType = parseScriptType(filname); ItemDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = createScriptExpression(scriptType, outputDefinition, desc); + ScriptExpression scriptExpression = createScriptExpression(scriptType, outputDefinition); ExpressionVariables variables = ExpressionVariables.create(getPrismContext(), "foo", "FOO", PrimitiveType.STRING, @@ -164,7 +158,7 @@ private long executeScript(String filname, String expectedResult, String desc) t return (endTime - startTime); } - private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition, String shortDesc) throws ExpressionSyntaxException { + private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType expressionType, ItemDefinition outputDefinition) { ScriptExpression expression = new ScriptExpression(scriptExpressionfactory.getEvaluators().get(expressionType.getLanguage()), expressionType); expression.setOutputDefinition(outputDefinition); expression.setObjectResolver(scriptExpressionfactory.getObjectResolver()); @@ -172,7 +166,7 @@ private ScriptExpression createScriptExpression(ScriptExpressionEvaluatorType ex return expression; } - private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { + private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java index 6ca0b3af3aa..9e0c05a5932 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingComplex.java @@ -44,9 +44,6 @@ public void setupFactory() throws SAXException, IOException, SchemaException { @Test public void testModifyObjectSetAdditionalName() throws Exception { - final String TEST_NAME = "testModifyObjectSetAdditionalName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -55,9 +52,9 @@ public void testModifyObjectSetAdditionalName() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -72,9 +69,6 @@ public void testModifyObjectSetAdditionalName() throws Exception { @Test public void testModifyObjectSetAdditionalNameFalse() throws Exception { - final String TEST_NAME = "testModifyObjectSetAdditionalNameFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -86,9 +80,9 @@ public void testModifyObjectSetAdditionalNameFalse() throws Exception { userOld.asObjectable().getEmployeeType().add("WHATEVER"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta, userOld); + getTestNameShort(), "title", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -103,9 +97,6 @@ public void testModifyObjectSetAdditionalNameFalse() throws Exception { */ @Test public void testModifyObjectUnrelated() throws Exception { - final String TEST_NAME = "testModifyObjectUnrelated"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -113,9 +104,9 @@ public void testModifyObjectUnrelated() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -130,9 +121,6 @@ public void testModifyObjectUnrelated() throws Exception { @Test public void testModifyObjectUnrelatedFalse() throws Exception { - final String TEST_NAME = "testModifyObjectUnrelatedFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, @@ -143,9 +131,9 @@ public void testModifyObjectUnrelatedFalse() throws Exception { userOld.asObjectable().getEmployeeType().add("WHATEVER"); MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta, userOld); + getTestNameShort(), "title", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -157,9 +145,6 @@ public void testModifyObjectUnrelatedFalse() throws Exception { @Test public void testAddObjectUnrelatedFalse() throws Exception { - final String TEST_NAME = "testAddObjectUnrelatedFalse"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); @@ -168,9 +153,9 @@ public void testAddObjectUnrelatedFalse() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -182,9 +167,6 @@ public void testAddObjectUnrelatedFalse() throws Exception { @Test public void testAddObjectUnrelatedEmptyFalse() throws Exception { - final String TEST_NAME = "testAddObjectUnrelatedEmptyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); @@ -192,9 +174,9 @@ public void testAddObjectUnrelatedEmptyFalse() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( MAPPING_COMPLEX_FILENAME, - TEST_NAME, "title", delta); + getTestNameShort(), "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java index b9da769043e..fc6445e5912 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDomain.java @@ -11,8 +11,6 @@ import java.io.IOException; import java.util.List; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.test.NullTaskImpl; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -26,17 +24,20 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.test.NullTaskImpl; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Tests for mapping domain. Those are multival input and multival output. - * + *

* MID-3692 + * * @author Radovan Semancik */ -public class TestMappingDomain { +public class TestMappingDomain extends AbstractUnitTest { private static final String MAPPING_DOMAIN_FILENAME = "mapping-domain.xml"; @@ -53,9 +54,6 @@ public void setupFactory() throws SchemaException, SAXException, IOException { */ @Test public void testControlReplaceSingleValue() throws Exception { - final String TEST_NAME = "testControlReplaceSingleValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -64,15 +62,14 @@ public void testControlReplaceSingleValue() throws Exception { employeeTypeOld.add("1234567890"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "321"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(MAPPING_DOMAIN_FILENAME, getTestNameShort(), "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -81,8 +78,8 @@ public void testControlReplaceSingleValue() throws Exception { PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (321)")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (1234567890)")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (321)")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (1234567890)")); } private Task createTask() { @@ -94,11 +91,7 @@ private Task createTask() { */ @Test public void testControlReplaceMultiValue() throws Exception { - final String TEST_NAME = "testControlReplaceMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - PrismObject userOld = evaluator.getUserOld(); List employeeTypeOld = userOld.asObjectable().getEmployeeType(); employeeTypeOld.clear(); @@ -107,37 +100,32 @@ public void testControlReplaceMultiValue() throws Exception { employeeTypeOld.add("003"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "991", "992"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); - - OperationResult opResult = new OperationResult(TEST_NAME); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); // WHEN - mapping.evaluate(createTask(), opResult); + mapping.evaluate(createTask(), new OperationResult(shortTestName)); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (991)"), - PrismTestUtil.createPolyString("Pirate Jackie (992)")); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate null (001)"), - PrismTestUtil.createPolyString("Pirate null (002)"), - PrismTestUtil.createPolyString("Pirate null (003)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (991)"), + PrismTestUtil.createPolyString("Pirate Jackie (992)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate null (001)"), + PrismTestUtil.createPolyString("Pirate null (002)"), + PrismTestUtil.createPolyString("Pirate null (003)")); } @Test public void testReplaceMixedMultiValue() throws Exception { - final String TEST_NAME = "testReplaceMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -149,39 +137,37 @@ public void testReplaceMixedMultiValue() throws Exception { employeeTypeOld.add("004"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Jackie"); + .createModificationReplaceProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_ADDITIONAL_NAME, "Jackie"); delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (992)"), - PrismTestUtil.createPolyString("Pirate Jackie (994)")); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate null (001)"), - PrismTestUtil.createPolyString("Pirate null (004)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (992)"), + PrismTestUtil.createPolyString("Pirate Jackie (994)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate null (001)"), + PrismTestUtil.createPolyString("Pirate null (004)")); } @Test public void testAddMixedMultiValue() throws Exception { - final String TEST_NAME = "testAddMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -194,38 +180,36 @@ public void testAddMixedMultiValue() throws Exception { employeeTypeOld.add("004"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); + .createModificationAddProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (001)"), - PrismTestUtil.createPolyString("Pirate Jackie (004)")); - PrismAsserts.assertTriplePlus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (992)"), - PrismTestUtil.createPolyString("Pirate Jackie (994)")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismTestUtil.createPolyString("Pirate Jackie (001)"), + PrismTestUtil.createPolyString("Pirate Jackie (004)")); + PrismAsserts.assertTriplePlus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (992)"), + PrismTestUtil.createPolyString("Pirate Jackie (994)")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testDeleteMixedMultiValue() throws Exception { - final String TEST_NAME = "testDeleteMixedMultiValue"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN PrismObject userOld = evaluator.getUserOld(); @@ -241,31 +225,31 @@ public void testDeleteMixedMultiValue() throws Exception { employeeTypeOld.add("007"); ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "005", "C06", "007"); + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_EMPLOYEE_TYPE, "005", "C06", "007"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - MAPPING_DOMAIN_FILENAME, - TEST_NAME, "organization", delta, userOld); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + MAPPING_DOMAIN_FILENAME, shortTestName, "organization", delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("Output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (001)"), - PrismTestUtil.createPolyString("Pirate Jackie (004)")); + PrismTestUtil.createPolyString("Pirate Jackie (001)"), + PrismTestUtil.createPolyString("Pirate Jackie (004)")); PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, - PrismTestUtil.createPolyString("Pirate Jackie (005)"), - PrismTestUtil.createPolyString("Pirate Jackie (007)")); + PrismAsserts.assertTripleMinus(outputTriple, + PrismTestUtil.createPolyString("Pirate Jackie (005)"), + PrismTestUtil.createPolyString("Pirate Jackie (007)")); } } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java index 48803088a07..b9abafbe4b9 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSimple.java @@ -6,28 +6,17 @@ */ package com.evolveum.midpoint.model.common.mapping; -import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.prism.util.PrismAsserts.assertTripleNoMinus; import static com.evolveum.midpoint.prism.util.PrismAsserts.assertTripleZero; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.testng.AssertJUnit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -35,6 +24,9 @@ import com.evolveum.midpoint.model.common.AbstractModelCommonTest; import com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluator; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -47,15 +39,10 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik @@ -75,9 +62,6 @@ public void setupFactory() throws SAXException, IOException, SchemaException { @Test public void testValueSingleDeep() throws Exception { - final String TEST_NAME = "testValueSingleDeep"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-deep.xml", @@ -95,9 +79,6 @@ public void testValueSingleDeep() throws Exception { @Test public void testValueSingleShallow() throws Exception { - final String TEST_NAME = "testValueSingleShallow"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-shallow.xml", @@ -115,9 +96,6 @@ public void testValueSingleShallow() throws Exception { @Test public void testValueMultiDeep() throws Exception { - final String TEST_NAME = "testValueMultiDeep"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-multi-deep.xml", @@ -135,9 +113,6 @@ public void testValueMultiDeep() throws Exception { @Test public void testValueMultiShallow() throws Exception { - final String TEST_NAME = "testValueMultiShallow"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-multi-shallow.xml", @@ -155,9 +130,6 @@ public void testValueMultiShallow() throws Exception { @Test public void testValueSingleEnum() throws Exception { - final String TEST_NAME = "testValueSingleEnum"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-value-single-enum.xml", @@ -175,9 +147,6 @@ public void testValueSingleEnum() throws Exception { @Test public void testAsIsAdd() throws Exception { - final String TEST_NAME = "testAsIsAdd"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-asis.xml", @@ -195,9 +164,6 @@ public void testAsIsAdd() throws Exception { @Test public void testAsIsDelete() throws Exception { - final String TEST_NAME = "testAsIsDelete"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicDelete( "mapping-asis.xml", @@ -213,12 +179,8 @@ public void testAsIsDelete() throws Exception { PrismAsserts.assertTripleMinus(outputTriple, "PIRATE"); } - @Test public void testAsIsStringToPolyString() throws Exception { - final String TEST_NAME = "testAsIsStringToPolyString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis.xml", @@ -234,9 +196,6 @@ public void testAsIsStringToPolyString() throws Exception { @Test public void testAsIsStringToProtectedString() throws Exception { - final String TEST_NAME = "testAsIsStringToProtectedString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis.xml", @@ -252,9 +211,6 @@ public void testAsIsStringToProtectedString() throws Exception { @Test public void testAsIsProtectedStringToProtectedString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToProtectedString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -270,9 +226,6 @@ public void testAsIsProtectedStringToProtectedString() throws Exception { @Test public void testAsIsProtectedStringToString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -288,9 +241,6 @@ public void testAsIsProtectedStringToString() throws Exception { @Test public void testAsIsProtectedStringToPolyString() throws Exception { - final String TEST_NAME = "testAsIsProtectedStringToPolyString"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-asis-password.xml", @@ -304,12 +254,8 @@ public void testAsIsProtectedStringToPolyString() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testPathVariables() throws Exception { - final String TEST_NAME = "testPathVariables"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( "mapping-path-system-variables.xml", @@ -327,9 +273,6 @@ public void testPathVariables() throws Exception { @Test public void testPathExtensionProperty() throws Exception { - final String TEST_NAME = "testPathExtensionProperty"; - displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMapping( "mapping-path-extension-variable.xml", @@ -359,7 +302,6 @@ public void testPathVariablesNamespace() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testPathVariablesPolyStringShort() throws Exception { // WHEN @@ -554,7 +496,7 @@ public void testScriptVariablesPolyStringGroovyNormReplaceNull() throws Exceptio "testScriptVariablesPolyStringGroovy", "description", // target "fullName" // changed property - ); // changed values + ); // changed values // THEN outputTriple.checkConsistence(); @@ -597,23 +539,22 @@ public void testAsIsVariablesPolyStringOrig() throws Exception { PrismAsserts.assertTripleNoMinus(outputTriple); } - @Test public void testScriptExtraVariablesRef() throws Exception { // GIVEN - MappingImpl.Builder,PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", + MappingImpl.Builder, PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", "testScriptExtraVariablesRef", "employeeType", null); VariablesMap vars = new VariablesMap(); ObjectReferenceType ref = MiscSchemaUtil.createObjectReference( - "c0c010c0-d34d-b33f-f00d-111111111112", - UserType.COMPLEX_TYPE); + "c0c010c0-d34d-b33f-f00d-111111111112", + UserType.COMPLEX_TYPE); vars.put("sailor", ref, PrismTestUtil.getPrismContext().definitionFactory().createReferenceDefinition( new QName(SchemaConstants.NS_C, "sailor"), UserType.COMPLEX_TYPE)); builder.addVariableDefinitions(vars); - MappingImpl,PrismPropertyDefinition> mapping = builder.build(); + MappingImpl, PrismPropertyDefinition> mapping = builder.build(); OperationResult opResult = new OperationResult("testScriptExtraVariablesRef"); @@ -630,21 +571,20 @@ public void testScriptExtraVariablesRef() throws Exception { @Test public void testScriptExtraVariablesJaxb() throws Exception { - final String TEST_NAME = "testScriptExtraVariablesJaxb"; - displayTestTitle(TEST_NAME); - // GIVEN - MappingImpl.Builder,PrismPropertyDefinition> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", - TEST_NAME, "employeeType", null); + String shortTestName = getTestNameShort(); + MappingImpl.Builder, PrismPropertyDefinition> builder = + evaluator.createMappingBuilder( + "mapping-script-extra-variables.xml", shortTestName, "employeeType", null); VariablesMap vars = new VariablesMap(); UserType userType = (UserType) PrismTestUtil.parseObject( new File(MidPointTestConstants.OBJECTS_DIR, "c0c010c0-d34d-b33f-f00d-111111111112.xml")).asObjectable(); vars.put("sailor", userType, userType.asPrismObject().getDefinition()); builder.addVariableDefinitions(vars); - MappingImpl,PrismPropertyDefinition> mapping = builder.build(); + MappingImpl, PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -665,7 +605,6 @@ public void testScriptFullNameNoChange() throws Exception { "testScriptVariablesPolyStringGroovy", "fullName"); // target - // THEN outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("Jack Sparrow")); @@ -675,15 +614,14 @@ public void testScriptFullNameNoChange() throws Exception { @Test public void testScriptFullNameReplaceGivenName() throws Exception { - final String TEST_NAME = "testScriptFullNameReplaceGivenName"; - displayTestTitle(TEST_NAME); // WHEN + String shortTestName = getTestNameShort(); PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( "mapping-script-fullname.xml", - TEST_NAME, - "fullName", // target - "givenName", // changed property - PrismTestUtil.createPolyString("Jackie")); // changed values + shortTestName, + "fullName", // target + "givenName", // changed property + PrismTestUtil.createPolyString("Jackie")); // changed values // THEN outputTriple.checkConsistence(); @@ -694,21 +632,21 @@ public void testScriptFullNameReplaceGivenName() throws Exception { @Test public void testScriptFullNameDeleteGivenName() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty( + UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-fullname.xml", - TEST_NAME, - "fullName", // target - delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping( + "mapping-script-fullname.xml", + shortTestName, + "fullName", // target + delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -723,24 +661,22 @@ public void testScriptFullNameDeleteGivenName() throws Exception { @Test public void testScriptFullNameDeleteGivenNameFromNull() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenNameFromNull"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); PrismObject userOld = evaluator.getUserOld(); userOld.asObjectable().setGivenName(null); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", - TEST_NAME, + shortTestName, "fullName", // target delta, userOld); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -755,22 +691,20 @@ public void testScriptFullNameDeleteGivenNameFromNull() throws Exception { @Test public void testScriptFullNameDeleteGivenNameFamilyName() throws Exception { - final String TEST_NAME = "testScriptFullNameDeleteGivenNameFamilyName"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); + .createModificationDeleteProperty(UserType.class, MappingTestEvaluator.USER_OLD_OID, + UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Jack")); delta.addModificationDeleteProperty(UserType.F_FAMILY_NAME, PrismTestUtil.createPolyString("Sparrow")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-fullname.xml", - TEST_NAME, + shortTestName, "fullName", // target delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -806,22 +740,22 @@ public void testScriptFullNameReplaceEmployeeNumber() throws Exception { /** * Return type is a date, script returns string. */ - @Test - public void testScriptDateGroovy() throws Exception { - // WHEN - PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( - "mapping-script-date-groovy.xml", - "testScriptDateGroovy", - PATH_ACTIVATION_VALID_FROM, // target - "employeeNumber", // changed property - "1975-05-30"); // changed values - - // THEN - outputTriple.checkConsistence(); - PrismAsserts.assertTripleZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0)); - PrismAsserts.assertTripleNoMinus(outputTriple); - } + @Test + public void testScriptDateGroovy() throws Exception { + // WHEN + PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( + "mapping-script-date-groovy.xml", + "testScriptDateGroovy", + PATH_ACTIVATION_VALID_FROM, // target + "employeeNumber", // changed property + "1975-05-30"); // changed values + + // THEN + outputTriple.checkConsistence(); + PrismAsserts.assertTripleZero(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0)); + PrismAsserts.assertTripleNoMinus(outputTriple); + } @Test public void testScriptCustomEnum() throws Exception { @@ -864,7 +798,6 @@ public void testScriptListAbsoluteGroovy() throws Exception { testScriptListAbsolute("mapping-script-list-absolute-groovy.xml"); } - public void testScriptListAbsolute(String fileName) throws Exception { // WHEN PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd( @@ -897,8 +830,8 @@ public void testValueConditionTrue() throws Exception { // THEN outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, "foobar"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -918,19 +851,17 @@ public void testValueConditionFalse() throws Exception { @Test public void testConditionNonEmptyCaptain() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyCaptain"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -939,26 +870,24 @@ public void testConditionNonEmptyCaptain() throws Exception { PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The CAPTAIN")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The CAPTAIN")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testConditionNonEmptyEmpty() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyEmpty"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add(""); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -971,18 +900,16 @@ public void testConditionNonEmptyEmpty() throws Exception { @Test public void testConditionNonEmptyNoValue() throws Exception { // GIVEN - final String TEST_NAME = "testConditionNonEmptyNoValue"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-condition-nonempty.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -994,21 +921,18 @@ public void testConditionNonEmptyNoValue() throws Exception { @Test public void testScriptTransformMultiAddDelete() throws Exception { - final String TEST_NAME = "testScriptTransformMultiAddDelete"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createEmptyModifyDelta(UserType.class, evaluator.USER_OLD_OID + .createEmptyModifyDelta(UserType.class, MappingTestEvaluator.USER_OLD_OID ); PropertyDelta propDelta = delta.createPropertyModification(evaluator.toPath("employeeType")); propDelta.addRealValuesToAdd("CAPTAIN"); propDelta.addRealValuesToDelete("LANDLUBER"); delta.addModification(propDelta); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-transform.xml", - TEST_NAME, "organizationalUnit", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + "mapping-script-transform.xml", shortTestName, "organizationalUnit", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("LANDLUBER"); @@ -1016,19 +940,19 @@ public void testScriptTransformMultiAddDelete() throws Exception { display("user before", user); display("delta", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); outputTriple.checkConsistence(); PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The landluber deck")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The landluber deck")); } /** @@ -1036,47 +960,41 @@ public void testScriptTransformMultiAddDelete() throws Exception { */ @Test public void testScriptTransformMultiReplace() throws Exception { - final String TEST_NAME = "testScriptTransformMultiReplace"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createEmptyModifyDelta(UserType.class, evaluator.USER_OLD_OID + .createEmptyModifyDelta(UserType.class, MappingTestEvaluator.USER_OLD_OID ); PropertyDelta propDelta = delta.createPropertyModification(evaluator.toPath("employeeType")); propDelta.setRealValuesToReplace("CAPTAIN"); delta.addModification(propDelta); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-script-transform.xml", - TEST_NAME, "organizationalUnit", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + "mapping-script-transform.xml", shortTestName, "organizationalUnit", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); display("user before", user); display("delta", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); display("output triple", outputTriple); outputTriple.checkConsistence(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The pirate deck")); } @Test - public void testInboundMapping() throws Exception{ - final String TEST_NAME = "testInboundMapping"; - displayTestTitle(TEST_NAME); - + public void testInboundMapping() throws Exception { PrismContext prismContext = evaluator.getPrismContext(); PrismObject account = PrismTestUtil.parseObject(new File(MappingTestEvaluator.TEST_DIR, "account-inbound-mapping.xml")); @@ -1090,15 +1008,21 @@ public void testInboundMapping() throws Exception{ IntegrationTestTools.display("Account", account); Item oldItem = account.findItem(ItemPath.create(ShadowType.F_ATTRIBUTES, SchemaTestConstants.ICFS_NAME)); - ItemDelta delta = prismContext.deltaFactory().property().createModificationAddProperty(SchemaTestConstants.ICFS_NAME_PATH_PARTS, (PrismPropertyDefinition) oldItem.getDefinition(), ((PrismPropertyValue) oldItem.getAnyValue()).getValue()); + ItemDelta delta = prismContext.deltaFactory().property().createModificationAddProperty( + SchemaTestConstants.ICFS_NAME_PATH_PARTS, + (PrismPropertyDefinition) oldItem.getDefinition(), + ((PrismPropertyValue) oldItem.getAnyValue()).getValue()); PrismObject user = evaluator.getUserDefinition().instantiate(); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createInboudMapping("mapping-inbound.xml", TEST_NAME, delta, user.asObjectable(), account.asObjectable(), null, null); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createInboudMapping( + "mapping-inbound.xml", shortTestName, delta, user.asObjectable(), account.asObjectable(), null, null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); - displayWhen(TEST_NAME); + when(); mapping.evaluate(createTask(), opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); @@ -1110,15 +1034,14 @@ public void testInboundMapping() throws Exception{ @Test public void testGenerateDefault() throws Exception { - final String TEST_NAME = "testGenerateDefault"; - displayTestTitle(TEST_NAME); - final ValuePolicyType stringPolicy = evaluator.getValuePolicy(); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", - TEST_NAME, stringPolicy, "employeeNumber", null); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-generate.xml", + shortTestName, stringPolicy, "employeeNumber", null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1132,7 +1055,7 @@ public void testGenerateDefault() throws Exception { System.out.println("Generated value (1): " + value1); assertGeneratedValue(value1, stringPolicy, null, false, false); - mapping = evaluator.createMapping("mapping-generate.xml", TEST_NAME, stringPolicy, "employeeNumber", null); + mapping = evaluator.createMapping("mapping-generate.xml", shortTestName, stringPolicy, "employeeNumber", null); // WHEN (2) mapping.evaluate(createTask(), opResult); @@ -1181,17 +1104,16 @@ public void testGeneratePolicyNumericString() throws Exception { private void generatePolicy(final String TEST_NAME, String mappingFileName, String policyFileName, String pattern, boolean ignoreMax) throws Exception { - displayTestTitle(TEST_NAME); // This is just for validation. The expression has to resolve reference of its own PrismObject valuePolicy = PrismTestUtil.parseObject( new File(MidPointTestConstants.OBJECTS_DIR, policyFileName)); final ValuePolicyType stringPolicy = valuePolicy.asObjectable(); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping(mappingFileName, TEST_NAME, stringPolicy, "employeeNumber", null); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1232,15 +1154,15 @@ private void assertGeneratedValue(String value, ValuePolicyType valuePolicy, Str assertEquals("Unexpected generated value length", GenerateExpressionEvaluator.DEFAULT_LENGTH, value.length()); } else { if (!ignoreMin) { - assertTrue("Value '"+value+"' too short, minLength="+stringPolicy.getLimitations().getMinLength()+", length="+value.length(), value.length() >= stringPolicy.getLimitations().getMinLength()); + assertTrue("Value '" + value + "' too short, minLength=" + stringPolicy.getLimitations().getMinLength() + ", length=" + value.length(), value.length() >= stringPolicy.getLimitations().getMinLength()); } if (!ignoreMax) { - assertTrue("Value '"+value+"' too long, maxLength="+stringPolicy.getLimitations().getMaxLength()+", length="+value.length(), value.length() <= stringPolicy.getLimitations().getMaxLength()); + assertTrue("Value '" + value + "' too long, maxLength=" + stringPolicy.getLimitations().getMaxLength() + ", length=" + value.length(), value.length() <= stringPolicy.getLimitations().getMaxLength()); } // TODO: better validation } if (pattern != null) { - assertTrue("Value '"+value+"' does not match pattern '"+pattern+"'", value.matches(pattern)); + assertTrue("Value '" + value + "' does not match pattern '" + pattern + "'", value.matches(pattern)); } } @@ -1248,26 +1170,26 @@ private void assertGeneratedValue(String value, ValuePolicyType valuePolicy, Str public void testGeneratePolicyNumericInt() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "intType", Integer.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "intType"); } @Test public void testGeneratePolicyNumericInteger() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "integerType", Integer.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "integerType"); } @Test public void testGeneratePolicyNumericLong() throws Exception { final String TEST_NAME = "testGeneratePolicyNumericInt"; generatePolicyNumeric(TEST_NAME, "mapping-generate-policy-numeric.xml", - "c0c010c0-d34d-b33f-f00d-999888111112.xml", "longType", Long.class); + "c0c010c0-d34d-b33f-f00d-999888111112.xml", "longType"); } - private void generatePolicyNumeric(final String TEST_NAME, String mappingFileName, - String policyFileName, String extensionPropName, Class clazz) throws Exception { - displayTestTitle(TEST_NAME); + private void generatePolicyNumeric(final String TEST_NAME, + String mappingFileName, String policyFileName, String extensionPropName) + throws Exception { // This is just for validation. The expression has to resolve reference of its own PrismObject valuePolicy = PrismTestUtil.parseObject( @@ -1275,13 +1197,13 @@ private void generatePolicyNumeric(final String TEST_NAME, String mappingFil final ValuePolicyType valuePolicyType = valuePolicy.asObjectable(); // GIVEN PrismContext prismContext = evaluator.getPrismContext(); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMappingBuilder(mappingFileName, + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMappingBuilder(mappingFileName, TEST_NAME, valuePolicyType, ItemPath.create( UserType.F_EXTENSION, new QName(NS_EXTENSION, extensionPropName)), null) .build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN (1) mapping.evaluate(createTask(), opResult); @@ -1324,12 +1246,12 @@ private void generatePolicyNumeric(final String TEST_NAME, String mappingFil @Test public void testGenerateProtectedString() throws Exception { - final String TEST_NAME = "testGenerateProtectedString"; - displayTestTitle(TEST_NAME); // GIVEN - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping("mapping-generate.xml", - TEST_NAME, SchemaConstants.PATH_PASSWORD_VALUE, null); - OperationResult opResult = new OperationResult(TEST_NAME); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-generate.xml", + shortTestName, SchemaConstants.PATH_PASSWORD_VALUE, null); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -1341,7 +1263,7 @@ public void testGenerateProtectedString() throws Exception { PrismAsserts.assertTripleNoPlus(outputTriple); PrismAsserts.assertTripleNoMinus(outputTriple); - System.out.println("Generated excrypted value: "+value1); + System.out.println("Generated excrypted value: " + value1); assertNotNull(value1); assertNotNull(value1.getEncryptedDataType()); } diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java index 0e5820b9caa..0d2d1ca8caf 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingDynamicSysVar.java @@ -13,10 +13,6 @@ import java.math.BigDecimal; import java.math.BigInteger; -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -26,15 +22,16 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismPropertyValue; +import com.evolveum.midpoint.prism.delta.DeltaFactory; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -42,6 +39,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik @@ -50,9 +48,6 @@ public class TestMappingDynamicSysVar extends AbstractModelCommonTest { private static final Trace LOGGER = TraceManager.getTrace(TestMappingDynamicSysVar.class); - private static final String NS_EXTENSION = "http://midpoint.evolveum.com/xml/ns/test/extension"; - private static final String PATTERN_NUMERIC = "^\\d+$"; - private MappingTestEvaluator evaluator; @BeforeClass @@ -73,19 +68,16 @@ public void testScriptSystemVariablesConditionAddObjectTrueSourcecontextGroovy() public void testScriptSystemVariablesConditionAddObjectTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectTrue"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("CAPTAIN"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( + filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -93,8 +85,8 @@ public void testScriptSystemVariablesConditionAddObjectTrue(String filename) thr // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } /** @@ -102,26 +94,24 @@ public void testScriptSystemVariablesConditionAddObjectTrue(String filename) thr */ @Test public void testScriptSystemVariablesConditionModifyObjectTrueGroovyUnrelated() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectTrueGroovyUnrelated"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber"), "666"); + evaluator.toPath("employeeNumber"), "666"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-condition-groovy.xml", - TEST_NAME, "title", delta); + shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test @@ -136,26 +126,23 @@ public void testScriptSystemVariablesConditionAddObjectFalseSourcecontextGroovy( public void testScriptSystemVariablesConditionAddObjectFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalse"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().getEmployeeType().add("SAILOR"); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } @Test @@ -170,26 +157,23 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoValSourcecontextGr public void testScriptSystemVariablesConditionAddObjectFalseNoVal(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalseNoVal"; - displayTestTitle(TEST_NAME); - PrismObject user = evaluator.getUserOld(); PrismProperty employeeTypeProperty = user.findProperty(UserType.F_EMPLOYEE_TYPE); employeeTypeProperty.clear(); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } @Test @@ -204,29 +188,24 @@ public void testScriptSystemVariablesConditionAddObjectFalseNoPropertySourcecont public void testScriptSystemVariablesConditionAddObjectFalseNoProperty(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalseNoProperty"; - displayTestTitle(TEST_NAME); - - PrismObject user = evaluator.getUserOld(); user.removeProperty(UserType.F_EMPLOYEE_TYPE); ObjectDelta delta = DeltaFactory.Object.createAddDelta(user); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected output triple: "+outputTriple, outputTriple); + assertNull("Unexpected output triple: " + outputTriple, outputTriple); } - @Test public void testScriptSystemVariablesConditionTrueToTrueGroovy() throws Exception { testScriptSystemVariablesConditionTrueToTrue("mapping-script-system-variables-condition-groovy.xml"); @@ -234,22 +213,19 @@ public void testScriptSystemVariablesConditionTrueToTrueGroovy() throws Exceptio public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionTrueToTrue"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -257,8 +233,8 @@ public void testScriptSystemVariablesConditionTrueToTrue(String filename) throws // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); } @Test @@ -268,25 +244,22 @@ public void testScriptSystemVariablesConditionFalseToFalseGroovy() throws Except public void testScriptSystemVariablesConditionFalseToFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionFalseToFalse"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test @@ -296,18 +269,16 @@ public void testScriptSystemVariablesConditionFalseToTrueGroovy() throws Excepti public void testScriptSystemVariablesConditionFalseToTrue(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionFalseToTrue"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); delta.addModificationAddProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -315,8 +286,8 @@ public void testScriptSystemVariablesConditionFalseToTrue(String filename) throw // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Captain Jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test @@ -326,22 +297,20 @@ public void testScriptSystemVariablesConditionTrueToFalseGroovy() throws Excepti public void testScriptSystemVariablesConditionTrueToFalse(String filename) throws Exception { // GIVEN - final String TEST_NAME = "testScriptSystemVariablesConditionTrueToFalse"; - displayTestTitle(TEST_NAME); - ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), "Jack"); + evaluator.toPath("name"), "Jack"); delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - filename, TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping(filename, shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("CAPTAIN"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -349,52 +318,51 @@ public void testScriptSystemVariablesConditionTrueToFalse(String filename) throw // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack")); } @Test public void testScriptSystemVariablesConditionEmptyTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyTrue"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyTrue"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty.xml"); } @Test public void testScriptSystemVariablesConditionEmptyTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyTrueFunction"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyTrueFunction"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-function.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrue"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrue"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueFunction"; - testScriptSystemVariablesConditionEmptyTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueFunction"; + testScriptSystemVariablesConditionEmptyTrue(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyTrue(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyTrue(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().clear(); user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -402,39 +370,38 @@ public void testScriptSystemVariablesConditionEmptyTrue(final String TEST_NAME, // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber Jack")); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber Jack")); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseToTrue() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseToTrue"; - testScriptSystemVariablesConditionEmptyFalseToTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseToTrue"; + testScriptSystemVariablesConditionEmptyFalseToTrue(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction"; - testScriptSystemVariablesConditionEmptyFalseToTrue(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseToTrueFunction"; + testScriptSystemVariablesConditionEmptyFalseToTrue(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber")); + evaluator.toPath("employeeNumber")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -442,90 +409,88 @@ public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testScriptSystemVariablesConditionEmptyFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty.xml"); } @Test public void testScriptSystemVariablesConditionEmptyFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptyFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptyFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-function.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalse"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalse"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleFalseFunction"; - testScriptSystemVariablesConditionEmptyFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleFalseFunction"; + testScriptSystemVariablesConditionEmptyFalse(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyFalse(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyFalse(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); + evaluator.toPath("name"), PrismTestUtil.createPolyString("Jack")); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().getEmployeeType().add("SAILOR"); user.asObjectable().setEmployeeNumber("666"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); - assertNull("Unexpected value in outputTriple: "+outputTriple, outputTriple); + assertNull("Unexpected value in outputTriple: " + outputTriple, outputTriple); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueToFalse() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueToFalse"; - testScriptSystemVariablesConditionEmptyTrueToFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueToFalse"; + testScriptSystemVariablesConditionEmptyTrueToFalse(shortTestName, "mapping-script-system-variables-condition-empty-single.xml"); } @Test public void testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction() throws Exception { - final String TEST_NAME = "testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction"; - testScriptSystemVariablesConditionEmptyTrueToFalse(TEST_NAME, "mapping-script-system-variables-condition-empty-single-function.xml"); + final String shortTestName = "testScriptSystemVariablesConditionEmptySingleTrueToFalseFunction"; + testScriptSystemVariablesConditionEmptyTrueToFalse(shortTestName, "mapping-script-system-variables-condition-empty-single-function.xml"); } - public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String TEST_NAME, String filename) throws Exception { - displayTestTitle(TEST_NAME); + public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String shortTestName, String filename) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - evaluator.toPath("employeeNumber"), "666"); + evaluator.toPath("employeeNumber"), "666"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( filename, - TEST_NAME, "title", delta); + shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setEmployeeNumber(null); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -533,25 +498,22 @@ public void testScriptSystemVariablesConditionEmptyTrueToFalse(final String TEST // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack")); } @Test public void testNpeFalseToTrue() throws Exception { - final String TEST_NAME = "testNpeFalseToTrue"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME, "Captain Sparrow"); + UserType.F_ADDITIONAL_NAME, "Captain Sparrow"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-npe.xml", - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-npe.xml", shortTestName, "title", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -559,29 +521,26 @@ public void testNpeFalseToTrue() throws Exception { // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("15")); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("15")); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testNpeTrueToFalse() throws Exception { - final String TEST_NAME = "testNpeTrueToFalse"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_ADDITIONAL_NAME); + UserType.F_ADDITIONAL_NAME); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-npe.xml", - TEST_NAME, "title", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-npe.xml", shortTestName, "title", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); user.asObjectable().setAdditionalName(PrismTestUtil.createPolyStringType("Sultan of the Caribbean")); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN mapping.evaluate(createTask(), opResult); @@ -589,25 +548,22 @@ public void testNpeTrueToFalse() throws Exception { // THEN PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("23")); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("23")); } @Test public void testPathEnum() throws Exception { - final String TEST_NAME = "testPathEnum"; - displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); + SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( - "mapping-path-enum.xml", - TEST_NAME, "costCenter", delta); + String shortTestName = getTestNameShort(); + MappingImpl, PrismPropertyDefinition> mapping = + evaluator.createMapping("mapping-path-enum.xml", shortTestName, "costCenter", delta); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(shortTestName); // WHEN System.out.println("WHEN"); @@ -619,8 +575,8 @@ public void testPathEnum() throws Exception { System.out.println("\nOutput triple"); System.out.println(outputTriple.debugDump(1)); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, ActivationStatusType.DISABLED.value()); - PrismAsserts.assertTripleMinus(outputTriple, ActivationStatusType.ENABLED.value()); + PrismAsserts.assertTriplePlus(outputTriple, ActivationStatusType.DISABLED.value()); + PrismAsserts.assertTripleMinus(outputTriple, ActivationStatusType.ENABLED.value()); } @Test @@ -641,15 +597,15 @@ public void testEmployeeNumberString() throws Exception { @Test public void testEmployeeNumberPolyString() throws Exception { - final String TEST_NAME = "testEmployeeNumberPolyString"; - displayTestTitle(TEST_NAME); // WHEN - PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicReplace( - "mapping-script-system-variables-employee-number.xml", - TEST_NAME, - "additionalName", // target - "employeeNumber", // changed property - "666"); // changed values + String shortTestName = getTestNameShort(); + PrismValueDeltaSetTriple> outputTriple = + evaluator.evaluateMappingDynamicReplace( + "mapping-script-system-variables-employee-number.xml", + shortTestName, + "additionalName", // target + "employeeNumber", // changed property + "666"); // changed values // THEN PrismAsserts.assertTripleNoZero(outputTriple); @@ -658,7 +614,7 @@ public void testEmployeeNumberPolyString() throws Exception { // Make sure it is recomputed PolyString plusval = outputTriple.getPlusSet().iterator().next().getValue(); - System.out.println("Plus polystring\n"+ plusval.debugDump()); + System.out.println("Plus polystring\n" + plusval.debugDump()); assertEquals("Wrong norm value", "666", plusval.getNorm()); } @@ -745,23 +701,20 @@ public void testEmployeeNumberProtectedString() throws Exception { @Test public void testEmployeeTypeDeltaAreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), "A"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -770,29 +723,26 @@ public void testEmployeeTypeDeltaAreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleMinus(outputTriple, "A"); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleMinus(outputTriple, "A"); } @Test public void testEmployeeTypeDeltaNullreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNullreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable()); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -801,29 +751,26 @@ public void testEmployeeTypeDeltaNullreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaBreplaceB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBreplaceB"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, "B"); + .createModificationReplaceProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, "B"); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), "B"); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -832,88 +779,74 @@ public void testEmployeeTypeDeltaBreplaceB() throws Exception { evaluator.assertResult(opResult); PrismValueDeltaSetTriple> outputTriple = mapping.getOutputTriple(); PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaAaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "A"); + employeeTypeDeltaABAdd("B", "A"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaABaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaABaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "A", "B"); + employeeTypeDeltaABAdd("B", "A", "B"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaBaddB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBaddB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B", "B"); + employeeTypeDeltaABAdd("B", "B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } @Test public void testEmployeeTypeDeltaNulladdB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNulladdB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaABAdd(TEST_NAME, "B"); + employeeTypeDeltaABAdd("B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTriplePlus(outputTriple, "B"); - PrismAsserts.assertTripleNoMinus(outputTriple); + PrismAsserts.assertTriplePlus(outputTriple, "B"); + PrismAsserts.assertTripleNoMinus(outputTriple); } public PrismValueDeltaSetTriple> employeeTypeDeltaABAdd( - final String TEST_NAME, String addVal, String... oldVals) throws Exception { - TestUtil.displayTestTitle(TEST_NAME); - + String addVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, addVal); + .createModificationAddProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, addVal); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); @@ -925,88 +858,75 @@ public PrismValueDeltaSetTriple> employeeTypeDeltaABA private void setEmployeeType(UserType userType, String... vals) { userType.getEmployeeType().clear(); - for (String val: vals) { + for (String val : vals) { userType.getEmployeeType().add(val); } } @Test public void testEmployeeTypeDeltaBdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaBdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "B"); + employeeTypeDeltaDelete("B", "B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test public void testEmployeeTypeDeltaABdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaABdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "A", "B"); + employeeTypeDeltaDelete("B", "A", "B"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test public void testEmployeeTypeDeltaAdeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaAdeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B", "A"); + employeeTypeDeltaDelete("B", "A"); // THEN PrismAsserts.assertTripleZero(outputTriple, "A"); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } @Test public void testEmployeeTypeDeltaNulldeleteB() throws Exception { - final String TEST_NAME = "testEmployeeTypeDeltaNulldeleteB"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN PrismValueDeltaSetTriple> outputTriple = - employeeTypeDeltaDelete(TEST_NAME, "B"); + employeeTypeDeltaDelete("B"); // THEN PrismAsserts.assertTripleNoZero(outputTriple); - PrismAsserts.assertTripleNoPlus(outputTriple); - PrismAsserts.assertTripleMinus(outputTriple, "B"); + PrismAsserts.assertTripleNoPlus(outputTriple); + PrismAsserts.assertTripleMinus(outputTriple, "B"); } - public PrismValueDeltaSetTriple> employeeTypeDeltaDelete(final String TEST_NAME, String delVal, String... oldVals) throws Exception { - TestUtil.displayTestTitle(TEST_NAME); - + public PrismValueDeltaSetTriple> employeeTypeDeltaDelete( + String delVal, String... oldVals) throws Exception { // GIVEN ObjectDelta delta = evaluator.getPrismContext().deltaFactory().object() - .createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, - UserType.F_EMPLOYEE_TYPE, delVal); + .createModificationDeleteProperty( + UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, delVal); - MappingImpl,PrismPropertyDefinition> mapping = evaluator.createMapping( + MappingImpl, PrismPropertyDefinition> mapping = evaluator.createMapping( "mapping-script-system-variables-employee-type.xml", - TEST_NAME, "employeeType", delta); + getTestNameShort(), "employeeType", delta); PrismObject user = (PrismObject) mapping.getSourceContext().getOldObject(); setEmployeeType(user.asObjectable(), oldVals); mapping.getSourceContext().recompute(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(getTestNameShort()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java index 2211aa73804..2fc67983729 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingStatic.java @@ -9,6 +9,7 @@ import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple; import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.exception.SchemaException; import org.testng.annotations.BeforeClass; @@ -20,7 +21,7 @@ /** * @author Radovan Semancik */ -public class TestMappingStatic { +public class TestMappingStatic extends AbstractUnitTest { private MappingTestEvaluator evaluator; diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java index 4232dc62dd9..5028dbed3c7 100644 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java +++ b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestMappingTime.java @@ -31,6 +31,7 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; @@ -39,7 +40,7 @@ /** * @author Radovan Semancik */ -public class TestMappingTime { +public class TestMappingTime extends AbstractUnitTest { private static final String MAPPING_TIME_FROM_TO_FILENAME = "mapping-time-from-to.xml"; private static final String MAPPING_TIME_ACTIVATION = "mapping-time-deferred-delete.xml"; @@ -75,7 +76,7 @@ public void testBeforeTimeFrom() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -107,7 +108,7 @@ public void testBetweenTimes() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -138,7 +139,7 @@ public void testAfterTimeTo() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -168,7 +169,7 @@ public void testExistenceBefore() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -198,7 +199,7 @@ public void testExistenceAfter() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -234,7 +235,7 @@ public void testNoReferenceTime() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -274,7 +275,7 @@ public void testSetReferenceTimeBefore() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); @@ -313,7 +314,7 @@ public void testSetReferenceTimeAfter() throws Exception { MappingImpl,PrismPropertyDefinition> mapping = builder.build(); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = new OperationResult(contextName()); // WHEN mapping.evaluate(createTask(), opResult); diff --git a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java b/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java deleted file mode 100644 index d2c4b6149cf..00000000000 --- a/model/model-common/src/test/java/com/evolveum/midpoint/model/common/mapping/TestValueConstructionAbsolute.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010-2013 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.common.mapping; - -import com.evolveum.midpoint.util.exception.SchemaException; -import org.testng.annotations.BeforeClass; -import org.xml.sax.SAXException; - -import java.io.IOException; - -/** - * @author Radovan Semancik - */ -public class TestValueConstructionAbsolute { - - private MappingTestEvaluator evaluator; - - @BeforeClass - public void setupFactory() throws SAXException, IOException, SchemaException { - evaluator = new MappingTestEvaluator(); - evaluator.init(); - } - - -// @Test -// public void testConstructionExpressionInputMulti() throws JAXBException, ExpressionEvaluationException, ObjectNotFoundException, SchemaException, FileNotFoundException { -// // WHEN -// PrismValueDeltaSetTriple> outputTriple = evaluator.evaluateMappingDynamicAdd(String.class, -// "absolute/construction-expression-input-multi.xml", "employeeType", "rock", null, "testConstructionExpressionSimple", -// "apple", "orange"); -// -// // THEN -// PrismAsserts.assertTripleZero(outputTriple, "apple", "orange", "rock" ); -// PrismAsserts.assertTripleNoPlus(outputTriple); -// PrismAsserts.assertTripleNoMinus(outputTriple); -// } - -} diff --git a/model/model-impl/pom.xml b/model/model-impl/pom.xml index 658321c8a0d..5112a06f0ab 100644 --- a/model/model-impl/pom.xml +++ b/model/model-impl/pom.xml @@ -352,7 +352,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java index 5bb3b624b0e..0f53e75c191 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/SpringApplicationContextTest.java @@ -8,24 +8,23 @@ package com.evolveum.midpoint.model.impl; import static org.testng.AssertJUnit.assertNotNull; -import org.testng.annotations.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.Test; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** - * * Test of spring application context initialization * * @author Igor Farinic - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) -public class SpringApplicationContextTest extends AbstractTestNGSpringContextTests { +@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) +public class SpringApplicationContextTest extends AbstractSpringTest { - @Autowired(required = true) + @Autowired RepositoryService repositoryService; @Test diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java index 9ed8689f1c7..275cf01a12f 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestFilterResolver.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDependencyType; @@ -39,9 +38,6 @@ public class TestFilterResolver extends AbstractInternalModelIntegrationTest { @Test public void test001resolveDependencyFilter() throws Exception { - final String TEST_NAME = "test001resolveDependencyFilter"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN importObjectFromFile(RESOURCE_DUMMY_DEPENDENCY_FILTER_FILE); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java index 765e019f0ba..2c491503749 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/TestRefinedSchema.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; @@ -61,9 +60,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(getDummyResourceType(), prismContext); @@ -75,9 +71,6 @@ public void test000Sanity() throws Exception { @Test public void test010SanityModel() throws Exception { - final String TEST_NAME = "test010SanityModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN refinedSchemaModel = RefinedResourceSchemaImpl.getRefinedSchema(getDummyResourceType(), LayerType.MODEL, prismContext); @@ -91,10 +84,7 @@ public void test010SanityModel() throws Exception { } @Test - public void test100EntitlementRefinedObjectClasses() throws Exception { - final String TEST_NAME = "test100EntitlementRefinedObjectClasses"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test100EntitlementRefinedObjectClasses() { // WHEN Collection entitlementROcDefs = refinedSchema.getRefinedDefinitions(ShadowKindType.ENTITLEMENT); @@ -109,10 +99,7 @@ public void test100EntitlementRefinedObjectClasses() throws Exception { } @Test - public void test101EntitlementRefinedObjectClassesModel() throws Exception { - final String TEST_NAME = "test101EntitlementRefinedObjectClassesModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test101EntitlementRefinedObjectClassesModel() { // WHEN Collection entitlementROcDefs = refinedSchemaModel.getRefinedDefinitions(ShadowKindType.ENTITLEMENT); @@ -128,10 +115,7 @@ public void test101EntitlementRefinedObjectClassesModel() throws Exception { @Test public void test110DetermineObjectClassObjectClass() throws Exception { - final String TEST_NAME = "test110DetermineObjectClassObjectClass"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -151,10 +135,7 @@ public void test110DetermineObjectClassObjectClass() throws Exception { @Test public void test112DetermineObjectClassKindIntent() throws Exception { - final String TEST_NAME = "test112DetermineObjectClassKindIntent"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -174,10 +155,7 @@ public void test112DetermineObjectClassKindIntent() throws Exception { @Test public void test114DetermineObjectClassKindIntentObjectClass() throws Exception { - final String TEST_NAME = "test114DetermineObjectClassKindIntentObjectClass"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); @@ -197,10 +175,7 @@ public void test114DetermineObjectClassKindIntentObjectClass() throws Exception @Test public void test120DetermineObjectClassObjectClassModel() throws Exception { - final String TEST_NAME = "test120DetermineObjectClassObjectClassModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_OBJECTCLASS_FILE); @@ -221,10 +196,7 @@ public void test120DetermineObjectClassObjectClassModel() throws Exception { @Test public void test122DetermineObjectClassKindIntentModel() throws Exception { - final String TEST_NAME = "test122DetermineObjectClassKindIntentModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_FILE); @@ -246,10 +218,7 @@ public void test122DetermineObjectClassKindIntentModel() throws Exception { @Test public void test124DetermineObjectClassKindIntentObjectClassModel() throws Exception { - final String TEST_NAME = "test124DetermineObjectClassKindIntentObjectClassModel"; - TestUtil.displayTestTitle(this, TEST_NAME); - - OperationResult result = new OperationResult(TestRefinedSchema.class.getName() + "." + TEST_NAME); + OperationResult result = new OperationResult(getTestNameShort()); importObjectFromFile(TASK_RECONCILE_DUMMY_KIND_INTENT_OBJECTCLASS_FILE); @@ -269,8 +238,8 @@ public void test124DetermineObjectClassKindIntentObjectClassModel() throws Excep ShadowKindType.ENTITLEMENT, "privilege", LayerType.MODEL); } - private void assertObjectClass(ObjectClassComplexTypeDefinition objectClass, - QName objectClassQName) { + private void assertObjectClass( + ObjectClassComplexTypeDefinition objectClass, QName objectClassQName) { assertNotNull("No object class", objectClass); assertEquals("Wrong object class QName in object class " + objectClass, objectClassQName, objectClass.getTypeName()); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java index 399078f6af7..9e46d817f58 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/ExpressionHandlerImplTest.java @@ -11,9 +11,7 @@ import java.io.File; import java.io.IOException; - -import com.evolveum.midpoint.prism.xnode.MapXNode; -import com.evolveum.midpoint.prism.xnode.RootXNode; +import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -21,43 +19,32 @@ import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xnode.MapXNode; +import com.evolveum.midpoint.prism.xnode.RootXNode; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.SchemaDebugUtil; import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -import javax.xml.namespace.QName; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** - * * @author lazyman - * */ @ContextConfiguration(locations = { "classpath:ctx-model-test-no-repo.xml" }) -public class ExpressionHandlerImplTest extends AbstractTestNGSpringContextTests { +public class ExpressionHandlerImplTest extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(ExpressionHandlerImplTest.class); private static final File TEST_FOLDER = new File("./src/test/resources/expr"); @@ -81,8 +68,7 @@ public void setup() throws SchemaException, SAXException, IOException { // This test is wrong. Maybe wrong place. // But the problem is, that the account here contains raw values. It does not have // the definition applied. Therefore the equals() in groovy won't work. - @Test(enabled=false) - @SuppressWarnings("unchecked") + @Test(enabled = false) public void testConfirmUser() throws Exception { PrismObject account = PrismTestUtil.parseObject(new File( TEST_FOLDER, "account-xpath-evaluation.xml")); @@ -109,7 +95,6 @@ public void testConfirmUser() throws Exception { assertTrue("Wrong expression result (expected true)", confirmed); } - @SuppressWarnings("unchecked") @Test public void testEvaluateExpression() throws Exception { PrismObject account = PrismTestUtil.parseObject(new File(TEST_FOLDER, "account.xml")); @@ -121,14 +106,14 @@ public void testEvaluateExpression() throws Exception { accountType.setResourceRef(resourceRef); ObjectSynchronizationType synchronization = resourceType.getSynchronization().getObjectSynchronization().get(0); - for (ConditionalSearchFilterType filter : synchronization.getCorrelation()){ + for (ConditionalSearchFilterType filter : synchronization.getCorrelation()) { MapXNode clauseXNode = filter.getFilterClauseXNode(); // key = q:equal, value = map (path + expression) RootXNode expressionNode = ((MapXNode) clauseXNode.getSingleSubEntry("filter value").getValue()) .getEntryAsRoot(new QName(SchemaConstants.NS_C, "expression")); ExpressionType expression = PrismTestUtil.getPrismContext().parserFor(expressionNode).parseRealValue(ExpressionType.class); - LOGGER.debug("Expression: {}",SchemaDebugUtil.prettyPrint(expression)); + LOGGER.debug("Expression: {}", SchemaDebugUtil.prettyPrint(expression)); OperationResult result = new OperationResult("testCorrelationRule"); String name = expressionHandler.evaluateExpression(accountType, expression, "test expression", null, result); @@ -137,16 +122,4 @@ public void testEvaluateExpression() throws Exception { assertEquals("Wrong expression result", "hbarbossa", name); } } - - private Element findChildElement(Element element, String namespace, String name) { - NodeList list = element.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node node = list.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE && namespace.equals(node.getNamespaceURI()) - && name.equals(node.getLocalName())) { - return (Element) node; - } - } - return null; - } } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java index 4775c26f6a4..ca2822ae06c 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestFilterExpression.java @@ -12,10 +12,6 @@ import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -50,7 +46,6 @@ import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -67,10 +62,10 @@ public class TestFilterExpression extends AbstractInternalModelIntegrationTest { private static final String TEST_DIR = "src/test/resources/expr"; - @Autowired(required = true) + @Autowired private ExpressionFactory expressionFactory; - @Autowired(required = true) + @Autowired private TaskManager taskManager; @BeforeSuite @@ -81,42 +76,31 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100EvaluateExpressionEmployeeTypeUndefinedFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeUndefinedFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-undefined-filter.xml", - null, UndefinedFilter.class, task, result); + null, UndefinedFilter.class, task, task.getResult()); - executeFilter(filter, 5, task, result); + executeFilter(filter, 5, task, task.getResult()); } @Test public void test110EvaluateExpressionEmployeeTypeNoneFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeNoneFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-none-filter.xml", - null, NoneFilter.class, task, result); + null, NoneFilter.class, task, task.getResult()); - executeFilter(filter, 0, task, result); + executeFilter(filter, 0, task, task.getResult()); } @Test public void test120EvaluateExpressionEmployeeTypeAllFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeAllFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-all-filter.xml", null, AllFilter.class, task, result); @@ -126,12 +110,9 @@ public void test120EvaluateExpressionEmployeeTypeAllFilter() throws Exception { @Test public void test130EvaluateExpressionEmployeeTypeError() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeError"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); try { evaluateExpressionAssertFilter("expression-employeeType-error.xml", @@ -146,12 +127,9 @@ public void test130EvaluateExpressionEmployeeTypeError() throws Exception { @Test public void test140EvaluateExpressionEmployeeTypeEmptyFilter() throws Exception { - final String TEST_NAME = "testEvaluateExpressionEmployeeTypeEmptyFilter"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-empty-filter.xml", null, EqualFilter.class, task, result); @@ -164,13 +142,9 @@ public void test140EvaluateExpressionEmployeeTypeEmptyFilter() throws Exception @Test public void test150EvaluateExpressionEmployeeTypeDefaultsNull() throws Exception { - final String TEST_NAME = "test150EvaluateExpressionEmployeeTypeDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); - + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", null, EqualFilter.class, task, result); @@ -183,12 +157,9 @@ public void test150EvaluateExpressionEmployeeTypeDefaultsNull() throws Exception @Test public void test152EvaluateExpressionEmployeeTypeDefaultsCaptain() throws Exception { - final String TEST_NAME = "test152EvaluateExpressionEmployeeTypeDefaultsCaptain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", "CAPTAIN", EqualFilter.class, task, result); @@ -202,12 +173,9 @@ public void test152EvaluateExpressionEmployeeTypeDefaultsCaptain() throws Except @Test public void test200EvaluateExpressionLinkRefDefaultsNull() throws Exception { - final String TEST_NAME = "test200EvaluateExpressionLinkRefDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", null, RefFilter.class, task, result); @@ -220,12 +188,9 @@ public void test200EvaluateExpressionLinkRefDefaultsNull() throws Exception { @Test public void test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull() throws Exception { - final String TEST_NAME = "test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-object-reference-type-filter-defaults.xml", null, RefFilter.class, task, result); @@ -238,12 +203,9 @@ public void test202EvaluateExpressionLinkRefObjectReferenceTypeDefaultsNull() th @Test public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception { - final String TEST_NAME = "test210EvaluateExpressionLinkRefDefaultsVal"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result); @@ -256,12 +218,9 @@ public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception { @Test public void test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal() throws Exception { - final String TEST_NAME = "test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME); - Task task = taskManager.createTaskInstance(TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-object-reference-type-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java index c27e780df15..64381d33186 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/expr/TestModelExpressions.java @@ -6,17 +6,16 @@ */ package com.evolveum.midpoint.model.impl.expr; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; import static org.testng.AssertJUnit.assertEquals; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; - -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import org.springframework.beans.factory.annotation.Autowired; @@ -48,23 +47,14 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -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.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** - * * @author lazyman * @author mederly * @author semancik - * */ @ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @@ -74,8 +64,6 @@ public class TestModelExpressions extends AbstractInternalModelIntegrationTest { private static final QName PROPERTY_NAME = new QName(SchemaConstants.NS_C, "foo"); - private static final Trace LOGGER = TraceManager.getTrace(TestModelExpressions.class); - private static final String CHEF_OID = "00000003-0000-0000-0000-000000000000"; private static final String CHEESE_OID = "00000002-0000-0000-0000-000000000000"; private static final String CHEESE_JR_OID = "00000002-0000-0000-0000-000000000001"; @@ -83,11 +71,11 @@ public class TestModelExpressions extends AbstractInternalModelIntegrationTest { private static final String LECHUCK_OID = "00000007-0000-0000-0000-000000000000"; private static final String F0006_OID = "00000000-8888-6666-0000-100000000006"; - @Autowired(required=true) + @Autowired private ScriptExpressionFactory scriptExpressionFactory; @Autowired private ExpressionFactory expressionFactory; - @Autowired(required = true) + @Autowired private TaskManager taskManager; private static final File TEST_EXPRESSIONS_OBJECTS_FILE = new File(TEST_DIR, "orgstruct.xml"); @@ -107,13 +95,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void testHello() throws Exception { - final String TEST_NAME = "testHello"; - TestUtil.displayTestTitle(this, TEST_NAME); - - assertExecuteScriptExpressionString(TEST_NAME, null, "Hello swashbuckler"); + assertExecuteScriptExpressionString(null, "Hello swashbuckler"); } - private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { + private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; @@ -122,7 +107,6 @@ private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws Sc @Test public void testGetUserByOid() throws Exception { final String TEST_NAME = "testGetUserByOid"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); @@ -131,28 +115,31 @@ public void testGetUserByOid() throws Exception { ExpressionVariables variables = createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); // WHEN, THEN - assertExecuteScriptExpressionString(TEST_NAME, variables, chef.asObjectable().getName().getOrig()); + assertExecuteScriptExpressionString(variables, chef.asObjectable().getName().getOrig()); } @Test public void testGetManagersOids() throws Exception { - final String TEST_NAME = "testGetManagersOids"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); + OperationResult result = createOperationalResult(); + String shortTestName = getTestNameShort(); PrismObject chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result); - ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml"); - PrismPropertyDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, - MiscSchemaUtil.getExpressionProfile(), expressionFactory, TEST_NAME, task, result); - ExpressionVariables variables = createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); + ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml"); + PrismPropertyDefinition outputDefinition = + getPrismContext().definitionFactory().createPropertyDefinition( + PROPERTY_NAME, DOMUtil.XSD_STRING); + ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression( + scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), + expressionFactory, shortTestName, task, result); + ExpressionVariables variables = + createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition()); // WHEN - List> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result); + List> scriptOutputs = + evaluate(scriptExpression, variables, false, shortTestName, null, result); // THEN display("Script output", scriptOutputs); @@ -161,7 +148,7 @@ public void testGetManagersOids() throws Exception { oids.add(scriptOutputs.get(0).getValue()); oids.add(scriptOutputs.get(1).getValue()); oids.add(scriptOutputs.get(2).getValue()); - Set expectedOids = new HashSet<>(Arrays.asList(new String[]{CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID})); + Set expectedOids = new HashSet<>(Arrays.asList(new String[] { CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID })); assertEquals("Unexpected script output", expectedOids, oids); } @@ -171,7 +158,6 @@ public void testGetManagersOids() throws Exception { @Test public void testIsUniquePropertyValue() throws Exception { final String TEST_NAME = "testIsUniquePropertyValue"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -201,14 +187,12 @@ public void testIsUniquePropertyValue() throws Exception { @Test public void testGetOrgByName() throws Exception { final String TEST_NAME = "testGetOrgByName"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertExecuteScriptExpressionString(TEST_NAME, null, F0006_OID); + assertExecuteScriptExpressionString(null, F0006_OID); } @Test public void testGetLinkedShadowName() throws Exception { final String TEST_NAME = "testGetLinkedShadowName"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -216,7 +200,7 @@ public void testGetLinkedShadowName() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -224,7 +208,6 @@ public void testGetLinkedShadowName() throws Exception { @Test public void testGetLinkedShadowKindIntentUsername() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentUsername"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -232,7 +215,7 @@ public void testGetLinkedShadowKindIntentUsername() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -240,7 +223,6 @@ public void testGetLinkedShadowKindIntentUsername() throws Exception { @Test public void testGetLinkedShadowKindIntentFullname() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentFullname"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -248,7 +230,7 @@ public void testGetLinkedShadowKindIntentFullname() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); } @@ -256,7 +238,6 @@ public void testGetLinkedShadowKindIntentFullname() throws Exception { @Test public void testGetLinkedShadowNameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowNameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -264,7 +245,7 @@ public void testGetLinkedShadowNameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } @@ -272,7 +253,6 @@ public void testGetLinkedShadowNameRepo() throws Exception { @Test public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentUsernameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -280,7 +260,7 @@ public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); + assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } @@ -288,7 +268,6 @@ public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception { @Test public void testGetLinkedShadowKindIntentFullnameRepo() throws Exception { final String TEST_NAME = "testGetLinkedShadowKindIntentFullnameRepo"; - TestUtil.displayTestTitle(this, TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -296,36 +275,44 @@ public void testGetLinkedShadowKindIntentFullnameRepo() throws Exception { ExpressionVariables variables = createVariables( ExpressionConstants.VAR_USER, user, user.getDefinition()); - assertExecuteScriptExpressionString(TEST_NAME, variables, null); + assertExecuteScriptExpressionString(variables, null); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); } - - private void assertExecuteScriptExpressionString(final String TEST_NAME, ExpressionVariables variables, String expectedOutput) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, IOException, JAXBException, CommunicationException, ConfigurationException, SecurityViolationException { - String output = executeScriptExpressionString(TEST_NAME, variables); + private void assertExecuteScriptExpressionString( + ExpressionVariables variables, String expectedOutput) + throws ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, + IOException, CommunicationException, SchemaException, SecurityViolationException { + String output = executeScriptExpressionString(variables); assertEquals("Unexpected script output", expectedOutput, output); } - private String executeScriptExpressionString(final String TEST_NAME, ExpressionVariables variables) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { + private String executeScriptExpressionString(ExpressionVariables variables) + throws SecurityViolationException, ExpressionEvaluationException, SchemaException, + ObjectNotFoundException, CommunicationException, ConfigurationException, IOException { // GIVEN - Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME); - - ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml"); - ItemDefinition outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING); - ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, - MiscSchemaUtil.getExpressionProfile(), expressionFactory, TEST_NAME, task, result); + Task task = createPlainTask("executeScriptExpressionString"); + OperationResult result = createOperationalResult(); + String shortTestName = getTestNameShort(); + + ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml"); + ItemDefinition outputDefinition = + getPrismContext().definitionFactory().createPropertyDefinition( + PROPERTY_NAME, DOMUtil.XSD_STRING); + ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression( + scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), + expressionFactory, shortTestName, task, result); if (variables == null) { variables = new ExpressionVariables(); } // WHEN - TestUtil.displayWhen(TEST_NAME); - List> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result); + when(); + List> scriptOutputs = evaluate(scriptExpression, variables, false, shortTestName, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Script output", scriptOutputs); result.computeStatus(); TestUtil.assertSuccess(result); @@ -344,7 +331,7 @@ private String executeScriptExpressionString(final String TEST_NAME, ExpressionV } private List> evaluate(ScriptExpression scriptExpression, ExpressionVariables variables, boolean useNew, - String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { + String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { if (task == null) { task = taskManager.createTaskInstance(); } 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 3e09c7aa1e6..962958ebdb5 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 @@ -111,7 +111,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100Direct() throws Exception { final String TEST_NAME = "test100Direct"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -126,13 +125,13 @@ public void test100Direct() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -151,7 +150,6 @@ public void test100Direct() throws Exception { @Test public void test110DirectExpression() throws Exception { final String TEST_NAME = "test110DirectExpression"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -167,13 +165,13 @@ public void test110DirectExpression() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -191,7 +189,6 @@ public void test110DirectExpression() throws Exception { @Test public void test120DirectExpressionReplaceDescription() throws Exception { final String TEST_NAME = "test120DirectExpressionReplaceDescription"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -216,13 +213,13 @@ public void test120DirectExpressionReplaceDescription() throws Exception { display("Assignment IDI", assignmentIdi); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -254,7 +251,6 @@ public void test120DirectExpressionReplaceDescription() throws Exception { @Test public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception { final String TEST_NAME = "test130DirectExpressionReplaceDescriptionFromNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -279,13 +275,13 @@ public void test130DirectExpressionReplaceDescriptionFromNull() throws Exception assignmentIdi.recompute(); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testDirect", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -339,7 +335,6 @@ Explanation for roles structure (copied from role-corp-generic-metarole.xml) @Test public void test140RoleVisitor() throws Exception { final String TEST_NAME = "test140RoleVisitor"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -354,13 +349,13 @@ public void test140RoleVisitor() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -385,7 +380,6 @@ public void test140RoleVisitor() throws Exception { @Test public void test142RoleVisitorDisabledAssignment() throws Exception { final String TEST_NAME = "test142RoleVisitorDisabledAssignment"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -401,13 +395,13 @@ public void test142RoleVisitorDisabledAssignment() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -433,7 +427,6 @@ public void test142RoleVisitorDisabledAssignment() throws Exception { @Test public void test150RoleEngineer() throws Exception { final String TEST_NAME = "test150RoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -448,13 +441,13 @@ public void test150RoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -480,7 +473,6 @@ public void test150RoleEngineer() throws Exception { @Test public void test160AddRoleEngineer() throws Exception { final String TEST_NAME = "test160AddRoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -502,13 +494,13 @@ public void test160AddRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, AssignmentOrigin.createNotVirtual(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(evaluatedAssignment); @@ -553,7 +545,6 @@ public void test160AddRoleEngineer() throws Exception { @Test public void test170RoleManagerChangeCostCenter() throws Exception { final String TEST_NAME = "test170RoleManagerChangeCostCenter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -576,13 +567,13 @@ public void test170RoleManagerChangeCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -617,7 +608,6 @@ public void test170RoleManagerChangeCostCenter() throws Exception { @Test public void test180RoleManagerRemoveCostCenter() throws Exception { final String TEST_NAME = "test180RoleManagerRemoveCostCenter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -641,13 +631,13 @@ public void test180RoleManagerRemoveCostCenter() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, TEST_NAME, AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -678,7 +668,6 @@ public void test180RoleManagerRemoveCostCenter() throws Exception { @Test(enabled = false) public void test200DisableEngineerEmployeeInducement() throws Exception { final String TEST_NAME = "test200DisableEngineerEmployeeInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -701,13 +690,13 @@ public void test200DisableEngineerEmployeeInducement() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -720,7 +709,6 @@ public void test200DisableEngineerEmployeeInducement() throws Exception { @Test(enabled = false) public void test299ReenableEngineerEmployeeInducement() throws Exception { final String TEST_NAME = "test299ReenableEngineerEmployeeInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -741,7 +729,6 @@ public void test299ReenableEngineerEmployeeInducement() throws Exception { @Test public void test300DisableRoleEmployee() throws Exception { final String TEST_NAME = "test300DisableRoleEmployee"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -764,13 +751,13 @@ public void test300DisableRoleEmployee() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -797,7 +784,6 @@ public void test300DisableRoleEmployee() throws Exception { @Test public void test310DisableRoleEngineer() throws Exception { final String TEST_NAME = "test310DisableRoleEngineer"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -820,13 +806,13 @@ public void test310DisableRoleEngineer() throws Exception { ItemDeltaItem,PrismContainerDefinition> assignmentIdi = createAssignmentIdi(assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, userTypeJack, "testRoleEngineer", AssignmentOrigin.createInObject(), task, result); evaluatedAssignment.evaluateConstructions(userOdo, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -858,7 +844,6 @@ public void test310DisableRoleEngineer() throws Exception { @Test public void test400UserFred() throws Exception { final String TEST_NAME = "test400UserFred"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentEvaluator.class.getName() + "." + TEST_NAME); @@ -883,11 +868,11 @@ public void test400UserFred() throws Exception { addFocusDeltaToContext(lensContext, descriptionDelta); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(lensContext, "test", task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); DeltaSetTriple> triple = lensContext.getEvaluatedAssignmentTriple(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java index 2130f5e7103..b4fbc6ba597 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestAssignedMappings.java @@ -16,7 +16,6 @@ import com.evolveum.midpoint.test.TestResource; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; import org.springframework.beans.factory.annotation.Autowired; @@ -142,10 +141,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignSimpleToJim() throws Exception { final String TEST_NAME = "test100AssignSimpleToJim"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -189,10 +188,10 @@ public void test100AssignSimpleToJim() throws Exception { @Test public void test110AssignRingToFrodo() throws Exception { final String TEST_NAME = "test110AssignRingToFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -239,10 +238,10 @@ public void test110AssignRingToFrodo() throws Exception { @Test public void test120AssignStingToFrodo() throws Exception { final String TEST_NAME = "test120AssignStingToFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -288,10 +287,10 @@ public void test120AssignStingToFrodo() throws Exception { @Test public void test130UnassignRingFromFrodo() throws Exception { final String TEST_NAME = "test130UnassignRingFromFrodo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -344,10 +343,10 @@ public void test130UnassignRingFromFrodo() throws Exception { @Test public void test200AssignRolesToAdam() throws Exception { final String TEST_NAME = "test200AssignRolesToAdam"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -402,10 +401,10 @@ public void test200AssignRolesToAdam() throws Exception { @Test public void test210AssignRolesToBenjamin() throws Exception { final String TEST_NAME = "test210AssignRolesToBenjamin"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -487,10 +486,10 @@ public void test210AssignRolesToBenjamin() throws Exception { @Test public void test220AdamConditionFalseToTrue() throws Exception { final String TEST_NAME = "test220AdamConditionFalseToTrue"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -566,10 +565,10 @@ public void test220AdamConditionFalseToTrue() throws Exception { @Test public void test230BenjaminConditionTrueToFalse() throws Exception { final String TEST_NAME = "test230BenjaminConditionTrueToFalse"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -600,10 +599,10 @@ public void test230BenjaminConditionTrueToFalse() throws Exception { @Test public void test280UnassignRolesFromAdam() throws Exception { final String TEST_NAME = "test280UnassignRolesFromAdam"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -630,10 +629,10 @@ public void test280UnassignRolesFromAdam() throws Exception { @Test public void test290UnassignRolesFromBenjamin() throws Exception { final String TEST_NAME = "test290UnassignRolesFromBenjamin"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestAssignedMappings.class.getName() + "." + TEST_NAME); + TestAssignedMappings.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN 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 3cffc187f3a..8796cdf2065 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 @@ -71,7 +71,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001OutboundEmpty() throws Exception { final String TEST_NAME = "test001OutboundEmpty"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -96,7 +95,6 @@ public void test001OutboundEmpty() throws Exception { @Test public void test002ModifyUser() throws Exception { final String TEST_NAME = "test002ModifyUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -159,7 +157,6 @@ public void test002ModifyUser() throws Exception { @Test public void test011AddAssignmentAddAccountDirect() throws Exception { final String TEST_NAME = "test011AddAssignmentAddAccountDirect"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -201,7 +198,6 @@ public void test011AddAssignmentAddAccountDirect() throws Exception { @Test public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exception { final String TEST_NAME = "test012AddAssignmentAddAccountDirectAssignmentWithAttrs"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -217,11 +213,11 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc assertFocusModificationSanity(context); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Output context", context); display("outbound processor result", result); // assertSuccess("Outbound processor failed (result)", result); @@ -272,7 +268,6 @@ public void test012AddAssignmentAddAccountDirectAssignmentWithAttrs() throws Exc @Test public void test021AddAssignmentModifyAccountAssignment() throws Exception { final String TEST_NAME = "test021AddAssignmentModifyAccountAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -366,7 +361,6 @@ public void test021AddAssignmentModifyAccountAssignment() throws Exception { @Test public void test031DeleteAssignmentModifyAccount() throws Exception { final String TEST_NAME = "test031DeleteAssignmentModifyAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); @@ -386,11 +380,11 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); assignmentProcessor.processAssignments(context, getNow(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Output context", context.dump(true)); display("result", result); assertSuccess(result); @@ -452,9 +446,8 @@ public void test031DeleteAssignmentModifyAccount() throws Exception { @Test public void test032ModifyUserLegalizeAccount() throws Exception { final String TEST_NAME = "test032ModifyUserLegalizeAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -501,7 +494,6 @@ public void test032ModifyUserLegalizeAccount() throws Exception { @Test public void test100AddAssignmentWithConditionalMetarole() throws Exception { final String TEST_NAME = "test100AddAssignmentWithConditionalMetarole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -566,7 +558,6 @@ public void test100AddAssignmentWithConditionalMetarole() throws Exception { @Test public void test102EnableConditionalMetarole() throws Exception { final String TEST_NAME = "test102EnableConditionalMetarole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -650,7 +641,6 @@ public void test102EnableConditionalMetarole() throws Exception { @Test public void test200AssignVisitor() throws Exception { final String TEST_NAME = "test200AssignVisitor"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -705,7 +695,6 @@ public void test200AssignVisitor() throws Exception { @Test public void test210AssignEngineer() throws Exception { final String TEST_NAME = "test210AssignEngineer"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); 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 1459ca52902..754fcdf405d 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 @@ -155,8 +155,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti initDummyResourcePirate(RESOURCE_DUMMY_EMPTY_INSTANCE_NAME, RESOURCE_DUMMY_EMPTY_FILE, RESOURCE_DUMMY_EMPTY_OID, initTask, initResult); - setAutoTaskManagementEnabled(true); - if (FIRST_PART) { createObjectsInFirstPart(false, initTask, initResult, null); } @@ -170,8 +168,8 @@ public void test000Sanity() throws Exception { @Test(enabled = FIRST_PART) public void test010AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -228,17 +226,17 @@ private void processAssignments(LensContext context, OperationResult r @Test(enabled = FIRST_PART) public void test020AssignMR1ToR1() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(RoleType.class, ROLE_R1_OID, RoleType.class, ROLE_MR1_OID, null, null, result); // WHEN - displayWhen(); + when(); assignmentProcessor.processAssignments(context, clock.currentTimeXMLGregorianCalendar(), task, result); // THEN - displayThen(); + then(); display("Output context", context); display("Evaluated assignment triple", context.getEvaluatedAssignmentTriple()); assertSuccess(result); @@ -274,8 +272,8 @@ public void test020AssignMR1ToR1() throws Exception { @Test(enabled = FIRST_PART) public void test030AssignR1ToJackProjectorDisabled() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, a -> a.setActivation(ActivationUtil.createDisabled()), result); @@ -303,8 +301,8 @@ public void test030AssignR1ToJackProjectorDisabled() throws Exception { @Test(enabled = FIRST_PART) public void test040AssignR1ToJackAsApprover() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -357,8 +355,8 @@ public void test040AssignR1ToJackAsApprover() throws Exception { @Test(enabled = FIRST_PART) public void test050JackDeputyOfBarbossa() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); AssignmentType policyRuleAssignment = new AssignmentType(prismContext); PolicyRuleType rule = new PolicyRuleType(prismContext); @@ -436,8 +434,8 @@ public void test050JackDeputyOfBarbossa() throws Exception { @Test(enabled = FIRST_PART) public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); AssignmentType deputyOfBarbossaAssignment = ObjectTypeUtil.createAssignmentTo(USER_BARBOSSA_OID, ObjectTypes.USER, prismContext); deputyOfBarbossaAssignment.getTargetRef().setRelation(SchemaConstants.ORG_DEPUTY); @@ -500,8 +498,8 @@ public void test060JackDeputyOfGuybrushDeputyOfBarbossa() throws Exception { @Test(enabled = FIRST_PART) public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType jackGuybrushAssignment = new AssignmentType(prismContext) @@ -533,12 +531,12 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce jackGuybrushAssignment.asPrismContainerValue().getDefinition()); // WHEN - displayWhen(); + when(); EvaluatedAssignmentImpl evaluatedAssignment = assignmentEvaluator .evaluate(assignmentIdi, PlusMinusZero.ZERO, false, jack.asObjectable(), jack.toString(), AssignmentOrigin.createInObject(), task, result); // THEN - displayThen(); + then(); display("Output context", context); display("Evaluated assignment", evaluatedAssignment); @@ -587,8 +585,8 @@ public void test062JackDeputyOfGuybrushDeputyOfBarbossaInLoginMode() throws Exce @Test(enabled = FIRST_PART) public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); unassignAllRoles(USER_JACK_OID); unassignAllRoles(USER_GUYBRUSH_OID); @@ -664,8 +662,8 @@ public void test070JackDeputyOfBarbossaApproverOfR1() throws Exception { @Test(enabled = FIRST_PART) public void test100DisableSomeRoles() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableRoles("MMR1 R2 MR3 R4")); @@ -678,8 +676,8 @@ public void test100DisableSomeRoles() throws Exception { @Test(enabled = FIRST_PART) public void test110AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -736,8 +734,8 @@ public void test110AssignR1ToJack() throws Exception { @Test(enabled = FIRST_PART) public void test150DisableSomeAssignments() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> disableAssignments("MR4-R6 MR1-MR3 R1-R2")); @@ -748,8 +746,8 @@ public void test150DisableSomeAssignments() throws Exception { @Test(enabled = FIRST_PART) public void test160AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); @@ -806,8 +804,8 @@ public void test160AssignR1ToJack() throws Exception { @Test(enabled = FIRST_PART) public void test200AddConditions() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN createObjectsInFirstPart(true, task, result, () -> { @@ -824,8 +822,8 @@ public void test200AddConditions() throws Exception { @Test(enabled = FIRST_PART) public void test210AssignR1ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForRoleAssignment(USER_JACK_OID, ROLE_R1_OID, null, null, result); context.getFocusContext().swallowToPrimaryDelta( @@ -887,8 +885,8 @@ public void test210AssignR1ToJack() throws Exception { @Test(enabled = SECOND_PART) public void test300AssignR7ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); createObjectsInSecondPart(false, task, result, null); @@ -1027,8 +1025,8 @@ public void test300AssignR7ToJack() throws Exception { @Test(enabled = THIRD_PART) public void test400AssignJackPirate() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); createObjectsInThirdPart(false, task, result, () -> { @@ -1490,8 +1488,8 @@ public static void finishCallback(String desc) { @Test(enabled = FOURTH_PART) public void test500AssignJackOrg11() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); createObjectsInFourthPart(false, task, result, null); @@ -1548,8 +1546,8 @@ public void test500AssignJackOrg11() throws Exception { @Test(enabled = FOURTH_PART) public void test505AssignJackOrg11AsManager() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_MANAGER, null, result); @@ -1603,8 +1601,8 @@ public void test505AssignJackOrg11AsManager() throws Exception { @Test(enabled = FOURTH_PART) public void test507AssignJackOrg11AsApprover() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG11_OID, SchemaConstants.ORG_APPROVER, null, result); @@ -1657,8 +1655,8 @@ public void test507AssignJackOrg11AsApprover() throws Exception { @Test(enabled = FOURTH_PART) public void test510AssignJackOrg21() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, null, null, result); // intentionally unqualified @@ -1710,8 +1708,8 @@ public void test510AssignJackOrg21() throws Exception { @Test(enabled = FOURTH_PART) public void test515AssignJackOrg21AsManager() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG21_OID, new QName("manager"), null, result); // intentionally unqualified @@ -1777,8 +1775,8 @@ public void test515AssignJackOrg21AsManager() throws Exception { @Test(enabled = FOURTH_PART) public void test520AssignJackOrg41AsApprover() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createContextForAssignment(UserType.class, USER_JACK_OID, OrgType.class, ORG41_OID, new QName("approver"), null, result); // intentionally unqualified @@ -1841,8 +1839,8 @@ public void test520AssignJackOrg41AsApprover() throws Exception { @Test(enabled = FIFTH_PART) public void test600AssignA1ToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); createObjectsInFifthPart(false, task, result, null); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java index 33f54317ae6..07aae4b0647 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestClockwork.java @@ -90,10 +90,9 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test010SerializeAddUserBarbossa() throws Exception { final String TEST_NAME = "test010SerializeAddUserBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createUserLensContext(); @@ -101,7 +100,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { fillContextWithAddUserDelta(context, bill); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.click(context, task, result); // one round - compute projections display("Context before serialization", context); @@ -117,7 +116,7 @@ public void test010SerializeAddUserBarbossa() throws Exception { display("Context after deserialization", context); // THEN - displayThen(TEST_NAME); + then(); assertEquals("Secondary deltas are not preserved - their number differs", context.getFocusContext().getSecondaryDeltas().size(), context2.getFocusContext().getSecondaryDeltas().size()); for (int i = 0; i < context.getFocusContext().getSecondaryDeltas().size(); i++) { assertTrue("Secondary delta #" + i + " is not preserved correctly, " @@ -130,12 +129,11 @@ public void test010SerializeAddUserBarbossa() throws Exception { @Test public void test020AssignAccountToJackSync() throws Exception { final String TEST_NAME = "test020AssignAccountToJackSync"; - displayTestTitle(TEST_NAME); try { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createJackAssignAccountContext(result); @@ -148,11 +146,11 @@ public void test020AssignAccountToJackSync() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(); mockClockworkHook.setRecord(false); display("Output context", context); display("Hook contexts", mockClockworkHook); @@ -209,10 +207,9 @@ public void test031AssignAccountToJackAsyncSerialize() throws Exception { @Test public void test053ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test053ModifyUserBarbossaDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); LensContext context = createUserLensContext(); @@ -226,11 +223,11 @@ public void test053ModifyUserBarbossaDisable() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); @@ -266,10 +263,9 @@ public void test053ModifyUserBarbossaDisable() throws Exception { } private void assignAccountToJackAsync(String testName, boolean serialize) throws Exception { - displayTestTitle(testName); // GIVEN - Task task = createTask(testName); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); @@ -285,7 +281,7 @@ private void assignAccountToJackAsync(String testName, boolean serialize) throws rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(testName); + when(testName); while(context.getState() != ModelState.FINAL) { display("CLICK START: "+context.getState()); @@ -315,7 +311,7 @@ private void assignAccountToJackAsync(String testName, boolean serialize) throws } // THEN - displayThen(testName); + then(testName); mockClockworkHook.setRecord(false); // display("Output context", context); // display("Hook contexts", mockClockworkHook); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java index e075240e2f0..fe3f57430f6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestDependencies.java @@ -33,7 +33,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -109,7 +108,6 @@ private String getDummuAccountOid(String dummyName, String accountName) { @Test public void test100SortToWavesIdependent() throws Exception { final String TEST_NAME = "test100SortToWavesIdependent"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -138,7 +136,6 @@ public void test100SortToWavesIdependent() throws Exception { @Test public void test101SortToWavesAB() throws Exception { final String TEST_NAME = "test101SortToWavesAB"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -169,7 +166,6 @@ public void test101SortToWavesAB() throws Exception { @Test public void test102SortToWavesABCD() throws Exception { final String TEST_NAME = "test102SortToWavesABCD"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -204,7 +200,6 @@ public void test102SortToWavesABCD() throws Exception { @Test public void test120SortToWavesBCUnsatisfied() throws Exception { final String TEST_NAME = "test120SortToWavesBCUnsatisfied"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -235,7 +230,6 @@ public void test120SortToWavesBCUnsatisfied() throws Exception { @Test public void test151SortToWavesPR() throws Exception { final String TEST_NAME = "test151SortToWavesPR"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -269,7 +263,6 @@ public void test151SortToWavesPR() throws Exception { @Test public void test152SortToWavesRP() throws Exception { final String TEST_NAME = "test152SortToWavesRP"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -299,7 +292,6 @@ public void test152SortToWavesRP() throws Exception { @Test public void test200SortToWavesIdependentDeprovision() throws Exception { final String TEST_NAME = "test200SortToWavesIdependentDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -329,7 +321,6 @@ public void test200SortToWavesIdependentDeprovision() throws Exception { @Test public void test201SortToWavesABDeprovision() throws Exception { final String TEST_NAME = "test201SortToWavesABDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -361,7 +352,6 @@ public void test201SortToWavesABDeprovision() throws Exception { @Test public void test202SortToWavesABCDDeprovision() throws Exception { final String TEST_NAME = "test202SortToWavesABCDDeprovision"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); @@ -403,7 +393,6 @@ private void setDelete(LensProjectionContext accountContext) { @Test public void test300SortToWavesXYZCircular() throws Exception { final String TEST_NAME = "test300SortToWavesXYZCircular"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java index 7b6df49a5f6..402fdb0f9a6 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicy.java @@ -13,8 +13,6 @@ import java.io.File; import java.io.IOException; -import javax.xml.bind.JAXBException; - import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -32,25 +30,19 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +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.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType; import com.evolveum.midpoint.xml.ns._public.common.common_3.StringPolicyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; -@ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestPasswordPolicy extends AbstractInternalModelIntegrationTest { - public static final File TEST_DIR = new File("src/test/resources/lens/ppolicy/"); + public static final File TEST_DIR = new File("src/test/resources/lens/ppolicy/"); private static final Trace LOGGER = TraceManager.getTrace(TestPasswordPolicy.class); @@ -62,11 +54,11 @@ public class TestPasswordPolicy extends AbstractInternalModelIntegrationTest { private static final int USERNAME_ATTEMPTS = 200; private static final int USER_PROPS_ATTEMPTS = 5000; - @Autowired(required = true) + @Autowired private ValuePolicyProcessor valuePolicyProcessor; @Test - public void stringPolicyUtilsMinimalTest() throws JAXBException, SchemaException, IOException { + public void stringPolicyUtilsMinimalTest() throws SchemaException, IOException { File file = new File(TEST_DIR, "password-policy-minimal.xml"); ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); StringPolicyType sp = pp.getStringPolicy(); @@ -81,9 +73,6 @@ public void stringPolicyUtilsMinimalTest() throws JAXBException, SchemaException @Test public void stringPolicyUtilsComplexTest() { - final String TEST_NAME = "stringPolicyUtilsComplexTest"; - TestUtil.displayTestTitle(TEST_NAME); - File file = new File(TEST_DIR, "password-policy-complex.xml"); ValuePolicyType pp = null; try { @@ -98,10 +87,7 @@ public void stringPolicyUtilsComplexTest() { @Test public void testPasswordGeneratorComplexNegative() throws Exception { - final String TEST_NAME = "testPasswordGeneratorComplexNegative"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, "password-policy-complex.xml"); @@ -112,11 +98,11 @@ public void testPasswordGeneratorComplexNegative() throws Exception { pp.getStringPolicy().getLimitations().setMinUniqueChars(5); // WHEN - TestUtil.displayWhen(TEST_NAME); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + when(); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); AssertJUnit.assertTrue(result.isAcceptable()); @@ -128,7 +114,7 @@ public void testPasswordGeneratorComplexNegative() throws Exception { } LOGGER.info("Negative testing: passwordGeneratorComplexTest"); try { - valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); assertNotReached(); } catch (ExpressionEvaluationException e) { result.computeStatus(); @@ -138,40 +124,37 @@ public void testPasswordGeneratorComplexNegative() throws Exception { @Test public void testPasswordGeneratorComplex() throws Exception { - passwordGeneratorTest("testPasswordGeneratorComplex", "password-policy-complex.xml"); + passwordGeneratorTest("password-policy-complex.xml"); } @Test public void testPasswordGeneratorLong() throws Exception { - passwordGeneratorTest("testPasswordGeneratorLong", "password-policy-long.xml"); + passwordGeneratorTest("password-policy-long.xml"); } @Test public void testPasswordGeneratorNumeric() throws Exception { - passwordGeneratorTest("testPasswordGeneratorNumeric", "password-policy-numeric.xml"); + passwordGeneratorTest("password-policy-numeric.xml"); } @Test public void testValueGeneratorMustBeFirst() throws Exception { - passwordGeneratorTest("testValueGeneratorMustBeFirst", "value-policy-must-be-first.xml"); + passwordGeneratorTest("value-policy-must-be-first.xml"); } @Test public void testValueGenerateRandomPin() throws Exception { - final String TEST_NAME = "testValueGenerateRandomPin"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ValuePolicyType pp = parsePasswordPolicy("value-policy-random-pin.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + when(); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -182,20 +165,17 @@ public void testValueGenerateRandomPin() throws Exception { @Test public void testValueGenerate() throws Exception { - final String TEST_NAME = "testValueGenerate"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ValuePolicyType pp = parsePasswordPolicy("value-policy-generate.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + when(); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,10 +186,7 @@ public void testValueGenerate() throws Exception { @Test public void testValueGenerateEmpty() throws Exception { - final String TEST_NAME = "testValueGenerateEmpty"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, "value-policy-generate-empty.xml"); @@ -217,11 +194,11 @@ public void testValueGenerateEmpty() throws Exception { ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); // WHEN - TestUtil.displayWhen(TEST_NAME); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + when(); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Generated password", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -229,25 +206,25 @@ public void testValueGenerateEmpty() throws Exception { assertPassword(psswd, pp); } - public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) throws JAXBException, SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + public void passwordGeneratorTest(String policyFilename) + throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, + CommunicationException, ConfigurationException, SecurityViolationException { + Task task = getTestTask(); OperationResult result = task.getResult(); File file = new File(TEST_DIR, policyFilename); - LOGGER.info("Positive testing {}: {}", TEST_NAME, policyFilename); + LOGGER.info("Positive testing {}: {}", getTestNameShort(), policyFilename); ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable(); String psswd; // generate minimal size passwd for (int i = 0; i < 100; i++) { - psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, TEST_NAME, task, result); + psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, null, getTestNameShort(), task, result); LOGGER.info("Generated password:" + psswd); result.computeStatus(); if (!result.isSuccess()) { LOGGER.info("Result:" + result.debugDump()); - AssertJUnit.fail("Password generator failed:\n"+result.debugDump()); + AssertJUnit.fail("Password generator failed:\n" + result.debugDump()); } assertNotNull(psswd); assertPassword(psswd, pp); @@ -256,7 +233,7 @@ public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) LOGGER.info("-------------------------"); // Generate up to possible for (int i = 0; i < 100; i++) { - psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, TEST_NAME, task, result); + psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, false, null, getTestNameShort(), task, result); LOGGER.info("Generated password:" + psswd); result.computeStatus(); if (!result.isSuccess()) { @@ -268,12 +245,16 @@ public void passwordGeneratorTest(final String TEST_NAME, String policyFilename) } } - private void assertPassword(String passwd, ValuePolicyType pp) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + private void assertPassword(String passwd, ValuePolicyType pp) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { assertPassword(passwd, pp, null); } - private void assertPassword(String passwd, ValuePolicyType pp, PrismObject object) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPassword"); + private void assertPassword(String passwd, ValuePolicyType pp, PrismObject object) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { + Task task = getTestTask(); OperationResult result = task.getResult(); boolean isValid = valuePolicyProcessor.validateValue(passwd, pp, createUserOriginResolver(object), "assertPassword", task, result); result.computeStatus(); @@ -285,9 +266,6 @@ private void assertPassword(String passwd, ValuePolicyTyp @Test public void passwordValidationTestComplex() throws Exception { - final String TEST_NAME = "passwordValidationTestComplex"; - TestUtil.displayTestTitle(TEST_NAME); - ValuePolicyType pp = parsePasswordPolicy("password-policy-complex.xml"); // WHEN, THEN @@ -299,9 +277,6 @@ public void passwordValidationTestComplex() throws Exception { @Test public void passwordValidationTestTri() throws Exception { - final String TEST_NAME = "passwordValidationTestTri"; - TestUtil.displayTestTitle(TEST_NAME); - ValuePolicyType pp = parsePasswordPolicy("password-policy-tri.xml"); // WHEN, THEN @@ -318,32 +293,29 @@ public void passwordValidationTestTri() throws Exception { */ @Test public void testUsername() throws Exception { - final String TEST_NAME = "testUsername"; - TestUtil.displayTestTitle(TEST_NAME); - PrismObject user = createUserAb(); ValuePolicyType pp = parsePasswordPolicy("password-policy-username.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < USERNAME_ATTEMPTS; i++) { - Task task = createTask(TEST_NAME+":"+i); + Task task = getTestTask(); OperationResult result = task.getResult(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); - display("Generated password ("+i+")", psswd); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result); + display("Generated password (" + i + ")", psswd); result.computeStatus(); TestUtil.assertSuccess(result); assertNotNull(psswd); assertPassword(psswd, pp, user); - assertFalse("Generated password that matches the username: "+psswd, psswd.equals(USER_AB_USERNAME)); + assertFalse("Generated password that matches the username: " + psswd, psswd.equals(USER_AB_USERNAME)); } // THEN - TestUtil.displayThen(TEST_NAME); + then(); } /** @@ -351,22 +323,19 @@ public void testUsername() throws Exception { */ @Test public void testUserProps() throws Exception { - final String TEST_NAME = "testUserProps"; - TestUtil.displayTestTitle(TEST_NAME); - PrismObject user = createUserAb(); display("User", user); ValuePolicyType pp = parsePasswordPolicy("password-policy-props.xml"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < USER_PROPS_ATTEMPTS; i++) { - Task task = createTask(TEST_NAME+":"+i); + Task task = getTestTask(); OperationResult result = task.getResult(); - String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), TEST_NAME, task, result); - display("Generated password ("+i+")", psswd); + String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp, 10, true, createUserOriginResolver(user), getTestNameShort(), task, result); + display("Generated password (" + i + ")", psswd); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,7 +348,7 @@ public void testUserProps() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + then(); } private PrismObject createUserAb() throws SchemaException { @@ -389,7 +358,7 @@ private PrismObject createUserAb() throws SchemaException { } private void assertNotContains(String psswd, String val) { - assertFalse("Generated password "+psswd+" contains value "+val, StringUtils.containsIgnoreCase(psswd, val)); + assertFalse("Generated password " + psswd + " contains value " + val, StringUtils.containsIgnoreCase(psswd, val)); } private ValuePolicyType parsePasswordPolicy(String filename) throws SchemaException, IOException { @@ -398,11 +367,11 @@ private ValuePolicyType parsePasswordPolicy(String filename) throws SchemaExcept } private boolean pwdValidHelper(String password, ValuePolicyType pp) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("pwdValidHelper"); + Task task = getTestTask(); OperationResult result = task.getResult(); valuePolicyProcessor.validateValue(password, pp, null, "pwdValidHelper", task, result); result.computeStatus(); - String msg = "-> Policy "+pp.getName()+", password '"+password+"': "+result.getStatus(); + String msg = "-> Policy " + pp.getName() + ", password '" + password + "': " + result.getStatus(); System.out.println(msg); LOGGER.info(msg); LOGGER.trace(result.debugDump()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java index 485f0cdbae4..09984f0de96 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPasswordPolicyProcessor.java @@ -50,8 +50,6 @@ public abstract class TestPasswordPolicyProcessor extends A @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - - setAutoTaskManagementEnabled(true); } abstract Class getType(); @@ -69,8 +67,8 @@ public void test000initPasswordPolicyForHistory() throws Exception { @Test public void test100CreateFocusWithPassword() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN addObject(getTestResource(), task, result); @@ -89,8 +87,8 @@ private PrismObject getFocus() throws Exception { @Test public void test110ModifyPassword() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD1, task, result); @@ -112,8 +110,8 @@ public void test110ModifyPassword() throws Exception { @Test public void test120ModifyPasswordSecondTime() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD2, task, result); @@ -135,8 +133,8 @@ public void test120ModifyPasswordSecondTime() throws Exception { @Test public void test130ModifyPasswordThirdTime() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyFocusChangePassword(getType(), getOid(), PASSWORD3, task, result); @@ -172,8 +170,8 @@ public void test160ModifyPasswordSamePassword3() throws Exception { } private void doTestModifyPasswordExpectFailure(String password) throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); try { // WHEN @@ -208,8 +206,8 @@ public void test201deleteFocus() throws Exception { @Test public void test210CreateFocusNoPasswordHistory() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN addObject(getTestResource(), task, result); @@ -239,8 +237,8 @@ public void test230ModifySamePasswordNoPasswordHistory() throws Exception { } private void modifyPasswordNoHistory() throws Exception{ - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN ProtectedStringType newValue = new ProtectedStringType(); @@ -270,8 +268,8 @@ private void assertPasswords(String password, ProtectedStringType passwordAfterC } private void setPasswordHistoryLength(int historyLength) throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); modifyObjectReplaceProperty(SecurityPolicyType.class, SECURITY_POLICY_OID, SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_LENGTH, task, result, historyLength); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java index c7792fdf5b2..5127eb3df3d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules.java @@ -72,23 +72,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); InternalMonitor.reset(); -// InternalMonitor.setTraceShadowFetchOperation(true); - -// DebugUtil.setPrettyPrintBeansAs(PrismContext.LANG_YAML); - -// setPredefinedTestMethodTracing(MODEL_LOGGING); - } - - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; } @Test public void test005JackAttemptAssignRoleJudge() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); - + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); + // GIVEN LensContext context = createUserLensContext(); @@ -101,16 +91,15 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); assertTargetTriggers(context, PolicyConstraintKindType.OBJECT_STATE, 2); @@ -120,8 +109,8 @@ public void test005JackAttemptAssignRoleJudge() throws Exception { @Test(enabled = false) public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -137,16 +126,15 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 4); assertTargetTriggers(context, PolicyConstraintKindType.ASSIGNMENT_MODIFICATION, 0); @@ -158,17 +146,17 @@ public void test007JackAttemptAssignRoleJudgeAsOwner() throws Exception { */ @Test public void test010JackAssignRoleJudge() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -182,8 +170,8 @@ public void test010JackAssignRoleJudge() throws Exception { */ @Test public void test020JackUnassignRoleJudge() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -197,11 +185,11 @@ public void test020JackUnassignRoleJudge() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -219,8 +207,8 @@ public void test020JackUnassignRoleJudge() throws Exception { */ @Test public void test100AssignRoleMutinierToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -234,20 +222,16 @@ public void test100AssignRoleMutinierToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); @@ -256,8 +240,8 @@ public void test100AssignRoleMutinierToJack() throws Exception { @Test(enabled = false) // after MID-4797 the projector.project now raises PolicyViolationException on conflicting roles public void test110AssignRolePirateToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -271,20 +255,16 @@ public void test110AssignRolePirateToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 7); @@ -298,8 +278,8 @@ public void test110AssignRolePirateToJack() throws Exception { */ @Test public void test112AssignRolePirateWithExceptionToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -318,20 +298,16 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); assertAssignAccountToJack(context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); List evaluatedRules = assertEvaluatedTargetPolicyRules(context, 7); @@ -346,8 +322,8 @@ public void test112AssignRolePirateWithExceptionToJack() throws Exception { @Test public void test120AssignRoleConstableToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -361,27 +337,19 @@ public void test120AssignRoleConstableToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("Output context", context); -// DeltaSetTriple> evaluatedAssignmentTriple = -// (DeltaSetTriple)context.getEvaluatedAssignmentTriple(); -// display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); assertEvaluatedTargetPolicyRules(context, 8); - // conflicting assignment was pruned, so the exclusion is no longer present here -// EvaluatedExclusionTrigger trigger = (EvaluatedExclusionTrigger) assertTriggeredTargetPolicyRule(context, null, PolicyConstraintKindType.EXCLUSION, 1, true); -// assertNotNull("No conflicting assignment in trigger", trigger.getConflictingAssignment()); -// assertEquals("Wrong conflicting assignment in trigger", ROLE_JUDGE_OID, trigger.getConflictingAssignment().getTarget().getOid()); ObjectDelta focusSecondaryDelta = context.getFocusContext().getSecondaryDelta(); PrismAsserts.assertIsModify(focusSecondaryDelta); @@ -405,8 +373,8 @@ public void test120AssignRoleConstableToJack() throws Exception { */ @Test public void test150AssignRoleThiefToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -420,11 +388,11 @@ public void test150AssignRoleThiefToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -455,17 +423,17 @@ public void test150AssignRoleThiefToJack() throws Exception { */ @Test public void test200JackAssignRoleContractor() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_CORP_CONTRACTOR_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,8 +447,8 @@ public void test200JackAssignRoleContractor() throws Exception { */ @Test public void test210AssignRoleEmployeeToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -494,17 +462,14 @@ public void test210AssignRoleEmployeeToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); -// DeltaSetTriple> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple(); - //display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); @@ -523,8 +488,8 @@ public void test210AssignRoleEmployeeToJack() throws Exception { */ @Test public void test220AssignRoleEngineerToJack() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -538,17 +503,14 @@ public void test220AssignRoleEngineerToJack() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); -// DeltaSetTriple> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple(); - //display("Output evaluatedAssignmentTriple", evaluatedAssignmentTriple); - dumpPolicyRules(context); dumpPolicySituations(context); @@ -592,13 +554,13 @@ public void test220AssignRoleEngineerToJack() throws Exception { */ @Test public void test300DrakeChangeEmployeeType() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN // WHEN - displayWhen(); + when(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(ObjectTypeUtil.createAssignmentTo(ROLE_JUDGE_OID, ObjectTypes.ROLE, prismContext)) @@ -609,7 +571,7 @@ public void test300DrakeChangeEmployeeType() throws Exception { modelService.executeChanges(Collections.singletonList(delta), null, task, Collections.singleton(recordingListener), result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -628,8 +590,8 @@ public void test300DrakeChangeEmployeeType() throws Exception { */ @Test public void test400AssignRoleLocalized() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -642,16 +604,15 @@ public void test400AssignRoleLocalized() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(); + when(); projector.project(context, "test", task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); dumpPolicyRules(context); - //dumpPolicySituations(context); Locale SLOVAK = Locale.forLanguageTag("sk-SK"); assertNotNull("No Slovak locale", SLOVAK); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java index fa964336e81..eeb397ef622 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyRules2.java @@ -129,7 +129,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAttemptAssignRoleStudent() throws Exception { final String TEST_NAME = "test100JackAttemptAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -144,11 +143,11 @@ public void test100JackAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpPolicyRules(context); @@ -172,7 +171,6 @@ public void test100JackAttemptAssignRoleStudent() throws Exception { @Test public void test110JoeAttemptAssignRoleStudent() throws Exception { final String TEST_NAME = "test110JoeAttemptAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -187,11 +185,11 @@ public void test110JoeAttemptAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -218,7 +216,6 @@ public void test110JoeAttemptAssignRoleStudent() throws Exception { @Test public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exception { final String TEST_NAME = "test120JackAttemptToMoveTo1900AndAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -237,11 +234,11 @@ public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exceptio assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -270,7 +267,6 @@ public void test120JackAttemptToMoveTo1900AndAssignRoleStudent() throws Exceptio @Test public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { final String TEST_NAME = "test130JackMoveTo1900AndAssignRoleStudent"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -289,12 +285,12 @@ public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -325,7 +321,6 @@ public void test130JackMoveTo1900AndAssignRoleStudent() throws Exception { @Test public void test135JackChangeValidTo() throws Exception { final String TEST_NAME = "test135JackChangeValidTo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -343,13 +338,13 @@ public void test135JackChangeValidTo() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); // cannot run the clockwork as in the secondary state the deltas are no longer considered (!) projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -373,7 +368,6 @@ public void test135JackChangeValidTo() throws Exception { @Test public void test140JackNoChange() throws Exception { final String TEST_NAME = "test140JackNoChange"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -386,12 +380,12 @@ public void test140JackNoChange() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -414,7 +408,6 @@ public void test140JackNoChange() throws Exception { @Test public void test142JackNoChangeButTaskExists() throws Exception { final String TEST_NAME = "test142JackNoChangeButTaskExists"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -445,12 +438,12 @@ public void test142JackNoChangeButTaskExists() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -474,7 +467,6 @@ public void test142JackNoChangeButTaskExists() throws Exception { @Test public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception { final String TEST_NAME = "test150FrankAttemptToAssignRoleStudentButDisabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -494,11 +486,11 @@ public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -522,7 +514,6 @@ public void test150FrankAttemptToAssignRoleStudentButDisabled() throws Exception @Test public void test160AttemptToAddPeter() throws Exception { final String TEST_NAME = "test160AttemptToAddPeter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -535,11 +526,11 @@ public void test160AttemptToAddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -562,7 +553,6 @@ public void test160AttemptToAddPeter() throws Exception { @Test public void test170AddPeter() throws Exception { final String TEST_NAME = "test170AddPeter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -575,11 +565,11 @@ public void test170AddPeter() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -616,7 +606,6 @@ public void test170AddPeter() throws Exception { @Test public void test180StudentRecompute() throws Exception { final String TEST_NAME = "test180StudentRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -629,12 +618,12 @@ public void test180StudentRecompute() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, ACTIVITY_DESCRIPTION, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -652,7 +641,6 @@ public void test180StudentRecompute() throws Exception { @Test public void test200AddUnresolvable() throws Exception { final String TEST_NAME = "test200AddUnresolvable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -665,13 +653,13 @@ public void test200AddUnresolvable() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (ObjectNotFoundException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("No policy constraint named 'unresolvable' could be found")) { @@ -683,7 +671,6 @@ public void test200AddUnresolvable() throws Exception { @Test public void test210AddCyclic() throws Exception { final String TEST_NAME = "test210AddCyclic"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -696,13 +683,13 @@ public void test210AddCyclic() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (SchemaException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Trying to resolve cyclic reference to constraint")) { @@ -714,7 +701,6 @@ public void test210AddCyclic() throws Exception { @Test public void test220AddChained() throws Exception { final String TEST_NAME = "test220AddChained"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -727,10 +713,10 @@ public void test220AddChained() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); display("Output context", context); Map rules = new HashMap<>(); @@ -774,7 +760,6 @@ public void test220AddChained() throws Exception { @Test public void test230AddAmbiguous() throws Exception { final String TEST_NAME = "test230AddAmbiguous"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -787,13 +772,13 @@ public void test230AddAmbiguous() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (SchemaException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!e.getMessage().contains("Conflicting definitions of 'constraint-B'")) { @@ -806,7 +791,6 @@ public void test230AddAmbiguous() throws Exception { @Test public void test300ModifyInducement() throws Exception { final String TEST_NAME = "test300ModifyInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -822,13 +806,13 @@ public void test300ModifyInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"Immutable inducements\" is to be modified")) { @@ -841,7 +825,6 @@ public void test300ModifyInducement() throws Exception { @Test public void test310ModifyInducementPass() throws Exception { final String TEST_NAME = "test310ModifyInducementPass"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -857,9 +840,9 @@ public void test310ModifyInducementPass() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -868,7 +851,6 @@ public void test310ModifyInducementPass() throws Exception { @Test public void test320ModifyInducementPass2() throws Exception { final String TEST_NAME = "test320ModifyInducementPass2"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -884,9 +866,9 @@ public void test320ModifyInducementPass2() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess("unexpected failure", result); } @@ -895,7 +877,6 @@ public void test320ModifyInducementPass2() throws Exception { @Test public void test330AddInducement() throws Exception { final String TEST_NAME = "test330AddInducement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -911,13 +892,13 @@ public void test330AddInducement() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete\" is to be modified")) { @@ -930,7 +911,6 @@ public void test330AddInducement() throws Exception { @Test public void test340AddInducementViaExpression() throws Exception { final String TEST_NAME = "test340AddInducementViaExpression"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestPolicyRules2.class.getName() + "." + TEST_NAME); @@ -946,13 +926,13 @@ public void test340AddInducementViaExpression() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); try { clockwork.run(context, task, result); - displayThen(TEST_NAME); + then(); fail("unexpected success"); } catch (PolicyViolationException e) { - displayThen(TEST_NAME); + then(); System.out.println("Expected exception: " + e); e.printStackTrace(System.out); if (!getTranslatedMessage(e).contains("Role \"No inducements add or delete (expression)\" is to be modified")) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java index bb75daaedc9..6bcab29513a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestPolicyStateRecording.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; @@ -39,8 +38,6 @@ @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestPolicyStateRecording extends AbstractLensTest { - private static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_NAME = "criminal exclusion"; - protected static final File TEST_DIR = new File(AbstractLensTest.TEST_DIR, "policy/state"); private static final File USER_BOB_FILE = new File(TEST_DIR, "user-bob.xml"); @@ -97,19 +94,18 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAssignRoleJudge() throws Exception { - TestCtx t = createContext(this, "test100JackAssignRoleJudge"); - // GIVEN + Task task = createPlainTask(); // WHEN - t.displayWhen(); - assignRole(USER_JACK_OID, ROLE_JUDGE_OID, t.task, t.result); + when(); + assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, task.getResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(task.getResult()); assertAssignedRole(jack.asPrismObject(), ROLE_JUDGE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); @@ -123,17 +119,15 @@ public void test100JackAssignRoleJudge() throws Exception { @Test public void test110JackAssignRolePirate() throws Exception { - TestCtx t = createContext(this, "test110JackAssignRolePirate"); - // WHEN - t.displayWhen(); - assignRole(USER_JACK_OID, ROLE_PIRATE_OID, t.task, t.result); + when(); + assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -148,21 +142,18 @@ public void test110JackAssignRolePirate() throws Exception { // should keep the situation for both assignments @Test public void test120RecomputeJack() throws Exception { - TestCtx t = createContext(this, "test120RecomputeJack"); - // GIVEN dummyAuditService.clear(); // WHEN - t.displayWhen(); - executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), t.task, t.result); - //recomputeUser(USER_JACK_OID, t.task, t.result); + when(); + executeChanges(prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID), createReconcile(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); UserType jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); // TODO test that assignment IDs are filled in correctly (currently they are not) assertEquals("Wrong # of assignments", 2, jack.getAssignment().size()); @@ -179,25 +170,23 @@ public void test120RecomputeJack() throws Exception { @Test public void test130JackUnassignRolePirate() throws Exception { - TestCtx t = createContext(this, "test130JackUnassignRolePirate"); - // GIVEN UserType jack = getUser(USER_JACK_OID).asObjectable(); AssignmentType pirateAssignment = findAssignmentByTargetRequired(jack.asPrismObject(), ROLE_PIRATE_OID); // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .delete(pirateAssignment.clone()) .asObjectDeltaCast(USER_JACK_OID); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertNotAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); @@ -211,24 +200,22 @@ public void test130JackUnassignRolePirate() throws Exception { @Test public void test200BobAssign2a3a() throws Exception { - TestCtx t = createContext(this, "test200BobAssign2a3a"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3aOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest3aOid); @@ -246,24 +233,22 @@ public void test200BobAssign2a3a() throws Exception { @Test public void test210BobAssign2b3b() throws Exception { - TestCtx t = createContext(this, "test210BobAssign2b3b"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext), createAssignmentTo(roleATest3bOid, ObjectTypes.ROLE, prismContext)) .asObjectDeltaCast(userBobOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); UserType bob = getUser(userBobOid).asObjectable(); display("bob", bob); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(bob.asPrismObject(), roleATest2aOid); assertAssignedRole(bob.asPrismObject(), roleATest2bOid); @@ -292,8 +277,6 @@ private void assertExclusionViolationState(AssignmentType assignment) { // new user, new assignments (no IDs) @Test public void test220AliceAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test220AliceAssign2a2b"); - // GIVEN UserType alice = prismContext.createObjectable(UserType.class) .name("alice") @@ -301,14 +284,14 @@ public void test220AliceAssign2a2b() throws Exception { .assignment(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext)); // WHEN - t.displayWhen(); - addObject(alice.asPrismObject(), t.task, t.result); + when(); + addObject(alice.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); alice = getUser(alice.getOid()).asObjectable(); display("alice", alice); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(alice.asPrismObject(), roleATest2aOid); assertAssignedRole(alice.asPrismObject(), roleATest2bOid); @@ -325,8 +308,6 @@ public void test220AliceAssign2a2b() throws Exception { // new user, new assignments (explicit IDs) @Test public void test230ChuckAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test230ChuckAssign2a2b"); - // GIVEN AssignmentType assignment2a = createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext); assignment2a.setId(100L); @@ -338,14 +319,14 @@ public void test230ChuckAssign2a2b() throws Exception { .assignment(assignment2b); // WHEN - t.displayWhen(); - addObject(chuck.asPrismObject(), t.task, t.result); + when(); + addObject(chuck.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); chuck = getUser(chuck.getOid()).asObjectable(); display("chuck", chuck); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(chuck.asPrismObject(), roleATest2aOid); assertAssignedRole(chuck.asPrismObject(), roleATest2bOid); @@ -362,8 +343,6 @@ public void test230ChuckAssign2a2b() throws Exception { // new user, new assignments (explicit IDs, explicit OID) @Test public void test240DanAssign2a2b() throws Exception { - TestCtx t = createContext(this, "test240DanAssign2a2b"); - // GIVEN AssignmentType assignment2a = createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext); assignment2a.setId(100L); @@ -376,14 +355,14 @@ public void test240DanAssign2a2b() throws Exception { .assignment(assignment2b); // WHEN - t.displayWhen(); - addObject(dan.asPrismObject(), t.task, t.result); + when(); + addObject(dan.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); dan = getUser(dan.getOid()).asObjectable(); display("dan", dan); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(dan.asPrismObject(), roleATest2aOid); assertAssignedRole(dan.asPrismObject(), roleATest2bOid); @@ -400,23 +379,21 @@ public void test240DanAssign2a2b() throws Exception { // modified user, new assignment (with ID) @Test public void test250EveAssign2b() throws Exception { - TestCtx t = createContext(this, "test220AliceAssign2a2b"); - // WHEN - t.displayWhen(); + when(); AssignmentType assignment2b = createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext); assignment2b.setId(200L); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(assignment2b) .asObjectDeltaCast(userEveOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); UserType eve = getUser(userEveOid).asObjectable(); display("alice", eve); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertAssignedRole(eve.asPrismObject(), roleATest2aOid); assertAssignedRole(eve.asPrismObject(), roleATest2bOid); @@ -432,22 +409,20 @@ public void test250EveAssign2b() throws Exception { @Test public void test300MakeRoleWrong() throws Exception { - TestCtx t = createContext(this, "test300MakeRoleWrong"); - // GIVEN // WHEN - t.displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_DESCRIPTION).replace("wrong") .asObjectDeltaCast(roleATestWrongOid); - executeChangesAssertSuccess(delta, null, t.task, t.result); + executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); RoleType wrong = getRole(roleATestWrongOid).asObjectable(); display("role 'wrong'", wrong); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong.getPolicySituation()); @@ -457,8 +432,6 @@ public void test300MakeRoleWrong() throws Exception { @Test public void test310CreateWrongRole() throws Exception { - TestCtx t = createContext(this, "test310CreateWrongRole"); - // GIVEN RoleType wrong2 = prismContext.createObjectable(RoleType.class) .name("wrong-2") @@ -466,14 +439,14 @@ public void test310CreateWrongRole() throws Exception { .assignment(createAssignmentTo(metaroleCommonRulesOid, ObjectTypes.ROLE, prismContext)); // WHEN - t.displayWhen(); - addObject(wrong2.asPrismObject(), t.task, t.result); + when(); + addObject(wrong2.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); wrong2 = getRole(wrong2.getOid()).asObjectable(); display("role 'wrong-2'", wrong2); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong2.getPolicySituation()); @@ -483,8 +456,6 @@ public void test310CreateWrongRole() throws Exception { @Test public void test320CreateWrongRoleKnownOid() throws Exception { - TestCtx t = createContext(this, "test320CreateWrongRoleKnownOid"); - // GIVEN AssignmentType assignmentCommon = createAssignmentTo(metaroleCommonRulesOid, ObjectTypes.ROLE, prismContext); assignmentCommon.setId(300L); @@ -495,14 +466,14 @@ public void test320CreateWrongRoleKnownOid() throws Exception { .assignment(assignmentCommon); // WHEN - t.displayWhen(); - addObject(wrong3.asPrismObject(), t.task, t.result); + when(); + addObject(wrong3.asPrismObject(), getTestTask(), getTestOperationResult()); // THEN - t.displayThen(); + then(); wrong3 = getRole(wrong3.getOid()).asObjectable(); display("role 'wrong-3'", wrong3); - assertSuccess(t.result); + assertSuccess(getTestOperationResult()); assertEquals("Wrong policy situations for role", Collections.singletonList(WRONG_URI), wrong3.getPolicySituation()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java index 67f5b1c7fa3..9e6cbe449a1 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjector.java @@ -10,7 +10,6 @@ import static org.testng.AssertJUnit.*; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -60,10 +59,8 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType; /** * @author semancik @@ -92,7 +89,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertNoJackShadow(); } @@ -100,10 +96,9 @@ public void test000Sanity() throws Exception { @Test public void test010BasicContextOperations() throws Exception { final String TEST_NAME = "test010BasicContextOperations"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -186,10 +181,9 @@ public void test010BasicContextOperations() throws Exception { @Test public void test100AddAccountToJackDirect() throws Exception { final String TEST_NAME = "test100AddAccountToJackDirect"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -205,11 +199,11 @@ public void test100AddAccountToJackDirect() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Output context", context); // Not loading anything. The account is already loaded in the context assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -254,10 +248,9 @@ public void test100AddAccountToJackDirect() throws Exception { @Test public void test110AssignAccountToJack() throws Exception { final String TEST_NAME = "test110AssignAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -283,10 +276,9 @@ public void test110AssignAccountToJack() throws Exception { @Test public void test111AssignAccountToJackBroken() throws Exception { final String TEST_NAME = "test111AssignAccountToJackBroken"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -347,10 +339,9 @@ private void assertAssignAccountToJack(LensContext context) { @Test public void test250ModifyUserBarbossaLocality() throws Exception { final String TEST_NAME = "test250ModifyUserBarbossaLocality"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -398,10 +389,9 @@ public void test250ModifyUserBarbossaLocality() throws Exception { @Test public void test251ModifyUserBarbossaFullname() throws Exception { final String TEST_NAME = "test251ModifyUserBarbossaFullname"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -450,10 +440,9 @@ public void test251ModifyUserBarbossaFullname() throws Exception { @Test public void test254ModifyUserBarbossaDisable() throws Exception { final String TEST_NAME = "test254ModifyUserBarbossaDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -513,10 +502,9 @@ public void test254ModifyUserBarbossaDisable() throws Exception { @Test public void test255ModifyUserBarbossaAssignment() throws Exception { final String TEST_NAME = "test255ModifyUserBarbossaAssignment"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -567,10 +555,9 @@ public void test255ModifyUserBarbossaAssignment() throws Exception { @Test public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { final String TEST_NAME = "test260ModifyAccountBarbossaDrinkReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -587,11 +574,11 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); } @@ -604,10 +591,9 @@ public void test260ModifyAccountBarbossaDrinkReplace() throws Exception { @Test public void test261ModifyAccountBarbossaQuoteReplace() throws Exception { final String TEST_NAME = "test261ModifyAccountBarbossaQuoteReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -666,10 +652,9 @@ public void test261ModifyAccountBarbossaQuoteReplace() throws Exception { @Test public void test269DeleteBarbossaDummyAccount() throws Exception { final String TEST_NAME = "test269DeleteBarbossaDummyAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -703,10 +688,9 @@ public void test269DeleteBarbossaDummyAccount() throws Exception { @Test public void test270AddUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test270AddUserBarbossaAssignmentBrethren"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -750,10 +734,9 @@ public void test270AddUserBarbossaAssignmentBrethren() throws Exception { @Test public void test275DeleteUserBarbossaAssignmentBrethren() throws Exception { final String TEST_NAME = "test275DeleteUserBarbossaAssignmentBrethren"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -799,10 +782,9 @@ public void test275DeleteUserBarbossaAssignmentBrethren() throws Exception { @Test public void test280AddUserBarbossaAssignmentMutinier() throws Exception { final String TEST_NAME = "test280AddUserBarbossaAssignmentMutinier"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -847,10 +829,9 @@ public void test280AddUserBarbossaAssignmentMutinier() throws Exception { @Test public void test301AssignConflictingAccountToJack() throws Exception { final String TEST_NAME = "test301AssignConflictingAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -867,11 +848,11 @@ public void test301AssignConflictingAccountToJack() throws Exception { assertFocusModificationSanity(context); // WHEN - displayWhen(TEST_NAME); + when(); projector.project(context, "test", task, result); // THEN - displayThen(TEST_NAME); + then(); display("Output context", context); assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY); @@ -896,10 +877,9 @@ public void test301AssignConflictingAccountToJack() throws Exception { @Test public void test400ImportHermanDummy() throws Exception { final String TEST_NAME = "test400ImportHermanDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -954,10 +934,9 @@ public void test400ImportHermanDummy() throws Exception { @Test public void test401ImportHermanDummy() throws Exception { final String TEST_NAME = "test401ImportHermanDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1001,10 +980,9 @@ public void test401ImportHermanDummy() throws Exception { @Test public void test450GuybrushInboundFromDelta() throws Exception { final String TEST_NAME = "test450GuybrushInboundFromDelta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1036,10 +1014,9 @@ public void test450GuybrushInboundFromDelta() throws Exception { @Test public void test451GuybrushInboundFromAbsolute() throws Exception { final String TEST_NAME = "test451GuybrushInboundFromAbsolute"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1078,10 +1055,9 @@ public void test451GuybrushInboundFromAbsolute() throws Exception { @Test public void test500ReconcileGuybrushDummy() throws Exception { final String TEST_NAME = "test500ReconcileGuybrushDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1143,10 +1119,9 @@ public void test500ReconcileGuybrushDummy() throws Exception { @Test public void test600AddLargo() throws Exception { final String TEST_NAME = "test600AddLargo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); 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 0c6ae89ca3a..10cc9f65ced 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 @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -52,7 +51,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignRolePersonaAdminToJack() throws Exception { final String TEST_NAME = "test100AssignRolePersonaAdminToJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorPersona.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java index 5f2e0bb81f9..d4001d796ec 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestProjectorRoleEntitlement.java @@ -34,7 +34,6 @@ import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** @@ -71,7 +70,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddEntitlementToPirateDirect() throws Exception { final String TEST_NAME = "test100AddEntitlementToPirateDirect"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); @@ -134,7 +132,6 @@ public void test100AddEntitlementToPirateDirect() throws Exception { @Test public void test110AssignEntitlementToPirate() throws Exception { final String TEST_NAME = "test110AssignEntitlementToPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); @@ -164,7 +161,6 @@ public void test110AssignEntitlementToPirate() throws Exception { @Test public void test111AssignEntitlementToPirateBroken() throws Exception { final String TEST_NAME = "test110AssignEntitlementToPirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java index 6d44ebba8ad..b3961d9f706 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/lens/TestReconScript.java @@ -49,10 +49,9 @@ public class TestReconScript extends AbstractInternalModelIntegrationTest { @Test public void text001testReconcileScriptsWhenProvisioning() throws Exception{ final String TEST_NAME = "text001testReconcileScriptsWhenProvisioning"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); ObjectDelta delta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); Collection> deltas = new ArrayList<>(); @@ -92,7 +91,6 @@ public void text001testReconcileScriptsWhenProvisioning() throws Exception{ @Test public void test002testReconcileScriptsWhenReconciling() throws Exception{ final String TEST_NAME = "test002testReconcileScriptsWhenReconciling"; - displayTestTitle(TEST_NAME); getDummyResource().getScriptHistory().clear(); @@ -124,10 +122,9 @@ public void test002testReconcileScriptsWhenReconciling() throws Exception{ @Test public void test003testReconcileScriptsAddUserAction() throws Exception{ final String TEST_NAME = "test003testReconcileScriptsAddUserAction"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); ShadowType shadow = parseObjectType(new File(ACCOUNT_BEFORE_SCRIPT_FILENAME), ShadowType.class); @@ -170,11 +167,9 @@ public void test003testReconcileScriptsAddUserAction() throws Exception{ @Test public void test005TestDryRunDelete() throws Exception{ final String TEST_NAME = "test005TestDryRunDelete"; - displayTestTitle(TEST_NAME); - PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), true); Collection modifications = new ArrayList<>(); @@ -203,10 +198,9 @@ public void test005TestDryRunDelete() throws Exception{ @Test public void test006TestReconDelete() throws Exception{ final String TEST_NAME = "test006TestReconDelete"; - displayTestTitle(TEST_NAME); PrismObject task = getTask(TASK_RECON_DUMMY_OID); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); PropertyDelta dryRunDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( PATH_MODEL_EXTENSION_DRY_RUN, task.getDefinition(), false); @@ -216,7 +210,7 @@ public void test006TestReconDelete() throws Exception{ repositoryService.modifyObject(TaskType.class, TASK_RECON_DUMMY_OID, modifications, parentResult); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskStart(TASK_RECON_DUMMY_OID, false); @@ -225,7 +219,7 @@ public void test006TestReconDelete() throws Exception{ waitForTaskFinish(TASK_RECON_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(); PrismObject shadow = repositoryService.getObject(ShadowType.class, ACCOUNT_BEFORE_SCRIPT_OID, null, parentResult); ShadowAsserter.forShadow(shadow) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java index 534d193d787..facdb4b6c49 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/migrator/TestMigrator.java @@ -10,6 +10,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; @@ -23,10 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; @@ -40,7 +38,7 @@ */ @ContextConfiguration(locations = {"classpath:ctx-model-test-main.xml"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TestMigrator extends AbstractTestNGSpringContextTests { +public class TestMigrator extends AbstractSpringTest { @Autowired PrismContext prismContext; @Autowired Migrator migrator; @@ -49,16 +47,8 @@ public class TestMigrator extends AbstractTestNGSpringContextTests { private static final File TEST_DIR_BEFORE = new File(TEST_DIR, "before"); private static final File TEST_DIR_AFTER = new File(TEST_DIR, "after"); - @BeforeSuite - public void setup() throws SchemaException, SAXException, IOException { -// PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); -// PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY); - } - @Test public void testMigrateUserTemplate() throws Exception { - TestUtil.displayTestTitle("testMigrateUserTemplate"); - for (File beforeFile: TEST_DIR_BEFORE.listFiles()) { String beforeName = beforeFile.getName(); if (!beforeName.endsWith(".xml")) { diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java index 18ff09c9839..1946f65eb3d 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/ShadowIntegrityCheckerTest.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import org.springframework.test.annotation.DirtiesContext; @@ -66,10 +65,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { final String TEST_NAME = "test100FixDuplicatesWithDifferentObjectClasses"; - TestUtil.displayTestTitle(this, TEST_NAME); login(userAdministrator); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -82,11 +80,11 @@ public void test100FixDuplicatesWithDifferentObjectClasses() throws Exception { repoAddObjectFromFile(TASK_SHADOW_INTEGRITY_CHECK_FILE, result); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskCloseOrSuspend(TASK_SHADOW_INTEGRITY_CHECK_OID); // THEN - displayThen(TEST_NAME); + then(); PrismObject taskAfter = getTask(TASK_SHADOW_INTEGRITY_CHECK_OID); display("task after", taskAfter); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java index 5a282dfaf40..ff07b129b94 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/misc/TestRelationRegistry.java @@ -12,7 +12,6 @@ import com.evolveum.midpoint.schema.constants.RelationTypes; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationKindType; @@ -55,7 +54,6 @@ public class TestRelationRegistry extends AbstractInternalModelIntegrationTest { @Test public void test100DefaultRelations() { final String TEST_NAME = "test100DefaultRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); assertEquals("Wrong # of default relations", RelationTypes.values().length, relationRegistry.getRelationDefinitions().size()); @@ -137,7 +135,6 @@ public void test100DefaultRelations() { @Test public void test110AddedCustomRelations() throws SchemaException, IOException { final String TEST_NAME = "test110AddedCustomRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject sysconfigObject = prismContext.parseObject(SYSCONFIG_ADDED_CUSTOM_RELATIONS_FILE); relationRegistry.applyRelationsConfiguration(sysconfigObject.asObjectable()); @@ -259,7 +256,6 @@ public void test110AddedCustomRelations() throws SchemaException, IOException { @Test public void test120ReplacedAllRelations() throws SchemaException, IOException { final String TEST_NAME = "test120ReplacedAllRelations"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject sysconfigObject = prismContext.parseObject(SYSCONFIG_REPLACED_ALL_RELATIONS_FILE); relationRegistry.applyRelationsConfiguration(sysconfigObject.asObjectable()); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java index 9ea1784ab2d..75719d77874 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestAbstractAuthenticationEvaluator.java @@ -26,7 +26,6 @@ import com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.MessageSourceAccessor; -import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.CredentialsExpiredException; import org.springframework.security.authentication.DisabledException; @@ -61,8 +60,6 @@ import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.util.exception.SchemaException; 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.AbstractCredentialType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType; @@ -82,8 +79,6 @@ public abstract class TestAbstractAuthenticationEvaluator userAfter = getUser(USER_JACK_OID); @@ -273,16 +256,13 @@ public void test102PasswordLoginNullPasswordJack() throws Exception { @Test public void test103PasswordLoginEmptyPasswordJack() throws Exception { - final String TEST_NAME = "test103PasswordLoginEmptyPasswordJack"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, get103EmptyPasswordJack())); @@ -292,9 +272,9 @@ public void test103PasswordLoginEmptyPasswordJack() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertPasswordEncodingException(e, USER_JACK_USERNAME); + assertPasswordEncodingException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -304,17 +284,14 @@ public void test103PasswordLoginEmptyPasswordJack() throws Exception { } @Test - public void test105PasswordLoginNullUsernameNullPassword() throws Exception { - final String TEST_NAME = "test105PasswordLoginNullUsernameNullPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test105PasswordLoginNullUsernameNullPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(null, null)); @@ -324,25 +301,22 @@ public void test105PasswordLoginNullUsernameNullPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertPasswordEncodingException(e, null); + assertPasswordEncodingException(e); } } @Test - public void test106PasswordLoginEmptyUsernameBadPassword() throws Exception { - final String TEST_NAME = "test106PasswordLoginEmptyUsernameBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test106PasswordLoginEmptyUsernameBadPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext("", getBadPasswordJack())); @@ -352,25 +326,22 @@ public void test106PasswordLoginEmptyUsernameBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertNoUserException(e, null); + assertNoUserException(e); } } @Test - public void test107PasswordLoginBadUsernameBadPassword() throws Exception { - final String TEST_NAME = "test107PasswordLoginBadUsernameBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test107PasswordLoginBadUsernameBadPassword() { // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext("NoSuchUser", getBadPasswordJack())); @@ -380,9 +351,9 @@ public void test107PasswordLoginBadUsernameBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertNoUserException(e, null); + assertNoUserException(e); } } @@ -393,9 +364,6 @@ public void test107PasswordLoginBadUsernameBadPassword() throws Exception { */ @Test public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuration() throws Exception { - final String TEST_NAME = "test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT5M"); @@ -405,7 +373,7 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -415,9 +383,9 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -431,15 +399,12 @@ public void test125PasswordLoginBadPasswordJackAfterLockoutFailedAttemptsDuratio @Test public void test130PasswordLoginLockout() throws Exception { - final String TEST_NAME = "test130PasswordLoginLockout"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -449,7 +414,7 @@ public void test130PasswordLoginLockout() throws Exception { // This is expected display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } PrismObject userBetween = getUser(USER_JACK_OID); @@ -466,14 +431,14 @@ public void test130PasswordLoginLockout() throws Exception { // This is expected display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("user after", userAfter); @@ -484,14 +449,11 @@ public void test130PasswordLoginLockout() throws Exception { @Test public void test132PasswordLoginLockedoutGoodPassword() throws Exception { - final String TEST_NAME = "test132PasswordLoginLockedoutGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); @@ -501,9 +463,9 @@ public void test132PasswordLoginLockedoutGoodPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -514,14 +476,11 @@ public void test132PasswordLoginLockedoutGoodPassword() throws Exception { @Test public void test133PasswordLoginLockedoutBadPassword() throws Exception { - final String TEST_NAME = "test133PasswordLoginLockedoutBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -531,12 +490,12 @@ public void test133PasswordLoginLockedoutBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); // this is important. The exception should give no indication whether the password is // good or bad - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -547,9 +506,6 @@ public void test133PasswordLoginLockedoutBadPassword() throws Exception { @Test public void test135PasswordLoginLockedoutLockExpires() throws Exception { - final String TEST_NAME = "test135PasswordLoginLockedoutLockExpires"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT30M"); @@ -557,11 +513,11 @@ public void test135PasswordLoginLockedoutLockExpires() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -574,15 +530,12 @@ public void test135PasswordLoginLockedoutLockExpires() throws Exception { @Test public void test136PasswordLoginLockoutAgain() throws Exception { - final String TEST_NAME = "test136PasswordLoginLockoutAgain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getBadPasswordJack())); @@ -592,9 +545,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } PrismObject userBetween = getUser(USER_JACK_OID); @@ -611,9 +564,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } userBetween = getUser(USER_JACK_OID); @@ -630,9 +583,9 @@ public void test136PasswordLoginLockoutAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_JACK_USERNAME); + assertBadPasswordException(e); } @@ -647,14 +600,11 @@ public void test136PasswordLoginLockoutAgain() throws Exception { @Test public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { - final String TEST_NAME = "test137PasswordLoginLockedoutGoodPasswordAgain"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); @@ -664,9 +614,9 @@ public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertLockedException(e, USER_JACK_USERNAME); + assertLockedException(e); } PrismObject userAfter = getUser(USER_JACK_OID); @@ -677,21 +627,19 @@ public void test137PasswordLoginLockedoutGoodPasswordAgain() throws Exception { @Test public void test138UnlockUserGoodPassword() throws Exception { - final String TEST_NAME = "test138UnlockUserGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ConnectionEnvironment connEnv = createConnectionEnvironment(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.NORMAL); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userBetween = getUser(USER_JACK_OID); display("user after", userBetween); @@ -702,11 +650,11 @@ public void test138UnlockUserGoodPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -722,15 +670,13 @@ public void test138UnlockUserGoodPassword() throws Exception { */ @Test public void test139TryToLockByModelService() throws Exception { - final String TEST_NAME = "test139TryToLockByModelService"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.LOCKED); @@ -740,7 +686,7 @@ public void test139TryToLockByModelService() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -753,37 +699,31 @@ public void test139TryToLockByModelService() throws Exception { @Test public void test150PasswordLoginDisabledGoodPassword() throws Exception { - final String TEST_NAME = "test150PasswordLoginDisabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test152PasswordLoginEnabledGoodPassword() throws Exception { - final String TEST_NAME = "test152PasswordLoginEnabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test154PasswordLoginNotValidYetGoodPassword() throws Exception { - final String TEST_NAME = "test154PasswordLoginNotValidYetGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar validFrom = XmlTypeConverter.addDuration(clock.currentTimeXMLGregorianCalendar(), "PT1H"); @@ -793,142 +733,120 @@ public void test154PasswordLoginNotValidYetGoodPassword() throws Exception { modifyUserReplace(USER_JACK_OID, ACTIVATION_VALID_FROM_PATH, task, result, validFrom); modifyUserReplace(USER_JACK_OID, ACTIVATION_VALID_TO_PATH, task, result, validTo); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test155PasswordLoginValidGoodPassword() throws Exception { - final String TEST_NAME = "test155PasswordLoginValidGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("PT2H"); - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); - OperationResult result = task.getResult(); + TestAbstractAuthenticationEvaluator.class.getName(); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test156PasswordLoginNotValidAnyLongerGoodPassword() throws Exception { - final String TEST_NAME = "test156PasswordLoginNotValidAnyLongerGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P2D"); - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); - OperationResult result = task.getResult(); + TestAbstractAuthenticationEvaluator.class.getName(); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test159PasswordLoginNoLongerValidEnabledGoodPassword() throws Exception { - final String TEST_NAME = "test159PasswordLoginNoLongerValidEnabledGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test160PasswordLoginLifecycleActiveGoodPassword() throws Exception { - final String TEST_NAME = "test160PasswordLoginLifecycleActiveGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ACTIVE); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test162PasswordLoginLifecycleDraftGoodPassword() throws Exception { - final String TEST_NAME = "test162PasswordLoginLifecycleDraftGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_DRAFT); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test164PasswordLoginLifecycleDeprecatedGoodPassword() throws Exception { - final String TEST_NAME = "test164PasswordLoginLifecycleDeprecatedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_DEPRECATED); - loginJackGoodPasswordExpectSuccess(TEST_NAME, task, result); + loginJackGoodPasswordExpectSuccess(); } @Test public void test166PasswordLoginLifecycleProposedGoodPassword() throws Exception { - final String TEST_NAME = "test166PasswordLoginLifecycleProposedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_PROPOSED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test168PasswordLoginLifecycleArchivedGoodPassword() throws Exception { - final String TEST_NAME = "test168PasswordLoginLifecycleArchivedGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ARCHIVED); - loginJackGoodPasswordExpectDenied(TEST_NAME, task, result); + loginJackGoodPasswordExpectDenied(); } @Test public void test200UserGuybrushSetCredentials() throws Exception { - final String TEST_NAME = "test200UserGuybrushSetPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TestAbstractAuthenticationEvaluator.class.getName() + "." + TEST_NAME); + TestAbstractAuthenticationEvaluator.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserCredential(task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -942,19 +860,16 @@ public void test200UserGuybrushSetCredentials() throws Exception { @Test public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { - final String TEST_NAME = "test201UserGuybrushPasswordLoginGoodPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_GUYBRUSH_USERNAME); @@ -966,9 +881,6 @@ public void test201UserGuybrushPasswordLoginGoodPassword() throws Exception { @Test public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { - final String TEST_NAME = "test202UserGuybrushPasswordLoginBadPassword"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -976,7 +888,7 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getBadPasswordGuybrush())); @@ -986,9 +898,9 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertBadPasswordException(e, USER_GUYBRUSH_USERNAME); + assertBadPasswordException(e); } XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1000,9 +912,6 @@ public void test202UserGuybrushPasswordLoginBadPassword() throws Exception { @Test public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throws Exception { - final String TEST_NAME = "test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P29D"); @@ -1010,11 +919,11 @@ public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throw XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_GUYBRUSH_USERNAME); @@ -1026,19 +935,15 @@ public void test209UserGuybrushPasswordLoginGoodPasswordBeforeExpiration() throw @Test public void test210UserGuybrushPasswordLoginGoodPasswordExpired() throws Exception { - final String TEST_NAME = "test210UserGuybrushPasswordLoginGoodPasswordExpired"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN clock.overrideDuration("P2D"); ConnectionEnvironment connEnv = createConnectionEnvironment(); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); try { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_GUYBRUSH_USERNAME, getGoodPasswordGuybrush())); @@ -1048,11 +953,10 @@ public void test210UserGuybrushPasswordLoginGoodPasswordExpired() throws Excepti // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); - assertExpiredException(e, USER_GUYBRUSH_USERNAME); + assertExpiredException(e); } - XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); display("user after", userAfter); @@ -1066,7 +970,7 @@ private void assertGoodPasswordAuthentication(Authentication authentication, Str assertEquals("authentication: principal mismatch", expectedUsername, ((MidPointPrincipal)authentication.getPrincipal()).getUsername()); } - private void assertBadPasswordException(BadCredentialsException e, String username) { + private void assertBadPasswordException(BadCredentialsException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.invalid"), getTranslatedMessage(e)); } @@ -1074,27 +978,23 @@ private String getTranslatedMessage(Throwable t) { return localizationService.translate(t.getMessage(), new Object[0], Locale.getDefault()); } - private void assertPasswordEncodingException(BadCredentialsException e, String principal) { + private void assertPasswordEncodingException(BadCredentialsException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.password.encoding"), getTranslatedMessage(e)); } - private void assertDeniedException(AccessDeniedException e, String principal) { - assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.access.denied"), getTranslatedMessage(e)); - } - - private void assertLockedException(LockedException e, String principal) { + private void assertLockedException(LockedException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.locked"), getTranslatedMessage(e)); } - private void assertDisabledException(DisabledException e, String principal) { + private void assertDisabledException(DisabledException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.disabled"), getTranslatedMessage(e)); } - private void assertExpiredException(CredentialsExpiredException e, String principal) { + private void assertExpiredException(CredentialsExpiredException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.credential.expired"), getTranslatedMessage(e)); } - private void assertNoUserException(UsernameNotFoundException e, String principal) { + private void assertNoUserException(UsernameNotFoundException e) { assertEquals("Wrong exception meessage (key)", messages.getMessage("web.security.provider.invalid"), getTranslatedMessage(e)); } @@ -1147,17 +1047,19 @@ private void assertPrincipalJack(MidPointPrincipal principal) { assertEquals("Bad name in user in principal", USER_JACK_USERNAME, user.getName().getOrig()); } - private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + private void loginJackGoodPasswordExpectSuccess() + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { display("now", clock.currentTimeXMLGregorianCalendar()); ConnectionEnvironment connEnv = createConnectionEnvironment(); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Authentication authentication = getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); assertGoodPasswordAuthentication(authentication, USER_JACK_USERNAME); @@ -1167,13 +1069,12 @@ private void loginJackGoodPasswordExpectSuccess(final String TEST_NAME, Task tas assertLastSuccessfulLogin(userAfter, startTs, endTs); } - private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + private void loginJackGoodPasswordExpectDenied() throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { display("now", clock.currentTimeXMLGregorianCalendar()); ConnectionEnvironment connEnv = createConnectionEnvironment(); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); try { getAuthenticationEvaluator().authenticate(connEnv, getAuthenticationContext(USER_JACK_USERNAME, getGoodPasswordJack())); @@ -1183,12 +1084,12 @@ private void loginJackGoodPasswordExpectDenied(final String TEST_NAME, Task task // This is expected // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("expected exception", e); // this is important. The exception should give no indication whether the password is // good or bad - assertDisabledException(e, USER_JACK_USERNAME); + assertDisabledException(e); } PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java index edfbe85d392..a33e76abd0a 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestGuiProfiledPrincipalManager.java @@ -11,7 +11,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.security.api.DelegatorWithOtherPrivilegesLimitations; import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -79,7 +78,6 @@ public void test140DeputyBlockOtherPrivileges() throws Exception { private void executeDeputyLimitationsTest(String TEST_NAME, List expectedLimitations, Consumer assignmentModifier) throws CommonException { - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN AssignmentType assignment = new AssignmentType() @@ -94,12 +92,12 @@ private void executeDeputyLimitationsTest(String TEST_NAME, List delegators = principal.getDelegatorWithOtherPrivilegesLimitationsCollection(); display("delegators with other privileges limitations", delegators); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java index c9738744e1e..9753c0d9667 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/security/TestPasswordAuthenticationEvaluator.java @@ -15,22 +15,15 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractCredentialType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -public class TestPasswordAuthenticationEvaluator extends TestAbstractAuthenticationEvaluator>{ +public class TestPasswordAuthenticationEvaluator extends TestAbstractAuthenticationEvaluator> { - @Autowired(required=true) + @Autowired private AuthenticationEvaluator passwordAuthenticationEvaluator; @Override @@ -80,7 +73,11 @@ private ProtectedStringType getGuybrushPassword() { } @Override - public void modifyUserCredential(Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + public void modifyUserCredential(Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_PASSWORD_VALUE, task, result, getGuybrushPassword()); } diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/ActionManagerImplTest.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/ActionManagerImplTest.java index f48ce884561..03b7c15cb44 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/ActionManagerImplTest.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/ActionManagerImplTest.java @@ -11,17 +11,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.Test; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** * @author lazyman */ @ContextConfiguration(locations = { "classpath:ctx-model-test-no-repo.xml" }) -public class ActionManagerImplTest extends AbstractTestNGSpringContextTests { +public class ActionManagerImplTest extends AbstractSpringTest { - @Autowired(required = true) + @Autowired private ActionManager manager; @Test(expectedExceptions = IllegalArgumentException.class) diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java index 51b56f3d926..299a06df3ae 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestCorrelationConfirmationEvaluator.java @@ -62,7 +62,6 @@ public class TestCorrelationConfirmationEvaluator extends AbstractInternalModelI @Test public void test001CorrelationOrFilter() throws Exception{ String TEST_NAME = "test001CorrelationOrFilter"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -96,7 +95,6 @@ public void test001CorrelationOrFilter() throws Exception{ @Test public void test002CorrelationMoreThanOne() throws Exception{ String TEST_NAME = "test002CorrelationMoreThanOne"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -129,7 +127,6 @@ public void test002CorrelationMoreThanOne() throws Exception{ @Test public void test003CorrelationWithCondition() throws Exception{ String TEST_NAME = "test003CorrelationWithCondition"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -164,7 +161,6 @@ public void test003CorrelationWithCondition() throws Exception{ @Test public void test004CorrelationMatchCaseInsensitive() throws Exception{ String TEST_NAME = "test004CorrelationMatchCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -192,7 +188,6 @@ public void test004CorrelationMatchCaseInsensitive() throws Exception{ @Test public void test005CorrelationMatchCaseInsensitive() throws Exception{ String TEST_NAME = "test005CorrelationMatchCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -243,7 +238,6 @@ private SynchronizationContext createSynchronizationContext(File accou @Test public void test006CorrelationFindCaseInsensitive() throws Exception{ String TEST_NAME = "test006CorrelationFindCaseInsensitive"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java index b8df391eb64..c6ba6e0e3a9 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/sync/TestSynchronizationService.java @@ -88,11 +88,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010AddedAccountJack() throws Exception { - final String TEST_NAME = "test010AddedAccountJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -147,10 +144,9 @@ public void test010AddedAccountJack() throws Exception { @Test public void test020ModifyLootAbsolute() throws Exception { final String TEST_NAME = "test020ModifyLootAbsolute"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -164,11 +160,11 @@ public void test020ModifyLootAbsolute() throws Exception { change.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_LIVE_SYNC_URI); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -204,11 +200,8 @@ public void test020ModifyLootAbsolute() throws Exception { @Test public void test021ModifyLootAbsoluteEmpty() throws Exception { - final String TEST_NAME = "test021ModifyLootAbsoluteEmpty"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -266,11 +259,8 @@ public void test021ModifyLootAbsoluteEmpty() throws Exception { */ @Test public void test030Reconcile() throws Exception { - final String TEST_NAME = "test030Reconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -314,10 +304,9 @@ public void test030Reconcile() throws Exception { @Test public void test039DeletedAccountJack() throws Exception { final String TEST_NAME = "test039DeletedAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result); @@ -341,9 +330,8 @@ public void test039DeletedAccountJack() throws Exception { .assertIterationToken("") .assertSynchronizationSituation(SynchronizationSituationType.LINKED); - // In fact, it is responsibility of provisioning to mark shadow dead before invoking - // sync service. This is unit test, therefore we have to simulate behavior of provisioning - // here. + // In fact, it is responsibility of provisioning to mark shadow dead before invoking sync + // service. This is unit test, therefore we have to simulate behavior of provisioning here. markShadowTombstone(accountShadowJackDummyOid); shadowRepo = repositoryService.getObject(ShadowType.class, accountShadowJackDummyOid, null, result); @@ -369,11 +357,11 @@ public void test039DeletedAccountJack() throws Exception { change.setObjectDelta(syncDelta); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -417,10 +405,9 @@ public void test039DeletedAccountJack() throws Exception { @Test public void test050AddedAccountCalypso() throws Exception { final String TEST_NAME = "test050AddedAccountCalypso"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -443,11 +430,11 @@ public void test050AddedAccountCalypso() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -468,10 +455,9 @@ public void test050AddedAccountCalypso() throws Exception { @Test public void test051CalypsoRecon() throws Exception { final String TEST_NAME = "test051CalypsoRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -491,11 +477,11 @@ public void test051CalypsoRecon() throws Exception { display("Change notification", change); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); LensContext context = cleanDebugListener(); display("Resulting context (as seen by debug listener)", context); @@ -514,10 +500,9 @@ public void test051CalypsoRecon() throws Exception { @Test public void test100AddedAccountJack() throws Exception { final String TEST_NAME = "test100AddedAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(USER_JACK_OID) @@ -542,11 +527,11 @@ public void test100AddedAccountJack() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -586,10 +571,9 @@ public void test100AddedAccountJack() throws Exception { @Test public void test199DeletedAccountJackTotal() throws Exception { final String TEST_NAME = "test199DeletedAccountJackTotal"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); @@ -606,11 +590,11 @@ public void test199DeletedAccountJackTotal() throws Exception { repositoryService.deleteObject(ShadowType.class, accountShadowJackDummyOid, result); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 1); LensContext context = cleanDebugListener(); @@ -644,10 +628,9 @@ public void test199DeletedAccountJackTotal() throws Exception { @Test public void test200AddedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test200AddedAccountJackSchemaViolation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -674,11 +657,11 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -718,10 +701,9 @@ public void test200AddedAccountJackSchemaViolation() throws Exception { @Test public void test202UpdatedAccountJackSchemaViolation() throws Exception { final String TEST_NAME = "test202UpdatedAccountJackSchemaViolation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -738,11 +720,11 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); getDummyResource().resetBreakMode(); assertPartialError(result); @@ -781,21 +763,20 @@ public void test202UpdatedAccountJackSchemaViolation() throws Exception { @Test public void test210AssignJackDummy() throws Exception { final String TEST_NAME = "test210AssignJackDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -830,21 +811,20 @@ public void test210AssignJackDummy() throws Exception { @Test public void test212AssignJackDummyLimited() throws Exception { final String TEST_NAME = "test212AssignJackDummyLimited"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_LIMITED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); LensContext context = cleanDebugListener(); @@ -889,10 +869,9 @@ public void test212AssignJackDummyLimited() throws Exception { @Test public void test214UpdatedAccountJackLimited() throws Exception { final String TEST_NAME = "test214UpdatedAccountJackLimited"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -918,11 +897,11 @@ public void test214UpdatedAccountJackLimited() throws Exception { getDummyResource().setBreakMode(BreakMode.ASSERTION_ERROR); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); getDummyResource().resetBreakMode(); @@ -975,10 +954,9 @@ public void test214UpdatedAccountJackLimited() throws Exception { @Test public void test300AddedGroupPirates() throws Exception { final String TEST_NAME = "test300AddedGroupPirates"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setDebugListener(); getDummyResource().resetBreakMode(); @@ -997,11 +975,11 @@ public void test300AddedGroupPirates() throws Exception { change.setResource(getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); synchronizationService.notifyChange(change, task, result); // THEN - displayWhen(TEST_NAME); + when(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java index b9688ec850c..967ff147547 100644 --- a/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java +++ b/model/model-impl/src/test/java/com/evolveum/midpoint/model/impl/visualizer/TestVisualizer.java @@ -67,7 +67,7 @@ public void setup() throws SchemaException, SAXException, IOException { @Test public void test100UserBasic() throws Exception { final String TEST_NAME = "test100UserBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject u = prismContext.createObject(UserType.class); u.setOid("123"); @@ -75,11 +75,11 @@ public void test100UserBasic() throws Exception { u.asObjectable().setFullName(new PolyStringType("User User123")); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -88,7 +88,7 @@ public void test100UserBasic() throws Exception { @Test public void test110UserWithContainers() throws Exception { final String TEST_NAME = "test101UserWithContainers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject u = prismContext.createObject(UserType.class); UserType ut = u.asObjectable(); @@ -113,11 +113,11 @@ public void test110UserWithContainers() throws Exception { ut.getAssignment().add(ass3); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualize(u, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -126,18 +126,18 @@ public void test110UserWithContainers() throws Exception { @Test public void test200UserDeltaBasic() throws Exception { final String TEST_NAME = "test200UserDeltaBasic"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_NAME).replace("admin") .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -146,7 +146,7 @@ public void test200UserDeltaBasic() throws Exception { @Test public void test210UserDeltaContainers() throws Exception { final String TEST_NAME = "test210UserDeltaContainers"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setActivation(new ActivationType(prismContext)); @@ -163,11 +163,11 @@ public void test210UserDeltaContainers() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -176,7 +176,7 @@ public void test210UserDeltaContainers() throws Exception { @Test public void test212UserDeltaContainerSimple() throws Exception { final String TEST_NAME = "test212UserDeltaContainerSimple"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS).replace(ActivationStatusType.ENABLED) @@ -184,11 +184,11 @@ public void test212UserDeltaContainerSimple() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final List scenes = visualizer.visualizeDeltas((List) Collections.singletonList(delta), task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scenes", scenes); // TODO some asserts @@ -197,7 +197,7 @@ public void test212UserDeltaContainerSimple() throws Exception { @Test public void test220UserContainerReplace() throws Exception { final String TEST_NAME = "test220UserContainerReplace"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setActivation(new ActivationType(prismContext)); @@ -215,11 +215,11 @@ public void test220UserContainerReplace() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -228,7 +228,7 @@ public void test220UserContainerReplace() throws Exception { @Test public void test230UserContainerDelete() throws Exception { final String TEST_NAME = "test230UserContainerDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setId(1L); @@ -242,11 +242,11 @@ public void test230UserContainerDelete() throws Exception { .asObjectDelta(USER_ADMINISTRATOR_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta((ObjectDelta) delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -255,7 +255,7 @@ public void test230UserContainerDelete() throws Exception { @Test public void test300UserAssignmentPreview() throws Exception { final String TEST_NAME = "test300UserAssignmentPreview"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject jack = getUser(USER_JACK_OID); display("jack", jack); @@ -271,7 +271,7 @@ public void test300UserAssignmentPreview() throws Exception { delta.applyDefinitionIfPresent(jack.getDefinition(), false); /// WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -281,7 +281,7 @@ public void test300UserAssignmentPreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -291,7 +291,7 @@ public void test300UserAssignmentPreview() throws Exception { @Test public void test305UserAssignmentAdd() throws Exception { final String TEST_NAME = "test305UserAssignmentAdd"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); display("jack", getUser(USER_JACK_OID)); @@ -304,13 +304,13 @@ public void test305UserAssignmentAdd() throws Exception { .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); modelService.executeChanges(Collections.>singletonList(delta), null, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); display("jack with assignment", getUser(USER_JACK_OID)); @@ -320,14 +320,14 @@ public void test305UserAssignmentAdd() throws Exception { @Test public void test307UserDisablePreview() throws Exception { final String TEST_NAME = "test307UserDisablePreview"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED) .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(Collections.>singletonList(delta), null, task, task.getResult()); List> primaryDeltas = new ArrayList<>(); List> secondaryDeltas = new ArrayList<>(); @@ -337,7 +337,7 @@ public void test307UserDisablePreview() throws Exception { List secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); @@ -365,7 +365,7 @@ protected void fillDeltas(ModelContext modelContext, List delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).add(createObjectRef(dummyAccountOid, SHADOW).asReferenceValue()) .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -409,18 +409,18 @@ public void test320UserLinkRefAdd() throws Exception { @Test public void test330UserLinkRefReplaceNoOp() throws Exception { final String TEST_NAME = "test330UserLinkRefReplaceNoOp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).replace(createObjectRef(dummyAccountOid, SHADOW).asReferenceValue()) .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts @@ -429,18 +429,18 @@ public void test330UserLinkRefReplaceNoOp() throws Exception { @Test public void test340UserLinkRefReplaceOp() throws Exception { final String TEST_NAME = "test340UserLinkRefReplaceOp"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); ObjectDelta delta = deltaFor(UserType.class) .item(UserType.F_LINK_REF).replace(createObjectRef("777", SHADOW).asReferenceValue()) .asObjectDelta(USER_JACK_OID); /// WHEN - displayWhen(TEST_NAME); + when(); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); display("scene", scene); // TODO some asserts diff --git a/model/model-intest/pom.xml b/model/model-intest/pom.xml index 03662735da1..4aaba738eec 100644 --- a/model/model-intest/pom.xml +++ b/model/model-intest/pom.xml @@ -210,7 +210,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -336,10 +335,6 @@ spring-aop test - - org.jetbrains - annotations - diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index 100dc092a6f..222b2c92c08 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -1,852 +1,747 @@ -/* - * Copyright (c) 2010-2017 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.intest; - -import static org.testng.AssertJUnit.assertNotNull; - -import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; -import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.delta.ReferenceDelta; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance; -import com.evolveum.midpoint.schema.constants.MidPointConstants; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.QNameUtil; -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 org.jetbrains.annotations.NotNull; -import org.testng.AssertJUnit; -import org.testng.IHookCallBack; -import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -/** - * @author semancik - * - */ -public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest { - - public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); - - protected static final int NUMBER_OF_GLOBAL_POLICY_RULES = 7; - - public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); - protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - - protected static final String USER_TEMPLATE_FILENAME = COMMON_DIR + "/user-template.xml"; - protected static final String USER_TEMPLATE_OID = "10000000-0000-0000-0000-000000000002"; - - protected static final File USER_TEMPLATE_COMPLEX_FILE = new File(COMMON_DIR, "user-template-complex.xml"); - protected static final String USER_TEMPLATE_COMPLEX_OID = "10000000-0000-0000-0000-000000000222"; - - protected static final File USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE = new File(COMMON_DIR, "user-template-schema-constraints.xml"); - protected static final String USER_TEMPLATE_SCHEMA_CONSTRAINTS_OID = "c2e52c79-a0ea-42ec-8853-1e9ea16175a9"; - - protected static final String USER_TEMPLATE_INBOUNDS_FILENAME = COMMON_DIR + "/user-template-inbounds.xml"; - protected static final String USER_TEMPLATE_INBOUNDS_OID = "10000000-0000-0000-0000-000000000555"; - - protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME = COMMON_DIR + "/user-template-complex-include.xml"; - protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_OID = "10000000-0000-0000-0000-000000000223"; - - protected static final String USER_TEMPLATE_SYNC_FILENAME = COMMON_DIR + "/user-template-sync.xml"; - protected static final String USER_TEMPLATE_SYNC_OID = "10000000-0000-0000-0000-000000000333"; - - protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME = COMMON_DIR + "/user-template-org-assignment.xml"; - protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_OID = "10000000-0000-0000-0000-000000000444"; - - protected static final String USER_TEMPLATE_CARTHESIAN_FILENAME = COMMON_DIR + "/user-template-carthesian.xml"; - protected static final String USER_TEMPLATE_CARTHESIAN_OID = "8e47c2b2-dde6-44a9-a7c0-de21a14cb70d"; - - protected static final File OBJECT_TEMPLATE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "object-template-persona-admin.xml"); - protected static final String OBJECT_TEMPLATE_PERSONA_ADMIN_OID = "894ea1a8-2c0a-11e7-a950-ff2047b0c053"; - - protected static final String CONNECTOR_LDAP_FILENAME = COMMON_DIR + "/connector-ldap.xml"; - - protected static final String CONNECTOR_DBTABLE_FILENAME = COMMON_DIR + "/connector-dbtable.xml"; - - protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR + "/connector-dummy.xml"; - - protected static final File RESOURCE_DUMMY_FILE = new File(COMMON_DIR, "resource-dummy.xml"); - protected static final File RESOURCE_DUMMY_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-caching.xml"); - protected static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000004"; - protected static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004"; - protected static final String RESOURCE_DUMMY_DRINK = "rum"; - protected static final String RESOURCE_DUMMY_QUOTE = "Arr!"; - protected static final String RESOURCE_DUMMY_USELESS_STRING = "USEless"; - protected static final QName RESOURCE_DUMMY_GROUP_OBJECTCLASS = new QName(RESOURCE_DUMMY_NAMESPACE, "GroupObjectClass"); - protected static final QName RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "group"); - protected static final QName RESOURCE_DUMMY_ASSOCIATION_PRIV_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "priv"); - - // RED resource has STRONG mappings - protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml"); - protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104"; - protected static final String RESOURCE_DUMMY_RED_NAME = "red"; - protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI; - protected static final String RESOURCE_DUMMY_RED_USELESS_STRING = IntegrationTestTools.CONST_USELESS; - - // BLUE resource has WEAK mappings, outbound/inbound - protected static final File RESOURCE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "resource-dummy-blue.xml"); - protected static final File RESOURCE_DUMMY_BLUE_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-blue-caching.xml"); - protected static final String RESOURCE_DUMMY_BLUE_OID = "10000000-0000-0000-0000-000000000204"; - protected static final String RESOURCE_DUMMY_BLUE_NAME = "blue"; - protected static final String RESOURCE_DUMMY_BLUE_NAMESPACE = MidPointConstants.NS_RI; - - // CYAN has WEAK mappings, outbound only - protected static final File RESOURCE_DUMMY_CYAN_FILE = new File(COMMON_DIR, "resource-dummy-cyan.xml"); - protected static final String RESOURCE_DUMMY_CYAN_OID = "10000000-0000-0000-0000-00000000c204"; - protected static final String RESOURCE_DUMMY_CYAN_NAME = "cyan"; - protected static final String RESOURCE_DUMMY_CYAN_NAMESPACE = MidPointConstants.NS_RI; - - // WHITE dummy resource has almost no configuration: no schema, no schemahandling, no synchronization, ... - protected static final String RESOURCE_DUMMY_WHITE_FILENAME = COMMON_DIR + "/resource-dummy-white.xml"; - protected static final String RESOURCE_DUMMY_WHITE_OID = "10000000-0000-0000-0000-000000000304"; - protected static final String RESOURCE_DUMMY_WHITE_NAME = "white"; - protected static final String RESOURCE_DUMMY_WHITE_NAMESPACE = MidPointConstants.NS_RI; - - // YELLOW dummy resource is almost the same as default one but with strong asIs administrativeStatus mapping - // it also has minimal password length - protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(COMMON_DIR, "resource-dummy-yellow.xml"); - protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000704"; - protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow"; - protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI; - - // Green dummy resource is authoritative - protected static final File RESOURCE_DUMMY_GREEN_FILE = new File(COMMON_DIR, "resource-dummy-green.xml"); - protected static final File RESOURCE_DUMMY_GREEN_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-green-caching.xml"); - protected static final String RESOURCE_DUMMY_GREEN_OID = "10000000-0000-0000-0000-000000000404"; - protected static final String RESOURCE_DUMMY_GREEN_NAME = "green"; - protected static final String RESOURCE_DUMMY_GREEN_NAMESPACE = MidPointConstants.NS_RI; - - // This is authoritative resource similar to green resource but it has a bit wilder inbound mappings. - protected static final File RESOURCE_DUMMY_EMERALD_FILE = new File(COMMON_DIR, "resource-dummy-emerald.xml"); - protected static final String RESOURCE_DUMMY_EMERALD_OID = "10000000-0000-0000-0000-00000000e404"; - protected static final String RESOURCE_DUMMY_EMERALD_NAME = "emerald"; - protected static final String RESOURCE_DUMMY_EMERALD_NAMESPACE = MidPointConstants.NS_RI; - - // Black dummy resource for testing tolerant attributes - protected static final File RESOURCE_DUMMY_BLACK_FILE = new File(COMMON_DIR, "resource-dummy-black.xml"); - protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305"; - protected static final String RESOURCE_DUMMY_BLACK_NAME = "black"; - protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI; - - // Black dummy resource for testing tolerant attributes - protected static final File RESOURCE_DUMMY_RELATIVE_FILE = new File(COMMON_DIR, "resource-dummy-relative.xml"); - protected static final String RESOURCE_DUMMY_RELATIVE_OID = "adcd4654-0f15-11e7-8337-0bdf60ad7bcd"; - protected static final String RESOURCE_DUMMY_RELATIVE_NAME = "relative"; - protected static final String RESOURCE_DUMMY_RELATIVE_NAMESPACE = MidPointConstants.NS_RI; - - // Orange dummy resource for testing associations with resource-provided referential integrity - // It also have very little outbound expressions and it has some strange inbound expressions. - protected static final File RESOURCE_DUMMY_ORANGE_FILE = new File(COMMON_DIR, "resource-dummy-orange.xml"); - protected static final String RESOURCE_DUMMY_ORANGE_OID = "10000000-0000-0000-0000-000000001104"; - protected static final String RESOURCE_DUMMY_ORANGE_NAME = "orange"; - protected static final String RESOURCE_DUMMY_ORANGE_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName RESOURCE_DUMMY_ORANGE_ASSOCIATION_CREW_QNAME = new QName(RESOURCE_DUMMY_ORANGE_NAMESPACE, "crew"); - - protected static final String RESOURCE_DUMMY_SCHEMALESS_FILENAME = COMMON_DIR + "/resource-dummy-schemaless-no-schema.xml"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_OID = "ef2bc95b-76e0-59e2-86d6-9999dddd0000"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_NAME = "schemaless"; - protected static final String RESOURCE_DUMMY_SCHEMALESS_NAMESPACE = MidPointConstants.NS_RI; - - // Upcase resource turns all names to upper case. It is also caseInsensitive resource - protected static final File RESOURCE_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "resource-dummy-upcase.xml"); - protected static final String RESOURCE_DUMMY_UPCASE_OID = "10000000-0000-0000-0000-000000001204"; - protected static final String RESOURCE_DUMMY_UPCASE_NAME = "upcase"; - protected static final String RESOURCE_DUMMY_UPCASE_NAMESPACE = MidPointConstants.NS_RI; - protected static final QName RESOURCE_DUMMY_UPCASE_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_UPCASE_NAMESPACE, "group"); - - protected static final String RESOURCE_DUMMY_FAKE_FILENAME = COMMON_DIR + "/resource-dummy-fake.xml"; - protected static final String RESOURCE_DUMMY_FAKE_OID = "10000000-0000-0000-0000-00000000000f"; - - public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; - - protected static final File ROLE_PIRATE_FILE = new File(COMMON_DIR, "role-pirate.xml"); - protected static final String ROLE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556666"; - protected static final String ROLE_PIRATE_NAME = "Pirate"; - protected static final String ROLE_PIRATE_DESCRIPTION = "Scurvy Pirates"; - protected static final String ROLE_PIRATE_TITLE = "Bloody Pirate"; - protected static final String ROLE_PIRATE_WEAPON = "cutlass"; - - protected static final File ROLE_CARIBBEAN_PIRATE_FILE = new File(COMMON_DIR, "role-caribbean-pirate.xml"); - protected static final String ROLE_CARIBBEAN_PIRATE_OID = "0719ec66-edd9-11e6-bd70-03a74157ff9e"; - - protected static final File ROLE_PIRATE_GREEN_FILE = new File(COMMON_DIR, "role-pirate-green.xml"); - protected static final String ROLE_PIRATE_GREEN_OID = "12345678-d34d-b33f-f00d-555555557777"; - protected static final String ROLE_PIRATE_GREEN_NAME = "Pirate Green"; - protected static final String ROLE_PIRATE_GREEN_DESCRIPTION = "Scurvy Pirates"; - - protected static final File ROLE_PIRATE_RELATIVE_FILE = new File(COMMON_DIR, "role-pirate-relative.xml"); - protected static final String ROLE_PIRATE_RELATIVE_OID = "4a579cd0-0f17-11e7-967c-130ecd6fb7dc"; - protected static final String ROLE_PIRAT_RELATIVEE_NAME = "Relative Pirate"; - - protected static final File ROLE_BUCCANEER_GREEN_FILE = new File(COMMON_DIR, "role-buccaneer-green.xml"); - protected static final String ROLE_BUCCANEER_GREEN_OID = "12345678-d34d-b33f-f00d-555555558888"; - protected static final String ROLE_BUCCANEER_GREEN_NAME = "Bucaneers Green"; - protected static final String ROLE_BUCCANEER_GREEN_DESCRIPTION = "Scurvy Bucaneers"; - - protected static final String ROLE_NICE_PIRATE_FILENAME = COMMON_DIR + "/role-nice-pirate.xml"; - protected static final String ROLE_NICE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556677"; - - protected static final String ROLE_CAPTAIN_FILENAME = COMMON_DIR + "/role-captain.xml"; - protected static final String ROLE_CAPTAIN_OID = "12345678-d34d-b33f-f00d-55555555cccc"; - - // Excludes role "pirate" - protected static final File ROLE_JUDGE_FILE = new File(COMMON_DIR, "role-judge.xml"); - protected static final String ROLE_JUDGE_OID = "12345111-1111-2222-1111-121212111111"; - protected static final String ROLE_JUDGE_TITLE = "Honorable Justice"; - protected static final String ROLE_JUDGE_DRINK = "tea"; - protected static final String ROLE_JUDGE_DESCRIPTION = "Role with role exclusions"; - protected static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_PREFIX = "criminal exclusion: "; - - protected static final File ROLE_THIEF_FILE = new File(COMMON_DIR, "role-thief.xml"); - protected static final String ROLE_THIEF_OID = "b189fcb8-1ff9-11e5-8912-001e8c717e5b"; - - protected static final File ROLE_EMPTY_FILE = new File(COMMON_DIR, "role-empty.xml"); - protected static final String ROLE_EMPTY_OID = "12345111-1111-2222-1111-121212111112"; - - protected static final File ROLE_USELESS_FILE = new File(COMMON_DIR, "role-useless.xml"); - protected static final String ROLE_USELESS_OID = "12345111-1111-2222-1111-831209543124"; - - protected static final File ROLE_SAILOR_FILE = new File(COMMON_DIR, "role-sailor.xml"); - protected static final String ROLE_SAILOR_OID = "12345111-1111-2222-1111-121212111113"; - protected static final String ROLE_SAILOR_DRINK = "grog"; - - protected static final File ROLE_RED_SAILOR_FILE = new File(COMMON_DIR, "role-red-sailor.xml"); - protected static final String ROLE_RED_SAILOR_OID = "12345111-1111-2222-1111-121212111223"; - - protected static final File ROLE_CYAN_SAILOR_FILE = new File(COMMON_DIR, "role-cyan-sailor.xml"); - protected static final String ROLE_CYAN_SAILOR_OID = "d3abd794-9c30-11e6-bb5a-af14bf2cc29b"; - - protected static final File ROLE_STRONG_SAILOR_FILE = new File(COMMON_DIR, "role-strong-sailor.xml"); - protected static final String ROLE_STRONG_SAILOR_OID = "0bf7532e-7d15-11e7-8594-7bff6e0adc6e"; - - protected static final File ROLE_DRINKER_FILE = new File(COMMON_DIR, "role-drinker.xml"); - protected static final String ROLE_DRINKER_OID = "0abbde4c-ab3f-11e6-910d-d7dabf5f09f0"; - - protected static final File ROLE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "role-persona-admin.xml"); - protected static final String ROLE_PERSONA_ADMIN_OID = "16813ae6-2c0a-11e7-91fc-8333c244329e"; - - protected static final File ROLE_AUTOMATIC_FILE = new File(COMMON_DIR, "role-automatic.xml"); - protected static final String ROLE_AUTOMATIC_OID = "8fdb56d8-e3f3-11e6-8be9-cb9862ab7c04"; - - protected static final File ROLE_AUTOCRATIC_FILE = new File(COMMON_DIR, "role-autocratic.xml"); - protected static final String ROLE_AUTOCRATIC_OID = "4a678382-e3f4-11e6-8c3d-cfd3dba8168f"; - - protected static final File ROLE_AUTODIDACTIC_FILE = new File(COMMON_DIR, "role-autodidactic.xml"); - protected static final String ROLE_AUTODIDACTIC_OID = "a4f941dc-e3f4-11e6-8eba-9fe432784017"; - - protected static final File ROLE_AUTOGRAPHIC_FILE = new File(COMMON_DIR, "role-autographic.xml"); - protected static final String ROLE_AUTOGRAPHIC_OID = "be835a70-e3f4-11e6-82cb-9b47ebe57b11"; - - protected static final File ROLE_AUTOTESTERS_FILE = new File(COMMON_DIR, "role-autotesters.xml"); - protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v14"; - - protected static final File ROLE_ADMINS_FILE = new File(COMMON_DIR, "role-admins.xml"); - protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v15"; - - protected static final File ROLE_END_USER_FILE = new File(COMMON_DIR, "role-end-user.xml"); - protected static final String ROLE_END_USER_OID = "00000000-0000-0000-0000-00000000aa0f"; - - public static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml"); - public static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; - public static final String USER_JACK_USERNAME = "jack"; - public static final String USER_JACK_FULL_NAME = "Jack Sparrow"; - public static final String USER_JACK_GIVEN_NAME = "Jack"; - public static final String USER_JACK_FAMILY_NAME = "Sparrow"; - public static final String USER_JACK_ADDITIONAL_NAME = "Jackie"; - public static final String USER_JACK_DESCRIPTION = "Where's the rum?"; - public static final String USER_JACK_SUBTYPE = "captain"; - public static final String USER_JACK_EMPLOYEE_NUMBER = "emp1234"; - public static final String USER_JACK_LOCALITY = "Caribbean"; - public static final String USER_JACK_PASSWORD = "deadmentellnotales"; - - protected static final File USER_BARBOSSA_FILE = new File(COMMON_DIR, "user-barbossa.xml"); - protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; - protected static final String USER_BARBOSSA_USERNAME = "barbossa"; - protected static final String USER_BARBOSSA_FULL_NAME = "Hector Barbossa"; - - protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); - protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; - protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; - protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; - protected static final String USER_GUYBRUSH_GIVEN_NAME = "Guybrush"; - protected static final String USER_GUYBRUSH_FAMILY_NAME = "Threepwood"; - protected static final String USER_GUYBRUSH_LOCALITY = "Melee Island"; - - public static final File USER_WILL_FILE = new File(COMMON_DIR, "user-will.xml"); - public static final String USER_WILL_OID = "c0c010c0-d34d-b33f-f00d-111111145118"; - - // Largo does not have a full name set, employeeType=PIRATE - protected static final File USER_LARGO_FILE = new File(COMMON_DIR, "user-largo.xml"); - protected static final String USER_LARGO_OID = "c0c010c0-d34d-b33f-f00d-111111111118"; - protected static final String USER_LARGO_USERNAME = "largo"; - - // Rapp does not have a full name set, employeeType=COOK - protected static final File USER_RAPP_FILE = new File(COMMON_DIR, "user-rapp.xml"); - protected static final String USER_RAPP_OID = "c0c010c0-d34d-b33f-f00d-11111111c008"; - protected static final String USER_RAPP_USERNAME = "rapp"; - protected static final String USER_RAPP_FULLNAME = "Rapp Scallion"; - - // Herman has a validity dates set in the activation part - protected static final File USER_HERMAN_FILE = new File(COMMON_DIR, "user-herman.xml"); - protected static final String USER_HERMAN_OID = "c0c010c0-d34d-b33f-f00d-111111111122"; - protected static final String USER_HERMAN_USERNAME = "herman"; - protected static final String USER_HERMAN_GIVEN_NAME = "Herman"; - protected static final String USER_HERMAN_FAMILY_NAME = "Toothrot"; - protected static final String USER_HERMAN_FULL_NAME = "Herman Toothrot"; - protected static final String USER_HERMAN_PASSWORD = "m0nk3y"; - protected static final Date USER_HERMAN_VALID_FROM_DATE = MiscUtil.asDate(1700, 5, 30, 11, 0, 0); - protected static final Date USER_HERMAN_VALID_TO_DATE = MiscUtil.asDate(2233, 3, 23, 18, 30, 0); - - // Has null name, doesn not have given name, no employeeType - protected static final File USER_THREE_HEADED_MONKEY_FILE = new File(COMMON_DIR, "/user-three-headed-monkey.xml"); - protected static final String USER_THREE_HEADED_MONKEY_OID = "c0c010c0-d34d-b33f-f00d-110011001133"; - protected static final String USER_THREE_HEADED_MONKEY_NAME = "monkey"; - protected static final String USER_THREE_HEADED_MONKEY_FULL_NAME = "Three-Headed Monkey"; - - // User with no OID - protected static final File USER_NOOID_FILE = new File(COMMON_DIR, "user-nooid.xml"); - protected static final String USER_NOOID_USERNAME = "nooid"; - - // Elaine has account on the dummy resources (default, red, blue) - // The accounts are also assigned - protected static final File USER_ELAINE_FILE = new File (COMMON_DIR, "user-elaine.xml"); - protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e"; - protected static final String USER_ELAINE_USERNAME = "elaine"; - - // Captain Kate Capsize does not exist in the repo. This user is designed to be added. - // She has account on dummy resources (default, red, blue) - // The accounts are also assigned - static final File USER_CAPSIZE_FILE = new File(COMMON_DIR, "user-capsize.xml"); - protected static final String USER_CAPSIZE_OID = "c0c010c0-d34d-b33f-f00d-11c1c1c1c11c"; - protected static final String USER_CAPSIZE_USERNAME = "capsize"; - static final File ACCOUNT_CAPSIZE_DUMMY_DEFAULT_FILE = new File(COMMON_DIR, "account-capsize-dummy-default.xml"); - static final File ACCOUNT_CAPSIZE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-capsize-dummy-red.xml"); - static final File ACCOUNT_CAPSIZE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-capsize-dummy-blue.xml"); - - protected static final File USER_DRAKE_FILE = new File(COMMON_DIR, "user-drake.xml"); - protected static final String USER_DRAKE_OID = "c0c010c0-d34d-b33f-f00d-11d1d1d1d1d1"; - protected static final String USER_DRAKE_USERNAME = "drake"; - protected static final String USER_DRAKE_FULLNAME = "Francis Drake"; - - public static final File ACCOUNT_JACK_DUMMY_FILE = new File(COMMON_DIR, "account-jack-dummy.xml"); - public static final File ACCOUNT_JACK_DUMMY_RED_FILE = new File(COMMON_DIR, "account-jack-dummy-red.xml"); - public static final String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; - public static final String ACCOUNT_JACK_DUMMY_FULLNAME = "Jack Sparrow"; - - public static final File ACCOUNT_HERMAN_DUMMY_FILE = new File(COMMON_DIR, "account-herman-dummy.xml"); - public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444"; - public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht"; - - public static final File ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-guybrush-dummy.xml"); - public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood"; - public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island"; - public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml"); - public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml"); - - public static final String ACCOUNT_SHADOW_JACK_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-jack-dummy.xml"; - - public static final String ACCOUNT_DAVIEJONES_DUMMY_USERNAME = "daviejones"; - public static final String ACCOUNT_CALYPSO_DUMMY_USERNAME = "calypso"; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_FILE = new File(COMMON_DIR, "account-elaine-dummy.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-22220004000e"; - public static final String ACCOUNT_ELAINE_DUMMY_USERNAME = USER_ELAINE_USERNAME; - public static final String ACCOUNT_ELAINE_DUMMY_FULLNAME = "Elaine Marley"; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-elaine-dummy-red.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID = "c0c010c0-d34d-b33f-f00d-22220104000e"; - public static final String ACCOUNT_ELAINE_DUMMY_RED_USERNAME = USER_ELAINE_USERNAME; - - public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-elaine-dummy-blue.xml"); - public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID = "c0c010c0-d34d-b33f-f00d-22220204000e"; - public static final String ACCOUNT_ELAINE_DUMMY_BLUE_USERNAME = USER_ELAINE_USERNAME; - - public static final File GROUP_PIRATE_DUMMY_FILE = new File(COMMON_DIR, "group-pirate-dummy.xml"); - public static final String GROUP_PIRATE_DUMMY_NAME = "pirate"; - public static final String GROUP_PIRATE_DUMMY_DESCRIPTION = "Scurvy pirates"; - - public static final File SHADOW_GROUP_DUMMY_TESTERS_FILE = new File(COMMON_DIR, "group-testers-dummy.xml"); - public static final String SHADOW_GROUP_DUMMY_TESTERS_OID = "20000000-0000-0000-3333-000000000002"; - public static final String GROUP_DUMMY_TESTERS_NAME = "testers"; - public static final String GROUP_DUMMY_TESTERS_DESCRIPTION = "To boldly go where no pirate has gone before"; - - public static final File GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "group-shadow-dummy-upcase-joker.xml"); - public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_OID = "bc2a1d98-9ca4-11e4-a600-001e8c717e5b"; - public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_NAME = "joker"; - public static final String GROUP_JOKER_DUMMY_UPCASE_NAME = "JOKER"; - - public static final String DUMMY_ORG_TOP_NAME = DummyResourceContoller.ORG_TOP_NAME; - - protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml"); - protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003"; - - protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml"); - protected static final String PASSWORD_POLICY_BENEVOLENT_OID = "ed8026dc-569a-11e7-abdf-4fce56706755"; - - protected static final File ORG_MONKEY_ISLAND_FILE = new File(COMMON_DIR, "org-monkey-island.xml"); - protected static final String ORG_GOVERNOR_OFFICE_OID = "00000000-8888-6666-0000-100000000001"; - protected static final String ORG_SCUMM_BAR_OID = "00000000-8888-6666-0000-100000000006"; - protected static final String ORG_SCUMM_BAR_NAME = "F0006"; - protected static final String ORG_SCUMM_BAR_DISPLAY_NAME = "Scumm Bar"; - protected static final String ORG_MINISTRY_OF_OFFENSE_OID = "00000000-8888-6666-0000-100000000003"; - protected static final String ORG_MINISTRY_OF_OFFENSE_NAME = "F0003"; - protected static final String ORG_MINISTRY_OF_DEFENSE_OID = "00000000-8888-6666-0000-100000000002"; - protected static final String ORG_MINISTRY_OF_DEFENSE_NAME = "F0002"; - protected static final String ORG_MINISTRY_OF_RUM_OID = "00000000-8888-6666-0000-100000000004"; - protected static final String ORG_MINISTRY_OF_RUM_NAME = "F0004"; - protected static final String ORG_SWASHBUCKLER_SECTION_OID = "00000000-8888-6666-0000-100000000005"; - protected static final String ORG_PROJECT_ROOT_OID = "00000000-8888-6666-0000-200000000000"; - protected static final String ORG_SAVE_ELAINE_OID = "00000000-8888-6666-0000-200000000001"; - protected static final String ORG_KIDNAP_AND_MARRY_ELAINE_OID = "00000000-8888-6666-0000-200000000002"; - - protected static final String ORG_TYPE_FUNCTIONAL = "functional"; - protected static final String ORG_TYPE_PROJECT = "project"; - - protected static final File CUSTOM_LIBRARY_FILE = new File(COMMON_DIR, "custom-library.xml"); - - protected static final File SERVICE_SHIP_SEA_MONKEY_FILE = new File(COMMON_DIR, "service-ship-sea-monkey.xml"); - protected static final String SERVICE_SHIP_SEA_MONKEY_OID = "914b94be-1901-11e6-9269-972ee32cd8db"; - - protected static final String TASK_RECONCILE_DUMMY_FILENAME = COMMON_DIR + "/task-reconcile-dummy.xml"; - protected static final String TASK_RECONCILE_DUMMY_OID = "10000000-0000-0000-5656-565600000004"; - - protected static final String TASK_RECONCILE_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-reconcile-dummy-blue.xml"; - protected static final String TASK_RECONCILE_DUMMY_BLUE_OID = "10000000-0000-0000-5656-565600000204"; - - protected static final String TASK_RECONCILE_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-reconcile-dummy-green.xml"; - protected static final String TASK_RECONCILE_DUMMY_GREEN_OID = "10000000-0000-0000-5656-565600000404"; - - protected static final String TASK_LIVE_SYNC_DUMMY_FILENAME = COMMON_DIR + "/task-dumy-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_OID = "10000000-0000-0000-5555-555500000004"; - - protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-dumy-blue-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_OID = "10000000-0000-0000-5555-555500000204"; - - protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-dumy-green-livesync.xml"; - protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_OID = "10000000-0000-0000-5555-555500000404"; - - protected static final String TASK_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-validity-scanner.xml"; - protected static final String TASK_PARTITIONED_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-partitioned-validity-scanner.xml"; - protected static final String TASK_VALIDITY_SCANNER_OID = "10000000-0000-0000-5555-555505060400"; - - protected static final File TASK_TRIGGER_SCANNER_FILE = new File(COMMON_DIR, "task-trigger-scanner.xml"); - protected static final String TASK_TRIGGER_SCANNER_OID = "00000000-0000-0000-0000-000000000007"; - - protected static final File TASK_MOCK_JACK_FILE = new File(COMMON_DIR, "task-mock-jack.xml"); - protected static final String TASK_MOCK_JACK_OID = "10000000-0000-0000-5656-565674633311"; - - protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS = COMMON_DIR + "/task-delete-not-updated-shadows.xml"; - protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS_OID = "5b2ba49f-6d4f-4618-afdf-4d138117e40a"; - - public static final File LOOKUP_LANGUAGES_FILE = new File(COMMON_DIR, "lookup-languages.xml"); - public static final String LOOKUP_LANGUAGES_OID = "70000000-0000-0000-1111-000000000001"; - public static final String LOOKUP_LANGUAGES_NAME = "Languages"; - - protected static final File SECURITY_POLICY_FILE = new File(COMMON_DIR, "security-policy.xml"); - protected static final String SECURITY_POLICY_OID = "28bf845a-b107-11e3-85bc-001e8c717e5b"; - - protected static final File ARCHETYPE_TASK_RECONCILIATION_FILE = new File(COMMON_DIR, "archetype-task-reconciliation.xml"); - protected static final String ARCHETYPE_TASK_RECONCILIATION_OID = "00000000-0000-0000-0000-000000000501"; - - protected static final File ARCHETYPE_EMPLOYEE_FILE = new File(COMMON_DIR, "archetype-employee.xml"); - protected static final String ARCHETYPE_EMPLOYEE_OID = "7135e68c-ee53-11e8-8025-170b77da3fd6"; - protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_LABEL = "Employee"; - protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_PLURAL_LABEL = "Employees"; - - protected static final File ARCHETYPE_APPROVAL_CASE_FILE = new File(COMMON_DIR, "archetype-approval-case.xml"); - protected static final String ARCHETYPE_APPROVAL_CASE_OID = "00000000-0000-0000-0000-000000000342"; - - protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; - protected static final ItemName PIRACY_SHIP = new ItemName(NS_PIRACY, "ship"); - protected static final ItemName PIRACY_SHIP_BROKEN = new ItemName(NS_PIRACY, "ship-broken"); - protected static final ItemName PIRACY_TALES = new ItemName(NS_PIRACY, "tales"); - protected static final ItemName PIRACY_WEAPON = new ItemName(NS_PIRACY, "weapon"); - protected static final ItemName PIRACY_LOOT = new ItemName(NS_PIRACY, "loot"); - protected static final ItemName PIRACY_BAD_LUCK = new ItemName(NS_PIRACY, "badLuck"); - protected static final ItemName PIRACY_FUNERAL_TIMESTAMP = new ItemName(NS_PIRACY, "funeralTimestamp"); - protected static final ItemName PIRACY_SEA_QNAME = new ItemName(NS_PIRACY, "sea"); - protected static final ItemName PIRACY_COLORS = new ItemName(NS_PIRACY, "colors"); - protected static final ItemName PIRACY_MARK = new ItemName(NS_PIRACY, "mark"); - protected static final ItemName PIRACY_KEY = new ItemName(NS_PIRACY, "key"); - protected static final ItemName PIRACY_BINARY_ID = new ItemName(NS_PIRACY, "binaryId"); - protected static final ItemName PIRACY_COST_CENTER = new ItemName(NS_PIRACY, "costCenter"); - protected static final ItemName PIRACY_RISK_VECTOR = new ItemName(NS_PIRACY, "riskVector"); - protected static final ItemName PIRACY_RISK_VECTOR_RISK = new ItemName(NS_PIRACY, "risk"); - protected static final ItemName PIRACY_RISK_VECTOR_VALUE = new ItemName(NS_PIRACY, "value"); - protected static final ItemName RELATION_PIRACY_CAPTAIN = new ItemName(NS_PIRACY, "captain"); - protected static final ItemName PIRACY_LOCKER = new ItemName(NS_PIRACY, "locker"); - - protected static final ItemPath ROLE_EXTENSION_COST_CENTER_PATH = ItemPath - .create(RoleType.F_EXTENSION, new QName(NS_PIRACY, "costCenter")); - - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME = "sea"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME = "mate"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME = "locker"; - protected static final String DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME = "proof"; - - protected static final String INTENT_TEST = "test"; - protected static final String INTENT_DUMMY_GROUP = "group"; - protected static final String INTENT_DUMMY_PRIVILEGE = "privilege"; - - // Authorizations - - protected static final String NS_TEST_AUTZ = "http://midpoint.evolveum.com/xml/ns/test/authorization"; - protected static final QName AUTZ_LOOT_QNAME = new QName(NS_TEST_AUTZ, "loot"); - protected static final String AUTZ_LOOT_URL = QNameUtil.qNameToUri(AUTZ_LOOT_QNAME); - protected static final QName AUTZ_COMMAND_QNAME = new QName(NS_TEST_AUTZ, "command"); - protected static final String AUTZ_COMMAND_URL = QNameUtil.qNameToUri(AUTZ_COMMAND_QNAME); - protected static final QName AUTZ_PUNISH_QNAME = new QName(NS_TEST_AUTZ, "punish"); - protected static final String AUTZ_PUNISH_URL = QNameUtil.qNameToUri(AUTZ_PUNISH_QNAME); - protected static final QName AUTZ_CAPSIZE_QNAME = new QName(NS_TEST_AUTZ, "capsize"); - protected static final String AUTZ_CAPSIZE_URL = QNameUtil.qNameToUri(AUTZ_CAPSIZE_QNAME); - protected static final QName AUTZ_SUPERSPECIAL_QNAME = new QName(NS_TEST_AUTZ, "superspecial"); - protected static final String AUTZ_SUPERSPECIAL_URL = QNameUtil.qNameToUri(AUTZ_SUPERSPECIAL_QNAME); - protected static final QName AUTZ_NONSENSE_QNAME = new QName(NS_TEST_AUTZ, "nonsense"); - protected static final String AUTZ_NONSENSE_URL = QNameUtil.qNameToUri(AUTZ_NONSENSE_QNAME); - protected static final QName AUTZ_SAIL_QNAME = new QName(NS_TEST_AUTZ, "sail"); - protected static final String AUTZ_SAIL_URL = QNameUtil.qNameToUri(AUTZ_SAIL_QNAME); - protected static final QName AUTZ_DRINK_QNAME = new QName(NS_TEST_AUTZ, "drink"); - protected static final String AUTZ_DRINK_URL = QNameUtil.qNameToUri(AUTZ_DRINK_QNAME); - protected static final QName AUTZ_APPARATE_QNAME = new QName(NS_TEST_AUTZ, "apparate"); - protected static final String AUTZ_APPARATE_URL = QNameUtil.qNameToUri(AUTZ_APPARATE_QNAME); - protected static final QName AUTZ_GAMBLE_QNAME = new QName(NS_TEST_AUTZ, "gamble"); - protected static final String AUTZ_GAMBLE_URL = QNameUtil.qNameToUri(AUTZ_GAMBLE_QNAME); - protected static final QName AUTZ_CROUPIER_QNAME = new QName(NS_TEST_AUTZ, "croupier"); - protected static final String AUTZ_CROUPIER_URL = QNameUtil.qNameToUri(AUTZ_CROUPIER_QNAME); - protected static final QName AUTZ_PIT_BOSS_QNAME = new QName(NS_TEST_AUTZ, "pitBoss"); - protected static final String AUTZ_PIT_BOSS_URL = QNameUtil.qNameToUri(AUTZ_PIT_BOSS_QNAME); - - protected static final String NOTIFIER_ACCOUNT_PASSWORD_NAME = "accountPasswordNotifier"; - protected static final String NOTIFIER_USER_PASSWORD_NAME = "userPasswordNotifier"; - protected static final String NOTIFIER_ACCOUNT_ACTIVATION_NAME = "accountActivationNotifier"; - - private static final Trace LOGGER = TraceManager.getTrace(AbstractConfiguredModelIntegrationTest.class); - - protected PrismObject userAdministrator; - - public AbstractConfiguredModelIntegrationTest() { - super(); - } - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); - - // We want logging config from logback-test.xml and not from system config object (unless suppressed) - InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); - super.initSystem(initTask, initResult); - - modelService.postInit(initResult); - ManualConnectorInstance.setRandomDelayRange(0); - - // System Configuration - PrismObject configuration; - try { - File systemConfigurationFile = getSystemConfigurationFile(); - if (systemConfigurationFile != null) { - configuration = repoAddObjectFromFile(systemConfigurationFile, initResult); - } else { - configuration = addSystemConfigurationObject(initResult); - } - } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + - "looks like the previous test haven't cleaned it up", e); - } - if (configuration != null) { - relationRegistry.applyRelationsConfiguration(configuration.asObjectable()); - } - - // Users - userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); - repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult); - login(userAdministrator); - } - - protected int getNumberOfUsers() { - return 1; // Administrator - } - - protected int getNumberOfRoles() { - return 1; // Superuser role - } - - protected File getSystemConfigurationFile() { - return SYSTEM_CONFIGURATION_FILE; - } - - // to be used in very specific cases only (it is invoked when getSystemConfigurationFile returns null). - protected PrismObject addSystemConfigurationObject(OperationResult initResult) throws IOException, CommonException, - EncryptionException { - return null; - } - - protected PrismObject getDefaultActor() { - return userAdministrator; - } - - @Override - public void run(@NotNull IHookCallBack callBack, ITestResult testResult) { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> run start"); - super.run(callBack, testResult); - LOGGER.info("###>>> run end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @AfterClass - @Override - protected void springTestContextAfterTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestClass start"); - super.springTestContextAfterTestClass(); - - nullAllFields(this, getClass()); - - LOGGER.info("###>>> springTestContextAfterTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - /** - * This method null all fields which are not static, final or primitive type. - * - * All this is just to make GC work during DirtiesContext after every test class, - * because memory consumption is too big. Test class instances can't be GCed - * immediately. If they holds autowired fields like sessionFactory (for example - * through SqlRepositoryService impl), their memory footprint is getting big. - */ - public static void nullAllFields(Object object, Class forClass) throws Exception{ - if (forClass.getSuperclass() != null) { - nullAllFields(object, forClass.getSuperclass()); - } - - for (Field field : forClass.getDeclaredFields()) { - if (Modifier.isFinal(field.getModifiers()) - || Modifier.isStatic(field.getModifiers()) - || field.getType().isPrimitive()) { - continue; - } - - nullField(object, field); - } - } - - private static void nullField(Object obj, Field field) throws Exception { - LOGGER.info("Setting {} to null on {}.", new Object[]{field.getName(), obj.getClass().getSimpleName()}); - boolean accessible = field.isAccessible(); - if (!accessible) { - field.setAccessible(true); - } - field.set(obj, null); - field.setAccessible(accessible); - } - - @AfterMethod - @Override - protected void springTestContextAfterTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextAfterTestMethod start"); - super.springTestContextAfterTestMethod(testMethod); - LOGGER.info("###>>> springTestContextAfterTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextBeforeTestClass() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestClass start"); - super.springTestContextBeforeTestClass(); - LOGGER.info("###>>> springTestContextBeforeTestClass end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeMethod - @Override - protected void springTestContextBeforeTestMethod(@NotNull Method testMethod) throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextBeforeTestMethod start"); - super.springTestContextBeforeTestMethod(testMethod); - LOGGER.info("###>>> springTestContextBeforeTestMethod end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - @BeforeClass - @Override - protected void springTestContextPrepareTestInstance() throws Exception { - long time = System.currentTimeMillis(); - LOGGER.info("###>>> springTestContextPrepareTestInstance start"); - super.springTestContextPrepareTestInstance(); - LOGGER.info("###>>> springTestContextPrepareTestInstance end ({}ms)", new Object[]{(System.currentTimeMillis() - time)}); - } - - protected PrismSchema getPiracySchema() { - return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); - } - - protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - XMLGregorianCalendar lastScanTimestamp = getLastScanTimestamp(taskOid); - assertNotNull("null lastScanTimestamp", lastScanTimestamp); - TestUtil.assertBetween("lastScanTimestamp", startCal, endCal, lastScanTimestamp); - } - - protected XMLGregorianCalendar getLastScanTimestamp(String taskOid) - throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - PrismObject task = getTask(taskOid); - display("Task", task); - PrismContainer taskExtension = task.getExtension(); - assertNotNull("No task extension", taskExtension); - PrismProperty lastScanTimestampProp = taskExtension.findProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); - assertNotNull("no lastScanTimestamp property", lastScanTimestampProp); - return lastScanTimestampProp.getRealValue(); - } - - protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end) { - assertPasswordMetadata(user, create, start, end, USER_ADMINISTRATOR_OID, SchemaConstants.CHANNEL_GUI_USER_URI); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OperationResult result = new OperationResult("clearUserOrgAndRoleRefs"); - Collection modifications = new ArrayList<>(); - ReferenceDelta parentOrgRefDelta = prismContext.deltaFactory().reference().createModificationReplace( - UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue)null); - modifications.add(parentOrgRefDelta); - ReferenceDelta roleMembershipRefDelta = prismContext.deltaFactory().reference().createModificationReplace( - UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue)null); - modifications.add(roleMembershipRefDelta); - repositoryService.modifyObject(UserType.class, userOid, modifications, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - PrismObject userBefore = getUser(userOid); - display("User before", userBefore); - } - - protected void assertEvaluatedRole(Collection evaluatedRoles, - String expectedRoleOid) { - for (EvaluatedAssignmentTarget evalRole: evaluatedRoles) { - if (expectedRoleOid.equals(evalRole.getTarget().getOid())) { - return; - } - } - AssertJUnit.fail("Role "+expectedRoleOid+" no present in evaluated roles "+evaluatedRoles); - } - - protected void assertSingleAccountPasswordNotification(String dummyResourceName, String username, - String password) { - assertAccountPasswordNotifications(1); - assertSingleDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, - getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); - } - - protected void assertSingleUserPasswordNotification(String username, String password) { - assertUserPasswordNotifications(1); - assertSingleDummyTransportMessage(NOTIFIER_USER_PASSWORD_NAME, - getExpectedUserPasswordNotificationBody(username, password)); - } - - protected void assertAccountPasswordNotifications(int expected) { - checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, expected); - } - - protected void assertUserPasswordNotifications(int expected) { - checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, expected); - } - - protected void assertNoAccountPasswordNotifications() { - checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); - } - - protected void assertNoUserPasswordNotifications() { - checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, 0); - } - - protected void assertHasAccountPasswordNotification(String dummyResourceName, String username, - String password) { - assertHasDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, - getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); - } - - protected void assertSingleAccountPasswordNotificationGenerated(String dummyResourceName, String username) { - assertAccountPasswordNotifications(1); - String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); - String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); - if (!body.startsWith(expectedPrefix)) { - fail("Expected that "+dummyResourceName+" dummy password notification message starts with prefix '"+expectedPrefix+"', but it was: "+body); - } - String suffix = body.substring(expectedPrefix.length()); - if (suffix.isEmpty()) { - fail("Empty password in "+dummyResourceName+" dummy password notification message"); - } - } - - protected String getExpectedAccountPasswordNotificationBody(String dummyResourceName, String username, - String password) { - return getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username) + password; - } - - protected String getExpectedAccountPasswordNotificationBodyPrefix(String dummyResourceName, String username) { - String resourceName = getDummyResourceType(dummyResourceName).getName().getOrig(); - return "Password for account "+username+" on "+resourceName+" is: "; - } - - protected String getExpectedUserPasswordNotificationBody(String username, String password) { - return getExpectedUserPasswordNotificationBodyPrefix(username) + password; - } - - protected String getExpectedUserPasswordNotificationBodyPrefix(String username) { - return "Password for user "+username+" is: "; - } - - protected void displayAccountPasswordNotifications() { - displayNotifications(NOTIFIER_ACCOUNT_PASSWORD_NAME); - } - - protected void displayUserPasswordNotifications() { - displayNotifications(NOTIFIER_USER_PASSWORD_NAME); - } - - protected Object getQuote(String description, String fullName) { - return description + " -- " + fullName; - } - - protected void loginAdministrator() throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - login(userAdministrator); - } -} +/* + * Copyright (c) 2010-2017 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.intest; + +import static org.testng.AssertJUnit.assertNotNull; + +import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; +import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.delta.ReferenceDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.schema.PrismSchema; +import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance; +import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.QNameUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.testng.AssertJUnit; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; + +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +/** + * @author semancik + */ +public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegrationTest { + + public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); + public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); + + protected static final int NUMBER_OF_GLOBAL_POLICY_RULES = 7; + + public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); + protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; + + protected static final String USER_TEMPLATE_FILENAME = COMMON_DIR + "/user-template.xml"; + protected static final String USER_TEMPLATE_OID = "10000000-0000-0000-0000-000000000002"; + + protected static final File USER_TEMPLATE_COMPLEX_FILE = new File(COMMON_DIR, "user-template-complex.xml"); + protected static final String USER_TEMPLATE_COMPLEX_OID = "10000000-0000-0000-0000-000000000222"; + + protected static final File USER_TEMPLATE_SCHEMA_CONSTRAINTS_FILE = new File(COMMON_DIR, "user-template-schema-constraints.xml"); + protected static final String USER_TEMPLATE_SCHEMA_CONSTRAINTS_OID = "c2e52c79-a0ea-42ec-8853-1e9ea16175a9"; + + protected static final String USER_TEMPLATE_INBOUNDS_FILENAME = COMMON_DIR + "/user-template-inbounds.xml"; + protected static final String USER_TEMPLATE_INBOUNDS_OID = "10000000-0000-0000-0000-000000000555"; + + protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_FILENAME = COMMON_DIR + "/user-template-complex-include.xml"; + protected static final String USER_TEMPLATE_COMPLEX_INCLUDE_OID = "10000000-0000-0000-0000-000000000223"; + + protected static final String USER_TEMPLATE_SYNC_FILENAME = COMMON_DIR + "/user-template-sync.xml"; + protected static final String USER_TEMPLATE_SYNC_OID = "10000000-0000-0000-0000-000000000333"; + + protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_FILENAME = COMMON_DIR + "/user-template-org-assignment.xml"; + protected static final String USER_TEMPLATE_ORG_ASSIGNMENT_OID = "10000000-0000-0000-0000-000000000444"; + + protected static final String USER_TEMPLATE_CARTHESIAN_FILENAME = COMMON_DIR + "/user-template-carthesian.xml"; + protected static final String USER_TEMPLATE_CARTHESIAN_OID = "8e47c2b2-dde6-44a9-a7c0-de21a14cb70d"; + + protected static final File OBJECT_TEMPLATE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "object-template-persona-admin.xml"); + protected static final String OBJECT_TEMPLATE_PERSONA_ADMIN_OID = "894ea1a8-2c0a-11e7-a950-ff2047b0c053"; + + protected static final String CONNECTOR_LDAP_FILENAME = COMMON_DIR + "/connector-ldap.xml"; + + protected static final String CONNECTOR_DBTABLE_FILENAME = COMMON_DIR + "/connector-dbtable.xml"; + + protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR + "/connector-dummy.xml"; + + protected static final File RESOURCE_DUMMY_FILE = new File(COMMON_DIR, "resource-dummy.xml"); + protected static final File RESOURCE_DUMMY_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-caching.xml"); + protected static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000004"; + protected static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004"; + protected static final String RESOURCE_DUMMY_DRINK = "rum"; + protected static final String RESOURCE_DUMMY_QUOTE = "Arr!"; + protected static final String RESOURCE_DUMMY_USELESS_STRING = "USEless"; + protected static final QName RESOURCE_DUMMY_GROUP_OBJECTCLASS = new QName(RESOURCE_DUMMY_NAMESPACE, "GroupObjectClass"); + protected static final QName RESOURCE_DUMMY_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "group"); + protected static final QName RESOURCE_DUMMY_ASSOCIATION_PRIV_QNAME = new QName(RESOURCE_DUMMY_NAMESPACE, "priv"); + + // RED resource has STRONG mappings + protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml"); + protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104"; + protected static final String RESOURCE_DUMMY_RED_NAME = "red"; + protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI; + protected static final String RESOURCE_DUMMY_RED_USELESS_STRING = IntegrationTestTools.CONST_USELESS; + + // BLUE resource has WEAK mappings, outbound/inbound + protected static final File RESOURCE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "resource-dummy-blue.xml"); + protected static final File RESOURCE_DUMMY_BLUE_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-blue-caching.xml"); + protected static final String RESOURCE_DUMMY_BLUE_OID = "10000000-0000-0000-0000-000000000204"; + protected static final String RESOURCE_DUMMY_BLUE_NAME = "blue"; + protected static final String RESOURCE_DUMMY_BLUE_NAMESPACE = MidPointConstants.NS_RI; + + // CYAN has WEAK mappings, outbound only + protected static final File RESOURCE_DUMMY_CYAN_FILE = new File(COMMON_DIR, "resource-dummy-cyan.xml"); + protected static final String RESOURCE_DUMMY_CYAN_OID = "10000000-0000-0000-0000-00000000c204"; + protected static final String RESOURCE_DUMMY_CYAN_NAME = "cyan"; + protected static final String RESOURCE_DUMMY_CYAN_NAMESPACE = MidPointConstants.NS_RI; + + // WHITE dummy resource has almost no configuration: no schema, no schemahandling, no synchronization, ... + protected static final String RESOURCE_DUMMY_WHITE_FILENAME = COMMON_DIR + "/resource-dummy-white.xml"; + protected static final String RESOURCE_DUMMY_WHITE_OID = "10000000-0000-0000-0000-000000000304"; + protected static final String RESOURCE_DUMMY_WHITE_NAME = "white"; + protected static final String RESOURCE_DUMMY_WHITE_NAMESPACE = MidPointConstants.NS_RI; + + // YELLOW dummy resource is almost the same as default one but with strong asIs administrativeStatus mapping + // it also has minimal password length + protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(COMMON_DIR, "resource-dummy-yellow.xml"); + protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000704"; + protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow"; + protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI; + + // Green dummy resource is authoritative + protected static final File RESOURCE_DUMMY_GREEN_FILE = new File(COMMON_DIR, "resource-dummy-green.xml"); + protected static final File RESOURCE_DUMMY_GREEN_CACHING_FILE = new File(COMMON_DIR, "resource-dummy-green-caching.xml"); + protected static final String RESOURCE_DUMMY_GREEN_OID = "10000000-0000-0000-0000-000000000404"; + protected static final String RESOURCE_DUMMY_GREEN_NAME = "green"; + protected static final String RESOURCE_DUMMY_GREEN_NAMESPACE = MidPointConstants.NS_RI; + + // This is authoritative resource similar to green resource but it has a bit wilder inbound mappings. + protected static final File RESOURCE_DUMMY_EMERALD_FILE = new File(COMMON_DIR, "resource-dummy-emerald.xml"); + protected static final String RESOURCE_DUMMY_EMERALD_OID = "10000000-0000-0000-0000-00000000e404"; + protected static final String RESOURCE_DUMMY_EMERALD_NAME = "emerald"; + protected static final String RESOURCE_DUMMY_EMERALD_NAMESPACE = MidPointConstants.NS_RI; + + // Black dummy resource for testing tolerant attributes + protected static final File RESOURCE_DUMMY_BLACK_FILE = new File(COMMON_DIR, "resource-dummy-black.xml"); + protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305"; + protected static final String RESOURCE_DUMMY_BLACK_NAME = "black"; + protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI; + + // Black dummy resource for testing tolerant attributes + protected static final File RESOURCE_DUMMY_RELATIVE_FILE = new File(COMMON_DIR, "resource-dummy-relative.xml"); + protected static final String RESOURCE_DUMMY_RELATIVE_OID = "adcd4654-0f15-11e7-8337-0bdf60ad7bcd"; + protected static final String RESOURCE_DUMMY_RELATIVE_NAME = "relative"; + protected static final String RESOURCE_DUMMY_RELATIVE_NAMESPACE = MidPointConstants.NS_RI; + + // Orange dummy resource for testing associations with resource-provided referential integrity + // It also have very little outbound expressions and it has some strange inbound expressions. + protected static final File RESOURCE_DUMMY_ORANGE_FILE = new File(COMMON_DIR, "resource-dummy-orange.xml"); + protected static final String RESOURCE_DUMMY_ORANGE_OID = "10000000-0000-0000-0000-000000001104"; + protected static final String RESOURCE_DUMMY_ORANGE_NAME = "orange"; + protected static final String RESOURCE_DUMMY_ORANGE_NAMESPACE = MidPointConstants.NS_RI; + protected static final QName RESOURCE_DUMMY_ORANGE_ASSOCIATION_CREW_QNAME = new QName(RESOURCE_DUMMY_ORANGE_NAMESPACE, "crew"); + + protected static final String RESOURCE_DUMMY_SCHEMALESS_FILENAME = COMMON_DIR + "/resource-dummy-schemaless-no-schema.xml"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_OID = "ef2bc95b-76e0-59e2-86d6-9999dddd0000"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_NAME = "schemaless"; + protected static final String RESOURCE_DUMMY_SCHEMALESS_NAMESPACE = MidPointConstants.NS_RI; + + // Upcase resource turns all names to upper case. It is also caseInsensitive resource + protected static final File RESOURCE_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "resource-dummy-upcase.xml"); + protected static final String RESOURCE_DUMMY_UPCASE_OID = "10000000-0000-0000-0000-000000001204"; + protected static final String RESOURCE_DUMMY_UPCASE_NAME = "upcase"; + protected static final String RESOURCE_DUMMY_UPCASE_NAMESPACE = MidPointConstants.NS_RI; + protected static final QName RESOURCE_DUMMY_UPCASE_ASSOCIATION_GROUP_QNAME = new QName(RESOURCE_DUMMY_UPCASE_NAMESPACE, "group"); + + protected static final String RESOURCE_DUMMY_FAKE_FILENAME = COMMON_DIR + "/resource-dummy-fake.xml"; + protected static final String RESOURCE_DUMMY_FAKE_OID = "10000000-0000-0000-0000-00000000000f"; + + public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); + protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; + + protected static final File ROLE_PIRATE_FILE = new File(COMMON_DIR, "role-pirate.xml"); + protected static final String ROLE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556666"; + protected static final String ROLE_PIRATE_NAME = "Pirate"; + protected static final String ROLE_PIRATE_DESCRIPTION = "Scurvy Pirates"; + protected static final String ROLE_PIRATE_TITLE = "Bloody Pirate"; + protected static final String ROLE_PIRATE_WEAPON = "cutlass"; + + protected static final File ROLE_CARIBBEAN_PIRATE_FILE = new File(COMMON_DIR, "role-caribbean-pirate.xml"); + protected static final String ROLE_CARIBBEAN_PIRATE_OID = "0719ec66-edd9-11e6-bd70-03a74157ff9e"; + + protected static final File ROLE_PIRATE_GREEN_FILE = new File(COMMON_DIR, "role-pirate-green.xml"); + protected static final String ROLE_PIRATE_GREEN_OID = "12345678-d34d-b33f-f00d-555555557777"; + protected static final String ROLE_PIRATE_GREEN_NAME = "Pirate Green"; + protected static final String ROLE_PIRATE_GREEN_DESCRIPTION = "Scurvy Pirates"; + + protected static final File ROLE_PIRATE_RELATIVE_FILE = new File(COMMON_DIR, "role-pirate-relative.xml"); + protected static final String ROLE_PIRATE_RELATIVE_OID = "4a579cd0-0f17-11e7-967c-130ecd6fb7dc"; + protected static final String ROLE_PIRAT_RELATIVEE_NAME = "Relative Pirate"; + + protected static final File ROLE_BUCCANEER_GREEN_FILE = new File(COMMON_DIR, "role-buccaneer-green.xml"); + protected static final String ROLE_BUCCANEER_GREEN_OID = "12345678-d34d-b33f-f00d-555555558888"; + protected static final String ROLE_BUCCANEER_GREEN_NAME = "Bucaneers Green"; + protected static final String ROLE_BUCCANEER_GREEN_DESCRIPTION = "Scurvy Bucaneers"; + + protected static final String ROLE_NICE_PIRATE_FILENAME = COMMON_DIR + "/role-nice-pirate.xml"; + protected static final String ROLE_NICE_PIRATE_OID = "12345678-d34d-b33f-f00d-555555556677"; + + protected static final String ROLE_CAPTAIN_FILENAME = COMMON_DIR + "/role-captain.xml"; + protected static final String ROLE_CAPTAIN_OID = "12345678-d34d-b33f-f00d-55555555cccc"; + + // Excludes role "pirate" + protected static final File ROLE_JUDGE_FILE = new File(COMMON_DIR, "role-judge.xml"); + protected static final String ROLE_JUDGE_OID = "12345111-1111-2222-1111-121212111111"; + protected static final String ROLE_JUDGE_TITLE = "Honorable Justice"; + protected static final String ROLE_JUDGE_DRINK = "tea"; + protected static final String ROLE_JUDGE_DESCRIPTION = "Role with role exclusions"; + protected static final String ROLE_JUDGE_POLICY_RULE_EXCLUSION_PREFIX = "criminal exclusion: "; + + protected static final File ROLE_THIEF_FILE = new File(COMMON_DIR, "role-thief.xml"); + protected static final String ROLE_THIEF_OID = "b189fcb8-1ff9-11e5-8912-001e8c717e5b"; + + protected static final File ROLE_EMPTY_FILE = new File(COMMON_DIR, "role-empty.xml"); + protected static final String ROLE_EMPTY_OID = "12345111-1111-2222-1111-121212111112"; + + protected static final File ROLE_USELESS_FILE = new File(COMMON_DIR, "role-useless.xml"); + protected static final String ROLE_USELESS_OID = "12345111-1111-2222-1111-831209543124"; + + protected static final File ROLE_SAILOR_FILE = new File(COMMON_DIR, "role-sailor.xml"); + protected static final String ROLE_SAILOR_OID = "12345111-1111-2222-1111-121212111113"; + protected static final String ROLE_SAILOR_DRINK = "grog"; + + protected static final File ROLE_RED_SAILOR_FILE = new File(COMMON_DIR, "role-red-sailor.xml"); + protected static final String ROLE_RED_SAILOR_OID = "12345111-1111-2222-1111-121212111223"; + + protected static final File ROLE_CYAN_SAILOR_FILE = new File(COMMON_DIR, "role-cyan-sailor.xml"); + protected static final String ROLE_CYAN_SAILOR_OID = "d3abd794-9c30-11e6-bb5a-af14bf2cc29b"; + + protected static final File ROLE_STRONG_SAILOR_FILE = new File(COMMON_DIR, "role-strong-sailor.xml"); + protected static final String ROLE_STRONG_SAILOR_OID = "0bf7532e-7d15-11e7-8594-7bff6e0adc6e"; + + protected static final File ROLE_DRINKER_FILE = new File(COMMON_DIR, "role-drinker.xml"); + protected static final String ROLE_DRINKER_OID = "0abbde4c-ab3f-11e6-910d-d7dabf5f09f0"; + + protected static final File ROLE_PERSONA_ADMIN_FILE = new File(COMMON_DIR, "role-persona-admin.xml"); + protected static final String ROLE_PERSONA_ADMIN_OID = "16813ae6-2c0a-11e7-91fc-8333c244329e"; + + protected static final File ROLE_AUTOMATIC_FILE = new File(COMMON_DIR, "role-automatic.xml"); + protected static final String ROLE_AUTOMATIC_OID = "8fdb56d8-e3f3-11e6-8be9-cb9862ab7c04"; + + protected static final File ROLE_AUTOCRATIC_FILE = new File(COMMON_DIR, "role-autocratic.xml"); + protected static final String ROLE_AUTOCRATIC_OID = "4a678382-e3f4-11e6-8c3d-cfd3dba8168f"; + + protected static final File ROLE_AUTODIDACTIC_FILE = new File(COMMON_DIR, "role-autodidactic.xml"); + protected static final String ROLE_AUTODIDACTIC_OID = "a4f941dc-e3f4-11e6-8eba-9fe432784017"; + + protected static final File ROLE_AUTOGRAPHIC_FILE = new File(COMMON_DIR, "role-autographic.xml"); + protected static final String ROLE_AUTOGRAPHIC_OID = "be835a70-e3f4-11e6-82cb-9b47ebe57b11"; + + protected static final File ROLE_AUTOTESTERS_FILE = new File(COMMON_DIR, "role-autotesters.xml"); + protected static final String ROLE_AUTOTESTERS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v14"; + + protected static final File ROLE_ADMINS_FILE = new File(COMMON_DIR, "role-admins.xml"); + protected static final String ROLE_ADMINS_OID = "be835a70-e3f4-11e6-82cb-9b47ecb57v15"; + + protected static final File ROLE_END_USER_FILE = new File(COMMON_DIR, "role-end-user.xml"); + protected static final String ROLE_END_USER_OID = "00000000-0000-0000-0000-00000000aa0f"; + + public static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml"); + public static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111"; + public static final String USER_JACK_USERNAME = "jack"; + public static final String USER_JACK_FULL_NAME = "Jack Sparrow"; + public static final String USER_JACK_GIVEN_NAME = "Jack"; + public static final String USER_JACK_FAMILY_NAME = "Sparrow"; + public static final String USER_JACK_ADDITIONAL_NAME = "Jackie"; + public static final String USER_JACK_DESCRIPTION = "Where's the rum?"; + public static final String USER_JACK_SUBTYPE = "captain"; + public static final String USER_JACK_EMPLOYEE_NUMBER = "emp1234"; + public static final String USER_JACK_LOCALITY = "Caribbean"; + public static final String USER_JACK_PASSWORD = "deadmentellnotales"; + + protected static final File USER_BARBOSSA_FILE = new File(COMMON_DIR, "user-barbossa.xml"); + protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112"; + protected static final String USER_BARBOSSA_USERNAME = "barbossa"; + protected static final String USER_BARBOSSA_FULL_NAME = "Hector Barbossa"; + + protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); + protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; + protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; + protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; + protected static final String USER_GUYBRUSH_GIVEN_NAME = "Guybrush"; + protected static final String USER_GUYBRUSH_FAMILY_NAME = "Threepwood"; + protected static final String USER_GUYBRUSH_LOCALITY = "Melee Island"; + + public static final File USER_WILL_FILE = new File(COMMON_DIR, "user-will.xml"); + public static final String USER_WILL_OID = "c0c010c0-d34d-b33f-f00d-111111145118"; + + // Largo does not have a full name set, employeeType=PIRATE + protected static final File USER_LARGO_FILE = new File(COMMON_DIR, "user-largo.xml"); + protected static final String USER_LARGO_OID = "c0c010c0-d34d-b33f-f00d-111111111118"; + protected static final String USER_LARGO_USERNAME = "largo"; + + // Rapp does not have a full name set, employeeType=COOK + protected static final File USER_RAPP_FILE = new File(COMMON_DIR, "user-rapp.xml"); + protected static final String USER_RAPP_OID = "c0c010c0-d34d-b33f-f00d-11111111c008"; + protected static final String USER_RAPP_USERNAME = "rapp"; + protected static final String USER_RAPP_FULLNAME = "Rapp Scallion"; + + // Herman has a validity dates set in the activation part + protected static final File USER_HERMAN_FILE = new File(COMMON_DIR, "user-herman.xml"); + protected static final String USER_HERMAN_OID = "c0c010c0-d34d-b33f-f00d-111111111122"; + protected static final String USER_HERMAN_USERNAME = "herman"; + protected static final String USER_HERMAN_GIVEN_NAME = "Herman"; + protected static final String USER_HERMAN_FAMILY_NAME = "Toothrot"; + protected static final String USER_HERMAN_FULL_NAME = "Herman Toothrot"; + protected static final String USER_HERMAN_PASSWORD = "m0nk3y"; + protected static final Date USER_HERMAN_VALID_FROM_DATE = MiscUtil.asDate(1700, 5, 30, 11, 0, 0); + protected static final Date USER_HERMAN_VALID_TO_DATE = MiscUtil.asDate(2233, 3, 23, 18, 30, 0); + + // Has null name, doesn not have given name, no employeeType + protected static final File USER_THREE_HEADED_MONKEY_FILE = new File(COMMON_DIR, "/user-three-headed-monkey.xml"); + protected static final String USER_THREE_HEADED_MONKEY_OID = "c0c010c0-d34d-b33f-f00d-110011001133"; + protected static final String USER_THREE_HEADED_MONKEY_NAME = "monkey"; + protected static final String USER_THREE_HEADED_MONKEY_FULL_NAME = "Three-Headed Monkey"; + + // User with no OID + protected static final File USER_NOOID_FILE = new File(COMMON_DIR, "user-nooid.xml"); + protected static final String USER_NOOID_USERNAME = "nooid"; + + // Elaine has account on the dummy resources (default, red, blue) + // The accounts are also assigned + protected static final File USER_ELAINE_FILE = new File (COMMON_DIR, "user-elaine.xml"); + protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e"; + protected static final String USER_ELAINE_USERNAME = "elaine"; + + // Captain Kate Capsize does not exist in the repo. This user is designed to be added. + // She has account on dummy resources (default, red, blue) + // The accounts are also assigned + static final File USER_CAPSIZE_FILE = new File(COMMON_DIR, "user-capsize.xml"); + protected static final String USER_CAPSIZE_OID = "c0c010c0-d34d-b33f-f00d-11c1c1c1c11c"; + protected static final String USER_CAPSIZE_USERNAME = "capsize"; + static final File ACCOUNT_CAPSIZE_DUMMY_DEFAULT_FILE = new File(COMMON_DIR, "account-capsize-dummy-default.xml"); + static final File ACCOUNT_CAPSIZE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-capsize-dummy-red.xml"); + static final File ACCOUNT_CAPSIZE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-capsize-dummy-blue.xml"); + + protected static final File USER_DRAKE_FILE = new File(COMMON_DIR, "user-drake.xml"); + protected static final String USER_DRAKE_OID = "c0c010c0-d34d-b33f-f00d-11d1d1d1d1d1"; + protected static final String USER_DRAKE_USERNAME = "drake"; + protected static final String USER_DRAKE_FULLNAME = "Francis Drake"; + + public static final File ACCOUNT_JACK_DUMMY_FILE = new File(COMMON_DIR, "account-jack-dummy.xml"); + public static final File ACCOUNT_JACK_DUMMY_RED_FILE = new File(COMMON_DIR, "account-jack-dummy-red.xml"); + public static final String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; + public static final String ACCOUNT_JACK_DUMMY_FULLNAME = "Jack Sparrow"; + + public static final File ACCOUNT_HERMAN_DUMMY_FILE = new File(COMMON_DIR, "account-herman-dummy.xml"); + public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444"; + public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht"; + + public static final File ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-guybrush-dummy.xml"); + public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_LOCATION = "Melee Island"; + public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml"); + public static final File ACCOUNT_GUYBRUSH_DUMMY_RED_FILE = new File(COMMON_DIR, "account-guybrush-dummy-red.xml"); + + public static final String ACCOUNT_SHADOW_JACK_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-jack-dummy.xml"; + + public static final String ACCOUNT_DAVIEJONES_DUMMY_USERNAME = "daviejones"; + public static final String ACCOUNT_CALYPSO_DUMMY_USERNAME = "calypso"; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_FILE = new File(COMMON_DIR, "account-elaine-dummy.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-22220004000e"; + public static final String ACCOUNT_ELAINE_DUMMY_USERNAME = USER_ELAINE_USERNAME; + public static final String ACCOUNT_ELAINE_DUMMY_FULLNAME = "Elaine Marley"; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_RED_FILE = new File(COMMON_DIR, "account-elaine-dummy-red.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID = "c0c010c0-d34d-b33f-f00d-22220104000e"; + public static final String ACCOUNT_ELAINE_DUMMY_RED_USERNAME = USER_ELAINE_USERNAME; + + public static final File ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_FILE = new File(COMMON_DIR, "account-elaine-dummy-blue.xml"); + public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID = "c0c010c0-d34d-b33f-f00d-22220204000e"; + public static final String ACCOUNT_ELAINE_DUMMY_BLUE_USERNAME = USER_ELAINE_USERNAME; + + public static final File GROUP_PIRATE_DUMMY_FILE = new File(COMMON_DIR, "group-pirate-dummy.xml"); + public static final String GROUP_PIRATE_DUMMY_NAME = "pirate"; + public static final String GROUP_PIRATE_DUMMY_DESCRIPTION = "Scurvy pirates"; + + public static final File SHADOW_GROUP_DUMMY_TESTERS_FILE = new File(COMMON_DIR, "group-testers-dummy.xml"); + public static final String SHADOW_GROUP_DUMMY_TESTERS_OID = "20000000-0000-0000-3333-000000000002"; + public static final String GROUP_DUMMY_TESTERS_NAME = "testers"; + public static final String GROUP_DUMMY_TESTERS_DESCRIPTION = "To boldly go where no pirate has gone before"; + + public static final File GROUP_SHADOW_JOKER_DUMMY_UPCASE_FILE = new File(COMMON_DIR, "group-shadow-dummy-upcase-joker.xml"); + public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_OID = "bc2a1d98-9ca4-11e4-a600-001e8c717e5b"; + public static final String GROUP_SHADOW_JOKER_DUMMY_UPCASE_NAME = "joker"; + public static final String GROUP_JOKER_DUMMY_UPCASE_NAME = "JOKER"; + + public static final String DUMMY_ORG_TOP_NAME = DummyResourceContoller.ORG_TOP_NAME; + + protected static final File PASSWORD_POLICY_GLOBAL_FILE = new File(COMMON_DIR, "password-policy-global.xml"); + protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003"; + + protected static final File PASSWORD_POLICY_BENEVOLENT_FILE = new File(COMMON_DIR, "password-policy-benevolent.xml"); + protected static final String PASSWORD_POLICY_BENEVOLENT_OID = "ed8026dc-569a-11e7-abdf-4fce56706755"; + + protected static final File ORG_MONKEY_ISLAND_FILE = new File(COMMON_DIR, "org-monkey-island.xml"); + protected static final String ORG_GOVERNOR_OFFICE_OID = "00000000-8888-6666-0000-100000000001"; + protected static final String ORG_SCUMM_BAR_OID = "00000000-8888-6666-0000-100000000006"; + protected static final String ORG_SCUMM_BAR_NAME = "F0006"; + protected static final String ORG_SCUMM_BAR_DISPLAY_NAME = "Scumm Bar"; + protected static final String ORG_MINISTRY_OF_OFFENSE_OID = "00000000-8888-6666-0000-100000000003"; + protected static final String ORG_MINISTRY_OF_OFFENSE_NAME = "F0003"; + protected static final String ORG_MINISTRY_OF_DEFENSE_OID = "00000000-8888-6666-0000-100000000002"; + protected static final String ORG_MINISTRY_OF_DEFENSE_NAME = "F0002"; + protected static final String ORG_MINISTRY_OF_RUM_OID = "00000000-8888-6666-0000-100000000004"; + protected static final String ORG_MINISTRY_OF_RUM_NAME = "F0004"; + protected static final String ORG_SWASHBUCKLER_SECTION_OID = "00000000-8888-6666-0000-100000000005"; + protected static final String ORG_PROJECT_ROOT_OID = "00000000-8888-6666-0000-200000000000"; + protected static final String ORG_SAVE_ELAINE_OID = "00000000-8888-6666-0000-200000000001"; + protected static final String ORG_KIDNAP_AND_MARRY_ELAINE_OID = "00000000-8888-6666-0000-200000000002"; + + protected static final String ORG_TYPE_FUNCTIONAL = "functional"; + protected static final String ORG_TYPE_PROJECT = "project"; + + protected static final File CUSTOM_LIBRARY_FILE = new File(COMMON_DIR, "custom-library.xml"); + + protected static final File SERVICE_SHIP_SEA_MONKEY_FILE = new File(COMMON_DIR, "service-ship-sea-monkey.xml"); + protected static final String SERVICE_SHIP_SEA_MONKEY_OID = "914b94be-1901-11e6-9269-972ee32cd8db"; + + protected static final String TASK_RECONCILE_DUMMY_FILENAME = COMMON_DIR + "/task-reconcile-dummy.xml"; + protected static final String TASK_RECONCILE_DUMMY_OID = "10000000-0000-0000-5656-565600000004"; + + protected static final String TASK_RECONCILE_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-reconcile-dummy-blue.xml"; + protected static final String TASK_RECONCILE_DUMMY_BLUE_OID = "10000000-0000-0000-5656-565600000204"; + + protected static final String TASK_RECONCILE_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-reconcile-dummy-green.xml"; + protected static final String TASK_RECONCILE_DUMMY_GREEN_OID = "10000000-0000-0000-5656-565600000404"; + + protected static final String TASK_LIVE_SYNC_DUMMY_FILENAME = COMMON_DIR + "/task-dumy-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_OID = "10000000-0000-0000-5555-555500000004"; + + protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_FILENAME = COMMON_DIR + "/task-dumy-blue-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_BLUE_OID = "10000000-0000-0000-5555-555500000204"; + + protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_FILENAME = COMMON_DIR + "/task-dumy-green-livesync.xml"; + protected static final String TASK_LIVE_SYNC_DUMMY_GREEN_OID = "10000000-0000-0000-5555-555500000404"; + + protected static final String TASK_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-validity-scanner.xml"; + protected static final String TASK_PARTITIONED_VALIDITY_SCANNER_FILENAME = COMMON_DIR + "/task-partitioned-validity-scanner.xml"; + protected static final String TASK_VALIDITY_SCANNER_OID = "10000000-0000-0000-5555-555505060400"; + + protected static final File TASK_TRIGGER_SCANNER_FILE = new File(COMMON_DIR, "task-trigger-scanner.xml"); + protected static final String TASK_TRIGGER_SCANNER_OID = "00000000-0000-0000-0000-000000000007"; + + protected static final File TASK_MOCK_JACK_FILE = new File(COMMON_DIR, "task-mock-jack.xml"); + protected static final String TASK_MOCK_JACK_OID = "10000000-0000-0000-5656-565674633311"; + + protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS = COMMON_DIR + "/task-delete-not-updated-shadows.xml"; + protected static final String TASK_DELETE_NOT_UPDATED_SHADOWS_OID = "5b2ba49f-6d4f-4618-afdf-4d138117e40a"; + + public static final File LOOKUP_LANGUAGES_FILE = new File(COMMON_DIR, "lookup-languages.xml"); + public static final String LOOKUP_LANGUAGES_OID = "70000000-0000-0000-1111-000000000001"; + public static final String LOOKUP_LANGUAGES_NAME = "Languages"; + + protected static final File SECURITY_POLICY_FILE = new File(COMMON_DIR, "security-policy.xml"); + protected static final String SECURITY_POLICY_OID = "28bf845a-b107-11e3-85bc-001e8c717e5b"; + + protected static final File ARCHETYPE_TASK_RECONCILIATION_FILE = new File(COMMON_DIR, "archetype-task-reconciliation.xml"); + protected static final String ARCHETYPE_TASK_RECONCILIATION_OID = "00000000-0000-0000-0000-000000000501"; + + protected static final File ARCHETYPE_EMPLOYEE_FILE = new File(COMMON_DIR, "archetype-employee.xml"); + protected static final String ARCHETYPE_EMPLOYEE_OID = "7135e68c-ee53-11e8-8025-170b77da3fd6"; + protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_LABEL = "Employee"; + protected static final String ARCHETYPE_EMPLOYEE_DISPLAY_PLURAL_LABEL = "Employees"; + + protected static final File ARCHETYPE_APPROVAL_CASE_FILE = new File(COMMON_DIR, "archetype-approval-case.xml"); + protected static final String ARCHETYPE_APPROVAL_CASE_OID = "00000000-0000-0000-0000-000000000342"; + + protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy"; + protected static final ItemName PIRACY_SHIP = new ItemName(NS_PIRACY, "ship"); + protected static final ItemName PIRACY_SHIP_BROKEN = new ItemName(NS_PIRACY, "ship-broken"); + protected static final ItemName PIRACY_TALES = new ItemName(NS_PIRACY, "tales"); + protected static final ItemName PIRACY_WEAPON = new ItemName(NS_PIRACY, "weapon"); + protected static final ItemName PIRACY_LOOT = new ItemName(NS_PIRACY, "loot"); + protected static final ItemName PIRACY_BAD_LUCK = new ItemName(NS_PIRACY, "badLuck"); + protected static final ItemName PIRACY_FUNERAL_TIMESTAMP = new ItemName(NS_PIRACY, "funeralTimestamp"); + protected static final ItemName PIRACY_SEA_QNAME = new ItemName(NS_PIRACY, "sea"); + protected static final ItemName PIRACY_COLORS = new ItemName(NS_PIRACY, "colors"); + protected static final ItemName PIRACY_MARK = new ItemName(NS_PIRACY, "mark"); + protected static final ItemName PIRACY_KEY = new ItemName(NS_PIRACY, "key"); + protected static final ItemName PIRACY_BINARY_ID = new ItemName(NS_PIRACY, "binaryId"); + protected static final ItemName PIRACY_COST_CENTER = new ItemName(NS_PIRACY, "costCenter"); + protected static final ItemName PIRACY_RISK_VECTOR = new ItemName(NS_PIRACY, "riskVector"); + protected static final ItemName PIRACY_RISK_VECTOR_RISK = new ItemName(NS_PIRACY, "risk"); + protected static final ItemName PIRACY_RISK_VECTOR_VALUE = new ItemName(NS_PIRACY, "value"); + protected static final ItemName RELATION_PIRACY_CAPTAIN = new ItemName(NS_PIRACY, "captain"); + protected static final ItemName PIRACY_LOCKER = new ItemName(NS_PIRACY, "locker"); + + protected static final ItemPath ROLE_EXTENSION_COST_CENTER_PATH = ItemPath + .create(RoleType.F_EXTENSION, new QName(NS_PIRACY, "costCenter")); + + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME = "sea"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME = "mate"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_LOCKER_NAME = "locker"; + protected static final String DUMMY_ACCOUNT_ATTRIBUTE_PROOF_NAME = "proof"; + + protected static final String INTENT_TEST = "test"; + protected static final String INTENT_DUMMY_GROUP = "group"; + protected static final String INTENT_DUMMY_PRIVILEGE = "privilege"; + + // Authorizations + + protected static final String NS_TEST_AUTZ = "http://midpoint.evolveum.com/xml/ns/test/authorization"; + protected static final QName AUTZ_LOOT_QNAME = new QName(NS_TEST_AUTZ, "loot"); + protected static final String AUTZ_LOOT_URL = QNameUtil.qNameToUri(AUTZ_LOOT_QNAME); + protected static final QName AUTZ_COMMAND_QNAME = new QName(NS_TEST_AUTZ, "command"); + protected static final String AUTZ_COMMAND_URL = QNameUtil.qNameToUri(AUTZ_COMMAND_QNAME); + protected static final QName AUTZ_PUNISH_QNAME = new QName(NS_TEST_AUTZ, "punish"); + protected static final String AUTZ_PUNISH_URL = QNameUtil.qNameToUri(AUTZ_PUNISH_QNAME); + protected static final QName AUTZ_CAPSIZE_QNAME = new QName(NS_TEST_AUTZ, "capsize"); + protected static final String AUTZ_CAPSIZE_URL = QNameUtil.qNameToUri(AUTZ_CAPSIZE_QNAME); + protected static final QName AUTZ_SUPERSPECIAL_QNAME = new QName(NS_TEST_AUTZ, "superspecial"); + protected static final String AUTZ_SUPERSPECIAL_URL = QNameUtil.qNameToUri(AUTZ_SUPERSPECIAL_QNAME); + protected static final QName AUTZ_NONSENSE_QNAME = new QName(NS_TEST_AUTZ, "nonsense"); + protected static final String AUTZ_NONSENSE_URL = QNameUtil.qNameToUri(AUTZ_NONSENSE_QNAME); + protected static final QName AUTZ_SAIL_QNAME = new QName(NS_TEST_AUTZ, "sail"); + protected static final String AUTZ_SAIL_URL = QNameUtil.qNameToUri(AUTZ_SAIL_QNAME); + protected static final QName AUTZ_DRINK_QNAME = new QName(NS_TEST_AUTZ, "drink"); + protected static final String AUTZ_DRINK_URL = QNameUtil.qNameToUri(AUTZ_DRINK_QNAME); + protected static final QName AUTZ_APPARATE_QNAME = new QName(NS_TEST_AUTZ, "apparate"); + protected static final String AUTZ_APPARATE_URL = QNameUtil.qNameToUri(AUTZ_APPARATE_QNAME); + protected static final QName AUTZ_GAMBLE_QNAME = new QName(NS_TEST_AUTZ, "gamble"); + protected static final String AUTZ_GAMBLE_URL = QNameUtil.qNameToUri(AUTZ_GAMBLE_QNAME); + protected static final QName AUTZ_CROUPIER_QNAME = new QName(NS_TEST_AUTZ, "croupier"); + protected static final String AUTZ_CROUPIER_URL = QNameUtil.qNameToUri(AUTZ_CROUPIER_QNAME); + protected static final QName AUTZ_PIT_BOSS_QNAME = new QName(NS_TEST_AUTZ, "pitBoss"); + protected static final String AUTZ_PIT_BOSS_URL = QNameUtil.qNameToUri(AUTZ_PIT_BOSS_QNAME); + + protected static final String NOTIFIER_ACCOUNT_PASSWORD_NAME = "accountPasswordNotifier"; + protected static final String NOTIFIER_USER_PASSWORD_NAME = "userPasswordNotifier"; + protected static final String NOTIFIER_ACCOUNT_ACTIVATION_NAME = "accountActivationNotifier"; + + protected PrismObject userAdministrator; + + public AbstractConfiguredModelIntegrationTest() { + super(); + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + logger.trace("initSystem"); + + // We want logging config from logback-test.xml and not from system config object (unless suppressed) + InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); + super.initSystem(initTask, initResult); + + modelService.postInit(initResult); + ManualConnectorInstance.setRandomDelayRange(0); + + // System Configuration + PrismObject configuration; + try { + File systemConfigurationFile = getSystemConfigurationFile(); + if (systemConfigurationFile != null) { + configuration = repoAddObjectFromFile(systemConfigurationFile, initResult); + } else { + configuration = addSystemConfigurationObject(initResult); + } + } catch (ObjectAlreadyExistsException e) { + throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + + "looks like the previous test haven't cleaned it up", e); + } + if (configuration != null) { + relationRegistry.applyRelationsConfiguration(configuration.asObjectable()); + } + + // Users + userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult); + repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult); + login(userAdministrator); + } + + protected int getNumberOfUsers() { + return 1; // Administrator + } + + protected int getNumberOfRoles() { + return 1; // Superuser role + } + + protected File getSystemConfigurationFile() { + return SYSTEM_CONFIGURATION_FILE; + } + + // to be used in very specific cases only (it is invoked when getSystemConfigurationFile returns null). + protected PrismObject addSystemConfigurationObject(OperationResult initResult) throws IOException, CommonException, + EncryptionException { + return null; + } + + protected PrismObject getDefaultActor() { + return userAdministrator; + } + + protected PrismSchema getPiracySchema() { + return prismContext.getSchemaRegistry().findSchemaByNamespace(NS_PIRACY); + } + + protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + XMLGregorianCalendar lastScanTimestamp = getLastScanTimestamp(taskOid); + assertNotNull("null lastScanTimestamp", lastScanTimestamp); + TestUtil.assertBetween("lastScanTimestamp", startCal, endCal, lastScanTimestamp); + } + + protected XMLGregorianCalendar getLastScanTimestamp(String taskOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + PrismObject task = getTask(taskOid); + display("Task", task); + PrismContainer taskExtension = task.getExtension(); + assertNotNull("No task extension", taskExtension); + PrismProperty lastScanTimestampProp = taskExtension.findProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); + assertNotNull("no lastScanTimestamp property", lastScanTimestampProp); + return lastScanTimestampProp.getRealValue(); + } + + protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end) { + assertPasswordMetadata(user, create, start, end, USER_ADMINISTRATOR_OID, SchemaConstants.CHANNEL_GUI_USER_URI); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected void clearUserOrgAndRoleRefs(String userOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OperationResult result = new OperationResult("clearUserOrgAndRoleRefs"); + Collection modifications = new ArrayList<>(); + ReferenceDelta parentOrgRefDelta = prismContext.deltaFactory().reference().createModificationReplace( + UserType.F_PARENT_ORG_REF, getUserDefinition(), (PrismReferenceValue)null); + modifications.add(parentOrgRefDelta); + ReferenceDelta roleMembershipRefDelta = prismContext.deltaFactory().reference().createModificationReplace( + UserType.F_ROLE_MEMBERSHIP_REF, getUserDefinition(), (PrismReferenceValue)null); + modifications.add(roleMembershipRefDelta); + repositoryService.modifyObject(UserType.class, userOid, modifications, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + PrismObject userBefore = getUser(userOid); + display("User before", userBefore); + } + + protected void assertEvaluatedRole(Collection evaluatedRoles, + String expectedRoleOid) { + for (EvaluatedAssignmentTarget evalRole: evaluatedRoles) { + if (expectedRoleOid.equals(evalRole.getTarget().getOid())) { + return; + } + } + AssertJUnit.fail("Role "+expectedRoleOid+" no present in evaluated roles "+evaluatedRoles); + } + + protected void assertSingleAccountPasswordNotification(String dummyResourceName, String username, + String password) { + assertAccountPasswordNotifications(1); + assertSingleDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, + getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); + } + + protected void assertSingleUserPasswordNotification(String username, String password) { + assertUserPasswordNotifications(1); + assertSingleDummyTransportMessage(NOTIFIER_USER_PASSWORD_NAME, + getExpectedUserPasswordNotificationBody(username, password)); + } + + protected void assertAccountPasswordNotifications(int expected) { + checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, expected); + } + + protected void assertUserPasswordNotifications(int expected) { + checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, expected); + } + + protected void assertNoAccountPasswordNotifications() { + checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); + } + + protected void assertNoUserPasswordNotifications() { + checkDummyTransportMessages(NOTIFIER_USER_PASSWORD_NAME, 0); + } + + protected void assertHasAccountPasswordNotification(String dummyResourceName, String username, + String password) { + assertHasDummyTransportMessage(NOTIFIER_ACCOUNT_PASSWORD_NAME, + getExpectedAccountPasswordNotificationBody(dummyResourceName, username, password)); + } + + protected void assertSingleAccountPasswordNotificationGenerated(String dummyResourceName, String username) { + assertAccountPasswordNotifications(1); + String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_PASSWORD_NAME, 0); + String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); + if (!body.startsWith(expectedPrefix)) { + fail("Expected that "+dummyResourceName+" dummy password notification message starts with prefix '"+expectedPrefix+"', but it was: "+body); + } + String suffix = body.substring(expectedPrefix.length()); + if (suffix.isEmpty()) { + fail("Empty password in "+dummyResourceName+" dummy password notification message"); + } + } + + protected String getExpectedAccountPasswordNotificationBody(String dummyResourceName, String username, + String password) { + return getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username) + password; + } + + protected String getExpectedAccountPasswordNotificationBodyPrefix(String dummyResourceName, String username) { + String resourceName = getDummyResourceType(dummyResourceName).getName().getOrig(); + return "Password for account "+username+" on "+resourceName+" is: "; + } + + protected String getExpectedUserPasswordNotificationBody(String username, String password) { + return getExpectedUserPasswordNotificationBodyPrefix(username) + password; + } + + protected String getExpectedUserPasswordNotificationBodyPrefix(String username) { + return "Password for user "+username+" is: "; + } + + protected void displayAccountPasswordNotifications() { + displayNotifications(NOTIFIER_ACCOUNT_PASSWORD_NAME); + } + + protected void displayUserPasswordNotifications() { + displayNotifications(NOTIFIER_USER_PASSWORD_NAME); + } + + protected Object getQuote(String description, String fullName) { + return description + " -- " + fullName; + } + + protected void loginAdministrator() throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + login(userAdministrator); + } +} diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java index 08947a29806..693be663603 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestActivation.java @@ -97,7 +97,7 @@ public class TestActivation extends AbstractInitializedModelIntegrationTest { private static final TestResource RESOURCE_DUMMY_PRECREATE = new TestResource(TEST_DIR, "resource-dummy-precreate.xml", "f18711a2-5db5-4562-b50d-3ef4c74f2e1d"); private static final String RESOURCE_DUMMY_PRECREATE_NAME = "precreate"; - + protected static final String ACCOUNT_MANCOMB_DUMMY_USERNAME = "mancomb"; private static final Date ACCOUNT_MANCOMB_VALID_FROM_DATE = MiscUtil.asDate(2011, 2, 3, 4, 5, 6); private static final Date ACCOUNT_MANCOMB_VALID_TO_DATE = MiscUtil.asDate(2066, 5, 4, 3, 2, 1); @@ -145,7 +145,7 @@ public void initSystem(Task initTask, OperationResult initResult) resourceDummyCoral = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_CORAL_FILE, RESOURCE_DUMMY_CORAL_OID, initTask, initResult); resourceDummyCoralType = resourceDummyCoral.asObjectable(); dummyResourceCtlCoral.setResource(resourceDummyCoral); - + dummyResourceCtlPrecreate = DummyResourceContoller.create(RESOURCE_DUMMY_PRECREATE_NAME, resourceDummyPrecreate); dummyResourcePrecreate = dummyResourceCtlPrecreate.getDummyResource(); resourceDummyPrecreate = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_PRECREATE.file, RESOURCE_DUMMY_PRECREATE.oid, initTask, initResult); @@ -156,7 +156,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050CheckJackEnabled() throws Exception { final String TEST_NAME = "test050CheckJackEnabled"; - displayTestTitle(TEST_NAME); // GIVEN, WHEN // this happens during test initialization when user-jack.xml is added @@ -173,7 +172,6 @@ public void test050CheckJackEnabled() throws Exception { @Test public void test051ModifyUserJackDisable() throws Exception { final String TEST_NAME = "test051ModifyUserJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -205,7 +203,6 @@ public void test051ModifyUserJackDisable() throws Exception { @Test public void test052ModifyUserJackNull() throws Exception { final String TEST_NAME = "test052ModifyUserJackNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -236,7 +233,6 @@ public void test052ModifyUserJackNull() throws Exception { @Test public void test055ModifyUserJackEnable() throws Exception { final String TEST_NAME = "test055ModifyUserJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -268,7 +264,6 @@ public void test055ModifyUserJackEnable() throws Exception { @Test public void test056RecomputeUserJackEffectiveEnable() throws Exception { final String TEST_NAME = "test056RecomputeUserJackEffectiveEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -321,7 +316,6 @@ public void test056RecomputeUserJackEffectiveEnable() throws Exception { @Test public void test060ModifyUserJackLifecycleActive() throws Exception { final String TEST_NAME = "test060ModifyUserJackLifecycleActive"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -353,7 +347,6 @@ public void test060ModifyUserJackLifecycleActive() throws Exception { @Test public void test061ModifyUserJackLifecycleDraft() throws Exception { final String TEST_NAME = "test061ModifyUserJackLifecycleDraft"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -385,7 +378,6 @@ public void test061ModifyUserJackLifecycleDraft() throws Exception { @Test public void test065ModifyUserJackLifecycleDeprecated() throws Exception { final String TEST_NAME = "test065ModifyUserJackLifecycleDeprecated"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -417,7 +409,6 @@ public void test065ModifyUserJackLifecycleDeprecated() throws Exception { @Test public void test068ModifyUserJackLifecycleArchived() throws Exception { final String TEST_NAME = "test068ModifyUserJackLifecycleArchived"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -448,7 +439,6 @@ public void test068ModifyUserJackLifecycleArchived() throws Exception { @Test public void test069ModifyUserJackLifecycleNull() throws Exception { final String TEST_NAME = "test069ModifyUserJackLifecycleNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -479,7 +469,6 @@ public void test069ModifyUserJackLifecycleNull() throws Exception { @Test public void test100ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME = "test100ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -554,7 +543,6 @@ public void test100ModifyUserJackAssignAccount() throws Exception { @Test public void test101ModifyUserJackDisable() throws Exception { final String TEST_NAME = "test101ModifyUserJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -586,8 +574,6 @@ public void test101ModifyUserJackDisable() throws Exception { @Test public void test102ModifyUserJackEnable() throws Exception { - TestUtil.displayTestTitle(this, "test102ModifyUserJackEnable"); - // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test052ModifyUserJackEnable"); OperationResult result = task.getResult(); @@ -617,7 +603,6 @@ public void test102ModifyUserJackEnable() throws Exception { */ @Test public void test111ModifyAccountJackDisable() throws Exception { - TestUtil.displayTestTitle(this, "test111ModifyAccountJackDisable"); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test111ModifyAccountJackDisable"); @@ -653,7 +638,6 @@ public void test111ModifyAccountJackDisable() throws Exception { @Test public void test112UserJackRecompute() throws Exception { final String TEST_NAME = "test112UserJackRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -693,7 +677,6 @@ public void test112UserJackRecompute() throws Exception { @Test public void test114ModifyUserJackEnable() throws Exception { final String TEST_NAME = "test114ModifyUserJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -731,7 +714,6 @@ public void test114ModifyUserJackEnable() throws Exception { @Test public void test115ModifyUserJackAdministrativeStatusNull() throws Exception { final String TEST_NAME = "test115ModifyUserJackAdministrativeStatusNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -772,7 +754,6 @@ public void test115ModifyUserJackAdministrativeStatusNull() throws Exception { @Test public void test118ModifyJackActivationUserAndAccount() throws Exception { final String TEST_NAME = "test118ModifyJackActivationUserAndAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -788,11 +769,11 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -819,21 +800,20 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception { @Test public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test120ModifyUserJackAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -871,7 +851,6 @@ public void test120ModifyUserJackAssignAccountDummyRed() throws Exception { @Test public void test121ModifyJackUserAndAccountRed() throws Exception { final String TEST_NAME = "test121ModifyJackUserAndAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -888,11 +867,11 @@ public void test121ModifyJackUserAndAccountRed() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -917,7 +896,6 @@ public void test121ModifyJackUserAndAccountRed() throws Exception { @Test public void test130ModifyAccountDefaultAndRed() throws Exception { - TestUtil.displayTestTitle(this, "test130ModifyAccountDefaultAndRed"); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + ".test121ModifyJackPasswordUserAndAccountRed"); @@ -952,7 +930,6 @@ public void test130ModifyAccountDefaultAndRed() throws Exception { @Test public void test138ModifyJackEnabled() throws Exception { final String TEST_NAME = "test138ModifyJackEnabled"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -960,11 +937,11 @@ public void test138ModifyJackEnabled() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -983,7 +960,6 @@ public void test138ModifyJackEnabled() throws Exception { @Test public void test139ModifyUserJackUnAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1021,21 +997,20 @@ public void test139ModifyUserJackUnAssignAccountDummyRed() throws Exception { @Test public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { final String TEST_NAME = "test140ModifyUserJackAssignAccountDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1071,21 +1046,20 @@ public void test140ModifyUserJackAssignAccountDummyRed() throws Exception { @Test public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { final String TEST_NAME = "test147ModifyUserJackUnassignAccountDummyRedRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); ObjectDelta userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, false); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1119,21 +1093,20 @@ public void test147ModifyUserJackUnassignAccountDummyRedRaw() throws Exception { @Test public void test149RecomputeJack() throws Exception { final String TEST_NAME = "test149RecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1168,10 +1141,9 @@ public void test149RecomputeJack() throws Exception { @Test public void test150ModifyUserJackAssignYellowAccount() throws Exception { final String TEST_NAME = "test150ModifyUserJackAssignYellowAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1182,11 +1154,11 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); assertSuccess(result); @@ -1219,19 +1191,18 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception { @Test public void test151ReconcileJack() throws Exception { final String TEST_NAME = "test151ReconcileJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1260,10 +1231,9 @@ public void test151ReconcileJack() throws Exception { @Test public void test152ModifyAccountsJackDisable() throws Exception { final String TEST_NAME = "test152ModifyAccountsJackDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1271,12 +1241,12 @@ public void test152ModifyAccountsJackDisable() throws Exception { ObjectDelta yellowDelta = createModifyAccountShadowReplaceDelta(accountYellowOid, null, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(dummyDelta, yellowDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1286,13 +1256,13 @@ public void test152ModifyAccountsJackDisable() throws Exception { checkAdminStatusFor15x(userJack, true, false, false); // WHEN (2) - now let's do a reconciliation on both resources - displayWhen(TEST_NAME); + when(); ObjectDelta innocentDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_LOCALITY, userJack.asObjectable().getLocality().toPolyString()); modelService.executeChanges(MiscSchemaUtil.createCollection(innocentDelta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess("executeChanges result (after reconciliation)", result); @@ -1305,7 +1275,6 @@ public void test152ModifyAccountsJackDisable() throws Exception { @Test public void test153ModifyAccountsJackEnable() throws Exception { final String TEST_NAME = "test153ModifyAccountsJackEnable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1378,10 +1347,9 @@ private void checkAdminStatusFor15x(PrismObject user, boolean userStat @Test public void test160ModifyUserJackAssignAccountKhaki() throws Exception { final String TEST_NAME = "test160ModifyUserJackAssignAccountKhaki"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1389,11 +1357,11 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_KHAKI_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -1457,7 +1425,6 @@ public void test160ModifyUserJackAssignAccountKhaki() throws Exception { @Test public void test170GetAccountUnlocked() throws Exception { final String TEST_NAME = "test170GetAccountUnlocked"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1481,7 +1448,6 @@ public void test170GetAccountUnlocked() throws Exception { @Test public void test172GetAccountLocked() throws Exception { final String TEST_NAME = "test172GetAccountLocked"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1509,7 +1475,6 @@ public void test172GetAccountLocked() throws Exception { @Test public void test174ModifyAccountUnlock() throws Exception { final String TEST_NAME = "test174ModifyAccountUnlock"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1544,7 +1509,6 @@ public void test174ModifyAccountUnlock() throws Exception { @Test public void test176ModifyUserUnlock() throws Exception { final String TEST_NAME = "test176ModifyUserUnlock"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1580,7 +1544,6 @@ public void test176ModifyUserUnlock() throws Exception { @Test public void test199DeleteUserJack() throws Exception { final String TEST_NAME = "test199DeleteUserJack"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1614,7 +1577,6 @@ public void test199DeleteUserJack() throws Exception { @Test public void test200AddUserLargo() throws Exception { final String TEST_NAME = "test200AddUserLargo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1640,7 +1602,6 @@ public void test200AddUserLargo() throws Exception { @Test public void test205ModifyUserLargoAssignAccount() throws Exception { final String TEST_NAME = "test205ModifyUserLargoAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1679,7 +1640,6 @@ public void test205ModifyUserLargoAssignAccount() throws Exception { @Test public void test210ModifyLargoValidTo10MinsAgo() throws Exception { final String TEST_NAME = "test210ModifyLargoValidTo10MinsAgo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1717,7 +1677,6 @@ public void test210ModifyLargoValidTo10MinsAgo() throws Exception { @Test public void test211ModifyLargoValidToManana() throws Exception { final String TEST_NAME = "test211ModifyLargoValidToManana"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1759,7 +1718,6 @@ public void test211ModifyLargoValidToManana() throws Exception { @Test public void test212SeeLargoTomorrow() throws Exception { final String TEST_NAME = "test212SeeLargoTomorrow"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1802,7 +1760,6 @@ public void test212SeeLargoTomorrow() throws Exception { @Test public void test213HastaLaMananaLargo() throws Exception { final String TEST_NAME = "test213HastaLaMananaLargo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = System.currentTimeMillis(); @@ -1842,7 +1799,6 @@ public void test213HastaLaMananaLargo() throws Exception { @Test public void test215ModifyLargoRemoveValidTo() throws Exception { final String TEST_NAME = "test215ModifyLargoRemoveValidTo"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); @@ -1879,7 +1835,6 @@ public void test215ModifyLargoRemoveValidTo() throws Exception { @Test public void test217ModifyLargoRemoveValidFrom() throws Exception { final String TEST_NAME = "test217ModifyLargoRemoveValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN long startMillis = clock.currentTimeMillis(); @@ -1921,7 +1876,6 @@ public void test217ModifyLargoRemoveValidFrom() throws Exception { @Test public void test230JackUnassignRepoRecompute() throws Exception { final String TEST_NAME = "test230JackUnassignRepoRecompute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -1937,11 +1891,11 @@ public void test230JackUnassignRepoRecompute() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1953,18 +1907,17 @@ public void test230JackUnassignRepoRecompute() throws Exception { @Test public void test231JackRecomputeReconcile() throws Exception { final String TEST_NAME = "test231JackRecomputeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false); @@ -1979,9 +1932,8 @@ public void test231JackRecomputeReconcile() throws Exception { @Test public void test240AddUserRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_RAPP_FILE); @@ -2001,11 +1953,11 @@ public void test240AddUserRappDraft() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2037,17 +1989,16 @@ public void test240AddUserRappDraft() throws Exception { @Test public void test241RecomputeRappDraft() throws Exception { final String TEST_NAME = "test240AddUserRappDraft"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2080,17 +2031,16 @@ public void test241RecomputeRappDraft() throws Exception { @Test public void test242RappAssignCaptain() throws Exception { final String TEST_NAME = "test242RappAssignCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2118,18 +2068,17 @@ public void test242RappAssignCaptain() throws Exception { @Test public void test245ActivateRapp() throws Exception { final String TEST_NAME = "test245ActivateRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ACTIVE); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2161,18 +2110,17 @@ public void test245ActivateRapp() throws Exception { @Test public void test248DeactivateRapp() throws Exception { final String TEST_NAME = "test248DeactivateRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_ARCHIVED); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2198,17 +2146,16 @@ public void test248DeactivateRapp() throws Exception { @Test public void test249DeleteUserRapp() throws Exception { final String TEST_NAME = "test249DeleteUserRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(UserType.class, USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2223,10 +2170,9 @@ public void test249DeleteUserRapp() throws Exception { @Test public void test300AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300AddDummyGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -2237,12 +2183,12 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account shadow after", accountMancomb); @@ -2264,10 +2210,10 @@ public void test300AddDummyGreenAccountMancomb() throws Exception { @Test public void test310ImportAccountsFromDummyGreen() throws Exception { final String TEST_NAME = "test310ImportAccountsFromDummyGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -2276,17 +2222,17 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { assertNull("Unexpected user mancomb before import", userMancomb); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_GREEN_OID, new QName(getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).getNamespace(), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); - displayThen(TEST_NAME); + then(); userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("No user mancomb after import", userMancomb); @@ -2302,7 +2248,6 @@ public void test310ImportAccountsFromDummyGreen() throws Exception { @Test public void test350AssignMancombBlueAccount() throws Exception { final String TEST_NAME = "test350AssignMancombBlueAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2329,7 +2274,6 @@ public void test350AssignMancombBlueAccount() throws Exception { @Test public void test352AssignMancombBlackAccount() throws Exception { final String TEST_NAME = "test352AssignMancombBlackAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2362,7 +2306,6 @@ public void test352AssignMancombBlackAccount() throws Exception { @Test public void test355MancombModifyAdministrativeStatusNull() throws Exception { final String TEST_NAME = "test355MancombModifyAdministrativeStatusNull"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2397,7 +2340,6 @@ public void test355MancombModifyAdministrativeStatusNull() throws Exception { @Test public void test400AddHerman() throws Exception { final String TEST_NAME = "test400AddHerman"; - displayTestTitle(TEST_NAME); // WHEN addObject(USER_HERMAN_FILE); @@ -2414,7 +2356,6 @@ public void test400AddHerman() throws Exception { @Test public void test410AssignHermanKhakiAccount() throws Exception { final String TEST_NAME = "test410AssignHermanKhakiAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2519,7 +2460,6 @@ public void test525SerivceSeaMonkeyRecompute() throws Exception { } private void test5X0CheckInitial(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN, WHEN // this happens during test initialization when the role is added @@ -2537,7 +2477,6 @@ private void test5X0CheckInitial(final String TEST_NAME, C * MID-2877 */ private void test5X1Recompute(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2564,7 +2503,6 @@ private void test5X1Recompute(final String TEST_NAME, Clas * MID-2877 */ private void test5X2ModifyDisable(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2596,7 +2534,6 @@ private void test5X2ModifyDisable(final String TEST_NAME, * MID-2877 */ private void test5X4ModifyEnable(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2628,7 +2565,6 @@ private void test5X4ModifyEnable(final String TEST_NAME, C * Make sure that recompute does not destroy anything. */ public void test5X5Recompute(final String TEST_NAME, Class type, String oid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2659,10 +2595,9 @@ public void test5X5Recompute(final String TEST_NAME, Class @Test public void test600AddUser1() throws Exception { final String TEST_NAME = "test600AddUser1"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user1 = prismContext.createObject(UserType.class); @@ -2676,11 +2611,11 @@ public void test600AddUser1() throws Exception { ObjectDelta addDelta = user1.createAddDelta(); // WHEN - displayWhen(TEST_NAME); + when(); Collection> executedChanges = executeChanges(addDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); user1 = getUser(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges)); display("User after change execution", user1); @@ -2705,7 +2640,6 @@ private void checkSuspendedAttribute(DummyAccount dummyAccount, Boolean expected @Test public void test610EnableUser1() throws Exception { final String TEST_NAME = "test610EnableUser1"; - displayTestTitle(TEST_NAME); // GIVEN PrismObject user1 = findUserByUsername("user1"); @@ -2742,7 +2676,6 @@ public void test610EnableUser1() throws Exception { @Test public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { final String TEST_NAME = "test700ModifyJackRemoveAdministrativeStatus"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2766,11 +2699,11 @@ public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { PrismAsserts.assertNoItem(userBefore, SchemaConstants.PATH_ACTIVATION_VALID_TO); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2794,7 +2727,6 @@ public void test700ModifyJackRemoveAdministrativeStatus() throws Exception { @Test public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { final String TEST_NAME = "test702ModifyJackFuneralTimestampBeforeNow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2813,11 +2745,11 @@ public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { XMLGregorianCalendar hourAgo = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() - 60 * 60 * 1000); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAgo); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2840,7 +2772,6 @@ public void test702ModifyJackFuneralTimestampBeforeNow() throws Exception { @Test public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { final String TEST_NAME = "test704ModifyJackFuneralTimestampAfterNow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2857,11 +2788,11 @@ public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { XMLGregorianCalendar hourAhead = XmlTypeConverter.createXMLGregorianCalendar(clock.currentTimeMillis() + 60 * 60 * 1000); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, hourAhead); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2882,7 +2813,6 @@ public void test704ModifyJackFuneralTimestampAfterNow() throws Exception { @Test public void test750AddAndDeleteUserWithPrecreate() throws Exception { final String TEST_NAME = "test750AddAndDeleteUserWithPrecreate"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); @@ -2910,11 +2840,11 @@ public void test750AddAndDeleteUserWithPrecreate() throws Exception { assertSuccess(result); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(UserType.class, oid, task, result); // THEN - displayThen(TEST_NAME); + then(); // There's a hidden FATAL_ERROR when unlinking deleted shadow (benign ... but it prevents us from asserting success tree-wide) //assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java index f2754aa3ed4..2c542850a86 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestAudit.java @@ -98,11 +98,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertTrue(modelAuditService.supportsRetrieval()); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -118,7 +117,6 @@ public void test000Sanity() throws Exception { @Test public void test010SanityJack() throws Exception { final String TEST_NAME = "test010SanityJack"; - displayTestTitle(TEST_NAME); // WHEN List auditRecords = getObjectAuditRecords(USER_JACK_OID); @@ -132,20 +130,19 @@ public void test010SanityJack() throws Exception { @Test public void test100ModifyUserJackKid() throws Exception { final String TEST_NAME = "test100ModifyUserJackKid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); initialTs = getTimeSafely(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString("Kid")); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -161,9 +158,8 @@ public void test100ModifyUserJackKid() throws Exception { @Test public void test105CreateUserHerman() throws Exception { final String TEST_NAME = "test105CreateUserHerman"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userHermanBefore = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -173,12 +169,12 @@ public void test105CreateUserHerman() throws Exception { hermanInitialTs = getTimeSafely(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userHermanBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -193,9 +189,8 @@ public void test105CreateUserHerman() throws Exception { @Test public void test110ModifyUserJackSailor() throws Exception { final String TEST_NAME = "test110ModifyUserJackSailor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -206,12 +201,12 @@ public void test110ModifyUserJackSailor() throws Exception { ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -226,9 +221,8 @@ public void test110ModifyUserJackSailor() throws Exception { @Test public void test115ModifyUserHermanMarooned() throws Exception { final String TEST_NAME = "test115ModifyUserHermanMarooned"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -237,12 +231,12 @@ public void test115ModifyUserHermanMarooned() throws Exception { objectDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -257,9 +251,8 @@ public void test115ModifyUserHermanMarooned() throws Exception { @Test public void test120ModifyUserJackCaptain() throws Exception { final String TEST_NAME = "test120ModifyUserJackCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_TITLE, @@ -269,12 +262,12 @@ public void test120ModifyUserJackCaptain() throws Exception { ActivationStatusType.ENABLED); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); jackCaptainTs = getTimeSafely(); @@ -288,9 +281,8 @@ public void test120ModifyUserJackCaptain() throws Exception { @Test public void test125ModifyUserHermanHermit() throws Exception { final String TEST_NAME = "test125ModifyUserHermanHermit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -305,13 +297,13 @@ public void test125ModifyUserHermanHermit() throws Exception { null, null, null, true)); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -325,9 +317,8 @@ public void test125ModifyUserHermanHermit() throws Exception { @Test public void test135ModifyUserHermanCivilisedHermit() throws Exception { final String TEST_NAME = "test135ModifyUserHermanCivilisedHermit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_HERMAN_OID, UserType.F_TITLE, @@ -337,13 +328,13 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { null, null, null, false)); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_HERMAN_OID); @@ -357,9 +348,8 @@ public void test135ModifyUserHermanCivilisedHermit() throws Exception { @Test public void test200ReconstructJackSailor() throws Exception { final String TEST_NAME = "test200ReconstructJackSailor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -368,13 +358,13 @@ public void test200ReconstructJackSailor() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackSailorEid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -388,9 +378,8 @@ public void test200ReconstructJackSailor() throws Exception { @Test public void test210ReconstructJackKid() throws Exception { final String TEST_NAME = "test210ReconstructJackKid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -399,13 +388,13 @@ public void test210ReconstructJackKid() throws Exception { PrismAsserts.assertPropertyValue(userBefore, UserType.F_TITLE, createPolyString("Captain")); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject jackReconstructed = modelAuditService.reconstructObject(UserType.class, USER_JACK_OID, jackKidEid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed jack", jackReconstructed); @@ -421,9 +410,8 @@ public void test210ReconstructJackKid() throws Exception { @Test public void test250ReconstructHermanCreated() throws Exception { final String TEST_NAME = "test250ReconstructHermanCreated"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_HERMAN_OID); @@ -435,13 +423,13 @@ public void test250ReconstructHermanCreated() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanCreatedEid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -461,19 +449,18 @@ public void test250ReconstructHermanCreated() throws Exception { @Test public void test252ReconstructHermanMarooned() throws Exception { final String TEST_NAME = "test252ReconstructHermanMarooned"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanMaroonedEid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -494,19 +481,18 @@ public void test252ReconstructHermanMarooned() throws Exception { @Test public void test254ReconstructHermanHermit() throws Exception { final String TEST_NAME = "test254ReconstructHermanHermit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject hermanReconstructed = modelAuditService.reconstructObject(UserType.class, USER_HERMAN_OID, hermanHermitEid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Reconstructed herman", hermanReconstructed); @@ -525,13 +511,12 @@ public void test254ReconstructHermanHermit() throws Exception { @Test public void test300QueryUnknown() throws Exception { final String TEST_NAME = "test300QueryUnknown"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); AuditEventRecord record = new AuditEventRecord(AuditEventType.SYNCHRONIZATION, AuditEventStage.EXECUTION); record.setOutcome(OperationResultStatus.UNKNOWN); @@ -542,7 +527,7 @@ public void test300QueryUnknown() throws Exception { List records = modelAuditService.listRecords("select * from m_audit_event as aer where aer.outcome = :outcome", params, task, result); // THEN - displayThen(TEST_NAME); + then(); display("records", records); assertEquals("Wrong # of records", 1, records.size()); @@ -551,9 +536,7 @@ public void test300QueryUnknown() throws Exception { } private String assertObjectAuditRecords(String oid, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertObjectAuditRecords"); - OperationResult result = task.getResult(); - List auditRecords = getObjectAuditRecords(oid, task, result); + List auditRecords = getObjectAuditRecords(oid); display("Object records", auditRecords); assertEquals("Wrong number of jack audit records", expectedNumberOfRecords, auditRecords.size()); return auditRecords.get(auditRecords.size() - 1).getEventIdentifier(); @@ -561,7 +544,7 @@ private String assertObjectAuditRecords(String oid, int expectedNumberOfRecords) private void assertRecordsFromPrevious(XMLGregorianCalendar from, XMLGregorianCalendar to, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertRecordsFromPrevious"); + Task task = getTestTask(); OperationResult result = task.getResult(); List auditRecordsSincePrevious = getAuditRecordsFromTo(from, to, task, result); display("From/to records (previous)", auditRecordsSincePrevious); @@ -569,7 +552,7 @@ private void assertRecordsFromPrevious(XMLGregorianCalendar from, XMLGregorianCa } private void assertRecordsFromInitial(XMLGregorianCalendar to, int expectedNumberOfRecords) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("assertRecordsFromInitial"); + Task task = getTestTask(); OperationResult result = task.getResult(); List auditRecordsSincePrevious = getAuditRecordsFromTo(initialTs, to, task, result); display("From/to records (initial)", auditRecordsSincePrevious); @@ -609,7 +592,7 @@ public void test300ConcurrentAudits() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = createTask(TEST_NAME); + Task threadTask = getTestTask(); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " on user " + index); @@ -680,7 +663,7 @@ public void test310ConcurrentAuditsRaw() throws Exception { Thread thread = new Thread(() -> { try { login(userAdministrator); - Task threadTask = createTask(TEST_NAME); + Task threadTask = getTestTask(); OperationResult threadResult = threadTask.getResult(); for (int iteration = 0; iteration < ITERATIONS; iteration++) { display("Executing iteration " + iteration + " in worker " + index); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java index 5c092a2171a..630832a6d11 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestCaseIgnore.java @@ -101,7 +101,6 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test000Sanity() throws Exception { final String TEST_NAME="test000Sanity"; - displayTestTitle(TEST_NAME); assertShadows(5); } @@ -109,7 +108,6 @@ public void test000Sanity() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -120,11 +118,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); // MID-4779 @@ -163,7 +161,6 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test133SeachAccountShadows() throws Exception { final String TEST_NAME="test133SeachAccountShadows"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -175,11 +172,11 @@ public void test133SeachAccountShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> foundShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -217,7 +214,6 @@ public void test133SeachAccountShadows() throws Exception { @Test public void test139ModifyUserJackUnassignAccount() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnassignAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME); @@ -257,7 +253,6 @@ public void test139ModifyUserJackUnassignAccount() throws Exception { @Test public void test150JackAssignRoleX() throws Exception { final String TEST_NAME = "test150JackAssignRoleX"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -269,7 +264,7 @@ public void test150JackAssignRoleX() throws Exception { assignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -304,7 +299,6 @@ public void test150JackAssignRoleX() throws Exception { @Test public void test152GetJack() throws Exception { final String TEST_NAME = "test152GetJack"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -313,7 +307,7 @@ public void test152GetJack() throws Exception { PrismObject userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -346,7 +340,6 @@ public void test152GetJack() throws Exception { @Test public void test159JackUnAssignRoleX() throws Exception { final String TEST_NAME = "test159JackUnAssignRoleX"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -358,7 +351,7 @@ public void test159JackUnAssignRoleX() throws Exception { unassignRole(USER_JACK_OID, ROLE_X_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -378,7 +371,6 @@ public void test159JackUnAssignRoleX() throws Exception { @Test public void test160JackAssignRoleBasic() throws Exception { final String TEST_NAME = "test160JackAssignRoleBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -387,11 +379,11 @@ public void test160JackAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -427,7 +419,6 @@ public void test160JackAssignRoleBasic() throws Exception { @Test public void test161JackAssignRoleJoker() throws Exception { final String TEST_NAME = "test161JackAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -436,11 +427,11 @@ public void test161JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -480,7 +471,6 @@ public void test161JackAssignRoleJoker() throws Exception { @Test public void test165JackUnAssignRoleJoker() throws Exception { final String TEST_NAME = "test165JackUnAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -489,11 +479,11 @@ public void test165JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -529,7 +519,6 @@ public void test165JackUnAssignRoleJoker() throws Exception { @Test public void test169JackUnAssignRoleBasic() throws Exception { final String TEST_NAME = "test169JackUnAssignRoleBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -538,11 +527,11 @@ public void test169JackUnAssignRoleBasic() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -564,7 +553,6 @@ public void test169JackUnAssignRoleBasic() throws Exception { @Test public void test170JackAssignRoleJoker() throws Exception { final String TEST_NAME = "test170JackAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -573,11 +561,11 @@ public void test170JackAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -612,7 +600,6 @@ public void test170JackAssignRoleJoker() throws Exception { @Test public void test179JackUnAssignRoleJoker() throws Exception { final String TEST_NAME = "test179JackUnAssignRoleJoker"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -621,11 +608,11 @@ public void test179JackUnAssignRoleJoker() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Make sure this is repository so we do not destroy the "evidence" yet. @@ -655,7 +642,6 @@ public void test179JackUnAssignRoleJoker() throws Exception { @Test public void test200GuybrushAssignRoleFools() throws Exception { final String TEST_NAME = "test200GuybrushAssignRoleFools"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -676,11 +662,11 @@ public void test200GuybrushAssignRoleFools() throws Exception { assertShadows(4); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_FOOL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertShadows(6); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java index 47618efce57..b5a9d804ce5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorDummyFake.java @@ -86,10 +86,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010ListConnectors() throws Exception { final String TEST_NAME = "test010ListConnectors"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -124,10 +123,9 @@ public void test010ListConnectors() throws Exception { @Test public void test020ImportFakeResource() throws Exception { final String TEST_NAME = "test020ImportFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -149,10 +147,9 @@ public void test020ImportFakeResource() throws Exception { @Test public void test021TestFakeResource() throws Exception { final String TEST_NAME = "test021TestFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -166,10 +163,9 @@ public void test021TestFakeResource() throws Exception { @Test public void test022ListAccountsFakeResource() throws Exception { final String TEST_NAME = "test022ListAccountsFakeResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -186,10 +182,9 @@ public void test022ListAccountsFakeResource() throws Exception { @Test public void test030ImportDummyResource() throws Exception { final String TEST_NAME = "test030ImportDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -211,10 +206,9 @@ public void test030ImportDummyResource() throws Exception { @Test public void test031TestDummyResource() throws Exception { final String TEST_NAME = "test031TestDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -228,10 +222,9 @@ public void test031TestDummyResource() throws Exception { @Test public void test032ListAccountsDummyResource() throws Exception { final String TEST_NAME = "test032ListAccountsDummyResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -250,10 +243,9 @@ public void test032ListAccountsDummyResource() throws Exception { @Test public void test100UpgradeModelAddDelete() throws Exception { final String TEST_NAME = "test100UpgradeModelAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -285,10 +277,9 @@ public void test100UpgradeModelAddDelete() throws Exception { @Test public void test150DowngradeModelAddDelete() throws Exception { final String TEST_NAME = "test150DowngradeModelAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -315,10 +306,9 @@ public void test150DowngradeModelAddDelete() throws Exception { @Test public void test200UpgradeModelReplace() throws Exception { final String TEST_NAME = "test200UpgradeModelReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -343,10 +333,9 @@ public void test200UpgradeModelReplace() throws Exception { @Test public void test250DowngradeModelReplace() throws Exception { final String TEST_NAME = "test250DowngradeModelReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -370,10 +359,9 @@ public void test250DowngradeModelReplace() throws Exception { @Test public void test300UpgradeRawAddDelete() throws Exception { final String TEST_NAME = "test300UpgradeRawAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -403,10 +391,9 @@ public void test300UpgradeRawAddDelete() throws Exception { @Test public void test350DowngradeRawAddDelete() throws Exception { final String TEST_NAME = "test350DowngradeRawAddDelete"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -438,10 +425,9 @@ public void test350DowngradeRawAddDelete() throws Exception { @Test public void test400UpgradeRawReplace() throws Exception { final String TEST_NAME = "test400UpgradeRawReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -471,10 +457,9 @@ public void test400UpgradeRawReplace() throws Exception { @Test public void test450DowngradeRawReplace() throws Exception { final String TEST_NAME = "test450DowngradeRawReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java index 1fd43a92ab1..970a2a46bbd 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConnectorMultiInstance.java @@ -82,10 +82,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_YELLOW_OID, task); @@ -100,10 +99,9 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignDummyYellow() throws Exception { final String TEST_NAME = "test100JackAssignDummyYellow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -132,7 +130,6 @@ public void test100JackAssignDummyYellow() throws Exception { @Test public void test102ReadJackDummyYellowAgain() throws Exception { final String TEST_NAME = "test102ReadJackDummyYellowAgain"; - displayTestTitle(TEST_NAME); // WHEN PrismObject shadowYellow = getShadowModel(accountJackYellowOid); @@ -155,7 +152,6 @@ public void test102ReadJackDummyYellowAgain() throws Exception { @Test public void test110ReadJackDummyYellowBlocking() throws Exception { final String TEST_NAME = "test110ReadJackDummyYellowBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder = new Holder<>(); @@ -200,7 +196,6 @@ public void test110ReadJackDummyYellowBlocking() throws Exception { @Test public void test120ReadJackDummyYellowTwoOperationsOneBlocking() throws Exception { final String TEST_NAME = "test120ReadJackDummyYellowTwoOperationsOneBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder1 = new Holder<>(); @@ -267,7 +262,6 @@ public void test120ReadJackDummyYellowTwoOperationsOneBlocking() throws Exceptio @Test public void test125ReadJackDummyYellowTwoBlocking() throws Exception { final String TEST_NAME = "test125ReadJackDummyYellowTwoBlocking"; - displayTestTitle(TEST_NAME); dummyResourceYellow.setBlockOperations(true); final Holder> shadowHolder1 = new Holder<>(); @@ -325,10 +319,9 @@ public void run() throws Exception { @Test public void test200GuybrushAssignDummyBlack() throws Exception { final String TEST_NAME = "test200GuybrushAssignDummyBlack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index 861d7c7c173..a328bd9bbec 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -146,10 +146,9 @@ public void test270Recompute_Delete_Delete() throws Exception { private void executeTest(final String TEST_NAME, FocusOperation focusOperation, ShadowOperation shadowOperation, ResourceObjectOperation resourceObjectOperation) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME + ".given"); + Task task = getTestTask(); OperationResult result = task.getResult(); cleanUpBeforeTest(task, result); @@ -195,11 +194,11 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, assertDummyAccount(null, "jack"); } - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); switch (focusOperation) { case RECOMPUTE: recomputeUser(USER_JACK_OID, task, result); @@ -214,7 +213,7 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Result", result); if (ASSERT_SUCCESS) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java index 9dec763e4b0..08282141cc0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestDeputy.java @@ -53,7 +53,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); PrismObject userJack = getUser(USER_JACK_OID); display("User Jack", userJack); @@ -75,18 +74,17 @@ public void test000Sanity() throws Exception { @Test public void test100AssignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test100AssignDeputyNoBigDeal"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -112,18 +110,17 @@ public void test100AssignDeputyNoBigDeal() throws Exception { @Test public void test109UnassignDeputyNoBigDeal() throws Exception { final String TEST_NAME = "test109UnassignDeputyNoBigDeal"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -148,18 +145,17 @@ public void test109UnassignDeputyNoBigDeal() throws Exception { @Test public void test110AssignJackPirate() throws Exception { final String TEST_NAME = "test110AssignJackPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -186,18 +182,17 @@ public void test110AssignJackPirate() throws Exception { @Test public void test112AssignDeputyPirate() throws Exception { final String TEST_NAME = "test112AssignDeputyPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -229,18 +224,17 @@ public void test112AssignDeputyPirate() throws Exception { @Test public void test119UnassignDeputyPirate() throws Exception { final String TEST_NAME = "test119UnassignDeputyPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -267,9 +261,8 @@ public void test119UnassignDeputyPirate() throws Exception { @Test public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test120AssignbarbossaDeputyOfGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -277,12 +270,12 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { assertLinks(userGuybrushBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -310,18 +303,17 @@ public void test120AssignbarbossaDeputyOfGuybrush() throws Exception { @Test public void test122AssignGuybrushPirate() throws Exception { final String TEST_NAME = "test122AssignGuybrushPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -349,18 +341,17 @@ public void test122AssignGuybrushPirate() throws Exception { @Test public void test124RecomputeBarbossa() throws Exception { final String TEST_NAME = "test124RecomputeBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -390,18 +381,17 @@ public void test124RecomputeBarbossa() throws Exception { @Test public void test126UnassignGuybrushPirate() throws Exception { final String TEST_NAME = "test126UnassignGuybrushPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -428,19 +418,18 @@ public void test126UnassignGuybrushPirate() throws Exception { @Test public void test128RecomputeBarbossa() throws Exception { final String TEST_NAME = "test128RecomputeBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -462,18 +451,17 @@ public void test128RecomputeBarbossa() throws Exception { @Test public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { final String TEST_NAME = "test129UnassignBarbossaDeputyOfGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -498,9 +486,8 @@ public void test129UnassignBarbossaDeputyOfGuybrush() throws Exception { @Test public void test150AssignJackMoreRoles() throws Exception { final String TEST_NAME = "test150AssignJackMoreRoles"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, @@ -520,12 +507,12 @@ public void test150AssignJackMoreRoles() throws Exception { null, null, (ActivationType) null, true))); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -552,20 +539,19 @@ public void test150AssignJackMoreRoles() throws Exception { @Test public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test152AssignbarbossaDeputyLimitedDeputy"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -589,20 +575,19 @@ public void test152AssignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { final String TEST_NAME = "test154UnassignbarbossaDeputyLimitedDeputy"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_PIRATE_OID), createOrgReference(ORG_MINISTRY_OF_RUM_OID, SchemaConstants.ORG_MANAGER)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -623,13 +608,12 @@ public void test154UnassignbarbossaDeputyLimitedDeputy() throws Exception { @Test public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test156AssignbarbossaDeputyLimitedDeputyRed"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -637,7 +621,7 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -661,16 +645,15 @@ public void test156AssignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { final String TEST_NAME = "test159UnassignbarbossaDeputyLimitedDeputyRed"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_RED_SAILOR_OID), @@ -678,7 +661,7 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -703,20 +686,19 @@ public void test159UnassignbarbossaDeputyLimitedDeputyRed() throws Exception { @Test public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test160AssignbarbossaDeputyLimitedDeputyEmpty"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -740,23 +722,22 @@ public void test160AssignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { final String TEST_NAME = "test162UnassignbarbossaDeputyLimitedDeputyEmpty"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID) ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -780,20 +761,19 @@ public void test162UnassignbarbossaDeputyLimitedDeputyEmpty() throws Exception { @Test public void test170AddRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_DRINKER_FILE); display("Adding role", role); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, ROLE_DRINKER_OID); @@ -805,17 +785,16 @@ public void test170AddRoleDrinker() throws Exception { @Test public void test172AssignJackRoleDrinker() throws Exception { final String TEST_NAME = "test170AssignJackRoleDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DRINKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -835,20 +814,19 @@ public void test172AssignJackRoleDrinker() throws Exception { @Test public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test174AssignBarbossaDeputyLimitedDeputyDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -874,9 +852,8 @@ public void test174AssignBarbossaDeputyLimitedDeputyDrinker() throws Exception { @Test public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test176AssignbarGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -888,7 +865,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -897,7 +874,7 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -912,23 +889,22 @@ public void test176AssignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception { final String TEST_NAME = "test178UnassignBsarbossaDeputyLimitedDeputyDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -959,13 +935,12 @@ public void test178UnassignBarbossaDeputyLimitedDeputyDrinker() throws Exception @Test public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test179UnassignbarGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, assignment -> assignment.beginLimitTargetContent().allowTransitive(true), @@ -974,7 +949,7 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -988,18 +963,17 @@ public void test179UnassignbarGuybrushLimitedDeputyOfBarbossa() throws Exception @Test public void test180AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test180AssignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1017,9 +991,8 @@ public void test180AssignBarbossaDeputyOfJack() throws Exception { @Test public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -1031,14 +1004,14 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1053,20 +1026,19 @@ public void test182AssignGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result, createRoleReference(ROLE_DRINKER_OID) ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1082,9 +1054,8 @@ public void test184UnassignGuybrushLimitedDeputyOfBarbossa() throws Exception { @Test public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test182AssignGuybrushLimitedDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userGuybrushBefore = getUser(USER_GUYBRUSH_OID); @@ -1096,12 +1067,12 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1116,18 +1087,17 @@ public void test186AssignGuybrushDeputyOfBarbossa() throws Exception { @Test public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { final String TEST_NAME = "test188UnassignGuybrushDeputyOfBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputy(USER_GUYBRUSH_OID, USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1140,18 +1110,17 @@ public void test188UnassignGuybrushDeputyOfBarbossa() throws Exception { @Test public void test189UnassignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test189UnassignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userBarbossaAfter = getUser(USER_BARBOSSA_OID); @@ -1164,13 +1133,12 @@ public void test189UnassignBarbossaDeputyOfJack() throws Exception { @Test public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1178,7 +1146,7 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except ); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1202,16 +1170,15 @@ public void test190AssignBarbossaDeputyLimitedDeputyEmptyDrinker() throws Except @Test public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exception { final String TEST_NAME = "test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignDeputyLimits(USER_BARBOSSA_OID, USER_JACK_OID, task, result, createRoleReference(ROLE_EMPTY_OID), @@ -1219,7 +1186,7 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce ); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1244,23 +1211,23 @@ public void test192UnassignbarbossaDeputyLimitedDeputyEmptyDrinker() throws Exce @Test public void test800ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test800ImportValidityScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME); + TestValidityRecomputeTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_VALIDITY_SCANNER_FILENAME); waitForTaskStart(TASK_VALIDITY_SCANNER_OID, false); waitForTaskFinish(TASK_VALIDITY_SCANNER_OID, true); // THEN - displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); } @@ -1272,9 +1239,8 @@ public void test800ImportValidityScannerTask() throws Exception { @Test public void test802AssignBarbossaDeputyOfJack() throws Exception { final String TEST_NAME = "test802AssignBarbossaDeputyOfJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -1289,13 +1255,13 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { activationType.setValidTo(XmlTypeConverter.addDuration(startTs, "PT2H")); // WHEN - displayWhen(TEST_NAME); + when(); assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, assignment -> assignment.setActivation(activationType), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1326,9 +1292,8 @@ public void test802AssignBarbossaDeputyOfJack() throws Exception { @Test public void test804BarbosaThreeHoursLater() throws Exception { final String TEST_NAME = "test804BarbosaThreeHoursLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT3H"); @@ -1336,12 +1301,12 @@ public void test804BarbosaThreeHoursLater() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java index 64a0e2f1706..e55a004f50a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestEntitlements.java @@ -23,7 +23,6 @@ import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; @@ -146,9 +145,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test100AddGroupShadowSwashbucklers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertSteadyResources(); @@ -175,9 +173,8 @@ public void test100AddGroupShadowSwashbucklers() throws Exception { @Test public void test101GetGroupShadowSwashbucklers() throws Exception { final String TEST_NAME = "test101GetGroupShadowSwashbucklers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -198,9 +195,8 @@ public void test101GetGroupShadowSwashbucklers() throws Exception { @Test public void test110AssociateGuybrushToSwashbucklers() throws Exception { final String TEST_NAME = "test110AssociateGuybrushToSwashbucklers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_SHADOW_GUYBRUSH_OID, @@ -208,11 +204,11 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { SHADOW_GROUP_DUMMY_SWASHBUCKLERS_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyGroupByName(null, GROUP_DUMMY_SWASHBUCKLERS_NAME) @@ -223,17 +219,16 @@ public void test110AssociateGuybrushToSwashbucklers() throws Exception { @Test public void test200AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test200AssignRoleSwashbucklerToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -254,17 +249,16 @@ public void test200AssignRoleSwashbucklerToJack() throws Exception { @Test public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test209UnAssignRoleSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -288,9 +282,8 @@ public void test209UnAssignRoleSwashbucklerFromJack() throws Exception { @Test public void test220AssignRoleLandluberToWally() throws Exception { final String TEST_NAME = "test220AssignRoleLandluberToWally"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(SHADOW_GROUP_DUMMY_LANDLUBERS_FILE); @@ -318,9 +311,8 @@ public void test220AssignRoleLandluberToWally() throws Exception { @Test public void test222AssignRoleMapmakerToWally() throws Exception { final String TEST_NAME = "test222AssignRoleMapmakerToWally"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup mapmakers = new DummyGroup(GROUP_DUMMY_MAPMAKERS_NAME); @@ -329,11 +321,11 @@ public void test222AssignRoleMapmakerToWally() throws Exception { PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, USER_WALLY_NAME, getDummyResource()); @@ -361,19 +353,18 @@ public void test222AssignRoleMapmakerToWally() throws Exception { @Test public void test224UnassignRoleMapmakerFromWally() throws Exception { final String TEST_NAME = "test224UnassignRoleMapmakerFromWally"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_WALLY_NAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(user.getOid(), ROLE_MAPMAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_MAPMAKERS_NAME); @@ -386,17 +377,16 @@ public void test224UnassignRoleMapmakerFromWally() throws Exception { @Test public void test300AddRoleWimp() throws Exception { final String TEST_NAME = "test300AddRoleWimp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ROLE_WIMP_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_WIMPS_NAME); @@ -419,17 +409,16 @@ public void test300AddRoleWimp() throws Exception { @Test public void test302AddRoleBrute() throws Exception { final String TEST_NAME = "test302AddRoleBrute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ROLE_BRUTE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -447,17 +436,16 @@ public void test302AddRoleBrute() throws Exception { @Test public void test304AddRoleThug() throws Exception { final String TEST_NAME = "test304AddRoleThug"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ROLE_THUG_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -475,19 +463,18 @@ public void test304AddRoleThug() throws Exception { @Test public void test310AssignRoleWimpToLargo() throws Exception { final String TEST_NAME = "test310AssignRoleWimpToLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_LARGO_FILE); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -502,17 +489,16 @@ public void test310AssignRoleWimpToLargo() throws Exception { @Test public void test312AssignRoleBruteToLargo() throws Exception { final String TEST_NAME = "test312AssignRoleBruteToLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -527,17 +513,16 @@ public void test312AssignRoleBruteToLargo() throws Exception { @Test public void test313UnAssignRoleBruteFromLargo() throws Exception { final String TEST_NAME = "test313UnAssignRoleBruteFromLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -562,17 +547,16 @@ public void test313UnAssignRoleBruteFromLargo() throws Exception { @Test public void test314AssignRoleThugToLargo() throws Exception { final String TEST_NAME = "test314AssignRoleThugToLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -587,17 +571,16 @@ public void test314AssignRoleThugToLargo() throws Exception { @Test public void test315UnAssignRoleThugFromLargo() throws Exception { final String TEST_NAME = "test315UnAssignRoleThugFromLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -625,17 +608,16 @@ public void test315UnAssignRoleThugFromLargo() throws Exception { @Test public void test317RenameLargo() throws Exception { final String TEST_NAME = "test317RenameLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_LARGO_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("newLargo")); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -657,17 +639,16 @@ public void test317RenameLargo() throws Exception { @Test public void test319UnassignRoleWimpFromLargo() throws Exception { final String TEST_NAME = "test319UnassignRoleWimpFromLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LARGO_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -694,19 +675,18 @@ public void test319UnassignRoleWimpFromLargo() throws Exception { @Test public void test320AssignRoleBruteToRapp() throws Exception { final String TEST_NAME = "test320AssignRoleBruteToRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_RAPP_FILE); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -721,17 +701,16 @@ public void test320AssignRoleBruteToRapp() throws Exception { @Test public void test322AssignRoleWimpToRapp() throws Exception { final String TEST_NAME = "test322AssignRoleWimpToRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -753,17 +732,16 @@ public void test322AssignRoleWimpToRapp() throws Exception { @Test public void test324AssignRoleThugToRapp() throws Exception { final String TEST_NAME = "test324AssignRoleThugToRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -792,17 +770,16 @@ public void test324AssignRoleThugToRapp() throws Exception { @Test public void test327UnassignRoleWimpFromRapp() throws Exception { final String TEST_NAME = "test327UnassignRoleWimpFromRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_WIMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -834,17 +811,16 @@ public void test327UnassignRoleWimpFromRapp() throws Exception { @Test public void test328UnassignRoleThugFromRapp() throws Exception { final String TEST_NAME = "test328UnassignRoleThugFromRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_THUG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -879,17 +855,16 @@ public void test328UnassignRoleThugFromRapp() throws Exception { @Test public void test329UnAssignRoleBruteFromRapp() throws Exception { final String TEST_NAME = "test329UnAssignRoleBruteFromRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_BRUTE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -918,18 +893,17 @@ public void test329UnAssignRoleBruteFromRapp() throws Exception { @Test public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { final String TEST_NAME = "test350AssignOrangeAccountToGuybrushAndRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); DummyAccount accountGuybrush = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -944,9 +918,8 @@ public void test350AssignOrangeAccountToGuybrushAndRapp() throws Exception { @Test public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test351AssignRoleCrewOfGuybrushToRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userRappBefore = getUser(USER_RAPP_OID); @@ -957,11 +930,11 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -989,9 +962,8 @@ public void test351AssignRoleCrewOfGuybrushToRapp() throws Exception { @Test public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { final String TEST_NAME = "test358UnassignRoleCrewOfGuybrushToRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userRappBefore = getUser(USER_RAPP_OID); @@ -1002,11 +974,11 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_RAPP_OID, ROLE_CREW_OF_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrushAfter = getUser(USER_GUYBRUSH_OID); @@ -1029,18 +1001,17 @@ public void test358UnassignRoleCrewOfGuybrushToRapp() throws Exception { @Test public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { final String TEST_NAME = "test359UnassignOrangeAccountFromGuybrushAndRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); unassignAccountFromUser(USER_RAPP_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); @@ -1052,17 +1023,16 @@ public void test359UnassignOrangeAccountFromGuybrushAndRapp() throws Exception { @Test public void test600AssignRolePirateToJack() throws Exception { final String TEST_NAME = "test600AssignRolePirateToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1087,17 +1057,16 @@ public void test600AssignRolePirateToJack() throws Exception { @Test public void test610AssignRoleSwashbucklerToJack() throws Exception { final String TEST_NAME = "test610AssignRoleSwashbucklerToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1121,17 +1090,16 @@ public void test610AssignRoleSwashbucklerToJack() throws Exception { @Test public void test620UnAssignSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test620UnAssignSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1159,9 +1127,8 @@ public void test620UnAssignSwashbucklerFromJack() throws Exception { @Test public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { final String TEST_NAME = "test630AssignRoleSwashbucklerToJackValidity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); jackSwashbucklerAssignmentActivation = new ActivationType(); @@ -1175,11 +1142,11 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { jackSwashbucklerAssignmentActivation.setValidTo(validTo); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1203,9 +1170,8 @@ public void test630AssignRoleSwashbucklerToJackValidity() throws Exception { @Test public void test640JackRoleSwashbucklerBecomesValid() throws Exception { final String TEST_NAME = "test640JackRoleSwashbucklerBecomesValid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT2H"); @@ -1239,9 +1205,8 @@ public void test640JackRoleSwashbucklerBecomesValid() throws Exception { @Test public void test645JackRoleSwashbucklerIsValid() throws Exception { final String TEST_NAME = "test645JackRoleSwashbucklerIsValid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1271,9 +1236,8 @@ public void test645JackRoleSwashbucklerIsValid() throws Exception { @Test public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { final String TEST_NAME = "test650JackRoleSwashbucklerBecomesInvalid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT2H"); @@ -1307,17 +1271,16 @@ public void test650JackRoleSwashbucklerBecomesInvalid() throws Exception { @Test public void test659UnassignRoleSwashbucklerFromJack() throws Exception { final String TEST_NAME = "test659UnassignRoleSwashbucklerFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, jackSwashbucklerAssignmentActivation.clone(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1347,17 +1310,16 @@ public void test659UnassignRoleSwashbucklerFromJack() throws Exception { @Test public void test699UnassignRolePirateFromJack() throws Exception { final String TEST_NAME = "test699UnassignRolePirateFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1373,9 +1335,8 @@ public void test699UnassignRolePirateFromJack() throws Exception { @Test public void test700ReconcileGuybrush() throws Exception { final String TEST_NAME = "test700ReconcileGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.resetOverride(); @@ -1390,11 +1351,11 @@ public void test700ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1407,9 +1368,8 @@ public void test700ReconcileGuybrush() throws Exception { @Test public void test710AssociateGuybrushToLandlubers() throws Exception { final String TEST_NAME = "test710AssociateGuybrushToLandlubers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = @@ -1433,9 +1393,8 @@ public void test710AssociateGuybrushToLandlubers() throws Exception { @Test public void test715AssociateGuybrushToThugs() throws Exception { final String TEST_NAME = "test715AssociateGuybrushToThugs"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -1460,11 +1419,11 @@ public void test715AssociateGuybrushToThugs() throws Exception { ObjectDelta delta = ObjectDeltaCollectionsUtil.summarize(delta1, delta2); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGroupMember(GROUP_THUG_NAME, ACCOUNT_GUYBRUSH_DUMMY_ORANGE_USERNAME, getDummyResource(RESOURCE_DUMMY_ORANGE_NAME)); @@ -1477,9 +1436,8 @@ public void test715AssociateGuybrushToThugs() throws Exception { @Test public void test720ReconcileGuybrush() throws Exception { final String TEST_NAME = "test720ReconcileGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1488,11 +1446,11 @@ public void test720ReconcileGuybrush() throws Exception { assertGroupMember(getDummyGroup(null, GROUP_DUMMY_LANDLUBERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(GROUP_DUMMY_LANDLUBERS_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, getDummyResource()); @@ -1503,9 +1461,8 @@ public void test720ReconcileGuybrush() throws Exception { @Test public void test729CleanupGuybrush() throws Exception { final String TEST_NAME = "test729CleanupGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -1513,11 +1470,11 @@ public void test729CleanupGuybrush() throws Exception { PrismObject userBefore = dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1535,9 +1492,8 @@ public void test729CleanupGuybrush() throws Exception { @Test public void test750PrepareGuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test750PrepareGuybrushFuturePerfect"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1552,11 +1508,11 @@ public void test750PrepareGuybrushFuturePerfect() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1578,19 +1534,18 @@ private String orgGroupName(String ou) { @Test public void test752GuybrushFuturePerfect() throws Exception { final String TEST_NAME = "test752GuybrushFuturePerfect"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResourceController().addGroup(orgGroupName(OU_CLUB_SCI_FI)); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1604,19 +1559,18 @@ public void test752GuybrushFuturePerfect() throws Exception { @Test public void test759CleanupGuybrush() throws Exception { final String TEST_NAME = "test759CleanupGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1631,9 +1585,8 @@ public void test759CleanupGuybrush() throws Exception { @Test public void test760GuybrushOrgGroupsRepo() throws Exception { final String TEST_NAME = "test760GuybrushOrgGroupsRepo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = dumpUserAndAccounts(USER_GUYBRUSH_OID); @@ -1641,11 +1594,11 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1659,18 +1612,17 @@ public void test760GuybrushOrgGroupsRepo() throws Exception { @Test public void test765ReconcileGuybrush() throws Exception { final String TEST_NAME = "test765ReconcileGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 1); @@ -1691,19 +1643,18 @@ public void test765ReconcileGuybrush() throws Exception { @Test public void test769CleanupGuybrush() throws Exception { final String TEST_NAME = "test769CleanupGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_ORG_GROUPING_REPO_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = dumpUserAndAccounts(USER_GUYBRUSH_OID); assertAssignments(userAfter, 0); @@ -1718,17 +1669,16 @@ public void test769CleanupGuybrush() throws Exception { @Test public void test780AssignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test780AssignGuybrushSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1743,9 +1693,8 @@ public void test780AssignGuybrushSwashbuckler() throws Exception { @Test public void test781GuybrushTheLostSwashbuckler() throws Exception { final String TEST_NAME = "test781GuybrushTheLostSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = getDummyResource().getGroupByName(GROUP_DUMMY_SWASHBUCKLERS_NAME); @@ -1753,11 +1702,11 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1767,17 +1716,16 @@ public void test781GuybrushTheLostSwashbuckler() throws Exception { @Test public void test784UnassignGuybrushSwashbuckler() throws Exception { final String TEST_NAME = "test784UnassignGuybrushSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(null, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1787,20 +1735,19 @@ public void test784UnassignGuybrushSwashbuckler() throws Exception { @Test public void test785AssignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test785AssignGuybrushBlueSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject group = prismContext.parseObject(SHADOW_GROUP_DUMMY_SWASHBUCKLERS_BLUE_FILE); addObject(group, task, result); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1815,9 +1762,8 @@ public void test785AssignGuybrushBlueSwashbuckler() throws Exception { @Test public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { final String TEST_NAME = "test786GuybrushTheLostBlueSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = getDummyResource(RESOURCE_DUMMY_BLUE_NAME).getGroupByName(GROUP_DUMMY_SWASHBUCKLERS_NAME); @@ -1825,11 +1771,11 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1839,17 +1785,16 @@ public void test786GuybrushTheLostBlueSwashbuckler() throws Exception { @Test public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { final String TEST_NAME = "test789UnassignGuybrushBlueSwashbuckler"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SWASHBUCKLER_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpUserAndAccounts(getUser(USER_GUYBRUSH_OID), task, result); assertNoGroupMember(getDummyGroup(RESOURCE_DUMMY_BLUE_NAME, GROUP_DUMMY_SWASHBUCKLERS_NAME), USER_GUYBRUSH_USERNAME); @@ -1862,9 +1807,8 @@ public void test789UnassignGuybrushBlueSwashbuckler() throws Exception { @Test public void test800AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test800AssignRoleSwashbucklerToJackNone"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1873,11 +1817,11 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1896,19 +1840,18 @@ public void test800AssignRoleSwashbucklerToJackNone() throws Exception { @Test public void test805ReconcileJackNone() throws Exception { final String TEST_NAME = "test805ReconcileJackNone"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1925,19 +1868,18 @@ public void test805ReconcileJackNone() throws Exception { @Test public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test809UnAssignRoleSwashbucklerFromJackNone"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1953,9 +1895,8 @@ public void test809UnAssignRoleSwashbucklerFromJackNone() throws Exception { @Test public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test810AssignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -1964,11 +1905,11 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1985,19 +1926,18 @@ public void test810AssignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test815ReconcileJackPositive() throws Exception { final String TEST_NAME = "test815ReconcileJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2014,19 +1954,18 @@ public void test815ReconcileJackPositive() throws Exception { @Test public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { final String TEST_NAME = "test817UnAssignRoleSwashbucklerFromJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2042,19 +1981,18 @@ public void test817UnAssignRoleSwashbucklerFromJackPositive() throws Exception { @Test public void test819ReconcileJackPositive() throws Exception { final String TEST_NAME = "test819ReconcileJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2075,9 +2013,8 @@ public void test819ReconcileJackPositive() throws Exception { @Test public void test820RecomputeJackFull() throws Exception { final String TEST_NAME = "test820RecomputeJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2086,11 +2023,11 @@ public void test820RecomputeJackFull() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2106,9 +2043,8 @@ public void test820RecomputeJackFull() throws Exception { @Test public void test822AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test822AssignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2117,11 +2053,11 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2138,19 +2074,18 @@ public void test822AssignRoleSwashbucklerToJackFull() throws Exception { @Test public void test825ReconcileJackFull() throws Exception { final String TEST_NAME = "test825ReconcileJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2167,19 +2102,18 @@ public void test825ReconcileJackFull() throws Exception { @Test public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { final String TEST_NAME = "test827UnAssignRoleSwashbucklerFromJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2195,19 +2129,18 @@ public void test827UnAssignRoleSwashbucklerFromJackFull() throws Exception { @Test public void test829ReconcileJackFull() throws Exception { final String TEST_NAME = "test829ReconcileJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2224,9 +2157,8 @@ public void test829ReconcileJackFull() throws Exception { @Test public void test830AssignJackAccountDummy() throws Exception { final String TEST_NAME = "test830AssignJackAccountDummy"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2235,11 +2167,11 @@ public void test830AssignJackAccountDummy() throws Exception { assertJackClean(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2255,9 +2187,8 @@ public void test830AssignJackAccountDummy() throws Exception { @Test public void test840AssignRoleSwashbucklerToJackNone() throws Exception { final String TEST_NAME = "test840AssignRoleSwashbucklerToJackNone"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2266,11 +2197,11 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2287,19 +2218,18 @@ public void test840AssignRoleSwashbucklerToJackNone() throws Exception { @Test public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { final String TEST_NAME = "test849UnassignRoleSwashbucklerFromJackNone"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2315,9 +2245,8 @@ public void test849UnassignRoleSwashbucklerFromJackNone() throws Exception { @Test public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test850AssignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -2326,11 +2255,11 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2347,19 +2276,18 @@ public void test850AssignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { final String TEST_NAME = "test859UnassignRoleSwashbucklerToJackPositive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2377,19 +2305,18 @@ public void test859UnassignRoleSwashbucklerToJackPositive() throws Exception { @Test public void test860RecomputeJackFull() throws Exception { final String TEST_NAME = "test860RecomputeJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2405,9 +2332,8 @@ public void test860RecomputeJackFull() throws Exception { @Test public void test862AssignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test862AssignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -2416,11 +2342,11 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { assertJackJustAccount(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2437,19 +2363,18 @@ public void test862AssignRoleSwashbucklerToJackFull() throws Exception { @Test public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { final String TEST_NAME = "test869UnassignRoleSwashbucklerToJackFull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SWASHBUCKLER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2465,19 +2390,18 @@ public void test869UnassignRoleSwashbucklerToJackFull() throws Exception { @Test public void test899UnAssignAccountJackDummy() throws Exception { final String TEST_NAME = "test899UnAssignAccountJackDummy"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2557,7 +2481,7 @@ private void dumpUsersAndTheirAccounts(Task task, OperationResult result) throws private void dumpUserAndAccounts(PrismObject user) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("dumpUserAndAccounts"); + Task task = getTestTask(); OperationResult result = task.getResult(); dumpUserAndAccounts(user, task, result); } @@ -2565,7 +2489,7 @@ private void dumpUserAndAccounts(PrismObject user) private PrismObject dumpUserAndAccounts(String userOid) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("dumpUserAndAccounts"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(userOid); dumpUserAndAccounts(user, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java index 8c57b3bc43b..0ac1594591b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestInbounds.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; @@ -58,17 +57,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ORANGE_OID, task); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess("Test orange resource", testResult); DummyResource dummyResourceOrange = getDummyResource(RESOURCE_DUMMY_ORANGE_NAME); @@ -78,10 +76,9 @@ public void test000Sanity() throws Exception { @Test public void test101ModifyUserSubtypePirate() throws Exception { final String TEST_NAME = "test101ModifyUserSubtypePirate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -92,11 +89,11 @@ public void test101ModifyUserSubtypePirate() throws Exception { .createXMLGregorianCalendar(System.currentTimeMillis())); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); jackEmployeeNumber = assertUserAfter(USER_JACK_OID) @@ -122,21 +119,20 @@ public void test101ModifyUserSubtypePirate() throws Exception { @Test public void test102ModifyUserSubtypeBuccaneer() throws Exception { final String TEST_NAME = "test102ModifyUserSubtypeBuccaneer"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "BUCCANEER"); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -157,10 +153,9 @@ public void test102ModifyUserSubtypeBuccaneer() throws Exception { @Test public void test103DeleteUserEmployeeTypeBartender() throws Exception { final String TEST_NAME = "test103ModifyUserEmployeeTypeBartender"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> deltas = new ArrayList<>(); @@ -198,21 +193,20 @@ public void test103DeleteUserEmployeeTypeBartender() throws Exception { @Test public void test200AssignAccountOrange() throws Exception { final String TEST_NAME = "test200AssignAccountOrange"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -241,10 +235,9 @@ public void test200AssignAccountOrange() throws Exception { @Test public void test202ModifyAccountOrangeGossip() throws Exception { final String TEST_NAME = "test202ModifyAccountOrangeGossip"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -286,10 +279,9 @@ public void test202ModifyAccountOrangeGossip() throws Exception { @Test public void test204AssignAccountOrangeAgain() throws Exception { final String TEST_NAME = "test204AssignAccountOrangeAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -330,10 +322,9 @@ public void test204AssignAccountOrangeAgain() throws Exception { @Test public void test209ModifyAccountOrangeGossipRemove() throws Exception { final String TEST_NAME = "test209ModifyAccountOrangeGossipRemove"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -376,10 +367,9 @@ public void test209ModifyAccountOrangeGossipRemove() throws Exception { @Test public void test210ModifyAccountOrangeQuoteMonkey() throws Exception { final String TEST_NAME = "test210ModifyAccountOrangeQuoteMonkey"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -427,10 +417,9 @@ public void test210ModifyAccountOrangeQuoteMonkey() throws Exception { @Test public void test211ModifyAccountOrangeQuotePirate() throws Exception { final String TEST_NAME = "test211ModifyAccountOrangeQuotePirate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -478,10 +467,9 @@ public void test211ModifyAccountOrangeQuotePirate() throws Exception { @Test public void test214ModifyAccountOrangeQuoteWoodchuck() throws Exception { final String TEST_NAME = "test214ModifyAccountOrangeQuoteWoodchuck"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -525,10 +513,9 @@ public void test214ModifyAccountOrangeQuoteWoodchuck() throws Exception { @Test public void test250UnlinkAccountDefaultDummy() throws Exception { final String TEST_NAME = "test250UnlinkAccountDefaultDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -570,10 +557,9 @@ public void test250UnlinkAccountDefaultDummy() throws Exception { @Test public void test252ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test252ModifyAccountOrangeGossipRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -616,10 +602,9 @@ public void test252ModifyAccountOrangeGossipRecon() throws Exception { @Test public void test259ModifyAccountOrangeGossipRemoveRecon() throws Exception { final String TEST_NAME = "test259ModifyAccountOrangeGossipRemoveRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -663,10 +648,9 @@ public void test259ModifyAccountOrangeGossipRemoveRecon() throws Exception { @Test public void test260ModifyAccountOrangeQuoteMonkeyRecon() throws Exception { final String TEST_NAME = "test260ModifyAccountOrangeQuoteMonkeyRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -718,10 +702,9 @@ public void test260ModifyAccountOrangeQuoteMonkeyRecon() throws Exception { @Test public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception { final String TEST_NAME = "test261ModifyAccountOrangeQuotePirateRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -768,10 +751,9 @@ public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception { @Test public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { final String TEST_NAME = "test264ModifyAccountOrangeQuoteWoodchuckRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -783,11 +765,11 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -816,10 +798,9 @@ public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception { @Test public void test297ModifyAccountOrangeGossipRecon() throws Exception { final String TEST_NAME = "test297ModifyAccountOrangeGossipRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -830,11 +811,11 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { display("Account orange before", dummyAccountBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_THIEF_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -858,10 +839,9 @@ public void test297ModifyAccountOrangeGossipRecon() throws Exception { @Test public void test299UnassignAccountOrange() throws Exception { final String TEST_NAME = "test299UnassignAccountOrange"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -869,11 +849,11 @@ public void test299UnassignAccountOrange() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_ORANGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java index ede644502b0..e6dc0fc48a9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIntent.java @@ -55,10 +55,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test131ModifyUserJackAssignAccountDefault() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccountDefault"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -70,11 +69,11 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -115,10 +114,9 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception { @Test public void test132ModifyUserJackAssignAccountTest() throws Exception { final String TEST_NAME="test132ModifyUserJackAssignAccountTest"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -130,11 +128,11 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -188,19 +186,18 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception { @Test public void test135ModifyUserJackFullName() throws Exception { final String TEST_NAME="test135ModifyUserJackFullName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("cpt. Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -250,10 +247,9 @@ public void test135ModifyUserJackFullName() throws Exception { @Test public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { final String TEST_NAME="test147ModifyUserJackUnAssignAccountDefault"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -265,11 +261,11 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -310,10 +306,9 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception { @Test public void test149ModifyUserJackUnassignAccountTest() throws Exception { final String TEST_NAME = "test149ModifyUserJackUnassignAccountTest"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java index e52dddd9ce1..06195eb4c2a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIteration.java @@ -227,10 +227,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100JackAssignAccountDummyConflicting() throws Exception { final String TEST_NAME = "test100JackAssignAccountDummyConflicting"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -245,11 +244,11 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -282,10 +281,9 @@ public void test100JackAssignAccountDummyConflicting() throws Exception { @Test public void test200JackAssignAccountDummyPinkConflicting() throws Exception { final String TEST_NAME = "test200JackAssignAccountDummyPinkConflicting"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -315,11 +313,11 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -366,21 +364,20 @@ public void test200JackAssignAccountDummyPinkConflicting() throws Exception { @Test public void test210GuybrushAssignAccountDummyPink() throws Exception { final String TEST_NAME = "test210GuybrushAssignAccountDummyPink"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userGuybrush = getUser(USER_GUYBRUSH_OID); @@ -419,10 +416,9 @@ public void test210GuybrushAssignAccountDummyPink() throws Exception { @Test public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { final String TEST_NAME = "test220DeWattAssignAccountDummyPinkCaseIgnore"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userDeWatt = createUser(USER_DEWATT_NAME, "Augustus DeWatt", true); @@ -443,11 +439,11 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -486,10 +482,9 @@ public void test220DeWattAssignAccountDummyPinkCaseIgnore() throws Exception { @Test public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception { final String TEST_NAME = "test230ScroogeAddAccountDummyConflictingNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -506,11 +501,11 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception userScrooge.asObjectable().getLinkRef().add(linkRef); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(DeltaFactory.Object.createAddDelta(userScrooge), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userScroogeAfter = findUserByUsername("scrooge"); @@ -538,10 +533,9 @@ public void test230ScroogeAddAccountDummyConflictingNoShadow() throws Exception @Test public void test235HackerAddAccountDummyEternalConflict() throws Exception { final String TEST_NAME = "test235HackerAddAccountDummyEternalConflict"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -555,14 +549,14 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { deltas.add(DeltaFactory.Object.createAddDelta(userJoeHacker)); // WHEN - displayWhen(TEST_NAME); + when(); // wrong behavior is throwing "java.lang.IllegalStateException: Model operation took too many clicks (limit is 30). Is there a cycle?" // good behavior is reporting ObjectAlreadyExistsException here modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -584,10 +578,9 @@ public void test235HackerAddAccountDummyEternalConflict() throws Exception { @Test public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception { final String TEST_NAME = "test240LargoAssignAccountDummyConflictingNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -601,11 +594,11 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_LARGO_OID, RESOURCE_DUMMY_PINK_OID, null, true); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(accountAssignmentUserDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userLargo = getUser(USER_LARGO_OID); @@ -652,10 +645,9 @@ public void test240LargoAssignAccountDummyConflictingNoShadow() throws Exception @Test public void test260JupiterConflictNoShadowSyncBack() throws Exception { final String TEST_NAME = "test260JupiterConflictNoShadowSyncBack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -669,11 +661,11 @@ public void test260JupiterConflictNoShadowSyncBack() throws Exception { PrismObject userJupiter = PrismTestUtil.parseObject(USER_JUPITER_FILE); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(DeltaFactory.Object.createAddDelta(userJupiter), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -713,21 +705,20 @@ public void test262JupiterCleanup() throws Exception { } protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, SchemaViolationException, ConflictException, InterruptedException { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", false); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -754,10 +745,9 @@ protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAl @Test public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { final String TEST_NAME = "test264JupiterConflictNoShadowSyncBackSeparate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -770,11 +760,11 @@ public void test264JupiterConflictNoShadowSyncBackSeparate() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -820,10 +810,9 @@ public void test266JupiterCleanupAgain() throws Exception { @Test public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { final String TEST_NAME = "test270JupiterConflictOtherNoShadowSyncBack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -836,11 +825,11 @@ public void test270JupiterConflictOtherNoShadowSyncBack() throws Exception { ObjectDelta delta = createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", true); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userJupiterAfter = findUserByUsername(USER_JUPITER_NAME); // jupiter @@ -902,10 +891,9 @@ private void assertUserJupiter(PrismObject user) { @Test public void test280RenameBobNoShadow() throws Exception { final String TEST_NAME = "test280RenameBobNoShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBob = createUser(USER_BOB_NAME, "Bob Andrews", true); @@ -932,11 +920,11 @@ public void test280RenameBobNoShadow() throws Exception { deltas.add(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject userBobAfter = getUser(userBobOid); display("User after change execution", userBobAfter); assertUser(userBobAfter, userBobOid, "bobby", "Bobby Andrews", null, null, null); @@ -963,10 +951,9 @@ public void test280RenameBobNoShadow() throws Exception { @Test public void test282RenamePeterNoShadowSync() throws Exception { final String TEST_NAME = "test282RenamePeterNoShadowSync"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userPeter = createUser("peter", "Peter Crenshaw", true); @@ -993,11 +980,11 @@ public void test282RenamePeterNoShadowSync() throws Exception { deltas.add(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject userPeteAfter = getUser(userPeterOid); display("User after change execution", userPeteAfter); assertUser(userPeteAfter, userPeterOid, "pete", "Pete Crenshaw", null, null, null); @@ -1040,10 +1027,9 @@ public void test282RenamePeterNoShadowSync() throws Exception { @Test public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { final String TEST_NAME = "test290AlfredConflictNoShadowSyncBackAdd"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1062,11 +1048,11 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { ObjectDelta delta = DeltaFactory.Object.createAddDelta(userAlfred); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAlfredAfter = findUserByUsername(USER_ALFRED_NAME); // alfred @@ -1092,10 +1078,9 @@ public void test290AlfredConflictNoShadowSyncBackAdd() throws Exception { @Test public void test300JackAssignAccountDummyVioletConflicting() throws Exception { final String TEST_NAME = "test300JackAssignAccountDummyVioletConflicting"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1112,11 +1097,11 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1159,10 +1144,9 @@ public void test300JackAssignAccountDummyVioletConflicting() throws Exception { @Test public void test350GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test350GuybrushAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1171,11 +1155,11 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1216,10 +1200,9 @@ public void test350GuybrushAssignAccountDummyViolet() throws Exception { @Test public void test360HermanAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test360HermanAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_HERMAN_FILE); @@ -1231,11 +1214,11 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1276,10 +1259,9 @@ public void test360HermanAssignAccountDummyViolet() throws Exception { @Test public void test400RenameAngelicaConflicting() throws Exception { final String TEST_NAME = "test400RenameAngelicaConflicting"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userLechuck = createUser(USER_ANGELICA_NAME, "Angelica", true); @@ -1310,10 +1292,9 @@ public void test400RenameAngelicaConflicting() throws Exception { @Test public void test500JackAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test500JackAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1322,11 +1303,11 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1379,10 +1360,9 @@ public void test500JackAssignAccountDummyMagenta() throws Exception { @Test public void test510DrakeAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test510DrakeAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userDrake = PrismTestUtil.parseObject(USER_DRAKE_FILE); @@ -1403,11 +1383,11 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1459,19 +1439,18 @@ public void test510DrakeAssignAccountDummyMagenta() throws Exception { @Test public void test520DrakeModifyLocality() throws Exception { final String TEST_NAME = "test520DrakeModifyLocality"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_DRAKE_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("London")); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1524,10 +1503,9 @@ public void test520DrakeModifyLocality() throws Exception { @Test public void test530GuybrushAssignAccountDummyMagenta() throws Exception { final String TEST_NAME = "test530GuybrushAssignAccountDummyMagenta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1536,11 +1514,11 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1591,19 +1569,18 @@ public void test530GuybrushAssignAccountDummyMagenta() throws Exception { @Test public void test532GuybrushModifyDescription() throws Exception { final String TEST_NAME = "test532GuybrushModifyDescription"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_DESCRIPTION, task, result, DESCRIPTION_RUM); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1655,20 +1632,19 @@ public void test532GuybrushModifyDescription() throws Exception { @Test public void test600JackRename() throws Exception { final String TEST_NAME = "test600JackRename"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_JACK_RENAMED_NAME)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1717,7 +1693,6 @@ public void test600JackRename() throws Exception { @Test public void test700DarkVioletSyncTask() throws Exception { final String TEST_NAME = "test700DarkVioletSyncTask"; - displayTestTitle(TEST_NAME); // WHEN importObjectFromFile(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_FILE); @@ -1732,7 +1707,6 @@ public void test700DarkVioletSyncTask() throws Exception { @Test public void test710DarkVioletAddLeChuck() throws Exception { final String TEST_NAME = "test710DarkVioletAddLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1742,7 +1716,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1750,7 +1724,7 @@ public void test710DarkVioletAddLeChuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); } @@ -1760,7 +1734,6 @@ public void test710DarkVioletAddLeChuck() throws Exception { @Test public void test712DarkVioletAddCharles() throws Exception { final String TEST_NAME = "test712DarkVioletAddCharles"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1770,7 +1743,7 @@ public void test712DarkVioletAddCharles() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1778,7 +1751,7 @@ public void test712DarkVioletAddCharles() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); } @@ -1789,7 +1762,6 @@ public void test712DarkVioletAddCharles() throws Exception { @Test public void test714DarkVioletAddShinetop() throws Exception { final String TEST_NAME = "test714DarkVioletAddShinetop"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1800,7 +1772,7 @@ public void test714DarkVioletAddShinetop() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1808,7 +1780,7 @@ public void test714DarkVioletAddShinetop() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1817,20 +1789,19 @@ public void test714DarkVioletAddShinetop() throws Exception { @Test public void test716DarkVioletDeleteCharles() throws Exception { final String TEST_NAME = "test716DarkVioletDeleteCharles"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_CHARLES_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Melee Island"); @@ -1839,7 +1810,6 @@ public void test716DarkVioletDeleteCharles() throws Exception { @Test public void test720DarkVioletModifyShinetopLocation() throws Exception { final String TEST_NAME = "test720DarkVioletModifyShinetopLocation"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1847,14 +1817,14 @@ public void test720DarkVioletModifyShinetopLocation() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Monkey Island"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1864,7 +1834,6 @@ public void test720DarkVioletModifyShinetopLocation() throws Exception { @Test public void test722DarkVioletModifyShinetopFullName() throws Exception { final String TEST_NAME = "test722DarkVioletModifyShinetopFullName"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1872,14 +1841,14 @@ public void test722DarkVioletModifyShinetopFullName() throws Exception { DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, CHUCKIE_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); @@ -1897,7 +1866,6 @@ public void test722DarkVioletModifyShinetopFullName() throws Exception { @Test public void test724DarkVioletAddLe_Chuck() throws Exception { final String TEST_NAME = "test724DarkVioletAddLe_Chuck"; - displayTestTitle(TEST_NAME); // GIVEN dummyAuditService.clear(); @@ -1908,7 +1876,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1916,7 +1884,7 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertUserNick(ACCOUNT_LE_CHUCK_USERNAME, LE_CHUCK_FULLNAME, LE_CHUCK_FULLNAME+".1", "Melee Island"); @@ -1931,10 +1899,9 @@ public void test724DarkVioletAddLe_Chuck() throws Exception { @Test public void test730DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test730DarkVioletAddBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1943,7 +1910,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1951,7 +1918,7 @@ public void test730DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); } @@ -1964,10 +1931,9 @@ public void test730DarkVioletAddBarbossa() throws Exception { @Test public void test732DarkVioletAddBarbossa() throws Exception { final String TEST_NAME = "test732DarkVioletAddBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1976,7 +1942,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -1984,7 +1950,7 @@ public void test732DarkVioletAddBarbossa() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".1"); assertUserNick("YA" + USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME+".4"); } @@ -1992,10 +1958,9 @@ public void test732DarkVioletAddBarbossa() throws Exception { @Test public void test750DarkVioletAddMatusalem() throws Exception { final String TEST_NAME = "test750DarkVioletAddMatusalem"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2008,7 +1973,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2016,7 +1981,7 @@ public void test750DarkVioletAddMatusalem() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); } @@ -2026,10 +1991,9 @@ public void test750DarkVioletAddMatusalem() throws Exception { @Test public void test752DarkVioletAddDiplomatico() throws Exception { final String TEST_NAME = "test752DarkVioletAddDiplomatico"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2038,7 +2002,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RUM_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2046,7 +2010,7 @@ public void test752DarkVioletAddDiplomatico() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); @@ -2061,10 +2025,9 @@ public void test752DarkVioletAddDiplomatico() throws Exception { @Test public void test754DarkVioletAddMilionario() throws Exception { final String TEST_NAME = "test754DarkVioletAddMilionario"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2074,7 +2037,7 @@ public void test754DarkVioletAddMilionario() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Peru"); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account); @@ -2082,7 +2045,7 @@ public void test754DarkVioletAddMilionario() throws Exception { waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2093,22 +2056,21 @@ public void test754DarkVioletAddMilionario() throws Exception { @Test public void test756DarkVioletDeleteDiplomatico() throws Exception { final String TEST_NAME = "test756DarkVioletDeleteDiplomatico"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).deleteAccountByName(ACCOUNT_DIPLOMATICO_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario, "Peru"); @@ -2117,24 +2079,23 @@ public void test756DarkVioletDeleteDiplomatico() throws Exception { @Test public void test760DarkVioletModifyMillonarioLocation() throws Exception { final String TEST_NAME = "test760DarkVioletModifyMillonarioLocation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Northern Peru"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2147,24 +2108,23 @@ public void test760DarkVioletModifyMillonarioLocation() throws Exception { @Test public void test762DarkVioletModifyMillonarioFullName() throws Exception { final String TEST_NAME = "test762DarkVioletModifyMillonarioFullName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); @@ -2178,24 +2138,23 @@ public void test762DarkVioletModifyMillonarioFullName() throws Exception { @Test public void test764DarkVioletModifyMatusalemFullName() throws Exception { final String TEST_NAME = "test764DarkVioletModifyMatusalemFullName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MATUSALEM_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN - displayThen(TEST_NAME); + then(); displayAllUsers(); assertNoUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); String iterationTokenMatusalem = lookupIterationTokenByAdditionalName(ACCOUNT_MATUSALEM_USERNAME); @@ -2212,10 +2171,9 @@ public void test764DarkVioletModifyMatusalemFullName() throws Exception { @Test public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { final String TEST_NAME = "test800UniqeEmailAddUserAlfredoFettucini"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2225,11 +2183,11 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { USER_FETTUCINI_NICKNAME, true); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2250,10 +2208,9 @@ public void test800UniqeEmailAddUserAlfredoFettucini() throws Exception { @Test public void test802UniqeEmailAddUserBillFettucini() throws Exception { final String TEST_NAME = "test802UniqeEmailAddUserBillFettucini"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2263,11 +2220,11 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { USER_BILL_FETTUCINI_FAMILY_NAME, USER_FETTUCINI_NICKNAME, true); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(user.getOid()); @@ -2287,10 +2244,9 @@ public void test802UniqeEmailAddUserBillFettucini() throws Exception { @Test public void test820SubtypeSetByInbound() throws Exception { final String TEST_NAME = "test820SubtypeSetByInbound"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -2311,12 +2267,12 @@ public void test820SubtypeSetByInbound() throws Exception { assertEquals("Wrong # of shadows", 2, shadows.size()); // WHEN - displayWhen(TEST_NAME); + when(); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(0).getOid(), task, result); importAccountsFromResourceTaskHandler.importSingleShadow(shadows.get(1).getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ObjectQuery userQuery = prismContext.queryFor(UserType.class) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java index f85e5339a86..a795680593f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestIterativeTasks.java @@ -71,16 +71,15 @@ private void createUser(OperationResult result, int number) throws ObjectAlready @Test public void test100RunBucketsMultithreaded() throws Exception { final String TEST_NAME = "test100RunBucketsMultithreaded"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_BUCKETS_MULTITHREADED_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_BUCKETS_MULTITHREADED_OID, false); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java index f186933438f..b08bf160ffe 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLifecycle.java @@ -88,13 +88,12 @@ protected File getSystemConfigurationFile() { @Test public void test050SetupJack() throws Exception { final String TEST_NAME = "test050SetupJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); assignRole(USER_JACK_OID, ROLE_GAMBLER_OID, task, result); @@ -104,7 +103,7 @@ public void test050SetupJack() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, USER_JACK_TELEPHONE_NUMBER); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -120,15 +119,14 @@ public void test050SetupJack() throws Exception { @Test public void test052PrincipalJackDraft() throws Exception { final String TEST_NAME = "test052AutzJackDraft"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertNotAuthorized(principal, AUTZ_GAMBLE_URL); assertNotAuthorized(principal, AUTZ_APPARATE_URL); @@ -143,17 +141,16 @@ public void test052PrincipalJackDraft() throws Exception { @Test public void test060TransitionJackToProposed() throws Exception { final String TEST_NAME = "test060TransitionJackToProposed"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result, SchemaConstants.LIFECYCLE_PROPOSED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -171,15 +168,14 @@ public void test060TransitionJackToProposed() throws Exception { @Test public void test062PrincipalJackProposed() throws Exception { final String TEST_NAME = "test062PrincipalJackProposed"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); // Although we are in the proposed lifecycle and assignments would not be active by default // the proposed lifecycle is forcing activation to enabled. Therefore also assignments are @@ -199,17 +195,16 @@ public void test062PrincipalJackProposed() throws Exception { @Test public void test090TransitionJackToDefaultActive() throws Exception { final String TEST_NAME = "test090TransitionJackToDefaultActive"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LIFECYCLE_STATE, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -225,15 +220,14 @@ public void test090TransitionJackToDefaultActive() throws Exception { @Test public void test092PrincipalJackDefaultActive() throws Exception { final String TEST_NAME = "test092PrincipalJackDefaultActive"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertAuthorized(principal, AUTZ_GAMBLE_URL); assertAuthorized(principal, AUTZ_APPARATE_URL); @@ -253,18 +247,17 @@ protected void assertLifecycleState(PrismObject object @Test public void test100AssignJackCaretaker() throws Exception { final String TEST_NAME = "test100AssignJackCaretaker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -278,18 +271,17 @@ public void test100AssignJackCaretaker() throws Exception { @Test public void test102UnassignJackHeadmaster() throws Exception { final String TEST_NAME = "test102UnassignJackHeadmaster"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -307,18 +299,17 @@ public void test102UnassignJackHeadmaster() throws Exception { @Test public void test110UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_CARETAKER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -335,18 +326,17 @@ public void test110UnassignJackCaretaker() throws Exception { @Test public void test112UnassignJackCaretaker() throws Exception { final String TEST_NAME = "test110UnassignJackCaretaker"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_HEADMASTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java index 2e35fe6d0a9..e8479b0b67a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestLoggingConfiguration.java @@ -65,14 +65,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001CreateSystemConfiguration() throws Exception { - final String TEST_NAME = "test001CreateSystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); PrismObject systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); ObjectDelta systemConfigurationAddDelta = DeltaFactory.Object.createAddDelta(systemConfiguration); Collection> deltas = MiscSchemaUtil.createCollection(systemConfigurationAddDelta); @@ -92,13 +89,10 @@ public void test001CreateSystemConfiguration() throws Exception { @Test public void test002InitialConfiguration() throws Exception { - final String TEST_NAME = "test002InitialConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE); @@ -146,13 +140,10 @@ public void test002InitialConfiguration() throws Exception { */ @Test public void test004OverwriteInitialConfiguration() throws Exception { - final String TEST_NAME = "test004OverwriteInitialConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value()); @@ -191,13 +182,10 @@ public void test004OverwriteInitialConfiguration() throws Exception { @Test public void test010AddModelSubsystemLogger() throws Exception { - final String TEST_NAME = "test010AddModelSubsystemLogger"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); // Precondition @@ -253,9 +241,6 @@ public void test010AddModelSubsystemLogger() throws Exception { @Test public void test020JulLoggingDisabled() throws Exception { - final String TEST_NAME = "test020JulLoggingDisabled"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); @@ -284,15 +269,12 @@ public void test020JulLoggingDisabled() throws Exception { @Test public void test021JulLoggingEnabled() throws Exception { - final String TEST_NAME = "test021JulLoggingEnabled"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(JUL_LOGGER_NAME); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); // Setup @@ -341,15 +323,12 @@ public void test021JulLoggingEnabled() throws Exception { */ @Test public void test030ConnectorLogging() throws Exception { - final String TEST_NAME = "test030ConnectorLogging"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); // ICF logging is prefixing the messages; tailer.setAllowPrefix(true); - Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); importObjectFromFile(RESOURCE_DUMMY_FILE, result); @@ -361,10 +340,10 @@ public void test030ConnectorLogging() throws Exception { applyTestLoggingConfig(logging); - ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType(); - classLogerCongif.setPackage(DummyConnector.class.getPackage().getName()); - classLogerCongif.setLevel(LoggingLevelType.ALL); - logging.getClassLogger().add(classLogerCongif); + ClassLoggerConfigurationType classLoggerConfig = new ClassLoggerConfigurationType(); + classLoggerConfig.setPackage(DummyConnector.class.getPackage().getName()); + classLoggerConfig.setLevel(LoggingLevelType.ALL); + logging.getClassLogger().add(classLoggerConfig); ObjectDelta systemConfigDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, @@ -375,9 +354,10 @@ public void test030ConnectorLogging() throws Exception { // INFO part - java.util.logging.Logger dummyConnctorJulLogger = java.util.logging.Logger.getLogger(DummyConnector.class.getName()); + java.util.logging.Logger dummyConnectorJulLogger = + java.util.logging.Logger.getLogger(DummyConnector.class.getName()); LOGGER.info("Dummy connector JUL logger as seen by the test: {}; classloader {}", - dummyConnctorJulLogger, dummyConnctorJulLogger.getClass().getClassLoader()); + dummyConnectorJulLogger, dummyConnectorJulLogger.getClass().getClassLoader()); // WHEN modelService.testResource(RESOURCE_DUMMY_OID, task); @@ -403,8 +383,6 @@ public void test030ConnectorLogging() throws Exception { @Test public void test101EnableBasicAudit() throws Exception { - TestUtil.displayTestTitle("test101EnableBasicAudit"); - // GIVEN LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME); @@ -417,7 +395,7 @@ public void test101EnableBasicAudit() throws Exception { // Setup PrismObject systemConfiguration = - PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); + PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging(); applyTestLoggingConfig(logging); @@ -468,15 +446,13 @@ public void test101EnableBasicAudit() throws Exception { // MID-5674 @Test public void test110SetMaxHistory() throws Exception { - TestUtil.displayTestTitle("test110SetMaxHistory"); - // GIVEN Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + ".test101EnableBasicAudit"); OperationResult result = task.getResult(); // Setup PrismObject systemConfiguration = - PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); + PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE); LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging(); applyTestLoggingConfig(logging); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java index 48ae6e10fb5..233651495f0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestMerge.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.util.FocusTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -71,7 +70,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); PrismObject userJackBefore = getUser(USER_JACK_OID); display("Jack before", userJackBefore); @@ -99,7 +97,6 @@ public void test000Sanity() throws Exception { @Test public void test100MergeJackGuybrushPreviewDelta() throws Exception { final String TEST_NAME = "test100MergeJackGuybrushPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -111,13 +108,13 @@ public void test100MergeJackGuybrushPreviewDelta() throws Exception { display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -162,19 +159,18 @@ public void test100MergeJackGuybrushPreviewDelta() throws Exception { @Test public void test102MergeJackGuybrushPreviewObject() throws Exception { final String TEST_NAME = "test102MergeJackGuybrushPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -213,7 +209,6 @@ public void test102MergeJackGuybrushPreviewObject() throws Exception { @Test public void test110MergeGuybrushJackPreviewDelta() throws Exception { final String TEST_NAME = "test110MergeGuybrushJackPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -225,13 +220,13 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception { display("Jack before", userJackBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -273,19 +268,18 @@ public void test110MergeGuybrushJackPreviewDelta() throws Exception { @Test public void test112MergeGuybrushJackPreviewObject() throws Exception { final String TEST_NAME = "test112MergeGuybrushJackPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_GUYBRUSH_OID, USER_JACK_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -321,7 +315,6 @@ public void test112MergeGuybrushJackPreviewObject() throws Exception { @Test public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { final String TEST_NAME = "test200MergeJackGuybrushExpressionPreviewDelta"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -333,13 +326,13 @@ public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -374,19 +367,18 @@ public void test200MergeJackGuybrushExpressionPreviewDelta() throws Exception { @Test public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { final String TEST_NAME = "test202MergeJackGuybrushExpressionPreviewObject"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject object = modelInteractionService.mergeObjectsPreviewObject(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_EXPRESSION_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -425,7 +417,6 @@ public void test202MergeJackGuybrushExpressionPreviewObject() throws Exception { @Test public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Exception { final String TEST_NAME = "test300MergeJackGuybrushPreviewDeltaDefaultSpecific"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -437,13 +428,13 @@ public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Excepti display("Guybrush before", userGuybrushBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MergeDeltas deltas = modelInteractionService.mergeObjectsPreviewDeltas(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_SPECIFIC_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -488,18 +479,17 @@ public void test300MergeJackGuybrushPreviewDeltaDefaultSpecific() throws Excepti @Test public void test500MergeJackGuybrush() throws Exception { final String TEST_NAME = "test500MergeJackGuybrush"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMerge.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.mergeObjects(UserType.class, USER_JACK_OID, USER_GUYBRUSH_OID, MERGE_CONFIG_DEFAULT_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java index c7be4d86f60..42d5fbf3cb2 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java @@ -60,7 +60,6 @@ public class TestModelCrudService extends AbstractInitializedModelIntegrationTes @Test public void test050AddResource() throws Exception { final String TEST_NAME = "test050AddResource"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + "." + TEST_NAME); @@ -87,7 +86,6 @@ public void test050AddResource() throws Exception { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + "." + TEST_NAME); @@ -133,7 +131,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test119ModifyUserDeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test119ModifyUserDeleteAccount"); @@ -173,7 +170,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test120AddAccount() throws Exception { - TestUtil.displayTestTitle(this, "test120AddAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test120AddAccount"); @@ -206,7 +202,6 @@ public void test120AddAccount() throws Exception { @Test public void test121ModifyUserAddAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test121ModifyUserAddAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test121ModifyUserAddAccountRef"); @@ -242,7 +237,6 @@ public void test121ModifyUserAddAccountRef() throws Exception { @Test public void test128ModifyUserDeleteAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test128ModifyUserDeleteAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test128ModifyUserDeleteAccountRef"); @@ -280,7 +274,6 @@ public void test128ModifyUserDeleteAccountRef() throws Exception { @Test public void test129DeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test129DeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test129DeleteAccount"); @@ -305,7 +298,6 @@ public void test129DeleteAccount() throws Exception { @Test public void test150AddUserBlackbeardWithAccount() throws Exception { - TestUtil.displayTestTitle(this, "test150AddUserBlackbeardWithAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test150AddUserBlackbeardWithAccount"); @@ -342,7 +334,6 @@ public void test150AddUserBlackbeardWithAccount() throws Exception { @Test public void test210AddUserMorganWithAssignment() throws Exception { - TestUtil.displayTestTitle(this, "test210AddUserMorganWithAssignment"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test210AddUserMorganWithAssignment"); @@ -377,7 +368,6 @@ public void test210AddUserMorganWithAssignment() throws Exception { @Test public void test220DeleteUserMorgan() throws Exception { - TestUtil.displayTestTitle(this, "test220DeleteUserMorgan"); // GIVEN Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test220DeleteUserMorgan"); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java index 1e3a0aa6486..bd8c306af06 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelServiceContract.java @@ -13,7 +13,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -55,7 +54,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; -import com.evolveum.midpoint.schema.internals.InternalOperationClasses; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; @@ -118,9 +116,8 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -140,9 +137,8 @@ public void test050GetUserJack() throws Exception { @Test public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -164,10 +160,9 @@ public void test051GetUserBarbossa() throws Exception { @Test public void test099ModifyUserAddAccountFailing() throws Exception { final String TEST_NAME = "test099ModifyUserAddAccountFailing"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -189,14 +184,14 @@ public void test099ModifyUserAddAccountFailing() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); } @@ -241,10 +236,9 @@ public void test099ModifyUserAddAccountFailing() throws Exception { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); getDummyResource().resetBreakMode(); @@ -252,11 +246,11 @@ public void test100ModifyUserAddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -331,10 +325,9 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test101GetAccount() throws Exception { final String TEST_NAME = "test101GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -393,7 +386,6 @@ public void test101GetAccount() throws Exception { @Test public void test102GetAccountNoFetch() throws Exception { - TestUtil.displayTestTitle(this, "test102GetAccountNoFetch"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test102GetAccountNoFetch"); @@ -420,7 +412,6 @@ public void test102GetAccountNoFetch() throws Exception { @Test public void test103GetAccountRaw() throws Exception { - TestUtil.displayTestTitle(this, "test103GetAccountRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test103GetAccountRaw"); @@ -447,7 +438,6 @@ public void test103GetAccountRaw() throws Exception { @Test public void test105SearchAccount() throws Exception { - TestUtil.displayTestTitle(this, "test105SearchAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test105SearchAccount"); @@ -479,7 +469,6 @@ public void test105SearchAccount() throws Exception { @Test public void test106SearchAccountWithoutResourceSchema() throws Exception { - TestUtil.displayTestTitle(this, "test106SearchAccountWithoutResourceSchema"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test106SearchAccountWithoutResourceSchema"); @@ -506,7 +495,6 @@ public void test106SearchAccountWithoutResourceSchema() throws Exception { @Test public void test108ModifyUserAddAccountAgain() throws Exception { - TestUtil.displayTestTitle(this, "test108ModifyUserAddAccountAgain"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test108ModifyUserAddAccountAgain"); @@ -555,10 +543,9 @@ public void test108ModifyUserAddAccountAgain() throws Exception { @Test public void test109ModifyUserAddAccountAgain() throws Exception { final String TEST_NAME = "test109ModifyUserAddAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -606,10 +593,9 @@ public void test109ModifyUserAddAccountAgain() throws Exception { @Test public void test110GetUserResolveAccount() throws Exception { final String TEST_NAME = "test110GetUserResolveAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -646,10 +632,9 @@ public void test110GetUserResolveAccount() throws Exception { @Test public void test111GetUserResolveAccountResource() throws Exception { final String TEST_NAME = "test111GetUserResolveAccountResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -689,10 +674,9 @@ public void test111GetUserResolveAccountResource() throws Exception { @Test public void test112GetUserResolveAccountNoFetch() throws Exception { final String TEST_NAME = "test112GetUserResolveAccountNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -732,10 +716,9 @@ public void test112GetUserResolveAccountNoFetch() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { final String TEST_NAME = "test119ModifyUserDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -749,11 +732,11 @@ public void test119ModifyUserDeleteAccount() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -805,7 +788,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test120AddAccount() throws Exception { final String TEST_NAME = "test120AddAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + "." + TEST_NAME); @@ -818,11 +800,11 @@ public void test120AddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); Collection> executeChanges = executeChanges(accountDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -882,10 +864,9 @@ public void test120AddAccount() throws Exception { @Test public void test121ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test121ModifyUserAddAccountRef"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -947,7 +928,6 @@ public void test121ModifyUserAddAccountRef() throws Exception { @Test public void test128ModifyUserDeleteAccountRef() throws Exception { - TestUtil.displayTestTitle(this, "test128ModifyUserDeleteAccountRef"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test128ModifyUserDeleteAccountRef"); @@ -1015,7 +995,6 @@ public void test128ModifyUserDeleteAccountRef() throws Exception { @Test public void test129DeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test129DeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test129DeleteAccount"); @@ -1074,7 +1053,6 @@ public void test129DeleteAccount() throws Exception { @Test public void test130PreviewModifyUserJackAssignAccount() throws Exception { - TestUtil.displayTestTitle(this, "test130PreviewModifyUserJackAssignAccount"); // GIVEN try{ @@ -1123,10 +1101,9 @@ public void test130PreviewModifyUserJackAssignAccount() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME="test131ModifyUserJackAssignAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1135,11 +1112,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1205,10 +1182,9 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test132ModifyAccountJackDummy() throws Exception { final String TEST_NAME = "test132ModifyAccountJackDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1297,19 +1273,18 @@ public void test132ModifyAccountJackDummy() throws Exception { @Test public void test135ModifyUserJackAssignAccountAgain() throws Exception { final String TEST_NAME="test135ModifyUserJackAssignAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess("executeChanges result", result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1361,21 +1336,20 @@ public void test135ModifyUserJackAssignAccountAgain() throws Exception { @Test public void test136JackRecomputeNoChange() throws Exception { final String TEST_NAME="test136JackRecomputeNoChange"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1424,10 +1398,9 @@ public void test136JackRecomputeNoChange() throws Exception { @Test public void test139ModifyUserJackUnassignAccount() throws Exception { final String TEST_NAME = "test139ModifyUserJackUnassignAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1487,10 +1460,9 @@ public void test139ModifyUserJackUnassignAccount() throws Exception { @Test public void test141ModifyUserJackAssignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test141ModifyUserJackAssignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1572,10 +1544,9 @@ public void test141ModifyUserJackAssignAccountPositiveEnforcement() throws Excep @Test public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test148ModifyUserJackUnassignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -1597,11 +1568,11 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // There is strong mapping. Complete account is fetched. assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -1668,10 +1639,9 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc @Test public void test149ModifyUserJackDeleteAccount() throws Exception { final String TEST_NAME = "test149ModifyUserJackDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -1741,10 +1711,9 @@ public void test149ModifyUserJackDeleteAccount() throws Exception { @Test public void test151ModifyUserJackAssignAccountRelativeEnforcement() throws Exception { final String TEST_NAME = "test151ModifyUserJackAssignAccountRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -1819,7 +1788,6 @@ public void test151ModifyUserJackAssignAccountRelativeEnforcement() throws Excep @Test public void test158ModifyUserJackUnassignAccountRelativeEnforcement() throws Exception { final String TEST_NAME = "test158ModifyUserJackUnassignAccountRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() @@ -1884,10 +1852,9 @@ public void test158ModifyUserJackUnassignAccountRelativeEnforcement() throws Exc @Test public void test161ModifyUserJackAssignAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test161ModifyUserJackAssignAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -1947,10 +1914,9 @@ public void test161ModifyUserJackAssignAccountNoneEnforcement() throws Exception @Test public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test163ModifyUserJackAddAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -2028,7 +1994,6 @@ public void test163ModifyUserJackAddAccountNoneEnforcement() throws Exception { @Test public void test164ModifyUserJackUnassignAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test164ModifyUserJackUnassignAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() @@ -2096,10 +2061,9 @@ public void test164ModifyUserJackUnassignAccountNoneEnforcement() throws Excepti @Test public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception { final String TEST_NAME = "test169ModifyUserJackDeleteAccountNoneEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.NONE); @@ -2164,10 +2128,9 @@ public void test169ModifyUserJackDeleteAccountNoneEnforcement() throws Exception @Test public void test180ModifyUserAddAccountFullEnforcement() throws Exception { final String TEST_NAME = "test180ModifyUserAddAccountFullEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2226,10 +2189,9 @@ public void test180ModifyUserAddAccountFullEnforcement() throws Exception { @Test public void test182ModifyUserAddAndAssignAccountPositiveEnforcement() throws Exception { final String TEST_NAME = "test182ModifyUserAddAndAssignAccountPositiveEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -2302,7 +2264,6 @@ public void test182ModifyUserAddAndAssignAccountPositiveEnforcement() throws Exc */ @Test public void test189ModifyUserJackUnassignAndDeleteAccount() throws Exception { - TestUtil.displayTestTitle(this, "test189ModifyUserJackUnassignAndDeleteAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test149ModifyUserJackUnassignAccount"); @@ -2361,10 +2322,9 @@ public void test189ModifyUserJackUnassignAndDeleteAccount() throws Exception { @Test public void test190ModifyUserJackAssignAccountAndModify() throws Exception { final String TEST_NAME = "test190ModifyUserJackAssignAccountAndModify"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2381,11 +2341,11 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -2447,10 +2407,9 @@ public void test190ModifyUserJackAssignAccountAndModify() throws Exception { @Test public void test191ModifyUserJackModifyAssignment() throws Exception { final String TEST_NAME = "test191ModifyUserJackModifyAssignment"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> deltas = new ArrayList<>(); @@ -2508,11 +2467,11 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { display("Deltas to execute execution", deltas); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -2562,20 +2521,19 @@ public void test191ModifyUserJackModifyAssignment() throws Exception { @Test public void test192ModifyUserJack() throws Exception { final String TEST_NAME = "test192ModifyUserJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Magnificent Captain Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2635,10 +2593,9 @@ public void test192ModifyUserJack() throws Exception { @Test public void test193ModifyUserJackLocationEmpty() throws Exception { final String TEST_NAME = "test193ModifyUserJackLocationEmpty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2702,10 +2659,9 @@ public void test193ModifyUserJackLocationEmpty() throws Exception { @Test public void test194ModifyUserJackLocationNull() throws Exception { final String TEST_NAME = "test194ModifyUserJackLocationNull"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -2736,19 +2692,18 @@ public void test194ModifyUserJackLocationNull() throws Exception { @Test public void test195ModifyUserJackLocationSea() throws Exception { final String TEST_NAME = "test195ModifyUserJackLocationSea"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("sea")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -2803,7 +2758,6 @@ public void test195ModifyUserJackLocationSea() throws Exception { @Test public void test198ModifyUserJackRaw() throws Exception { - TestUtil.displayTestTitle(this, "test198ModifyUserJackRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test196ModifyUserJackRaw"); @@ -2857,7 +2811,6 @@ public void test198ModifyUserJackRaw() throws Exception { @Test public void test199DeleteUserJack() throws Exception { - TestUtil.displayTestTitle(this, "test199DeleteUserJack"); // GIVEN Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName() + ".test199DeleteUserJack"); @@ -2921,10 +2874,9 @@ public void test199DeleteUserJack() throws Exception { @Test public void test200AddUserBlackbeardWithAccount() throws Exception { final String TEST_NAME = "test200AddUserBlackbeardWithAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // Use custom channel to trigger a special outbound mapping task.setChannel("http://pirates.net/avast"); OperationResult result = task.getResult(); @@ -3007,10 +2959,9 @@ public void test200AddUserBlackbeardWithAccount() throws Exception { @Test public void test210AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test210AddUserMorganWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3020,11 +2971,11 @@ public void test210AddUserMorganWithAssignment() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -3089,19 +3040,18 @@ public void test210AddUserMorganWithAssignment() throws Exception { @Test public void test212RenameUserMorgan() throws Exception { final String TEST_NAME = "test212RenameUserMorgan"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_MORGAN_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("sirhenry")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Strong mappings assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -3175,10 +3125,9 @@ public void test212RenameUserMorgan() throws Exception { @Test public void test240AddUserCharlesRaw() throws Exception { final String TEST_NAME = "test240AddUserCharlesRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3220,10 +3169,9 @@ public void test240AddUserCharlesRaw() throws Exception { @Test public void test241DeleteUserCharlesRaw() throws Exception { final String TEST_NAME = "test241DeleteUserCharlesRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3260,10 +3208,9 @@ public void test241DeleteUserCharlesRaw() throws Exception { @Test public void test300AddUserJackWithAssignmentBlue() throws Exception { final String TEST_NAME="test300AddUserJackWithAssignmentBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE); @@ -3276,11 +3223,11 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -3330,10 +3277,9 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception { @Test public void test302ModifyAccountJackDummyBlue() throws Exception { final String TEST_NAME = "test302ModifyAccountJackDummyBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); @@ -3397,11 +3343,8 @@ accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttr @Test // MID-5516 public void test400RemoveExtensionProtectedStringValue() throws Exception { - final String TEST_NAME = "test400RemoveExtensionProtectedStringValue"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java index 16935396520..17efd1c8c83 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelVisualization.java @@ -38,8 +38,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100VisualizeOneResource() throws Exception { final String TEST_NAME = "test100VisualizeOneResource"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN Task task = taskManager.createTaskInstance(TestModelVisualization.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -58,8 +56,6 @@ public void test100VisualizeOneResource() throws Exception { public void test110VisualizeTwoResources() throws Exception { final String TEST_NAME = "test110VisualizeTwoResources"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN Task task = taskManager.createTaskInstance(TestModelVisualization.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java index 3ddf06de60d..90d38b2af3e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestNotifications.java @@ -49,7 +49,6 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.concurrent.Executor; import static java.util.Collections.singletonList; import static org.testng.AssertJUnit.*; @@ -124,7 +123,6 @@ private int findFreePort() throws IOException { @Test public void test100ModifyUserAddAccount() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + ".test100ModifyUserAddAccount"); @@ -135,11 +133,11 @@ public void test100ModifyUserAddAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -215,7 +213,6 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test119ModifyUserDeleteAccount() throws Exception { final String TEST_NAME = "test119ModifyUserDeleteAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -233,11 +230,11 @@ public void test119ModifyUserDeleteAccount() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -289,7 +286,6 @@ public void test119ModifyUserDeleteAccount() throws Exception { @Test public void test131ModifyUserJackAssignAccount() throws Exception { final String TEST_NAME = "test131ModifyUserJackAssignAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -299,11 +295,11 @@ public void test131ModifyUserJackAssignAccount() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -364,7 +360,6 @@ public void test131ModifyUserJackAssignAccount() throws Exception { @Test public void test140ModifyUserJackAssignRole() throws Exception { final String TEST_NAME = "test135ModifyUserJackAssignRole"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -372,11 +367,11 @@ public void test140ModifyUserJackAssignRole() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -417,7 +412,6 @@ public void test140ModifyUserJackAssignRole() throws Exception { @Test public void test150ModifyUserJackModifyAssignment() throws Exception { final String TEST_NAME = "test150ModifyUserJackModifyAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -425,7 +419,7 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType assignment = findAssignmentByTargetRequired(jack, ROLE_SUPERUSER_OID); Long id = assignment.getId(); @@ -436,7 +430,7 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { .asObjectDeltaCast(jack.getOid()), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -479,7 +473,6 @@ public void test150ModifyUserJackModifyAssignment() throws Exception { @Test public void test160ModifyUserJackDeleteAssignment() throws Exception { final String TEST_NAME = "test160ModifyUserJackDeleteAssignment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -487,7 +480,7 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject jack = getUser(USER_JACK_OID); AssignmentType assignment = findAssignmentByTargetRequired(jack, ROLE_SUPERUSER_OID); Long id = assignment.getId(); @@ -498,7 +491,7 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { .asObjectDeltaCast(jack.getOid()), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -538,20 +531,19 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception { @Test public void test200SendSmsUsingGet() { final String TEST_NAME = "test200SendSmsUsingGet"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "get", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -563,20 +555,19 @@ public void test200SendSmsUsingGet() { @Test public void test210SendSmsUsingPost() { final String TEST_NAME = "test210SendSmsUsingPost"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "post", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -596,20 +587,19 @@ public void test210SendSmsUsingPost() { @Test public void test215SendSmsUsingGeneralPost() { final String TEST_NAME = "test215SendSmsUsingGeneralPost"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "general-post", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -629,20 +619,19 @@ public void test215SendSmsUsingGeneralPost() { @Test public void test220SendSmsViaProxy() { final String TEST_NAME = "test220SendSmsViaProxy"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "get-via-proxy", null, "hello world via proxy", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -655,7 +644,6 @@ public void test220SendSmsViaProxy() { @Test public void test300CheckVariables() { final String TEST_NAME = "test300CheckVariables"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -664,13 +652,13 @@ public void test300CheckVariables() { prepareNotifications(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); Event event = new CustomEvent(lightweightIdentifierGenerator, "check-variables", null, "hello world", EventOperationType.ADD, EventStatusType.SUCCESS, null); notificationManager.processEvent(event, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("processEvent result", result); @@ -681,7 +669,6 @@ public void test300CheckVariables() { @Test public void test400StringAttachment() throws Exception { final String TEST_NAME = "test400StringAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -689,14 +676,14 @@ public void test400StringAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testStringAttachmentUser") .asPrismObject(); addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -718,7 +705,6 @@ public void test400StringAttachment() throws Exception { @Test public void test410ByteAttachment() throws Exception { final String TEST_NAME = "test410ByteAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -726,14 +712,14 @@ public void test410ByteAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testByteAttachmentUser") .asPrismObject(); addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -769,7 +755,6 @@ public void test410ByteAttachment() throws Exception { @Test public void test420AttachmentFromFile() throws Exception { final String TEST_NAME = "test420AttachmentFromFile"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -777,14 +762,14 @@ public void test420AttachmentFromFile() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testAttachmentFromFileUser") .asPrismObject(); addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); @@ -805,7 +790,6 @@ public void test420AttachmentFromFile() throws Exception { @Test public void test430ExpressionAttachment() throws Exception { final String TEST_NAME = "test430ExpressionAttachment"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); @@ -813,14 +797,14 @@ public void test430ExpressionAttachment() throws Exception { preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = new UserType(prismContext) .name("testExpressionAttachmentUser") .asPrismObject(); addObject(user); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java index 946d4a7f7a7..e51648774c6 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestOptimizingTriggerCreator.java @@ -9,7 +9,6 @@ import com.evolveum.midpoint.model.api.expr.OptimizingTriggerCreator; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -34,7 +33,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100CreateThreeTriggers() throws Exception { final String TEST_NAME = "test100CreateThreeTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); boolean first = creator.createForNamedUser(USER_JACK_USERNAME); @@ -51,9 +49,9 @@ public void test100CreateThreeTriggers() throws Exception { @Test public void test110CreateTriggersWithUserDeletion() throws Exception { final String TEST_NAME = "test110CreateTriggersWithUserDeletion"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); @@ -83,7 +81,6 @@ public void test110CreateTriggersWithUserDeletion() throws Exception { @Test public void test200CreateThreeTriggersByOid() throws Exception { final String TEST_NAME = "test200CreateThreeTriggersByOid"; - TestUtil.displayTestTitle(this, TEST_NAME); OptimizingTriggerCreator creator = libraryMidpointFunctions.getOptimizingTriggerCreator(60000, 2000); boolean first = creator.createForObject(UserType.class, USER_BARBOSSA_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java index f7462ea2b8f..c90edae8443 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestPreviewChanges.java @@ -22,10 +22,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.ObjectChecker; -import com.evolveum.midpoint.test.ObjectSource; +import com.evolveum.midpoint.test.*; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -146,10 +143,9 @@ public void check(ModelContext modelContext) { private void modifyUserAddAccountImplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "Implicit"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -168,10 +164,9 @@ private void modifyUserAddAccountImplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "Explicit"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -187,10 +182,9 @@ private void modifyUserAddAccountExplicit(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitSame"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -210,10 +204,9 @@ private void modifyUserAddAccountImplicitExplicitSame(String bundleName, private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitSameReverse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -233,10 +226,9 @@ private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, private void modifyUserAddAccountImplicitExplicitEqual(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitEqual"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -256,10 +248,9 @@ private void modifyUserAddAccountImplicitExplicitEqual(String bundleName, private void modifyUserAddAccountImplicitExplicitEqualReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitEqualReverse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -279,10 +270,9 @@ private void modifyUserAddAccountImplicitExplicitEqualReverse(String bundleName, private void modifyUserAddAccountImplicitExplicitNotEqual(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitNotEqual"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -304,10 +294,9 @@ private void modifyUserAddAccountImplicitExplicitNotEqual(String bundleName, private void modifyUserAddAccountImplicitExplicitNotEqualReverse(String bundleName, ObjectSource> accountSource, ObjectChecker> checker) throws Exception { final String TEST_NAME = bundleName + "ImplicitExplicitNotEqualReverse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = accountSource.get(); @@ -405,10 +394,9 @@ private void assertAddAccount(ModelContext modelContext, boolean expec @Test public void test130GetCompiledGuiProfile() throws Exception { final String TEST_NAME = "test130GetCompiledGuiProfile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -434,10 +422,9 @@ public void test130GetCompiledGuiProfile() throws Exception { @Test public void test150GetGuybrushRefinedObjectClassDef() throws Exception { final String TEST_NAME = "test150GetGuybrushRefinedObjectClassDef"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = getShadowModel(ACCOUNT_SHADOW_GUYBRUSH_OID); @@ -459,10 +446,9 @@ public void test150GetGuybrushRefinedObjectClassDef() throws Exception { @Test public void test200ModifyUserGuybrushDeleteAccount() throws Exception { final String TEST_NAME = "test200ModifyUserGuybrushDeleteAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -478,11 +464,11 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -509,10 +495,9 @@ public void test200ModifyUserGuybrushDeleteAccount() throws Exception { @Test public void test210GuybrushAddAccount() throws Exception { final String TEST_NAME = "test210GuybrushAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -522,11 +507,11 @@ public void test210GuybrushAddAccount() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -560,10 +545,9 @@ public void test210GuybrushAddAccount() throws Exception { @Test public void test212ModifyUserAddAccountRef() throws Exception { final String TEST_NAME = "test212ModifyUserAddAccountRef"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -576,11 +560,11 @@ public void test212ModifyUserAddAccountRef() throws Exception { display("Input deltas: ", userDelta); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -618,10 +602,9 @@ public void test212ModifyUserAddAccountRef() throws Exception { @Test public void test220PreviewJackAssignRolePirate() throws Exception { final String TEST_NAME = "test220PreviewJackAssignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -629,12 +612,12 @@ public void test220PreviewJackAssignRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -646,10 +629,9 @@ public void test220PreviewJackAssignRolePirate() throws Exception { @Test public void test221PreviewJackAssignRolePirateReconcile() throws Exception { final String TEST_NAME = "test221PreviewJackAssignRolePirateReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -661,12 +643,12 @@ public void test221PreviewJackAssignRolePirateReconcile() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertPreviewJackAssignRolePirate(modelContext); @@ -750,10 +732,9 @@ private void assertPreviewJackAssignRolePirate(ModelContext modelConte @Test public void test230GuybrushAssignAccountDummy() throws Exception { final String TEST_NAME = "test230GuybrushAssignAccountDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -763,13 +744,13 @@ public void test230GuybrushAssignAccountDummy() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, ItemPath.create(UserType.F_EXTENSION, PIRACY_WEAPON), task, result, "tongue"); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountGuybrushOid = assertUserAfter(USER_GUYBRUSH_OID) @@ -788,22 +769,21 @@ public void test230GuybrushAssignAccountDummy() throws Exception { @Test public void test231PreviewGuybrushModifyAccountFullName() throws Exception { final String TEST_NAME = "test231PreviewGuybrushModifyAccountFullName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountGuybrushOid, dummyResourceCtl.getAttributeFullnamePath(), "Mighty Pirate Guybrush Threepwood"); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -841,10 +821,9 @@ public void test231PreviewGuybrushModifyAccountFullName() throws Exception { @Test public void test232PreviewGuybrushModifyAccountShip() throws Exception { final String TEST_NAME = "test232PreviewGuybrushModifyAccountShip"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -852,12 +831,12 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { "The Mad Monkey"); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(accountDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -893,10 +872,9 @@ public void test232PreviewGuybrushModifyAccountShip() throws Exception { @Test public void test233PreviewGuybrushAddRolePirate() throws Exception { final String TEST_NAME = "test233PreviewGuybrushAddRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -904,12 +882,12 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -960,10 +938,9 @@ public void test233PreviewGuybrushAddRolePirate() throws Exception { @Test public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { final String TEST_NAME = "test234PreviewGuybrushAddRolePirateRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -973,12 +950,12 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createReconcile(); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), options, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1029,10 +1006,9 @@ public void test234PreviewGuybrushAddRolePirateRecon() throws Exception { @Test public void test236PreviewGuybrushAddRoleSailor() throws Exception { final String TEST_NAME = "test236PreviewGuybrushAddRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1040,12 +1016,12 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1083,10 +1059,9 @@ public void test236PreviewGuybrushAddRoleSailor() throws Exception { @Test public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { final String TEST_NAME = "test238PreviewGuybrushAddRoleSailorOwner"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1094,12 +1069,12 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_OWNER, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1121,19 +1096,18 @@ public void test238PreviewGuybrushAddRoleSailorOwner() throws Exception { @Test public void test239GuybrushUnAssignAccountDummy() throws Exception { final String TEST_NAME = "test239GuybrushUnAssignAccountDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1147,19 +1121,18 @@ public void test239GuybrushUnAssignAccountDummy() throws Exception { @Test public void test240GuybrushAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test240GuybrushAssignAccountDummyRelative"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1176,10 +1149,9 @@ public void test240GuybrushAssignAccountDummyRelative() throws Exception { @Test public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { final String TEST_NAME = "test242PreviewGuybrushAddRolePirateRelative"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1187,12 +1159,12 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1244,10 +1216,9 @@ public void test242PreviewGuybrushAddRolePirateRelative() throws Exception { @Test public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception { final String TEST_NAME = "test244PreviewGuybrushAddRolePirateRelativeRecon"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1255,12 +1226,12 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception ROLE_PIRATE_RELATIVE_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1309,19 +1280,18 @@ public void test244PreviewGuybrushAddRolePirateRelativeRecon() throws Exception @Test public void test249GuybrushUnAssignAccountDummyRelative() throws Exception { final String TEST_NAME = "test249GuybrushUnAssignAccountDummyRelative"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1363,10 +1333,9 @@ private void assertAccountItemModify(ObjectDelta accountDelta, @Test public void test300ModifyElaineAccountDummyReplace() throws Exception { final String TEST_NAME = "test300ModifyElaineAccountDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1419,10 +1388,9 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_OID, getDummyResourceObject(), DummyResourceContolle @Test public void test301ModifyElaineAccountDummyDeleteAdd() throws Exception { final String TEST_NAME = "test301ModifyElaineAccountDummyDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1480,10 +1448,9 @@ public void test301ModifyElaineAccountDummyDeleteAdd() throws Exception { @Test public void test400ModifyElaineAccountDummyRedReplace() throws Exception { final String TEST_NAME = "test400ModifyElaineAccountDummyRedReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1494,11 +1461,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, getDummyResourceObject(RESOURCE_DUMMY_RED_N display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertPartialError(result); } @@ -1511,10 +1478,9 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, getDummyResourceObject(RESOURCE_DUMMY_RED_N @Test public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { final String TEST_NAME = "test401ModifyElaineAccountDummyRedDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1527,12 +1493,12 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); display("Preview context", modelContext); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); } @@ -1544,10 +1510,9 @@ public void test401ModifyElaineAccountDummyRedDeleteAdd() throws Exception { @Test public void test500ModifyElaineAccountDummyBlueReplace() throws Exception { final String TEST_NAME = "test500ModifyElaineAccountDummyBlueReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1600,10 +1565,9 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE @Test public void test501ModifyElaineAccountDummyBlueDeleteAdd() throws Exception { final String TEST_NAME = "test501ModifyElaineAccountDummyBlueDeleteAdd"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1664,10 +1628,9 @@ public void test501ModifyElaineAccountDummyBlueDeleteAdd() throws Exception { @Test public void test600ModifyElaineUserDummyReplace() throws Exception { final String TEST_NAME = "test600ModifyElaineUserDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1677,11 +1640,11 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1757,10 +1720,9 @@ public void test600ModifyElaineUserDummyReplace() throws Exception { @Test public void test610ModifyElaineUserAccountDummyReplace() throws Exception { final String TEST_NAME = "test610ModifyElaineUserAccountDummyReplace"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1781,11 +1743,11 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE display("Input deltas: ", deltas); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(deltas, new ModelExecuteOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); @@ -1861,10 +1823,9 @@ ACCOUNT_SHADOW_ELAINE_DUMMY_BLUE_OID, getDummyResourceObject(RESOURCE_DUMMY_BLUE @Test public void test620AddUserCapsize() throws Exception { final String TEST_NAME = "test620AddUserCapsize"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1952,10 +1913,9 @@ public void test620AddUserCapsize() throws Exception { @Test public void test630AddUserRogers() throws Exception { final String TEST_NAME = "test630AddUserRogers"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2050,10 +2010,9 @@ public void test630AddUserRogers() throws Exception { @Test public void test700DisableElaineAccountTwoResources() throws Exception { final String TEST_NAME = "test700DisableElaineAccountTwoResources"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2127,10 +2086,9 @@ public void test700DisableElaineAccountTwoResources() throws Exception { @Test public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { final String TEST_NAME = "test710PreviewGuybrushHavingRoleSailorOwner"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2139,12 +2097,12 @@ public void test710PreviewGuybrushHavingRoleSailorOwner() throws Exception { ObjectDelta empty = prismContext.deltaFor(UserType.class).asObjectDeltaCast(USER_GUYBRUSH_OID); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(singleton(empty), createEvaluateAllAssignmentRelationsOnRecompute(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("Preview context", modelContext); assertNotNull("Null model context", modelContext); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java index a7ebc2bd027..b8156f99141 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestRaceConditions.java @@ -51,14 +51,13 @@ protected ConflictResolutionActionType getDefaultConflictResolutionAction() { @Test public void test100AssignRoles() throws Exception { final String TEST_NAME="test100AssignRoles"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); @SuppressWarnings({"raw"}) ObjectDelta objectDelta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( @@ -68,7 +67,7 @@ public void test100AssignRoles() throws Exception { executeChangesAssertSuccess(objectDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); assertUserJack(userJack); @@ -93,7 +92,6 @@ public void test100AssignRoles() throws Exception { @Test public void test110UnassignRoles() throws Exception { final String TEST_NAME = "test110UnassignRoles"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestRaceConditions.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java index 004cab768fb..0fac7c4f8be 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestResources.java @@ -146,10 +146,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test050GetResourceRaw() throws Exception { final String TEST_NAME = "test050GetResourceRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -166,11 +165,11 @@ public void test050GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -196,10 +195,9 @@ public void test050GetResourceRaw() throws Exception { @Test public void test052GetResourceNoFetch() throws Exception { final String TEST_NAME = "test052GetResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -217,12 +215,12 @@ public void test052GetResourceNoFetch() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -248,10 +246,9 @@ public void test052GetResourceNoFetch() throws Exception { @Test public void test053GetResourceNoFetchAgain() throws Exception { final String TEST_NAME = "test053GetResourceNoFetchAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -269,12 +266,12 @@ public void test053GetResourceNoFetchAgain() throws Exception { GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -302,10 +299,9 @@ public void test053GetResourceNoFetchAgain() throws Exception { @Test public void test055GetResourceNoFetchReadOnly() throws Exception { final String TEST_NAME = "test055GetResourceNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -324,12 +320,12 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -357,10 +353,9 @@ public void test055GetResourceNoFetchReadOnly() throws Exception { @Test public void test100SearchResourcesNoFetch() throws Exception { final String TEST_NAME = "test100SearchResourcesNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -371,11 +366,11 @@ public void test100SearchResourcesNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -406,10 +401,9 @@ public void test100SearchResourcesNoFetch() throws Exception { @Test public void test102SearchResourcesNoFetchReadOnly() throws Exception { final String TEST_NAME = "test102SearchResourcesNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -422,11 +416,11 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -457,10 +451,9 @@ public void test102SearchResourcesNoFetchReadOnly() throws Exception { @Test public void test105SearchResourcesIterativeNoFetch() throws Exception { final String TEST_NAME = "test105SearchResourcesIterativeNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -479,11 +472,11 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); // WHEN - displayWhen(TEST_NAME); + when(); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -509,10 +502,9 @@ public void test105SearchResourcesIterativeNoFetch() throws Exception { @Test public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { final String TEST_NAME = "test107SearchResourcesIterativeNoFetchReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -533,11 +525,11 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { Collection> options = SelectorOptions.createCollection(option); // WHEN - displayWhen(TEST_NAME); + when(); modelService.searchObjectsIterative(ResourceType.class, null, handler, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertFalse("Empty search return", resources.isEmpty()); @@ -560,21 +552,20 @@ public void test107SearchResourcesIterativeNoFetchReadOnly() throws Exception { @Test public void test110GetResourceDummy() throws Exception { final String TEST_NAME = "test110GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 4); @@ -603,10 +594,9 @@ public void test110GetResourceDummy() throws Exception { @Test public void test112GetResourceDummyReadOnly() throws Exception { final String TEST_NAME = "test112GetResourceDummyReadOnly"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -616,12 +606,12 @@ public void test112GetResourceDummyReadOnly() throws Exception { GetOperationOptions.createReadOnly()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -645,7 +635,6 @@ public void test112GetResourceDummyReadOnly() throws Exception { @Test public void test120SearchResources() throws Exception { final String TEST_NAME = "test120SearchResources"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -656,11 +645,11 @@ public void test120SearchResources() throws Exception { assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(); List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertNotNull("null search return", resources); assertFalse("Empty search return", resources.isEmpty()); assertEquals("Unexpected number of resources found", 2, resources.size()); @@ -687,7 +676,6 @@ public void test120SearchResources() throws Exception { @Test public void test125SearchResourcesIterative() throws Exception { final String TEST_NAME = "test125SearchResourcesIterative"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -806,7 +794,6 @@ private void assertResource(PrismObject resource, boolean expectSc @Test public void test200GetResourceRawAfterSchema() throws Exception { final String TEST_NAME = "test200GetResourceRawAfterSchema"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestResources.class.getName() + "." + TEST_NAME); @@ -836,21 +823,20 @@ public void test200GetResourceRawAfterSchema() throws Exception { @Test public void test210GetResourceDummyRed() throws Exception { final String TEST_NAME = "test210GetResourceDummyRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_RED_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -872,10 +858,9 @@ public void test210GetResourceDummyRed() throws Exception { @Test public void test750GetResourceRaw() throws Exception { final String TEST_NAME = "test750GetResourceRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); @@ -891,11 +876,11 @@ public void test750GetResourceRaw() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, options , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource", resource); @@ -915,21 +900,20 @@ public void test750GetResourceRaw() throws Exception { @Test public void test752GetResourceDummy() throws Exception { final String TEST_NAME = "test752GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -949,20 +933,19 @@ public void test752GetResourceDummy() throws Exception { @Test public void test760ModifyConfigurationString() throws Exception { final String TEST_NAME = "test760ModifyConfigurationString"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta resourceDelta = createConfigurationPropertyDelta(IntegrationTestTools.RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME, "whatever wherever"); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -976,21 +959,20 @@ public void test760ModifyConfigurationString() throws Exception { @Test public void test761ModifyConfigurationStringRaw() throws Exception { final String TEST_NAME = "test761ModifyConfigurationStringRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta resourceDelta = createConfigurationPropertyDelta(IntegrationTestTools.RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME, "whatever raw wherever"); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(resourceDelta), ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -1045,9 +1027,8 @@ public void handleGlobalError(OperationResult currentResult) { private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, FailableFunction> parser) throws Exception { - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -1069,11 +1050,11 @@ private void modifyConfigurationDiffExpressionRaw(final String TEST_NAME, display("Diff delta", diffDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(diffDelta, ModelExecuteOptions.createRaw(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_INSTANCE_INITIALIZATION_COUNT, 0); @@ -1118,21 +1099,20 @@ private ItemPath getConfigurationPropertyPath(QName elementQName) { @Test public void test800GetResourceDummy() throws Exception { final String TEST_NAME = "test800GetResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE); rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 1); @@ -1152,9 +1132,8 @@ public void test800GetResourceDummy() throws Exception { @Test public void test820SingleDescriptionModify() throws Exception { final String TEST_NAME = "test820SingleDescriptionModify"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); singleModify(descriptionAnt, -1, task, result); @@ -1162,9 +1141,7 @@ public void test820SingleDescriptionModify() throws Exception { // @Test // public void test835ModifySchemaHandling() throws Exception { -// final String TEST_NAME = "test835ModifySchemaHandling"; -// displayTestTitle(TEST_NAME); -// +// // // Task task = createTask(TEST_NAME); // OperationResult result = task.getResult(); // CarefulAnt ant = ants.get(1); @@ -1174,9 +1151,8 @@ public void test820SingleDescriptionModify() throws Exception { @Test public void test840RandomModifySequence() throws Exception { final String TEST_NAME = "test840RandomModifySequence"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for(int i=0; i <= MAX_RANDOM_SEQUENCE_ITERATIONS; i++) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java index f73d6ddc4d1..1724860ba06 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestSchemalessResource.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; /** @@ -44,9 +43,8 @@ public TestSchemalessResource() throws JAXBException { @Test public void test001GetObject() throws Exception { final String TEST_NAME = "test001GetObject"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -59,9 +57,8 @@ public void test001GetObject() throws Exception { @Test public void test002TestConnection() throws Exception { final String TEST_NAME = "test002TestConnection"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_SCHEMALESS_OID, task); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java index 6b7a920003e..a4db2de84f1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestScriptHooks.java @@ -84,7 +84,6 @@ protected File getSystemConfigurationFile() { @Test public void test100JackAssignHookAccount() throws Exception { final String TEST_NAME = "test100JackAssignHookAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestScriptHooks.class.getName() + "." + TEST_NAME); @@ -138,7 +137,6 @@ public void test100JackAssignHookAccount() throws Exception { @Test public void test110JackAddOrganization() throws Exception { final String TEST_NAME = "test110JackAddOrganization"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestScriptHooks.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java index 88fb45fd645..0a8d0919d3f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestStrangeCases.java @@ -139,8 +139,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - setAutoTaskManagementEnabled(true); - initDummyResource(RESOURCE_DUMMY_CIRCUS_NAME, RESOURCE_DUMMY_CIRCUS_FILE, RESOURCE_DUMMY_CIRCUS_OID, initTask, initResult); getDummyResourceController(RESOURCE_DUMMY_RED_NAME).addAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", "Monkey Island"); @@ -200,8 +198,8 @@ public void test010SanityAdministrator() throws Exception { @Test public void test050AddRoleRecursionAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -233,8 +231,8 @@ public void test050AddRoleRecursionAssignment() throws Exception { @Test public void test060AddRoleStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -256,8 +254,8 @@ public void test060AddRoleStupidAssignment() throws Exception { @Test public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -359,8 +357,8 @@ public void test100ModifyUserGuybrushAddAccountDummyRedNoAttributesConflict() th @Test public void test180DeleteHalfAssignmentFromUser() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -382,7 +380,7 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN @@ -410,8 +408,8 @@ public void test180DeleteHalfAssignmentFromUser() throws Exception { @Test public void test190DeleteHalfAssignedUser() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -429,11 +427,11 @@ public void test190DeleteHalfAssignedUser() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result); @@ -464,8 +462,8 @@ public void test190DeleteHalfAssignedUser() throws Exception { @Test public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -475,12 +473,12 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio PolyString fullNamePolyString = new PolyString("Magnificent Captain Jack Sparrow", null); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, fullNamePolyString); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); @@ -508,17 +506,17 @@ public void test200ModifyUserJackBrokenAccountRefAndPolyString() throws Exceptio @Test public void test210ModifyUserAddAccount() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_FILE, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -538,17 +536,17 @@ public void test210ModifyUserAddAccount() throws Exception { @Test public void test212ModifyUserAddAccountRed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(); + when(); modifyUserAddAccount(USER_JACK_OID, ACCOUNT_JACK_DUMMY_RED_FILE, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -571,20 +569,20 @@ public void test212ModifyUserAddAccountRed() throws Exception { @Test public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, new PolyString("Cpt. Jack Sparrow", null)); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -613,19 +611,19 @@ public void test212ModifyUserJackBrokenSchemaViolationPolyString() throws Except @Test public void test214ModifyUserJackBrokenPassword() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_JACK_OID, "whereStheRUM", task, result); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -655,19 +653,19 @@ public void test214ModifyUserJackBrokenPassword() throws Exception { @Test public void test220ModifyUserJackBrokenConflict() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); getDummyResource().setModifyBreakMode(BreakMode.CONFLICT); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString("High seas")); // THEN - displayThen(); + then(); result.computeStatus(); display("Result", result); TestUtil.assertPartialError(result); @@ -701,22 +699,22 @@ public void test220ModifyUserJackBrokenConflict() throws Exception { @Test public void test230ModifyUserJackUserTemplatePolicyViolation() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource().setModifyBreakMode(BreakMode.NONE); dummyAuditService.clear(); try { // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_COST_CENTER, task, result, "broke"); assertNotReached(); } catch (ExpressionEvaluationException e) { // THEN - displayThen(); + then(); display("Exception (expected)", e); assertExceptionUserFriendly(e, "We do not serve your kind here"); @@ -754,8 +752,8 @@ public void test300ExtensionSanity() { @Test public void test301AddUserDeGhoulash() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -830,8 +828,8 @@ public void test317SearchDeGhoulashByFuneralTimestamp() throws Exception { private void searchDeGhoulash(QName propName, T propValue) throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -882,8 +880,8 @@ private void assertBasicDeGhoulashExtension(PrismObject userDeGhoulash @Test public void test330AssignDeGhoulashIdiot() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -908,8 +906,8 @@ public void test330AssignDeGhoulashIdiot() throws Exception { @Test public void test332AssignDeGhoulashRecursion() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -944,8 +942,8 @@ public void test332AssignDeGhoulashRecursion() throws Exception { @Test public void test334AssignDeGhoulashStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -973,8 +971,8 @@ public void test334AssignDeGhoulashStupidAssignment() throws Exception { @Test public void test336UnassignDeGhoulashStupidAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -994,8 +992,8 @@ public void test336UnassignDeGhoulashStupidAssignment() throws Exception { @Test public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1019,8 +1017,8 @@ public void test340AssignDeGhoulashConstructionNonExistentResource() throws Exce @Test public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1043,8 +1041,8 @@ public void test349UnAssignDeGhoulashConstructionNonExistentResource() throws Ex @Test public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1070,8 +1068,8 @@ public void test350AssignDeGhoulashRoleBadConstructionResourceRef() throws Excep @Test public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1097,8 +1095,8 @@ public void test351UnAssignDeGhoulashRoleBadConstructionResourceRef() throws Exc @Test public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1120,8 +1118,8 @@ public void test355AssignDeGhoulashRoleBadConstructionResourceRefLax() throws Ex @Test public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1143,8 +1141,8 @@ public void test356UnAssignDeGhoulashRoleBadConstructionResourceRefLax() throws @Test public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -1165,17 +1163,17 @@ public void test360AddRoleTargetBadConstructionResourceRef() throws Exception { @Test public void test400ImportJackMockTask() throws Exception { // GIVEN - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); importObjectFromFile(TASK_MOCK_JACK_FILE); // THEN - displayThen(); + then(); result.computeStatus(); assertSuccess(result); @@ -1185,18 +1183,18 @@ public void test400ImportJackMockTask() throws Exception { @Test public void test401ListTasks() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); List> objects = modelService.searchObjects(TaskType.class, null, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); display("Tasks", objects); @@ -1231,18 +1229,18 @@ public void test401ListTasks() throws Exception { @Test public void test410DeleteJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); deleteObject(UserType.class, USER_JACK_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); // Make sure the user is gone @@ -1284,8 +1282,8 @@ public void test410DeleteJack() throws Exception { @Test public void test450AddApprovalCase() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1320,8 +1318,8 @@ public void test500EnumerationExtension() { @Test public void test502EnumerationStoreGood() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); userDef.findPropertyDefinition(ItemPath.create(UserType.F_EXTENSION, PIRACY_MARK)); @@ -1333,7 +1331,7 @@ public void test502EnumerationStoreGood() throws Exception { task, result, "bravery"); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject user = getUser(USER_GUYBRUSH_OID); @@ -1360,8 +1358,8 @@ public void test510EnumerationGetBad() throws Exception { } // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1369,7 +1367,7 @@ public void test510EnumerationGetBad() throws Exception { PrismObject user = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismProperty markProp = user.findProperty(ItemPath.create(UserType.F_EXTENSION, PIRACY_MARK)); @@ -1386,8 +1384,8 @@ public void test510EnumerationGetBad() throws Exception { @Test public void test520ShipReadBadTolerateRawData() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1401,7 +1399,7 @@ public void test520ShipReadBadTolerateRawData() throws Exception { modelService.getObject(UserType.class, USER_GUYBRUSH_OID, SelectorOptions.createCollection(createTolerateRawData()), task, result); // THEN - displayThen(); + then(); assertSuccess(result); } @@ -1426,8 +1424,8 @@ private void changeDefinition(QName piracyShip, ItemName piracyShipBroken) { @Test public void test522ShipReadBadRaw() { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1449,8 +1447,8 @@ public void test522ShipReadBadRaw() { @Test public void test524ShipReadBadPlain() { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -1476,8 +1474,8 @@ public void test529FixSchema() { @Test public void test550AssignCircus() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); try { // WHEN @@ -1486,7 +1484,7 @@ public void test550AssignCircus() throws Exception { assertNotReached(); } catch (PolicyViolationException e) { // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -1496,8 +1494,8 @@ public void test550AssignCircus() throws Exception { @Test public void test600AddUserGuybrushAssignAccount() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1507,11 +1505,11 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { deltas.add(accountAssignmentUserDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, getCheckingProgressListenerCollection(), result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1537,8 +1535,8 @@ public void test600AddUserGuybrushAssignAccount() throws Exception { @Test(enabled=false) // MID-2880 public void test610GetAccountGuybrushRogueAttribute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource().setEnforceSchema(false); DummyAccount dummyAccount = getDummyAccount(null, USER_GUYBRUSH_USERNAME); @@ -1546,11 +1544,11 @@ public void test610GetAccountGuybrushRogueAttribute() throws Exception { getDummyResource().setEnforceSchema(true); // WHEN - displayWhen(); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountGuybrushOid, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); display("Shadow after", shadow); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java index cea50911872..b4fa08c557f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTolerantAttributes.java @@ -55,7 +55,6 @@ public class TestTolerantAttributes extends AbstractInitializedModelIntegrationT @Test public void test100ModifyUserAddAccount() throws Exception { - TestUtil.displayTestTitle(this, "test100ModifyUserAddAccount"); // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test100ModifyUserAddAccount"); @@ -122,10 +121,9 @@ public void test100ModifyUserAddAccount() throws Exception { @Test public void test101ModifyAddAttributesIntolerantPattern() throws Exception { final String TEST_NAME = "test101ModifyAddAttributesIntolerantPattern"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -138,11 +136,11 @@ UserType.F_DESCRIPTION, getUserDefinition().findPropertyDefinition(UserType.F_DE Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Check value in "quote attribute" @@ -168,9 +166,8 @@ UserType.F_DESCRIPTION, getUserDefinition().findPropertyDefinition(UserType.F_DE @Test public void test102modifyAddAttributeTolerantPattern() throws Exception{ - TestUtil.displayTestTitle(this, "test102modifyAddAttributeTolerantPattern"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test102modifyAddAttributeTolerantPattern"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -215,9 +212,8 @@ public void test102modifyAddAttributeTolerantPattern() throws Exception{ @Test public void test103modifyReplaceAttributeIntolerant() throws Exception{ - TestUtil.displayTestTitle(this, "test103modifyReplaceAttributeIntolerant"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test103modifyReplaceAttributeIntolerant"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -262,9 +258,8 @@ public void test103modifyReplaceAttributeIntolerant() throws Exception{ @Test public void test104modifyReplaceAttributeTolerantPattern() throws Exception{ - TestUtil.displayTestTitle(this, "test104modifyReplaceAttributeTolerantPattern"); - // GIVEN + // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test104modifyReplaceAttributeTolerantPattern"); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -311,7 +306,6 @@ public void test104modifyReplaceAttributeTolerantPattern() throws Exception{ @Test public void test105ModifyAddNonTolerantAttribute() throws Exception { final String TEST_NAME = "test105ModifyAddNonTolerantAttribute"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestTolerantAttributes.class.getName() + ".test105modifyAddNonTolerantAttribute"); @@ -328,11 +322,11 @@ public void test105ModifyAddNonTolerantAttribute() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java index 8b86659685e..a7c271e6a52 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestTriggerTask.java @@ -31,7 +31,6 @@ import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import java.util.Arrays; @@ -80,10 +79,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportScannerTask() throws Exception { final String TEST_NAME = "test100ImportScannerTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Make sure there is an object with a trigger set to a long time ago. @@ -93,14 +92,14 @@ public void test100ImportScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_TRIGGER_SCANNER_FILE); waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false); waitForTaskFinish(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_TRIGGER_SCANNER_OID, startCal, endCal); @@ -114,21 +113,21 @@ public void test100ImportScannerTask() throws Exception { @Test public void test105NoTrigger() throws Exception { final String TEST_NAME = "test105NoTrigger"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -142,10 +141,10 @@ public void test105NoTrigger() throws Exception { @Test public void test110TriggerCalledAgain() throws Exception { final String TEST_NAME = "test110TriggerCalledAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -154,11 +153,11 @@ public void test110TriggerCalledAgain() throws Exception { addTrigger(USER_JACK_OID, startCal, MockTriggerHandler.HANDLER_URI); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -173,10 +172,10 @@ public void test110TriggerCalledAgain() throws Exception { @Test public void test120TwoTriggers() throws Exception { final String TEST_NAME = "test120TwoTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -186,11 +185,11 @@ public void test120TwoTriggers() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -207,10 +206,10 @@ public void test120TwoTriggers() throws Exception { @Test public void test130TwoTriggersSame() throws Exception { final String TEST_NAME = "test130TwoTriggersSame"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -218,11 +217,11 @@ public void test130TwoTriggersSame() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal), MockTriggerHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -237,10 +236,10 @@ public void test130TwoTriggersSame() throws Exception { @Test public void test135TwoTriggersSamePlusOne() throws Exception { final String TEST_NAME = "test135TwoTriggersSamePlusOne"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -250,11 +249,11 @@ public void test135TwoTriggersSamePlusOne() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -269,10 +268,10 @@ public void test135TwoTriggersSamePlusOne() throws Exception { @Test public void test140TwoTriggersSameAggregable() throws Exception { final String TEST_NAME = "test140TwoTriggersSameAggregable"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -280,11 +279,11 @@ public void test140TwoTriggersSameAggregable() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCal), MockMultipleTriggersHandler.HANDLER_URI, true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -300,10 +299,10 @@ public void test140TwoTriggersSameAggregable() throws Exception { @Test public void test145TwoTriggersSamePlusOneAggregable() throws Exception { final String TEST_NAME = "test145TwoTriggersSamePlusOneAggregable"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testMultipleTriggersHandler.reset(); @@ -314,11 +313,11 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -334,10 +333,10 @@ public void test145TwoTriggersSamePlusOneAggregable() throws Exception { @Test public void test147TwoTriggersIdempotent() throws Exception { final String TEST_NAME = "test147TwoTriggersIdempotent"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); testTriggerHandler.setIdempotent(true); @@ -349,11 +348,11 @@ public void test147TwoTriggersIdempotent() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5ms), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -371,21 +370,21 @@ public void test147TwoTriggersIdempotent() throws Exception { @Test public void test150NoTriggerAgain() throws Exception { final String TEST_NAME = "test115NoTriggerAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -400,10 +399,10 @@ public void test150NoTriggerAgain() throws Exception { @Test public void test160TwoTriggersFirstFails() throws Exception { final String TEST_NAME = "test160TwoTriggersFirstFails"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -415,11 +414,11 @@ public void test160TwoTriggersFirstFails() throws Exception { testTriggerHandler.setFailOnNextInvocation(true); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 10000); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -444,7 +443,7 @@ public void test160TwoTriggersFirstFails() throws Exception { waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); endCal = clock.currentTimeXMLGregorianCalendar(); @@ -457,10 +456,10 @@ public void test160TwoTriggersFirstFails() throws Exception { @Test public void test200TwoDistantTriggers() throws Exception { final String TEST_NAME = "test200TwoDistantTriggers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -470,11 +469,11 @@ public void test200TwoDistantTriggers() throws Exception { addTriggers(USER_JACK_OID, Arrays.asList(startCal, startCalPlus5days), MockTriggerHandler.HANDLER_URI, false); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -490,10 +489,10 @@ public void test200TwoDistantTriggers() throws Exception { @Test public void test210InterruptedScanner() throws Exception { final String TEST_NAME = "test210InterruptedScanner"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); testTriggerHandler.reset(); @@ -515,13 +514,13 @@ public void test210InterruptedScanner() throws Exception { taskManager.resumeTasks(singleton(TASK_TRIGGER_SCANNER_OID), result); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); IntegrationTestTools.waitFor("Waiting for trigger handler invocation", () -> testTriggerHandler.getInvocationCount() > 0, 60000); suspended = taskManager.suspendTasks(singleton(TASK_TRIGGER_SCANNER_OID), 20000L, result); assertTrue("trigger scanner task was not suspended (after operation)", suspended); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN assertNotNull("Trigger was not called", testTriggerHandler.getLastObject()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java index dafb855e95d..fcdffed8f4c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplate.java @@ -121,26 +121,23 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti setDefaultObjectTemplate(UserType.COMPLEX_TYPE, SUBTYPE_MID_5892, USER_TEMPLATE_MID_5892.oid, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - protected int getNumberOfRoles() { return super.getNumberOfRoles() + NUMBER_OF_IMPORTED_ROLES; } @Test public void test000Sanity() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); - PrismObject systemConfiguration = modelService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), + when(); + PrismObject systemConfiguration = modelService.getObject( + SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, task, result); // THEN + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -172,8 +169,8 @@ private void assertObjectTemplate(List defaultObj @Test public void test100ModifyUserGivenName() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -214,8 +211,8 @@ public void test100ModifyUserGivenName() throws Exception { @Test public void test101ModifyUserEmployeeTypePirate() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -225,11 +222,11 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { deltas.add(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -262,8 +259,8 @@ public void test101ModifyUserEmployeeTypePirate() throws Exception { @Test public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -300,8 +297,8 @@ public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception { @Test public void test103ModifyUserEmployeeTypeBartender() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -340,8 +337,8 @@ public void test103ModifyUserEmployeeTypeBartender() throws Exception { @Test public void test104ModifyUserCostCenter() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -376,8 +373,8 @@ public void test104ModifyUserCostCenter() throws Exception { @Test public void test105ModifyUserTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -414,8 +411,8 @@ public void test105ModifyUserTelephoneNumber() throws Exception { @Test public void test106ModifyUserRemoveTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); Collection> deltas = new ArrayList<>(); ObjectDelta userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -452,8 +449,8 @@ public void test106ModifyUserRemoveTelephoneNumber() throws Exception { @Test public void test107ModifyUserSetTelephoneNumber() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_TELEPHONE_NUMBER, task, result, "1 222 3456789"); @@ -489,8 +486,8 @@ public void test107ModifyUserSetTelephoneNumber() throws Exception { @Test public void test120ReconcileUser() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -529,8 +526,8 @@ public void test120ReconcileUser() throws Exception { @Test public void test121ModifyUserReplaceLocality() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Tortuga")); @@ -565,8 +562,8 @@ public void test121ModifyUserReplaceLocality() throws Exception { @Test public void test140AssignDummy() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -597,8 +594,8 @@ public void test140AssignDummy() throws Exception { @Test public void test149UnAssignDummy() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); @@ -628,8 +625,8 @@ public void test149UnAssignDummy() throws Exception { @Test public void test150ModifyJackOrganizationalUnitRum() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -662,8 +659,8 @@ public void test150ModifyJackOrganizationalUnitRum() throws Exception { @Test public void test151ModifyJackOrganizationalUnitOffense() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -696,8 +693,8 @@ public void test151ModifyJackOrganizationalUnitOffense() throws Exception { @Test public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0004")); @@ -733,8 +730,8 @@ public void test152ModifyJackOrganizationalUnitAddRum() throws Exception { @Test public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("F0003")); @@ -769,8 +766,8 @@ public void test153ModifyJackOrganizationalUnitDeleteOffense() throws Exception @Test public void test155ModifyJackOrganizationalUnitFD001() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD001")); @@ -808,8 +805,8 @@ public void test155ModifyJackOrganizationalUnitFD001() throws Exception { @Test public void test156ReconcileJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -846,8 +843,8 @@ public void test156ReconcileJack() throws Exception { @Test public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -886,8 +883,8 @@ public void test157ModifyJackOrganizationalUnitFD0023() throws Exception { @Test public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, @@ -927,8 +924,8 @@ public void test159ModifyJackDeleteOrganizationalUnitFD002() throws Exception { @Test public void test160ModifyUserGivenNameAgain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); @@ -970,8 +967,8 @@ public void test160ModifyUserGivenNameAgain() throws Exception { @Test public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -984,11 +981,11 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { deltas.add(userDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); @@ -1008,8 +1005,8 @@ public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception { @Test public void test165ModifyUserGivenNameAgainAgain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); display("User before", userBefore); @@ -1055,19 +1052,19 @@ private void assertOnDemandOrgAssigned(String orgName, PrismObject use @Test public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "THIEF"); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1083,20 +1080,20 @@ public void test170ModifyUserGuybrushEmployeeTypeThief() throws Exception { @Test public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, task, result, PrismTestUtil.createPolyString("Thf.")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1113,19 +1110,19 @@ public void test172ModifyUserGuybrushHonorificPrefix() throws Exception { @Test public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedRole(userBefore, ROLE_THIEF_OID); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1142,8 +1139,8 @@ public void test174ModifyUserGuybrushHonorificPrefixNone() throws Exception { @Test public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1151,11 +1148,11 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_MAROONED); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1172,19 +1169,19 @@ public void test180ModifyUserGuybrushEmployeeTypeMarooned() throws Exception { @Test public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result); // THEN - displayThen(); + then(); assertSuccess(result); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_COST_CENTER, task, result, "S321"); @@ -1204,19 +1201,19 @@ public void test184ModifyUserGuybrushEmployeeTypeNone() throws Exception { @Test public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_MAROONED); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1230,19 +1227,19 @@ public void test185ModifyUserGuybrushSubtypeMarooned() throws Exception { @Test public void test189ModifyUserGuybrushSubtypeNone() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result); // THEN - displayThen(); + then(); assertSuccess(result); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_COST_CENTER, task, result, "S321"); @@ -1264,8 +1261,8 @@ public void test189ModifyUserGuybrushSubtypeNone() throws Exception { @Test public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); @@ -1273,11 +1270,11 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { assertAssignments(userBefore, 1); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("Whateveric")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -1295,19 +1292,19 @@ public void test190ModifyUserGuybrushOrganizationWhateveric() throws Exception { @Test public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-matic")); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1331,15 +1328,15 @@ public void test191ModifyUserGuybrushOrganizationAutomatic() throws Exception { @Test public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("DEMO-cratic"), createPolyString("AUTO-cratic"), @@ -1348,7 +1345,7 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1379,22 +1376,22 @@ public void test192ModifyUserGuybrushOrganizationAddMixed() throws Exception { @Test public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("meritocratic"), createPolyString("piratocratic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1427,15 +1424,15 @@ public void test193ModifyUserGuybrushOrganizationAddOutOfDomain() throws Excepti @Test public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-matic"), createPolyString("plutocratic"), @@ -1444,7 +1441,7 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1471,22 +1468,22 @@ public void test194ModifyUserGuybrushOrganizationDeleteMixed() throws Exception @Test public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("piratocratic"), createPolyString("DEMO-cratic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1512,19 +1509,19 @@ public void test195ModifyUserGuybrushOrganizationDeleteOutOfDomain() throws Exce @Test public void test196GuybrushAssignCaptain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 2); // WHEN - displayWhen(); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1551,15 +1548,15 @@ public void test196GuybrushAssignCaptain() throws Exception { @Test public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "PIRATE"); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1587,22 +1584,22 @@ public void test197ModifyGuybrushEmployeeTypePirate() throws Exception { @Test public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); modifyUserAdd(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-graphic"), createPolyString("AUTO-matic") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1634,22 +1631,22 @@ public void test198AModifyUserGuybrushOrganizationAddInDomain() throws Exception @Test public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 6); // WHEN - displayWhen(); + when(); modifyUserDelete(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result, createPolyString("AUTO-cratic"), createPolyString("Whateveric") ); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1677,19 +1674,19 @@ public void test198BModifyUserGuybrushOrganizationDeleteMixed() throws Exception @Test public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 5); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "wannabe"); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1716,19 +1713,19 @@ public void test199AGuyBrushModifyEmployeeTypeWannabe() throws Exception { @Test public void test199BGuyBrushUnassignCaptain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignments(userBefore, 4); // WHEN - displayWhen(); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1754,18 +1751,18 @@ public void test199BGuyBrushUnassignCaptain() throws Exception { @Test public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_ORGANIZATION, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1782,8 +1779,8 @@ public void test199CModifyUserGuybrushOrganizationCleanup() throws Exception { @Test public void test200AddUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_RAPP_FILE); Collection> deltas = new ArrayList<>(); @@ -1816,8 +1813,8 @@ public void test200AddUserRapp() throws Exception { @Test public void test201AddUserLargo() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // This simulates IMPORT to trigger the channel-limited mapping task.setChannel(QNameUtil.qNameToUri(SchemaConstants.CHANGE_CHANNEL_IMPORT)); @@ -1861,8 +1858,8 @@ public void test201AddUserLargo() throws Exception { @Test public void test202AddUserMonkey() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_THREE_HEADED_MONKEY_FILE); Collection> deltas = new ArrayList<>(); @@ -1899,8 +1896,8 @@ public void test202AddUserMonkey() throws Exception { @Test public void test204AddUserHerman() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject user = PrismTestUtil.parseObject(USER_HERMAN_FILE); Collection> deltas = new ArrayList<>(); @@ -1932,8 +1929,8 @@ public void test204AddUserHerman() throws Exception { @Test public void test220AssignRoleSailorToUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1964,8 +1961,8 @@ public void test220AssignRoleSailorToUserRapp() throws Exception { @Test public void test229UnassignRoleSailorFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result); @@ -1998,8 +1995,8 @@ public void test229UnassignRoleSailorFromUserRapp() throws Exception { @Test public void test230AssignRoleCaptainToUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2030,8 +2027,8 @@ public void test230AssignRoleCaptainToUserRapp() throws Exception { @Test public void test232ModifyUserRappCostCenter() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_RAPP_OID, UserType.F_COST_CENTER, task, result, "CC-RAPP"); @@ -2063,8 +2060,8 @@ public void test232ModifyUserRappCostCenter() throws Exception { @Test public void test239UnassignRoleCaptainFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_CAPTAIN_OID, task, result); @@ -2092,8 +2089,8 @@ public void test239UnassignRoleCaptainFromUserRapp() throws Exception { @Test public void test240ModifyUserRappLocalityScabb() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2137,8 +2134,8 @@ public void test240ModifyUserRappLocalityScabb() throws Exception { @Test public void test242AssignRoleRastamanToUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2175,8 +2172,8 @@ public void test242AssignRoleRastamanToUserRapp() throws Exception { @Test public void test244ModifyUserRappLocalityCoffin() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2213,8 +2210,8 @@ public void test244ModifyUserRappLocalityCoffin() throws Exception { @Test public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2258,8 +2255,8 @@ public void test245ModifyUserRappLocalityUnderReconcile() throws Exception { @Test public void test246ModifyUserRappTimezoneMonkey() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2298,8 +2295,8 @@ public void test246ModifyUserRappTimezoneMonkey() throws Exception { @Test public void test247ModifyUserRappLocaleMI() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result); display("User before", userBefore); @@ -2335,8 +2332,8 @@ public void test247ModifyUserRappLocaleMI() throws Exception { @Test public void test249UnassignRoleRastamanFromUserRapp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN unassignRole(USER_RAPP_OID, ROLE_RASTAMAN_OID, task, result); @@ -2372,8 +2369,8 @@ public void test249UnassignRoleRastamanFromUserRapp() throws Exception { @Test public void test300ImportStanFromEmeraldResource() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = new DummyAccount(ACCOUNT_STAN_USERNAME); @@ -2387,11 +2384,11 @@ public void test300ImportStanFromEmeraldResource() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(); + when(); modelService.importFromResource(shadowBefore.getOid(), task, result); // THEN - displayThen(); + then(); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -2414,8 +2411,8 @@ public void test300ImportStanFromEmeraldResource() throws Exception { @Test public void test302ModifyStanAccountAndReimport() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); DummyAccount dummyAccountBefore = dummyResourceEmerald.getAccountByUsername(ACCOUNT_STAN_USERNAME); @@ -2426,11 +2423,11 @@ public void test302ModifyStanAccountAndReimport() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(); + when(); modelService.importFromResource(shadowBefore.getOid(), task, result); // THEN - displayThen(); + then(); result.computeStatus(); display(result); TestUtil.assertSuccess(result); @@ -2477,8 +2474,8 @@ public void test800NullTimeFrom() throws Exception { @Test public void test802FuneralTimestamp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); funeralTimestamp = clock.currentTimeXMLGregorianCalendar(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, funeralTimestamp); @@ -2505,7 +2502,6 @@ public void test802FuneralTimestamp() throws Exception { @Test public void test804PreKaboom() throws Exception { final String TEST_NAME = "test804PreKaboom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P2D"); // total override is realTime + 2D @@ -2528,7 +2524,6 @@ public void test804PreKaboom() throws Exception { @Test public void test808Kaboom() throws Exception { final String TEST_NAME = "test808Kaboom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P1M"); // total override is realTime + 2D + 1M @@ -2559,7 +2554,6 @@ public void test808Kaboom() throws Exception { @Test public void test810PreTalesBomb() throws Exception { final String TEST_NAME = "test810PreTalesBomb"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P1D"); // total override is realTime + 2D + 1M + 1D @@ -2597,7 +2591,6 @@ public void test810PreTalesBomb() throws Exception { @Test public void test812TalesBoom() throws Exception { final String TEST_NAME = "test812TalesBoom"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P3M"); @@ -2622,7 +2615,6 @@ public void test812TalesBoom() throws Exception { @Test public void test813TalesBoomRecompute() throws Exception { final String TEST_NAME = "test813TalesBoomRecompute"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2659,8 +2651,8 @@ public void test813TalesBoomRecompute() throws Exception { @Test public void test820TalesUnBoom() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_TALES), task, result /* no value */); @@ -2708,8 +2700,8 @@ public void test820TalesUnBoom() throws Exception { @Test public void test830PreLootBoom() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, UserType.F_DESCRIPTION, task, result, "Rum is gone"); @@ -2767,7 +2759,6 @@ public void test830PreLootBoom() throws Exception { @Test public void test832LootBoomConditionFalse() throws Exception { final String TEST_NAME = "test832LootBoomConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("P9M"); @@ -2804,8 +2795,8 @@ public void test832LootBoomConditionFalse() throws Exception { @Test public void test835LootBoom() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2838,8 +2829,8 @@ public void test835LootBoom() throws Exception { @Test public void test840ResetFuneralTimestamp() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); @@ -2866,8 +2857,8 @@ public void test840ResetFuneralTimestamp() throws Exception { @Test public void test843UnLoot() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Justjack")); @@ -2901,8 +2892,8 @@ public void test843UnLoot() throws Exception { @Test public void test845ReLoot() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString("Lootjack")); @@ -2936,8 +2927,8 @@ public void test845ReLoot() throws Exception { @Test public void test850AddCannibalLemonhead() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, false), task, result); @@ -2964,8 +2955,8 @@ public void test850AddCannibalLemonhead() throws Exception { @Test public void test852AddCanibalRedSkull() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", false), task, result); @@ -2996,8 +2987,8 @@ public void test852AddCanibalRedSkull() throws Exception { @Test public void test854AddCanibalShaprtooth() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", false), task, result); @@ -3029,8 +3020,8 @@ public void test854AddCanibalShaprtooth() throws Exception { @Test public void test856AddCanibalOrangeskin() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", false), task, result); @@ -3060,8 +3051,8 @@ public void test856AddCanibalOrangeskin() throws Exception { @Test public void test858AddCanibalCherrybrain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", false), task, result); @@ -3093,8 +3084,8 @@ public void test858AddCanibalCherrybrain() throws Exception { @Test public void test859AddCanibalPineapplenose() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3127,8 +3118,8 @@ public void test859AddCanibalPineapplenose() throws Exception { @Test public void test860AddCannibalRottenLemonhead() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_LEMONHEAD_USERNAME, null, true), task, result); @@ -3155,8 +3146,8 @@ public void test860AddCannibalRottenLemonhead() throws Exception { @Test public void test862AddCanibalRottenRedSkull() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_REDSKULL_USERNAME, "", true), task, result); @@ -3187,8 +3178,8 @@ public void test862AddCanibalRottenRedSkull() throws Exception { @Test public void test864AddCanibalRottenShaprtooth() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_SHARPTOOTH_USERNAME, "-P1M1D", true), task, result); @@ -3230,8 +3221,8 @@ public void test864AddCanibalRottenShaprtooth() throws Exception { @Test public void test866AddCanibalRottenOrangeskin() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_ORANGESKIN_USERNAME, "-P3M1D", true), task, result); @@ -3264,8 +3255,8 @@ public void test866AddCanibalRottenOrangeskin() throws Exception { @Test public void test868AddCanibalRottenCherrybrain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject(createCannibal(CANNIBAL_CHERRYBRAIN_USERNAME, "-P1Y1D", true), task, result); @@ -3295,8 +3286,8 @@ public void test868AddCanibalRottenCherrybrain() throws Exception { @Test public void test869AddCanibalRottenPineapplenose() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3330,8 +3321,8 @@ public void test869AddCanibalRottenPineapplenose() throws Exception { @Test public void test870AddCanibalRottenPotatoleg() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN String userOid = addObject( @@ -3382,8 +3373,8 @@ private PrismObject createCannibal(String name, String funeralDateOffs @Test public void test900DeleteUser() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); Collection> deltas = new ArrayList<>(); @@ -3414,8 +3405,8 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { // GIVEN setDefaultUserTemplate(null); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3444,8 +3435,8 @@ public void test950CreateUserJackWithoutTemplate() throws Exception { @Test public void test952ModifyJackOrganizationalUnitFD004() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("FD004")); @@ -3475,8 +3466,8 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { // GIVEN setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN @@ -3502,19 +3493,19 @@ public void test960ReconcileUserJackWithTemplate() throws Exception { @Test public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); display("User before", userBefore); assertAssignedNoRole(userBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, SUBTYPE_USELESS); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, null, task, result); @@ -3530,8 +3521,8 @@ public void test970ModifyUserGuybrushEmployeeTypeUseless() throws Exception { @Test public void test980DeleteUserGivenName() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); UserType user = new UserType(prismContext) .name("test980DeleteUserGivenName") @@ -3543,14 +3534,14 @@ public void test980DeleteUserGivenName() throws Exception { repositoryService.addObject(user.asPrismObject(), null, result); // WHEN - displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_GIVEN_NAME).delete(new PolyString("jim")) .asObjectDeltaCast(user.getOid()); executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = modelService.getObject(UserType.class, user.getOid(), null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java index 71ced36eee3..012a91338dc 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestUserTemplateWithRanges.java @@ -82,7 +82,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100RecomputeElaine() throws Exception { final String TEST_NAME = "test100RecomputeElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -108,7 +107,6 @@ public void test100RecomputeElaine() throws Exception { @Test public void test110ChangeManagerAndRecomputeElaine() throws Exception { final String TEST_NAME = "test110ChangeManagerAndRecomputeElaine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -136,7 +134,6 @@ public void test110ChangeManagerAndRecomputeElaine() throws Exception { @Test public void test120RestoreManagerAndRecomputeElaineAgain() throws Exception { final String TEST_NAME = "test120RestoreManagerAndRecomputeElaineAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -168,7 +165,6 @@ public void test120RestoreManagerAndRecomputeElaineAgain() throws Exception { @Test public void test140ChangeManagerAndRecomputeElaineAgain() throws Exception { final String TEST_NAME = "test140ChangeManagerAndRecomputeElaineAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestUserTemplateWithRanges.class.getName() + "." + TEST_NAME); @@ -202,10 +198,9 @@ public void test140ChangeManagerAndRecomputeElaineAgain() throws Exception { @Test public void test200SimpleOrgUnitAddition() throws Exception { final String TEST_NAME = "test200SimpleOrgUnitAddition"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -245,10 +240,9 @@ public void test200SimpleOrgUnitAddition() throws Exception { @Test public void test210RemoveUnit1() throws Exception { final String TEST_NAME = "test210RemoveUnit1"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -285,10 +279,9 @@ public void test210RemoveUnit1() throws Exception { @Test public void test220RemoveUnit2AndNumber() throws Exception { final String TEST_NAME = "test220RemoveUnit2AndNumber"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -325,10 +318,9 @@ public void test220RemoveUnit2AndNumber() throws Exception { @Test public void test230RestoreNumber() throws Exception { final String TEST_NAME = "test230RestoreNumber"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -361,14 +353,13 @@ public void test230RestoreNumber() throws Exception { @Test public void test300GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test300GuybrushBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -376,7 +367,7 @@ public void test300GuybrushBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -393,14 +384,13 @@ public void test300GuybrushBloodyNose() throws Exception { @Test public void test309GuybrushNotBloody() throws Exception { final String TEST_NAME = "test309GuybrushNotBloody"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -408,7 +398,7 @@ public void test309GuybrushNotBloody() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -421,17 +411,16 @@ public void test309GuybrushNotBloody() throws Exception { @Test public void test310GuybrushBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test310GuybrushBloodyNoseFuneral"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_123456_CAL); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -439,7 +428,7 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -456,14 +445,13 @@ public void test310GuybrushBloodyNoseFuneral() throws Exception { @Test public void test319GuybrushNoBloodyNoseFuneral() throws Exception { final String TEST_NAME = "test319GuybrushNoBloodyNoseFuneral"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -471,7 +459,7 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -484,17 +472,16 @@ public void test319GuybrushNoBloodyNoseFuneral() throws Exception { @Test public void test320GuybrushBloodyNose() throws Exception { final String TEST_NAME = "test320GuybrushBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).add(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -502,7 +489,7 @@ public void test320GuybrushBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -519,19 +506,18 @@ public void test320GuybrushBloodyNose() throws Exception { @Test public void test322GuybrushSetFuneral() throws Exception { final String TEST_NAME = "test322GuybrushSetFuneral"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_123456_CAL); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -548,19 +534,18 @@ public void test322GuybrushSetFuneral() throws Exception { @Test public void test324GuybrushSetFuneral22222() throws Exception { final String TEST_NAME = "test324GuybrushSetFuneral22222"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result, GUYBRUSH_FUNERAL_DATE_22222_CAL); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -579,19 +564,18 @@ public void test324GuybrushSetFuneral22222() throws Exception { @Test public void test326GuybrushNoFuneral() throws Exception { final String TEST_NAME = "test326GuybrushNoFuneral"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, getExtensionPath(PIRACY_FUNERAL_TIMESTAMP), task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) @@ -607,14 +591,13 @@ public void test326GuybrushNoFuneral() throws Exception { @Test public void test329GuybrushNoBloodyNose() throws Exception { final String TEST_NAME = "test329GuybrushNoBloodyNose"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges( deltaFor(UserType.class) .item(UserType.F_TITLE).delete(PolyString.fromOrig(ROLE_BLOODY_NOSE_NAME)) @@ -622,7 +605,7 @@ public void test329GuybrushNoBloodyNose() throws Exception { null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_GUYBRUSH_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java index eee126385ec..7fe4da9d272 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestVolatility.java @@ -92,18 +92,18 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportLiveSyncTaskDummyHr() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyHr"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(); } @@ -111,10 +111,10 @@ public void test100ImportLiveSyncTaskDummyHr() throws Exception { @Test public void test110AddDummyHrAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyHrAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -125,14 +125,14 @@ public void test110AddDummyHrAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood"); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_HR_NAME).addAccount(account); waitForSyncTaskNextRun(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancombHr = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_HR_NAME)); @@ -175,14 +175,14 @@ public void test110AddDummyHrAccountMancomb() throws Exception { @Test public void test120UpdateDummyHrAccountMancomb() throws Exception { final String TEST_NAME = "test120UpdateDummyHrAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_HR_NAME).getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); account.replaceAttributeValue(DummyAccount.ATTR_FULLNAME_NAME, "Sir Mancomb Seepgood"); @@ -192,7 +192,7 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancombHr = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_HR_NAME)); @@ -241,16 +241,16 @@ public void test120UpdateDummyHrAccountMancomb() throws Exception { @Test public void test200ModifyGuybrushAssignAccount() throws Exception { final String TEST_NAME = "test200ModifyGuybrushAssignAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions //assertUsers(5); - TestUtil.displayWhen(TEST_NAME); + when(); Collection> deltas = new ArrayList<>(); ObjectDelta accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_GUYBRUSH_OID, RESOURCE_DUMMY_VOLATILE_OID, null, true); @@ -260,7 +260,7 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userGuybrush = findUserByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("User guybrush", userGuybrush); @@ -294,16 +294,16 @@ public void test200ModifyGuybrushAssignAccount() throws Exception { @Test public void test300AddLargo() throws Exception { final String TEST_NAME = "test300AddLargo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions //assertUsers(5); - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject user = PrismTestUtil.parseObject(USER_LARGO_WITH_ASSIGNMENT_FILE); ObjectDelta userDelta = DeltaFactory.Object.createAddDelta(user); Collection> deltas = MiscSchemaUtil.createCollection(userDelta); @@ -312,7 +312,7 @@ public void test300AddLargo() throws Exception { modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userLargo = findUserByUsername(ACCOUNT_LARGO_DUMMY_USERNAME); display("User largo", userLargo); @@ -349,10 +349,10 @@ public void test300AddLargo() throws Exception { @Test public void test400AddHerman() throws Exception { final String TEST_NAME = "test400AddHerman"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_HERMAN_FILE); @@ -364,11 +364,11 @@ public void test400AddHerman() throws Exception { display("User before", userBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -391,19 +391,19 @@ public void test400AddHerman() throws Exception { @Test public void test402ModifyHermanMonster() throws Exception { final String TEST_NAME = "test402ModifyHermanMonster"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(TestVolatility.class.getName() + "." + TEST_NAME); + TestVolatility.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserAdd(USER_HERMAN_OID, UserType.F_ORGANIZATION, task, result, createPolyString(DummyResource.VALUE_MONSTER)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java index 5025f22b31e..6d7b95dad37 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestArchetypes.java @@ -126,9 +126,8 @@ protected File getSystemConfigurationFile() { @Test public void test020SanityJack() throws Exception { final String TEST_NAME = "test020SanityJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = assertUserBefore(USER_JACK_OID) @@ -141,17 +140,16 @@ public void test020SanityJack() throws Exception { @Test public void test050AddArchetypeTest() throws Exception { final String TEST_NAME = "test050AddArchetypeTest"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ARCHETYPE_TEST_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject archetypeTest = modelService.getObject(ArchetypeType.class, ARCHETYPE_TEST_OID, null, task, result); @@ -161,19 +159,18 @@ public void test050AddArchetypeTest() throws Exception { @Test public void test060AddArchetypesAndRoles() throws Exception { final String TEST_NAME = "test060AddArchetypesAndRoles"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ARCHETYPE_BUSINESS_ROLE_FILE, task, result); addObject(ROLE_BUSINESS_CAPTAIN_FILE, task, result); addObject(ROLE_BUSINESS_BOSUN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject roleBusinessCaptainAfter = assertRoleAfter(ROLE_BUSINESS_CAPTAIN_OID) @@ -201,17 +198,16 @@ public void test060AddArchetypesAndRoles() throws Exception { @Test public void test070AssignGuybrushUserAdministrator() throws Exception { final String TEST_NAME = "test070AssignGuybrushUserAdministrator"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_USER_ADMINISTRATOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // TODO: assert guybrush @@ -221,18 +217,17 @@ public void test070AssignGuybrushUserAdministrator() throws Exception { @Test public void test100AssignJackArchetypeEmployee() throws Exception { final String TEST_NAME = "test100AssignJackArchetypeEmployee"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -265,9 +260,8 @@ private String costCenterEmployee() { @Test public void test102SearchEmployeeArchetypeRef() throws Exception { final String TEST_NAME = "test102SearchEmployeeArchetypeRef"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -275,12 +269,12 @@ public void test102SearchEmployeeArchetypeRef() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> searchResults = modelService.searchObjects(UserType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Search results", searchResults); assertEquals("Wrong number of search results", 1, searchResults.size()); @@ -303,12 +297,11 @@ public void test102SearchEmployeeArchetypeRef() throws Exception { @Test public void test104GetGuybryshCompiledGuiProfile() throws Exception { final String TEST_NAME = "test104GetGuybryshCompiledGuiProfile"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -369,20 +362,19 @@ public void test104GetGuybryshCompiledGuiProfile() throws Exception { @Test public void test109UnassignJackArchetypeEmployee() throws Exception { final String TEST_NAME = "test109UnassignJackArchetypeEmployee"; - displayTestTitle(TEST_NAME); loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -404,18 +396,17 @@ public void test109UnassignJackArchetypeEmployee() throws Exception { @Test public void test110AssignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test110AssignJackRoleEmployeeBase"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -460,18 +451,17 @@ public void test110AssignJackRoleEmployeeBase() throws Exception { @Test public void test115UnassignJackRoleEmployeeBase() throws Exception { final String TEST_NAME = "test115UnassignJackRoleEmployeeBase"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_EMPLOYEE_BASE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) @@ -504,18 +494,17 @@ public void test115UnassignJackRoleEmployeeBase() throws Exception { @Test public void test120AssignJackArchetypeTest() throws Exception { final String TEST_NAME = "test120AssignJackArchetypeTest"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -540,18 +529,17 @@ public void test120AssignJackArchetypeTest() throws Exception { @Test public void test129UnassignJackArchetypeTest() throws Exception { final String TEST_NAME = "test129UnassignJackArchetypeTest"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_TEST_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -572,18 +560,17 @@ public void test129UnassignJackArchetypeTest() throws Exception { @Test public void test130AssignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test130AssignJackArchetypeContractor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -605,18 +592,17 @@ public void test130AssignJackArchetypeContractor() throws Exception { @Test public void test132JackContractorRecompute() throws Exception { final String TEST_NAME = "test132JackContractorRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -639,18 +625,17 @@ public void test132JackContractorRecompute() throws Exception { @Test public void test135UnassignJackArchetypeContractor() throws Exception { final String TEST_NAME = "test135UnassignJackArchetypeContractor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -674,20 +659,19 @@ public void test135UnassignJackArchetypeContractor() throws Exception { @Test public void test137JackEmpnoAndRecompute() throws Exception { final String TEST_NAME = "test137JackEmpnoAndRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "Number ONE"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -711,18 +695,17 @@ public void test137JackEmpnoAndRecompute() throws Exception { @Test public void test140AddMeathookContractor() throws Exception { final String TEST_NAME = "test140AddMeathookContractor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_MEATHOOK_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_MEATHOOK_OID) @@ -746,18 +729,17 @@ public void test140AddMeathookContractor() throws Exception { @Test public void test150AddWannabe() throws Exception { final String TEST_NAME = "test150AddWannabe"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_WANNABE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_WANNABE_OID) @@ -782,18 +764,17 @@ public void test150AddWannabe() throws Exception { @Test public void test160AddSelfMadeMan() throws Exception { final String TEST_NAME = "test160AddSelfMadeMan"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_SELF_MADE_MAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_SELF_MADE_MAN_OID) @@ -816,9 +797,8 @@ public void test160AddSelfMadeMan() throws Exception { @Test public void test162AddFraudster() throws Exception { final String TEST_NAME = "test162AddFraudster"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // precondition @@ -826,7 +806,7 @@ public void test162AddFraudster() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_FRAUDSTER_FILE, task, result); @@ -837,7 +817,7 @@ public void test162AddFraudster() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); assertNoObject(UserType.class, USER_FRAUDSTER_OID); @@ -846,19 +826,18 @@ public void test162AddFraudster() throws Exception { @Test public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { final String TEST_NAME = "test200AssignJackBarbossaArchetypeEmployee"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignArchetype(USER_JACK_OID, ARCHETYPE_EMPLOYEE_OID, task, result); assignArchetype(USER_BARBOSSA_OID, ARCHETYPE_EMPLOYEE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -872,12 +851,11 @@ public void test200AssignJackBarbossaArchetypeEmployee() throws Exception { @Test public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exception { final String TEST_NAME = "test202GetGuybryshCompiledGuiProfileActiveEmployeesView"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -909,18 +887,17 @@ public void test202GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc @Test public void test203DisableBarbossa() throws Exception { final String TEST_NAME = "test203DisableBarbossa"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -934,12 +911,11 @@ public void test203DisableBarbossa() throws Exception { @Test public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exception { final String TEST_NAME = "test205GetGuybryshCompiledGuiProfileActiveEmployeesView"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_GUYBRUSH_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -971,13 +947,12 @@ public void test205GetGuybryshCompiledGuiProfileActiveEmployeesView() throws Exc @Test public void test300jackAssignArchetypeRaw() throws Exception { final String TEST_NAME = "test300jackAssignArchetypeRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); try { assignArchetype(USER_JACK_OID, ARCHETYPE_CONTRACTOR_OID, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java index 4e02c7b14a7..739febe6312 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/archetypes/TestCollections.java @@ -11,9 +11,7 @@ import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; -import java.io.File; import java.util.Collection; -import java.util.List; import java.util.stream.Collectors; import org.springframework.test.annotation.DirtiesContext; @@ -21,34 +19,19 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.model.api.CollectionStats; import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView; import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.FailableRunnable; -import com.evolveum.midpoint.util.Holder; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectCollectionType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -81,18 +64,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); collectionActiveUsers = modelService.getObject(ObjectCollectionType.class, COLLECTION_ACTIVE_USERS_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Collection", collectionActiveUsers); assertSuccess(result); assertNotNull("No collection", collectionActiveUsers); @@ -101,18 +83,17 @@ public void test000Sanity() throws Exception { @Test public void test100CompileCollectionView() throws Exception { final String TEST_NAME = "test100CompileCollectionView"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); collectionViewActiveUsers = modelInteractionService.compileObjectCollectionView(collectionActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Active users collection view", collectionViewActiveUsers); assertSuccess(result); assertNotNull("Null view", collectionActiveUsers); @@ -129,18 +110,17 @@ public void test100CompileCollectionView() throws Exception { @Test public void test102SearchCollectionUsers() throws Exception { final String TEST_NAME = "test102SearchCollectionUsers"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> users = modelService.searchObjects(UserType.class, prismContext.queryFactory().createQuery(collectionViewActiveUsers.getFilter()), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Users in collection", users); assertSuccess(result); assertEquals("Wrong number of users in collection", getNumberOfUsers(), users.size()); @@ -149,18 +129,17 @@ public void test102SearchCollectionUsers() throws Exception { @Test public void test110CollectionStatsAllEnabled() throws Exception { final String TEST_NAME = "test110CollectionStatsAllEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -173,18 +152,17 @@ public void test110CollectionStatsAllEnabled() throws Exception { @Test public void test112EvaluateRulesAllEnabled() throws Exception { final String TEST_NAME = "test112EvaluateRulesAllEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) @@ -195,21 +173,20 @@ public void test112EvaluateRulesAllEnabled() throws Exception { @Test public void test120CollectionStatsOneDisabled() throws Exception { final String TEST_NAME = "test120CollectionStatsOneDisabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); numberOfDisabledUsers++; // WHEN - displayWhen(TEST_NAME); + when(); CollectionStats stats = modelInteractionService.determineCollectionStats(collectionViewActiveUsers, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Collection stats", stats); assertSuccess(result); assertNotNull("Null stats", stats); @@ -222,18 +199,17 @@ public void test120CollectionStatsOneDisabled() throws Exception { @Test public void test122EvaluateRulesOneDisabled() throws Exception { final String TEST_NAME = "test122EvaluateRulesOneDisabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); Collection evaluatedRules = modelInteractionService.evaluateCollectionPolicyRules(collectionActiveUsers, collectionViewActiveUsers, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEvaluatedPolicyRules(evaluatedRules, collectionActiveUsers) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java index bd46b088079..0b666c1e6e1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateGrouperJson.java @@ -75,7 +75,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -83,7 +82,8 @@ public void test000Sanity() throws Exception { } private Task createTestTask(String TEST_NAME) { - return createTask(TestAsyncUpdateGrouperJson.class.getName() + "." + TEST_NAME); + TestAsyncUpdateGrouperJson.class.getName(); + return getTestTask(); } /** @@ -92,7 +92,6 @@ private Task createTestTask(String TEST_NAME) { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -139,7 +138,6 @@ private AsyncUpdateMessageType getAmqp091Message(File file) throws IOException { @Test public void test110AddAlumniAndStaff() throws Exception { final String TEST_NAME = "test110AddAlumniAndStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -186,7 +184,6 @@ public void test110AddAlumniAndStaff() throws Exception { @Test public void test200AddAlumniForAnderson() throws Exception { final String TEST_NAME = "test200AddAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -226,7 +223,6 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test210AddStaffForAnderson() throws Exception { final String TEST_NAME = "test210AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -266,7 +262,6 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test220AddAlumniForLewis() throws Exception { final String TEST_NAME = "test220AddAlumniForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -306,7 +301,6 @@ public void test220AddAlumniForLewis() throws Exception { @Test public void test230AddLewis() throws Exception { final String TEST_NAME = "test230AddLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -346,7 +340,6 @@ public void test230AddLewis() throws Exception { @Test public void test240AddStaffForAnderson() throws Exception { final String TEST_NAME = "test240AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -386,7 +379,6 @@ public void test240AddStaffForAnderson() throws Exception { @Test public void test250DeleteAlumniForAnderson() throws Exception { final String TEST_NAME = "test250DeleteAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -426,7 +418,6 @@ public void test250DeleteAlumniForAnderson() throws Exception { @Test public void test310DeleteStaff() throws Exception { final String TEST_NAME = "test310DeleteStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java index 48e9d65173f..8903595c106 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateTaskMechanics.java @@ -69,11 +69,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti importObjectFromFile(RESOURCE_HR.file, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; @@ -86,23 +81,23 @@ public void stop() { @Test public void test000Sanity() throws ObjectNotFoundException { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_HR.oid, task)); } @Test public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, CommonException { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); int usersBefore = getObjectCount(UserType.class); prepareMessages(CHANGE_USER_ADD_FILE, "100-", 10, true); - displayWhen(); + when(); importObjectFromFile(TASK_ASYNC_UPDATE_HR_NO_WORKERS.file, result); - displayThen(); + then(); waitForTaskFinish(TASK_ASYNC_UPDATE_HR_NO_WORKERS.oid, false, 30000); PrismObject taskAfter = getTask(TASK_ASYNC_UPDATE_HR_NO_WORKERS.oid); @@ -117,17 +112,17 @@ public void test100SmallTaskNoWorkers() throws IOException, TimeoutException, Co @Test public void test110SmallTaskOneWorker() throws IOException, TimeoutException, CommonException { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); int usersBefore = getObjectCount(UserType.class); prepareMessages(CHANGE_USER_ADD_FILE, "110-", 10, true); - displayWhen(); + when(); importObjectFromFile(TASK_ASYNC_UPDATE_HR_ONE_WORKER.file, result); - displayThen(); + then(); waitForTaskFinish(TASK_ASYNC_UPDATE_HR_ONE_WORKER.oid, false, 30000); PrismObject taskAfter = getTask(TASK_ASYNC_UPDATE_HR_ONE_WORKER.oid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java index 8e787c7be95..9f3e449ff30 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestAsyncUpdateUcf.java @@ -73,7 +73,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -90,7 +89,6 @@ private Task createTestTask(String TEST_NAME) { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -130,7 +128,6 @@ public void test100AddAnderson() throws Exception { @Test public void test110AddAlumniAndStaff() throws Exception { final String TEST_NAME = "test110AddAlumni"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -177,7 +174,6 @@ public void test110AddAlumniAndStaff() throws Exception { @Test public void test120AddWhite() throws Exception { final String TEST_NAME = "test120AddWhite"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -217,7 +213,6 @@ public void test120AddWhite() throws Exception { @Test public void test200AddAlumniForAnderson() throws Exception { final String TEST_NAME = "test200AddAlumniForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -257,7 +252,6 @@ public void test200AddAlumniForAnderson() throws Exception { @Test public void test210AddStaffForAnderson() throws Exception { final String TEST_NAME = "test210AddStaffForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -297,7 +291,6 @@ public void test210AddStaffForAnderson() throws Exception { @Test public void test220AddAlumniForLewis() throws Exception { final String TEST_NAME = "test220AddAlumniForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -337,7 +330,6 @@ public void test220AddAlumniForLewis() throws Exception { @Test public void test230MentionLewis() throws Exception { final String TEST_NAME = "test230MentionLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -377,7 +369,6 @@ public void test230MentionLewis() throws Exception { @Test public void test300DeleteAnderson() throws Exception { final String TEST_NAME = "test300DeleteAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); @@ -409,7 +400,6 @@ public void test300DeleteAnderson() throws Exception { @Test public void test310DeleteStaff() throws Exception { final String TEST_NAME = "test310DeleteStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = createTestTask(TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java index d552d613926..48d0fd78edf 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/async/TestNotifyChange.java @@ -87,7 +87,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task); @@ -100,7 +99,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddAnderson() throws Exception { final String TEST_NAME = "test100AddAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -138,7 +136,6 @@ public void test100AddAnderson() throws Exception { @Test public void test105AddLewis() throws Exception { final String TEST_NAME = "test105AddLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -179,7 +176,6 @@ public void test105AddLewis() throws Exception { @Test public void test110AddAlumni() throws Exception { final String TEST_NAME = "test110AddAlumni"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -217,7 +213,6 @@ public void test110AddAlumni() throws Exception { @Test public void test120AddStaff() throws Exception { final String TEST_NAME = "test120AddStaff"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -255,7 +250,6 @@ public void test120AddStaff() throws Exception { @Test public void test200AddGroupsForAnderson() throws Exception { final String TEST_NAME = "test200AddGroupsForAnderson"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -293,7 +287,6 @@ public void test200AddGroupsForAnderson() throws Exception { @Test public void test210AddGroupsForLewis() throws Exception { final String TEST_NAME = "test210AddGroupsForLewis"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java index 68261f071a3..1e8f7b62c7a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestAssociationInbound.java @@ -75,9 +75,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssociationInboundMateForOrangeResource() throws Exception { final String TEST_NAME = "test100AssociationInboundMateForOrangeResource"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = getDummyResourceObject(RESOURCE_DUMMY_PURPLE_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java index 3f4e6e512f9..792da9674d7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestEditSchema.java @@ -1,1763 +1,1724 @@ -/* - * Copyright (c) 2010-2017 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.intest.gensync; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -import com.evolveum.midpoint.prism.delta.DeltaFactory; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.Validator; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - -/** - * @author semancik - * - */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) -@DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public class TestEditSchema extends AbstractGenericSyncTest { - - public static final File LOOKUP_LANGUAGES_REPLACEMENT_FILE = new File(TEST_DIR, "lookup-languages-replacement.xml"); - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - super.initSystem(initTask, initResult); - - setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); - importObjectFromFile(ROLE_PRISONER_FILE); - importObjectFromFile(USER_OTIS_FILE); - - rememberSteadyResources(); - } - - @Test - public void test100LookupLanguagesGet() throws Exception { - final String TEST_NAME="test100LookupLanguagesGet"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); - - assertSteadyResources(); - } - - @Test - public void test102LookupLanguagesGetExclude() throws Exception { - final String TEST_NAME="test102LookupLanguagesGetExclude"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - Collection> options = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW).dontRetrieve() - .build(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); - - assertSteadyResources(); - } - - @Test - public void test110LookupLanguagesGetAll() throws Exception { - final String TEST_NAME="test110LookupLanguagesGetAll"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}, - new String[]{"sk_SK", "sk", "Slovak"}, - new String[]{"tr_TR", "tr", "Turkish"}); - } - - @Test - public void test120LookupLanguagesGetByKeyExact() throws Exception { - final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .eq("sk_SK") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - @Test - public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { - final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .startsWith("e") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}); - } - - @Test - public void test122LookupLanguagesGetByKeyContaining() throws Exception { - final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("r") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); - } - - @Test - public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception { - final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("_") - .offset(2) - .maxSize(1) - .asc(LookupTableRowType.F_KEY) - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - @Test - public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception { - final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_KEY) - .contains("xyz") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0); - - assertSteadyResources(); - } - - @Test - public void test130LookupLanguagesGetByValueExact() throws Exception { - final String TEST_NAME="test130LookupLanguagesGetByValueExact"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_VALUE) - .eq("sk") - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); - } - - /** - * Disabled because it's not clear how to treat polystrings in searches. - * - */ - @Test - public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { - final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - String fragment = "Eng"; - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_LABEL) - .startsWith(fragment) - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}); - } - - @Test - public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception { - final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW) - .retrieveQuery() - .item(LookupTableRowType.F_VALUE) - .contains("n") - .offset(0) - .maxSize(1) - .desc(LookupTableRowType.F_LABEL) // using sorting key other than the one used in search - .end(); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); - } - - /** - * This test is disabled because id-based searching is not available yet (and it's unclear if it would be eventually necessary). - */ - @Test(enabled = false) - public void test140LookupLanguagesGetByIdExisting() throws Exception { - final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - - Collection> options = SelectorOptions.createCollection( - prismContext.path(LookupTableType.F_ROW, 1L), - GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); - PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); - } - - - private void checkLookupResult(PrismObject lookup, String[]... tuples) { - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", tuples.length, tableContainer.size()); - - for (String[] tuple : tuples) { - assertLookupRow(tableContainer, tuple[0], tuple[1], tuple[2]); - } - assertSteadyResources(); - } - - - @Test - public void test150LookupLanguagesAddRowFull() throws Exception { - final String TEST_NAME="test150LookupLanguagesAddRow"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GI"); - row.setValue("gi"); - row.setLabel(PrismTestUtil.createPolyStringType("Gibberish")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 5, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - - assertSteadyResources(); - } - - @Test - public void test152LookupLanguagesAddRowKeyLabel() throws Exception { - final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GO"); - row.setLabel(PrismTestUtil.createPolyStringType("Gobbledygook")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 6, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertSteadyResources(); - } - - @Test - public void test154LookupLanguagesAddRowKeyValue() throws Exception { - final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_HU"); - row.setValue("gi"); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 7, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertLookupRow(tableContainer, "gi_HU", "gi", null); - - assertSteadyResources(); - } - - @Test - public void test156LookupLanguagesAddRowExistingKey() throws Exception { - final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_HU"); - row.setValue("gi"); - row.setLabel(PrismTestUtil.createPolyStringType("Humbug")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - boolean exception = false; - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - } catch (ObjectAlreadyExistsException ex) { - exception = true; - } - AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - task = createTask(TEST_NAME); - result = task.getResult(); - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 7, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - /** - * @throws Exception - */ - @Test - public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { - final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("sk_SK"); - row.setValue("sk"); - row.setLabel(PrismTestUtil.createPolyStringType("Slovak")); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 6, tableContainer.size()); - - assertLookupRow(tableContainer, "en_US", "en", "English (US)"); - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - @Test - public void test164LookupLanguagesDeleteRowFullId() throws Exception { - final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("en_US"); - row.setValue("en"); - row.setLabel(PrismTestUtil.createPolyStringType("English (US)")); - row.setId(1L); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - executeChanges(delta, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 5, tableContainer.size()); - - assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - - assertSteadyResources(); - } - - @Test - public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { - final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setId(2L); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - executeChanges(delta, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 4, tableContainer.size()); - - assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertSteadyResources(); - } - - @Test - public void test168LookupLanguagesDeleteRowByKey() throws Exception { - final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row = new LookupTableRowType(); - row.setKey("gi_GI"); - ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 3, tableContainer.size()); - - assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); - assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); - assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); - - assertSteadyResources(); - } - - @Test - public void test170LookupLanguagesReplaceRows() throws Exception { - final String TEST_NAME="test170LookupLanguagesReplaceRows"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - LookupTableRowType row1 = new LookupTableRowType(); - row1.setKey("ja_JA"); - row1.setValue("ja"); - row1.setLabel(PrismTestUtil.createPolyStringType("Jabber")); - - LookupTableRowType row2 = new LookupTableRowType(); - row2.setKey("ja_MJ"); - row2.setValue("ja"); - row2.setLabel(PrismTestUtil.createPolyStringType("Mumbojumbo")); - - LookupTableRowType row3 = new LookupTableRowType(); - row3.setKey("en_PR"); // existing key - row3.setValue("en1"); - row3.setLabel(PrismTestUtil.createPolyStringType("English (pirate1)")); - - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceContainer(LookupTableType.class, - LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); - - // WHEN - displayWhen(TEST_NAME); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 3, tableContainer.size()); - - assertLookupRow(tableContainer, "ja_JA", "ja", "Jabber"); - assertLookupRow(tableContainer, "ja_MJ", "ja", "Mumbojumbo"); - assertLookupRow(tableContainer, "en_PR", "en1", "English (pirate1)"); - - assertSteadyResources(); - } - - @Test - public void test180LookupLanguagesReplaceObject() throws Exception { - final String TEST_NAME="test180LookupLanguagesReplaceObject"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObject replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE); - ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); - - // WHEN - displayWhen(TEST_NAME); - ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); - options.setRaw(true); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig()); - - PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); - assertNotNull("Table container missing", tableContainer); - assertEquals("Unexpected table container size", 1, tableContainer.size()); - - assertLookupRow(tableContainer, "fr_FR", "fr", "Français"); - assertSteadyResources(); - } - - @Test - public void test182LookupLanguagesReimport() throws Exception { - final String TEST_NAME="test182LookupLanguagesReimport"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ImportOptionsType options = new ImportOptionsType(); - options.setOverwrite(true); - options.setKeepOid(true); - - // WHEN - displayWhen(TEST_NAME); - modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - - IntegrationTestTools.display("Languages", lookup); - - assertEquals("Wrong lang lookup name", "Languages", lookup.asObjectable().getName().getOrig()); - - checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, - new String[]{"en_PR", "en", "English (pirate)"}, - new String[]{"sk_SK", "sk", "Slovak"}, - new String[]{"tr_TR", "tr", "Turkish"}); - - assertSteadyResources(); - } - - - private void assertLookupRow(PrismContainer tableContainer, String key, String value, - String label) { - for (PrismContainerValue row: tableContainer.getValues()) { - LookupTableRowType rowType = row.asContainerable(); - if (key.equals(rowType.getKey())) { - assertEquals("Wrong value for key "+key, value, rowType.getValue()); - if (label == null) { - assertNull("Unexpected label for key "+key+": "+rowType.getLabel(), rowType.getLabel()); - } else { - assertEquals("Wrong label for key "+key, PrismTestUtil.createPolyStringType(label), rowType.getLabel()); - } - return; - } - } - AssertJUnit.fail("Row with key '"+key+"' was not found in lookup table"); - } - - private PrismObject getLookupTableAll(String oid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() - .item(LookupTableType.F_ROW).retrieve(); - return modelService.getObject(LookupTableType.class, oid, optionsBuilder.build(), task, result); - } - - @Test - public void test200EditSchemaUser() throws Exception { - final String TEST_NAME="test200EditSchemaUser"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - PrismObject user = userDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(user); - - // THEN - displayThen(TEST_NAME); - - - PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_GIVEN_NAME, false); - PrismAsserts.assertEmphasized(editDef, UserType.F_FAMILY_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_FULL_NAME, true); - PrismAsserts.assertEmphasized(editDef, UserType.F_DESCRIPTION, false); - - PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); - assertEquals("Wrong additionalName help", "Just a plain old middle name", additionalNameDef.getHelp()); // MID-5736 - assertTrue("additionalName not readable", additionalNameDef.canRead()); - PrismAsserts.assertEmphasized(additionalNameDef, false); - - PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); - assertTrue("costCenter not readable", costCenterDef.canRead()); - PrismAsserts.assertEmphasized(costCenterDef, true); - FormItemValidationType validationAnnotation = costCenterDef.getAnnotation(ItemRefinedDefinitionType.F_VALIDATION); - assertNotNull("No validation annotation in costCenter", validationAnnotation); - ExpressionType validationExpression = validationAnnotation.getServer().get(0).getExpression(); - assertNotNull("No validation expression annotation in costCenter", validationExpression); - - // This has overridden lookup def in object template - PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); - assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); - PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - - // This has default lookup def in schema - PrismPropertyDefinition timezoneDef = editDef.findPropertyDefinition(UserType.F_TIMEZONE); - assertNotNull("No definition for timezone in user", timezoneDef); - assertEquals("Wrong timezone displayName", "FocusType.timezone", timezoneDef.getDisplayName()); - assertTrue("timezone not readable", timezoneDef.canRead()); - valueEnumerationRef = timezoneDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for timezone", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for timezone", SystemObjectsType.LOOKUP_TIMEZONES.value(), valueEnumerationRef.getOid()); - - // Deprecated. But deprecation flag in overridden in object template (MID-4680) - PrismPropertyDefinition employeeTypeDef = editDef.findPropertyDefinition(UserType.F_EMPLOYEE_TYPE); - assertNotNull("No definition for employeeType in user", employeeTypeDef); - assertEquals("Wrong deprecation flag for employeeType", false, employeeTypeDef.isDeprecated()); - - PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password not readable", passwdValDef.canRead()); - - assertSteadyResources(); - } - - @Test - public void test210UserDefinition() throws Exception { - final String TEST_NAME="test210UserDefinition"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue("additionalName not readable", propDef.canRead()); - }, PrismTestUtil.createPolyString("Jackie")); - - - assertPropertyValues(user, UserType.F_COST_CENTER, (Validator>) (propDef, name) -> { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue("costCenter not readable", propDef.canRead()); - }); - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, - (Validator>) (propDef, name) -> { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - assertTrue("preferredLanguage not readable", propDef.canRead()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - }); - - assertContainer(user, UserType.F_CREDENTIALS, (credentialsDef, name) -> { - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - }, true); - - assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), - (propDef, name) -> { - assertTrue("Password not readable", propDef.canRead()); - }); - - assertSteadyResources(); - } - - /** - * Check that the user definition in schema registry was not ruined - * @throws Exception - */ - @Test - public void test211SchemaRegistryUntouched() throws Exception { - final String TEST_NAME="test211SchemaRegistryUntouched"; - displayTestTitle(TEST_NAME); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - /** - * Modify jack, see if the schema still applies. - */ - @Test - public void test213ModifiedUserJack() throws Exception { - final String TEST_NAME="test213ModifiedUserJack"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue("additionalName not readable", propDef.canRead()); - }, PrismTestUtil.createPolyString("Jackie")); - - assertPropertyValues(user, UserType.F_COST_CENTER, (propDef, name) -> { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue("costCenter not readable", propDef.canRead()); - },"G001"); // This is set by user template - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, (propDef, name) -> { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - assertTrue("preferredLanguage not readable", propDef.canRead()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - }, "en_PR"); - - - assertContainer(user, UserType.F_CREDENTIALS, new Validator>() { - @Override - public void validate(PrismContainerDefinition credentialsDef, String name) - throws Exception { - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - } - - }, true); - - assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), - (Validator>) (propDef, name) -> assertTrue("Password not readable", propDef.canRead())); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - @Test - public void test240EditSchemaReconciliationTask() throws Exception { - final String TEST_NAME="test240EditSchemaReconciliationTask"; - displayTestTitle(TEST_NAME); - - // GIVEN - PrismObjectDefinition taskDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class); - PrismObject task = taskDef.instantiate(); - task.asObjectable() - .beginAssignment() - .targetRef(ARCHETYPE_TASK_RECONCILIATION_OID, ArchetypeType.COMPLEX_TYPE); - - display("Task before", task); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(task); - - // THEN - displayThen(TEST_NAME); - - assertObjectDefinition(editDef) - .container(ObjectType.F_EXTENSION) - .assertSize(7) - .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECTCLASS) - .assertProperty(SchemaConstants.MODEL_EXTENSION_KIND) - .assertProperty(SchemaConstants.MODEL_EXTENSION_INTENT) - .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) - .assertProperty(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS) - .assertProperty(SchemaConstants.MODEL_EXTENSION_FINISH_OPERATIONS_ONLY) - .assertProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN); - - assertSteadyResources(); - } - - @Test - public void test250EditSchemaRole() throws Exception { - final String TEST_NAME="test250EditSchemaRole"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); - PrismObject role = roleDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(role); - - // THEN - displayThen(TEST_NAME); - - // TODO - PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); - assertNotNull("No definition for requestable in role", requestableDef); - assertEquals("Wrong requestable displayName", "Can request", requestableDef.getDisplayName()); - - assertSteadyResources(); - } - - @Test - public void test260EditShadowSchemaKindIntent() throws Exception { - final String TEST_NAME="test260EditShadowSchemaKindIntent"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); - assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); - assertTrue("additionalName not readable", attrFullNameDef.canRead()); - - PrismContainerDefinition identifiersDef = editDef.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION, - ShadowAssociationType.F_IDENTIFIERS)); - StringBuilder message = new StringBuilder(); - message.append("Wrong type for ").append(ShadowAssociationType.F_IDENTIFIERS) - .append(", expected ResourceAttributeContainerDefinition but was ") - .append(identifiersDef == null ? null : identifiersDef.getClass().getName()) - .append("; "); - assertClassType(message.toString(), identifiersDef, ResourceAttributeContainerDefinition.class); - - - assertSteadyResources(); - } - - @Test - public void test261EditShadowSchemaObjectclass() throws Exception { - final String TEST_NAME="test261EditShadowSchemaObjectclass"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName()); - IntegrationTestTools.display("Discr", discr); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); - assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); - assertTrue("additionalName not readable", attrFullNameDef.canRead()); - - assertSteadyResources(); - } - - @Test - public void test263EditShadowSchemaEmpty() throws Exception { - final String TEST_NAME="test263EditShadowSchemaEmpty"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null); - IntegrationTestTools.display("Discr", discr); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); - - assertSteadyResources(); - } - - @Test - public void test265EditShadowSchemaNull() throws Exception { - final String TEST_NAME="test265EditShadowSchemaNull"; - displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); - - // THEN - displayThen(TEST_NAME); - assertSuccess(result); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); - assertNotNull("No definition for name in shadow", nameDef); - assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("additionalName not readable", nameDef.canRead()); - - PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); - assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); - - assertSteadyResources(); - } - - /** - * MID-4660, MID-4491, MID-3581 - */ - @Test - public void test310CustomRelations() throws Exception { - final String TEST_NAME="test310CustomRelations"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - List relations = modelInteractionService.getRelationDefinitions(); - - // THEN - displayThen(TEST_NAME); - display("Relations", relations); - assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); - assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); - assertRelationDef(relations, RELATION_PIRACY_CAPTAIN, "Captain"); - assertEquals("Unexpected number of relation definitions", 8, relations.size()); - } - - /** - * Login as Otis. Otis has a restricted authorizations. Check that schema is presented accordingly to - * these limitations. - */ - @Test - public void test800OtisEditSchemaUser() throws Exception { - final String TEST_NAME="test800OtisEditSchemaUser"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - PrismObject user = userDef.instantiate(); - - // WHEN - displayWhen(TEST_NAME); - PrismObjectDefinition editDef = getEditObjectDefinition(user); - display("Otis edit schema", editDef); - - // THEN - displayThen(TEST_NAME); - - PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); - assertNotNull("No definition for name in user", nameDef); - assertEquals("Wrong name displayName", "ObjectType.name", nameDef.getDisplayName()); - assertTrue("name not readable", nameDef.canRead()); - assertTrue("name is creatable", !nameDef.canAdd()); - assertTrue("name is modifiable", !nameDef.canModify()); - - PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); - assertTrue("additionalName is readable", !additionalNameDef.canRead()); - assertTrue("additionalName is creatable", !additionalNameDef.canAdd()); - assertTrue("additionalName not modifiable", additionalNameDef.canModify()); - - PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); - assertTrue("costCenter is readable", !costCenterDef.canRead()); - assertTrue("costCenter is creatable", !costCenterDef.canAdd()); - assertTrue("costCenter is modifiable", !costCenterDef.canModify()); - - PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue("preferredLanguage is readable", !preferredLanguageDef.canRead()); - assertTrue("preferredLanguage is creatable", !preferredLanguageDef.canAdd()); - assertTrue("preferredLanguage is modifiable", !preferredLanguageDef.canModify()); - - PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials is readable", !credentialsDef.canRead()); - assertTrue("Credentials is creatable", !credentialsDef.canAdd()); - assertTrue("Credentials is modifiable", !credentialsDef.canModify()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password is readable", !passwdValDef.canRead()); - assertTrue("Password is creatable", !passwdValDef.canAdd()); - assertTrue("Password is modifiable", !passwdValDef.canModify()); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - @Test - public void test810OtisGetJack() throws Exception { - final String TEST_NAME="test810OtisGetJack"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertPropertyValues(user, UserType.F_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for name in user", propDef); - assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); - assertTrue(name+" not readable", propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }, PrismTestUtil.createPolyString("jack")); - - assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for description in user", propDef); - assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName()); - assertTrue(name+" not readable", propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" not modifiable", propDef.canModify()); - } - }, "Where's the rum?"); - - assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" not modifiable", propDef.canModify()); - } - }); - - assertPropertyValues(user, UserType.F_COST_CENTER, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }); - - assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue(name+" is readable", !propDef.canRead()); - assertTrue(name+" is creatable", !propDef.canAdd()); - assertTrue(name+" is modifiable", !propDef.canModify()); - } - }); - - PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); - - assertUntouchedUserDefinition(); - assertSteadyResources(); - } - - @Test - public void test820OtisSearchUsers() throws Exception { - final String TEST_NAME="test820OtisSearchUsers"; - displayTestTitle(TEST_NAME); - - // GIVEN - login(USER_OTIS_USERNAME); - - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - - // WHEN - displayWhen(TEST_NAME); - SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); - - // THEN - displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); - - assertEquals("Unexepected number of users found", 7, users.size()); - - for (final PrismObject user: users) { - assertProperty(user, UserType.F_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for name in user", propDef); - assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); - assertTrue(name+" of "+user+" not readable", propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - assertProperty(user, UserType.F_ADDITIONAL_NAME, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for additionalName in user", propDef); - assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" not modifiable", propDef.canModify()); - } - }); - assertProperty(user, UserType.F_COST_CENTER, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for costCenter in user", propDef); - assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - - assertProperty(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { - @Override - public void validate(PrismPropertyDefinition propDef, String name) throws Exception { - assertNotNull("No definition for preferredLanguage in user", propDef); - assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); - PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); - assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); - assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); - assertTrue(name+" of "+user+" is readable", !propDef.canRead()); - assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); - assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); - } - }); - - PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); - - assertUntouchedUserDefinition(); - } - - } - - - private void assertProperty(PrismObject object, ItemPath path, - Validator> validator) throws Exception { - assertPropertyValues(object, path, validator, (T[])null); - } - - private void assertPropertyValues(PrismObject object, ItemPath path, - Validator> validator, T... expectedValues) throws Exception { - PrismProperty prop = object.findProperty(path); - if (expectedValues == null) { - if (prop != null) { - PrismPropertyDefinition propDef = prop.getDefinition(); - assertNotNull("No definition in property "+path, propDef); - try { - validator.validate(propDef, path.toString()+" (propDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", propDef); - throw e; - } - } - } else if (expectedValues.length == 0) { - assertNull("Unexpected property "+path+" in "+object+": "+prop, prop); - } else { - assertNotNull("No property "+path+" in "+object, prop); - PrismAsserts.assertPropertyValue(prop, expectedValues); - PrismPropertyDefinition propDef = prop.getDefinition(); - assertNotNull("No definition in property "+path, propDef); - try { - validator.validate(propDef, path.toString()+" (propDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", propDef); - throw e; - } - } - - PrismPropertyDefinition objPropDef = object.getDefinition().findPropertyDefinition(path); - assertNotNull("No definition of property "+path+" in object "+object, objPropDef); - try { - validator.validate(objPropDef, path.toString()+" (objectDef) "); - } catch (Exception | Error e) { - IntegrationTestTools.display("Wrong definition", objPropDef); - throw e; - } - - } - - private void assertContainer(PrismObject object, ItemName contName, - Validator> validator, boolean valueExpected) throws Exception { - PrismContainer container = object.findContainer(contName); - if (valueExpected) { - assertNotNull("No container "+contName+" in "+object, container); - PrismContainerDefinition contDef = container.getDefinition(); - assertNotNull("No definition in container "+contName, contDef); - validator.validate(contDef, contName.toString()); - } else { - assertNull("Unexpected container "+contName+" in "+object+": "+container, container); - } - - PrismContainerDefinition objContDef = object.getDefinition().findContainerDefinition(contName); - assertNotNull("No definition of container "+contName+" in object "+object, objContDef); - validator.validate(objContDef, contName.toString()); - } - - private void assertUntouchedUserDefinition() { - // WHEN - PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); - - - // THEN - - PrismPropertyDefinition descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION); - assertNotNull("No definition for description in user", descriptionDef); - assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName()); - assertTrue("description not readable", descriptionDef.canRead()); - assertTrue("description not creatable", descriptionDef.canAdd()); - assertTrue("description not modifiable", descriptionDef.canModify()); - - PrismPropertyDefinition additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); - assertNotNull("No definition for additionalName in user", additionalNameDef); - assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName()); - assertTrue("additionalName not readable", additionalNameDef.canRead()); - assertTrue("additionalName not creatable", additionalNameDef.canAdd()); - assertTrue("additionalName not modifiable", additionalNameDef.canModify()); - - PrismPropertyDefinition costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER); - assertNotNull("No definition for costCenter in user", costCenterDef); - assertEquals("Wrong costCenter displayOrder", (Integer)420, costCenterDef.getDisplayOrder()); - assertTrue("costCenter not readable", costCenterDef.canRead()); - assertTrue("costCenter not creatable", costCenterDef.canAdd()); - assertTrue("costCenter not modifiable", costCenterDef.canModify()); - PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef(); - assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef); - - PrismPropertyDefinition preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); - assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); - assertEquals("Wrong preferredLanguage displayName", "FocusType.preferredLanguage", preferredLanguageDef.getDisplayName()); - assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); - assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd()); - assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify()); - valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); - assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef); - assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", - SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid()); - - PrismContainerDefinition credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS); - assertNotNull("No definition for credentials in user", credentialsDef); - assertTrue("Credentials not readable", credentialsDef.canRead()); - assertTrue("Credentials not creatable", credentialsDef.canAdd()); - assertTrue("Credentials not modifiable", credentialsDef.canModify()); - - ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); - PrismPropertyDefinition passwdValDef = userDefinition.findPropertyDefinition(passwdValPath); - assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); - assertTrue("Password not readable", passwdValDef.canRead()); - assertTrue("Password not creatable", passwdValDef.canAdd()); - assertTrue("Password not modifiable", passwdValDef.canModify()); - - } -} +/* + * Copyright (c) 2010-2017 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.intest.gensync; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.util.Collection; +import java.util.List; + +import com.evolveum.midpoint.prism.delta.DeltaFactory; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.model.api.ModelExecuteOptions; +import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismContainerDefinition; +import com.evolveum.midpoint.prism.PrismContainerValue; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.MiscSchemaUtil; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.Validator; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; + +/** + * @author semancik + * + */ +@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +public class TestEditSchema extends AbstractGenericSyncTest { + + public static final File LOOKUP_LANGUAGES_REPLACEMENT_FILE = new File(TEST_DIR, "lookup-languages-replacement.xml"); + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + super.initSystem(initTask, initResult); + + setDefaultUserTemplate(USER_TEMPLATE_COMPLEX_OID); + importObjectFromFile(ROLE_PRISONER_FILE); + importObjectFromFile(USER_OTIS_FILE); + + rememberSteadyResources(); + } + + @Test + public void test100LookupLanguagesGet() throws Exception { + final String TEST_NAME="test100LookupLanguagesGet"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); + + assertSteadyResources(); + } + + @Test + public void test102LookupLanguagesGetExclude() throws Exception { + final String TEST_NAME="test102LookupLanguagesGetExclude"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + Collection> options = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW).dontRetrieve() + .build(); + + // WHEN + when(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismAsserts.assertEmptyAndIncomplete(lookup, LookupTableType.F_ROW); + + assertSteadyResources(); + } + + @Test + public void test110LookupLanguagesGetAll() throws Exception { + final String TEST_NAME="test110LookupLanguagesGetAll"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}, + new String[]{"sk_SK", "sk", "Slovak"}, + new String[]{"tr_TR", "tr", "Turkish"}); + } + + @Test + public void test120LookupLanguagesGetByKeyExact() throws Exception { + final String TEST_NAME="test120LookupLanguagesGetByKeyExact"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .eq("sk_SK") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + @Test + public void test121LookupLanguagesGetByKeyStartingWith() throws Exception { + final String TEST_NAME="test121LookupLanguagesGetByKeyStartingWith"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .startsWith("e") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}); + } + + @Test + public void test122LookupLanguagesGetByKeyContaining() throws Exception { + final String TEST_NAME="test122LookupLanguagesGetByKeyContaining"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("r") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"tr_TR", "tr", "Turkish"}); + } + + @Test + public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception { + final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("_") + .offset(2) + .maxSize(1) + .asc(LookupTableRowType.F_KEY) + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + @Test + public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception { + final String TEST_NAME="test124LookupLanguagesGetByKeyContainingReturningNothing"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_KEY) + .contains("xyz") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0); + + assertSteadyResources(); + } + + @Test + public void test130LookupLanguagesGetByValueExact() throws Exception { + final String TEST_NAME="test130LookupLanguagesGetByValueExact"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_VALUE) + .eq("sk") + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" }); + } + + /** + * Disabled because it's not clear how to treat polystrings in searches. + * + */ + @Test + public void test131LookupLanguagesGetByLabelStartingWith() throws Exception { + final String TEST_NAME="test131LookupLanguagesGetByLabelStartingWith"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + String fragment = "Eng"; + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_LABEL) + .startsWith(fragment) + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}); + } + + @Test + public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception { + final String TEST_NAME="test123LookupLanguagesGetByKeyContainingWithPaging"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW) + .retrieveQuery() + .item(LookupTableRowType.F_VALUE) + .contains("n") + .offset(0) + .maxSize(1) + .desc(LookupTableRowType.F_LABEL) // using sorting key other than the one used in search + .end(); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); + } + + /** + * This test is disabled because id-based searching is not available yet (and it's unclear if it would be eventually necessary). + */ + @Test(enabled = false) + public void test140LookupLanguagesGetByIdExisting() throws Exception { + final String TEST_NAME="test140LookupLanguagesGetByIdExisting"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + + Collection> options = SelectorOptions.createCollection( + prismContext.path(LookupTableType.F_ROW, 1L), + GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); + PrismObject lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }); + } + + + private void checkLookupResult(PrismObject lookup, String[]... tuples) { + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", tuples.length, tableContainer.size()); + + for (String[] tuple : tuples) { + assertLookupRow(tableContainer, tuple[0], tuple[1], tuple[2]); + } + assertSteadyResources(); + } + + + @Test + public void test150LookupLanguagesAddRowFull() throws Exception { + final String TEST_NAME="test150LookupLanguagesAddRow"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GI"); + row.setValue("gi"); + row.setLabel(PrismTestUtil.createPolyStringType("Gibberish")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 5, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + + assertSteadyResources(); + } + + @Test + public void test152LookupLanguagesAddRowKeyLabel() throws Exception { + final String TEST_NAME="test152LookupLanguagesAddRowKeyLabel"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GO"); + row.setLabel(PrismTestUtil.createPolyStringType("Gobbledygook")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 6, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertSteadyResources(); + } + + @Test + public void test154LookupLanguagesAddRowKeyValue() throws Exception { + final String TEST_NAME="test154LookupLanguagesAddRowKeyValue"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_HU"); + row.setValue("gi"); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 7, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertLookupRow(tableContainer, "gi_HU", "gi", null); + + assertSteadyResources(); + } + + @Test + public void test156LookupLanguagesAddRowExistingKey() throws Exception { + final String TEST_NAME="test156LookupLanguagesAddRowExistingKey"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_HU"); + row.setValue("gi"); + row.setLabel(PrismTestUtil.createPolyStringType("Humbug")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + boolean exception = false; + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + } catch (ObjectAlreadyExistsException ex) { + exception = true; + } + AssertJUnit.assertFalse(exception); // as per description in https://wiki.evolveum.com/display/midPoint/Development+with+LookupTable + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + task = getTestTask(); + result = task.getResult(); + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 7, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + /** + * @throws Exception + */ + @Test + public void test162LookupLanguagesDeleteRowFullNoId() throws Exception { + final String TEST_NAME="test162LookupLanguagesDeleteRowFullNoId"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("sk_SK"); + row.setValue("sk"); + row.setLabel(PrismTestUtil.createPolyStringType("Slovak")); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 6, tableContainer.size()); + + assertLookupRow(tableContainer, "en_US", "en", "English (US)"); + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + @Test + public void test164LookupLanguagesDeleteRowFullId() throws Exception { + final String TEST_NAME="test164LookupLanguagesDeleteRowFullId"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("en_US"); + row.setValue("en"); + row.setLabel(PrismTestUtil.createPolyStringType("English (US)")); + row.setId(1L); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + executeChanges(delta, null, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 5, tableContainer.size()); + + assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + + assertSteadyResources(); + } + + @Test + public void test166LookupLanguagesDeleteRowIdOnly() throws Exception { + final String TEST_NAME="test166LookupLanguagesDeleteRowIdOnly"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setId(2L); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + executeChanges(delta, null, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 4, tableContainer.size()); + + assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish"); + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertSteadyResources(); + } + + @Test + public void test168LookupLanguagesDeleteRowByKey() throws Exception { + final String TEST_NAME="test168LookupLanguagesDeleteRowByKey"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row = new LookupTableRowType(); + row.setKey("gi_GI"); + ObjectDelta delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 3, tableContainer.size()); + + assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook"); + assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug"); + assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish"); + + assertSteadyResources(); + } + + @Test + public void test170LookupLanguagesReplaceRows() throws Exception { + final String TEST_NAME="test170LookupLanguagesReplaceRows"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + LookupTableRowType row1 = new LookupTableRowType(); + row1.setKey("ja_JA"); + row1.setValue("ja"); + row1.setLabel(PrismTestUtil.createPolyStringType("Jabber")); + + LookupTableRowType row2 = new LookupTableRowType(); + row2.setKey("ja_MJ"); + row2.setValue("ja"); + row2.setLabel(PrismTestUtil.createPolyStringType("Mumbojumbo")); + + LookupTableRowType row3 = new LookupTableRowType(); + row3.setKey("en_PR"); // existing key + row3.setValue("en1"); + row3.setLabel(PrismTestUtil.createPolyStringType("English (pirate1)")); + + ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceContainer(LookupTableType.class, + LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row1, row2, row3); + + // WHEN + when(); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 3, tableContainer.size()); + + assertLookupRow(tableContainer, "ja_JA", "ja", "Jabber"); + assertLookupRow(tableContainer, "ja_MJ", "ja", "Mumbojumbo"); + assertLookupRow(tableContainer, "en_PR", "en1", "English (pirate1)"); + + assertSteadyResources(); + } + + @Test + public void test180LookupLanguagesReplaceObject() throws Exception { + final String TEST_NAME="test180LookupLanguagesReplaceObject"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + PrismObject replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE); + ObjectDelta delta = DeltaFactory.Object.createAddDelta(replacement); + + // WHEN + when(); + ModelExecuteOptions options = ModelExecuteOptions.createOverwrite(); + options.setRaw(true); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig()); + + PrismContainer tableContainer = lookup.findContainer(LookupTableType.F_ROW); + assertNotNull("Table container missing", tableContainer); + assertEquals("Unexpected table container size", 1, tableContainer.size()); + + assertLookupRow(tableContainer, "fr_FR", "fr", "Français"); + assertSteadyResources(); + } + + @Test + public void test182LookupLanguagesReimport() throws Exception { + final String TEST_NAME="test182LookupLanguagesReimport"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + ImportOptionsType options = new ImportOptionsType(); + options.setOverwrite(true); + options.setKeepOid(true); + + // WHEN + when(); + modelService.importObjectsFromFile(LOOKUP_LANGUAGES_FILE, options, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + PrismObject lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + + IntegrationTestTools.display("Languages", lookup); + + assertEquals("Wrong lang lookup name", "Languages", lookup.asObjectable().getName().getOrig()); + + checkLookupResult(lookup, new String[]{"en_US", "en", "English (US)"}, + new String[]{"en_PR", "en", "English (pirate)"}, + new String[]{"sk_SK", "sk", "Slovak"}, + new String[]{"tr_TR", "tr", "Turkish"}); + + assertSteadyResources(); + } + + + private void assertLookupRow(PrismContainer tableContainer, String key, String value, + String label) { + for (PrismContainerValue row: tableContainer.getValues()) { + LookupTableRowType rowType = row.asContainerable(); + if (key.equals(rowType.getKey())) { + assertEquals("Wrong value for key "+key, value, rowType.getValue()); + if (label == null) { + assertNull("Unexpected label for key "+key+": "+rowType.getLabel(), rowType.getLabel()); + } else { + assertEquals("Wrong label for key "+key, PrismTestUtil.createPolyStringType(label), rowType.getLabel()); + } + return; + } + } + AssertJUnit.fail("Row with key '"+key+"' was not found in lookup table"); + } + + private PrismObject getLookupTableAll(String oid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + GetOperationOptionsBuilder optionsBuilder = schemaHelper.getOperationOptionsBuilder() + .item(LookupTableType.F_ROW).retrieve(); + return modelService.getObject(LookupTableType.class, oid, optionsBuilder.build(), task, result); + } + + @Test + public void test200EditSchemaUser() throws Exception { + final String TEST_NAME="test200EditSchemaUser"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + PrismObject user = userDef.instantiate(); + + // WHEN + when(); + PrismObjectDefinition editDef = getEditObjectDefinition(user); + + // THEN + then(); + + + PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_GIVEN_NAME, false); + PrismAsserts.assertEmphasized(editDef, UserType.F_FAMILY_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_FULL_NAME, true); + PrismAsserts.assertEmphasized(editDef, UserType.F_DESCRIPTION, false); + + PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); + assertEquals("Wrong additionalName help", "Just a plain old middle name", additionalNameDef.getHelp()); // MID-5736 + assertTrue("additionalName not readable", additionalNameDef.canRead()); + PrismAsserts.assertEmphasized(additionalNameDef, false); + + PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); + assertTrue("costCenter not readable", costCenterDef.canRead()); + PrismAsserts.assertEmphasized(costCenterDef, true); + FormItemValidationType validationAnnotation = costCenterDef.getAnnotation(ItemRefinedDefinitionType.F_VALIDATION); + assertNotNull("No validation annotation in costCenter", validationAnnotation); + ExpressionType validationExpression = validationAnnotation.getServer().get(0).getExpression(); + assertNotNull("No validation expression annotation in costCenter", validationExpression); + + // This has overridden lookup def in object template + PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); + assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); + PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + + // This has default lookup def in schema + PrismPropertyDefinition timezoneDef = editDef.findPropertyDefinition(UserType.F_TIMEZONE); + assertNotNull("No definition for timezone in user", timezoneDef); + assertEquals("Wrong timezone displayName", "FocusType.timezone", timezoneDef.getDisplayName()); + assertTrue("timezone not readable", timezoneDef.canRead()); + valueEnumerationRef = timezoneDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for timezone", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for timezone", SystemObjectsType.LOOKUP_TIMEZONES.value(), valueEnumerationRef.getOid()); + + // Deprecated. But deprecation flag in overridden in object template (MID-4680) + PrismPropertyDefinition employeeTypeDef = editDef.findPropertyDefinition(UserType.F_EMPLOYEE_TYPE); + assertNotNull("No definition for employeeType in user", employeeTypeDef); + assertEquals("Wrong deprecation flag for employeeType", false, employeeTypeDef.isDeprecated()); + + PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password not readable", passwdValDef.canRead()); + + assertSteadyResources(); + } + + @Test + public void test210UserDefinition() throws Exception { + final String TEST_NAME="test210UserDefinition"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue("additionalName not readable", propDef.canRead()); + }, PrismTestUtil.createPolyString("Jackie")); + + + assertPropertyValues(user, UserType.F_COST_CENTER, (Validator>) (propDef, name) -> { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue("costCenter not readable", propDef.canRead()); + }); + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, + (Validator>) (propDef, name) -> { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + assertTrue("preferredLanguage not readable", propDef.canRead()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + }); + + assertContainer(user, UserType.F_CREDENTIALS, (credentialsDef, name) -> { + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + }, true); + + assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), + (propDef, name) -> { + assertTrue("Password not readable", propDef.canRead()); + }); + + assertSteadyResources(); + } + + /** + * Check that the user definition in schema registry was not ruined + * @throws Exception + */ + @Test + public void test211SchemaRegistryUntouched() throws Exception { + final String TEST_NAME="test211SchemaRegistryUntouched"; + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + /** + * Modify jack, see if the schema still applies. + */ + @Test + public void test213ModifiedUserJack() throws Exception { + final String TEST_NAME="test213ModifiedUserJack"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR"); + + // WHEN + when(); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + then(); + assertSuccess(result); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue("additionalName not readable", propDef.canRead()); + }, PrismTestUtil.createPolyString("Jackie")); + + assertPropertyValues(user, UserType.F_COST_CENTER, (propDef, name) -> { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue("costCenter not readable", propDef.canRead()); + },"G001"); // This is set by user template + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, (propDef, name) -> { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + assertTrue("preferredLanguage not readable", propDef.canRead()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + }, "en_PR"); + + + assertContainer(user, UserType.F_CREDENTIALS, new Validator>() { + @Override + public void validate(PrismContainerDefinition credentialsDef, String name) + throws Exception { + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + } + + }, true); + + assertProperty(user, ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), + (Validator>) (propDef, name) -> assertTrue("Password not readable", propDef.canRead())); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test240EditSchemaReconciliationTask() throws Exception { + // GIVEN + PrismObjectDefinition taskDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class); + PrismObject task = taskDef.instantiate(); + task.asObjectable() + .beginAssignment() + .targetRef(ARCHETYPE_TASK_RECONCILIATION_OID, ArchetypeType.COMPLEX_TYPE); + + display("Task before", task); + + // WHEN + when(); + PrismObjectDefinition editDef = getEditObjectDefinition(task); + + // THEN + then(); + + assertObjectDefinition(editDef) + .container(ObjectType.F_EXTENSION) + .assertSize(7) + .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECTCLASS) + .assertProperty(SchemaConstants.MODEL_EXTENSION_KIND) + .assertProperty(SchemaConstants.MODEL_EXTENSION_INTENT) + .assertProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) + .assertProperty(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS) + .assertProperty(SchemaConstants.MODEL_EXTENSION_FINISH_OPERATIONS_ONLY) + .assertProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN); + + assertSteadyResources(); + } + + @Test + public void test250EditSchemaRole() throws Exception { + final String TEST_NAME="test250EditSchemaRole"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); + PrismObject role = roleDef.instantiate(); + + // WHEN + when(); + PrismObjectDefinition editDef = getEditObjectDefinition(role); + + // THEN + then(); + + // TODO + PrismPropertyDefinition requestableDef = editDef.findPropertyDefinition(RoleType.F_REQUESTABLE); + assertNotNull("No definition for requestable in role", requestableDef); + assertEquals("Wrong requestable displayName", "Can request", requestableDef.getDisplayName()); + + assertSteadyResources(); + } + + @Test + public void test260EditShadowSchemaKindIntent() throws Exception { + final String TEST_NAME="test260EditShadowSchemaKindIntent"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, null, false); + + // WHEN + when(); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); + assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); + assertTrue("additionalName not readable", attrFullNameDef.canRead()); + + PrismContainerDefinition identifiersDef = editDef.findContainerDefinition(ItemPath.create(ShadowType.F_ASSOCIATION, + ShadowAssociationType.F_IDENTIFIERS)); + StringBuilder message = new StringBuilder(); + message.append("Wrong type for ").append(ShadowAssociationType.F_IDENTIFIERS) + .append(", expected ResourceAttributeContainerDefinition but was ") + .append(identifiersDef == null ? null : identifiersDef.getClass().getName()) + .append("; "); + assertClassType(message.toString(), identifiersDef, ResourceAttributeContainerDefinition.class); + + + assertSteadyResources(); + } + + @Test + public void test261EditShadowSchemaObjectclass() throws Exception { + final String TEST_NAME="test261EditShadowSchemaObjectclass"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(RESOURCE_DUMMY_OID, dummyResourceCtl.getAccountObjectClassQName()); + IntegrationTestTools.display("Discr", discr); + + // WHEN + when(); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNotNull("No definition for fullname attribute in shadow", attrFullNameDef); + assertEquals("Wrong shadow fullname attribute displayName", "Full Name", attrFullNameDef.getDisplayName()); + assertTrue("additionalName not readable", attrFullNameDef.canRead()); + + assertSteadyResources(); + } + + @Test + public void test263EditShadowSchemaEmpty() throws Exception { + final String TEST_NAME="test263EditShadowSchemaEmpty"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(null, null); + IntegrationTestTools.display("Discr", discr); + + // WHEN + when(); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(discr, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); + + assertSteadyResources(); + } + + @Test + public void test265EditShadowSchemaNull() throws Exception { + final String TEST_NAME="test265EditShadowSchemaNull"; + + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + PrismObjectDefinition editDef = modelInteractionService.getEditShadowDefinition(null, AuthorizationPhaseType.REQUEST, task, result); + + // THEN + then(); + assertSuccess(result); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME); + assertNotNull("No definition for name in shadow", nameDef); + assertEquals("Wrong shadow name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("additionalName not readable", nameDef.canRead()); + + PrismPropertyDefinition attrFullNameDef = editDef.findPropertyDefinition(dummyResourceCtl.getAttributeFullnamePath()); + assertNull("Unexpected definition for fullname attribute in shadow", attrFullNameDef); + + assertSteadyResources(); + } + + /** + * MID-4660, MID-4491, MID-3581 + */ + @Test + public void test310CustomRelations() throws Exception { + final String TEST_NAME="test310CustomRelations"; + + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + List relations = modelInteractionService.getRelationDefinitions(); + + // THEN + then(); + display("Relations", relations); + assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); + assertRelationDef(relations, SchemaConstants.ORG_OWNER, "Master"); + assertRelationDef(relations, RELATION_PIRACY_CAPTAIN, "Captain"); + assertEquals("Unexpected number of relation definitions", 8, relations.size()); + } + + /** + * Login as Otis. Otis has a restricted authorizations. Check that schema is presented accordingly to + * these limitations. + */ + @Test + public void test800OtisEditSchemaUser() throws Exception { + final String TEST_NAME="test800OtisEditSchemaUser"; + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = getTestTask(); + OperationResult result = task.getResult(); + + PrismObjectDefinition userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + PrismObject user = userDef.instantiate(); + + // WHEN + when(); + PrismObjectDefinition editDef = getEditObjectDefinition(user); + display("Otis edit schema", editDef); + + // THEN + then(); + + PrismPropertyDefinition nameDef = editDef.findPropertyDefinition(UserType.F_NAME); + assertNotNull("No definition for name in user", nameDef); + assertEquals("Wrong name displayName", "ObjectType.name", nameDef.getDisplayName()); + assertTrue("name not readable", nameDef.canRead()); + assertTrue("name is creatable", !nameDef.canAdd()); + assertTrue("name is modifiable", !nameDef.canModify()); + + PrismPropertyDefinition additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName()); + assertTrue("additionalName is readable", !additionalNameDef.canRead()); + assertTrue("additionalName is creatable", !additionalNameDef.canAdd()); + assertTrue("additionalName not modifiable", additionalNameDef.canModify()); + + PrismPropertyDefinition costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, costCenterDef.getDisplayOrder()); + assertTrue("costCenter is readable", !costCenterDef.canRead()); + assertTrue("costCenter is creatable", !costCenterDef.canAdd()); + assertTrue("costCenter is modifiable", !costCenterDef.canModify()); + + PrismPropertyDefinition preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue("preferredLanguage is readable", !preferredLanguageDef.canRead()); + assertTrue("preferredLanguage is creatable", !preferredLanguageDef.canAdd()); + assertTrue("preferredLanguage is modifiable", !preferredLanguageDef.canModify()); + + PrismContainerDefinition credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials is readable", !credentialsDef.canRead()); + assertTrue("Credentials is creatable", !credentialsDef.canAdd()); + assertTrue("Credentials is modifiable", !credentialsDef.canModify()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = editDef.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password is readable", !passwdValDef.canRead()); + assertTrue("Password is creatable", !passwdValDef.canAdd()); + assertTrue("Password is modifiable", !passwdValDef.canModify()); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test810OtisGetJack() throws Exception { + final String TEST_NAME="test810OtisGetJack"; + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + PrismObject user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertPropertyValues(user, UserType.F_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for name in user", propDef); + assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); + assertTrue(name+" not readable", propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }, PrismTestUtil.createPolyString("jack")); + + assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for description in user", propDef); + assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName()); + assertTrue(name+" not readable", propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" not modifiable", propDef.canModify()); + } + }, "Where's the rum?"); + + assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" not modifiable", propDef.canModify()); + } + }); + + assertPropertyValues(user, UserType.F_COST_CENTER, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }); + + assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue(name+" is readable", !propDef.canRead()); + assertTrue(name+" is creatable", !propDef.canAdd()); + assertTrue(name+" is modifiable", !propDef.canModify()); + } + }); + + PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); + + assertUntouchedUserDefinition(); + assertSteadyResources(); + } + + @Test + public void test820OtisSearchUsers() throws Exception { + final String TEST_NAME="test820OtisSearchUsers"; + + // GIVEN + login(USER_OTIS_USERNAME); + + Task task = getTestTask(); + OperationResult result = task.getResult(); + + // WHEN + when(); + SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); + + // THEN + then(); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Unexepected number of users found", 7, users.size()); + + for (final PrismObject user: users) { + assertProperty(user, UserType.F_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for name in user", propDef); + assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName()); + assertTrue(name+" of "+user+" not readable", propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + assertProperty(user, UserType.F_ADDITIONAL_NAME, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for additionalName in user", propDef); + assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" not modifiable", propDef.canModify()); + } + }); + assertProperty(user, UserType.F_COST_CENTER, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for costCenter in user", propDef); + assertEquals("Wrong costCenter displayOrder", (Integer)123, propDef.getDisplayOrder()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + + assertProperty(user, UserType.F_PREFERRED_LANGUAGE, new Validator>() { + @Override + public void validate(PrismPropertyDefinition propDef, String name) throws Exception { + assertNotNull("No definition for preferredLanguage in user", propDef); + assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName()); + PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef(); + assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef); + assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid()); + assertTrue(name+" of "+user+" is readable", !propDef.canRead()); + assertTrue(name+" of "+user+" is creatable", !propDef.canAdd()); + assertTrue(name+" of "+user+" is modifiable", !propDef.canModify()); + } + }); + + PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS); + + assertUntouchedUserDefinition(); + } + + } + + + private void assertProperty(PrismObject object, ItemPath path, + Validator> validator) throws Exception { + assertPropertyValues(object, path, validator, (T[])null); + } + + private void assertPropertyValues(PrismObject object, ItemPath path, + Validator> validator, T... expectedValues) throws Exception { + PrismProperty prop = object.findProperty(path); + if (expectedValues == null) { + if (prop != null) { + PrismPropertyDefinition propDef = prop.getDefinition(); + assertNotNull("No definition in property "+path, propDef); + try { + validator.validate(propDef, path.toString()+" (propDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", propDef); + throw e; + } + } + } else if (expectedValues.length == 0) { + assertNull("Unexpected property "+path+" in "+object+": "+prop, prop); + } else { + assertNotNull("No property "+path+" in "+object, prop); + PrismAsserts.assertPropertyValue(prop, expectedValues); + PrismPropertyDefinition propDef = prop.getDefinition(); + assertNotNull("No definition in property "+path, propDef); + try { + validator.validate(propDef, path.toString()+" (propDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", propDef); + throw e; + } + } + + PrismPropertyDefinition objPropDef = object.getDefinition().findPropertyDefinition(path); + assertNotNull("No definition of property "+path+" in object "+object, objPropDef); + try { + validator.validate(objPropDef, path.toString()+" (objectDef) "); + } catch (Exception | Error e) { + IntegrationTestTools.display("Wrong definition", objPropDef); + throw e; + } + + } + + private void assertContainer(PrismObject object, ItemName contName, + Validator> validator, boolean valueExpected) throws Exception { + PrismContainer container = object.findContainer(contName); + if (valueExpected) { + assertNotNull("No container "+contName+" in "+object, container); + PrismContainerDefinition contDef = container.getDefinition(); + assertNotNull("No definition in container "+contName, contDef); + validator.validate(contDef, contName.toString()); + } else { + assertNull("Unexpected container "+contName+" in "+object+": "+container, container); + } + + PrismContainerDefinition objContDef = object.getDefinition().findContainerDefinition(contName); + assertNotNull("No definition of container "+contName+" in object "+object, objContDef); + validator.validate(objContDef, contName.toString()); + } + + private void assertUntouchedUserDefinition() { + // WHEN + PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class); + + + // THEN + + PrismPropertyDefinition descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION); + assertNotNull("No definition for description in user", descriptionDef); + assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName()); + assertTrue("description not readable", descriptionDef.canRead()); + assertTrue("description not creatable", descriptionDef.canAdd()); + assertTrue("description not modifiable", descriptionDef.canModify()); + + PrismPropertyDefinition additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME); + assertNotNull("No definition for additionalName in user", additionalNameDef); + assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName()); + assertTrue("additionalName not readable", additionalNameDef.canRead()); + assertTrue("additionalName not creatable", additionalNameDef.canAdd()); + assertTrue("additionalName not modifiable", additionalNameDef.canModify()); + + PrismPropertyDefinition costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER); + assertNotNull("No definition for costCenter in user", costCenterDef); + assertEquals("Wrong costCenter displayOrder", (Integer)420, costCenterDef.getDisplayOrder()); + assertTrue("costCenter not readable", costCenterDef.canRead()); + assertTrue("costCenter not creatable", costCenterDef.canAdd()); + assertTrue("costCenter not modifiable", costCenterDef.canModify()); + PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef(); + assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef); + + PrismPropertyDefinition preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE); + assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef); + assertEquals("Wrong preferredLanguage displayName", "FocusType.preferredLanguage", preferredLanguageDef.getDisplayName()); + assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead()); + assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd()); + assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify()); + valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef(); + assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef); + assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", + SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid()); + + PrismContainerDefinition credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS); + assertNotNull("No definition for credentials in user", credentialsDef); + assertTrue("Credentials not readable", credentialsDef.canRead()); + assertTrue("Credentials not creatable", credentialsDef.canAdd()); + assertTrue("Credentials not modifiable", credentialsDef.canModify()); + + ItemPath passwdValPath = ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE); + PrismPropertyDefinition passwdValDef = userDefinition.findPropertyDefinition(passwdValPath); + assertNotNull("No definition for "+passwdValPath+" in user", passwdValDef); + assertTrue("Password not readable", passwdValDef.canRead()); + assertTrue("Password not creatable", passwdValDef.canAdd()); + assertTrue("Password not modifiable", passwdValDef.canModify()); + + } +} diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java index 8396f77b24d..a168e1316c3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/gensync/TestRoleEntitlement.java @@ -61,9 +61,8 @@ public class TestRoleEntitlement extends AbstractGenericSyncTest { @Test public void test050GetRolePirate() throws Exception { final String TEST_NAME = "test050GetRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -88,10 +87,9 @@ protected void assertRolePirate(PrismObject role) { @Test public void test100ModifyRoleAddEntitlement() throws Exception { final String TEST_NAME = "test100ModifyRoleAddEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -155,10 +153,9 @@ public void test100ModifyRoleAddEntitlement() throws Exception { @Test public void test101GetGroup() throws Exception { final String TEST_NAME = "test101GetGroup"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -185,10 +182,9 @@ public void test101GetGroup() throws Exception { @Test public void test102GetGroupNoFetch() throws Exception { final String TEST_NAME = "test102GetGroupNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -211,10 +207,9 @@ public void test102GetGroupNoFetch() throws Exception { @Test public void test103GetGroupRaw() throws Exception { final String TEST_NAME = "test103GetGroupRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createRaw()); @@ -236,10 +231,9 @@ public void test103GetGroupRaw() throws Exception { @Test public void test108ModifyRoleAddEntitlementAgain() throws Exception { final String TEST_NAME = "test108ModifyRoleAddEntitlementAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -283,10 +277,9 @@ public void test108ModifyRoleAddEntitlementAgain() throws Exception { @Test public void test110GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test110GetRoleResolveEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -312,10 +305,9 @@ public void test110GetRoleResolveEntitlement() throws Exception { @Test public void test111GetRoleResolveEntitlement() throws Exception { final String TEST_NAME = "test111GetRoleResolveEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -345,10 +337,9 @@ public void test111GetRoleResolveEntitlement() throws Exception { @Test public void test112GetRoleResolveEntitlementNoFetch() throws Exception { final String TEST_NAME = "test112GetRoleResolveEntitlementNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -377,10 +368,9 @@ public void test112GetRoleResolveEntitlementNoFetch() throws Exception { @Test public void test119ModifyRoleDeleteEntitlement() throws Exception { final String TEST_NAME = "test119ModifyRoleDeleteEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -396,11 +386,11 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { prepareNotifications(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess("executeChanges result", result, 2); @@ -435,10 +425,9 @@ public void test119ModifyRoleDeleteEntitlement() throws Exception { @Test public void test120AddEntitlement() throws Exception { final String TEST_NAME = "test120AddEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -448,11 +437,11 @@ public void test120AddEntitlement() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); Collection> executedChanges = executeChanges(groupDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -490,10 +479,9 @@ public void test120AddEntitlement() throws Exception { @Test public void test121ModifyRoleLinkEntitlement() throws Exception { final String TEST_NAME = "test121ModifyRoleLinkEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -505,11 +493,11 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { roleDelta.addModification(linkDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(roleDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -543,10 +531,9 @@ public void test121ModifyRoleLinkEntitlement() throws Exception { @Test public void test128ModifyRoleUnlinkEntitlement() throws Exception { final String TEST_NAME = "test128ModifyRoleUnlinkEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -596,10 +583,9 @@ public void test128ModifyRoleUnlinkEntitlement() throws Exception { @Test public void test129DeleteEntitlement() throws Exception { final String TEST_NAME = "test129DeleteEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.POSITIVE); @@ -638,10 +624,9 @@ public void test129DeleteEntitlement() throws Exception { @Test public void test131ModifyRoleAssignEntitlement() throws Exception { final String TEST_NAME = "test131ModifyRoleAssignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -650,11 +635,11 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(assignmentDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess("executeChanges result", result); PrismObject role = getRole(ROLE_PIRATE_OID); @@ -700,10 +685,9 @@ public void test131ModifyRoleAssignEntitlement() throws Exception { @Test public void test132ModifyEntitlement() throws Exception { final String TEST_NAME = "test132ModifyEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -765,10 +749,9 @@ public void test132ModifyEntitlement() throws Exception { @Test public void test139ModifyRoleUnassignEntitlement() throws Exception { final String TEST_NAME = "test139ModifyRoleUnassignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -815,10 +798,9 @@ public void test139ModifyRoleUnassignEntitlement() throws Exception { @Test public void test151ModifyRoleAssignEntitlementRelativeEnforcement() throws Exception { final String TEST_NAME = "test151ModifyRoleAssignEntitlementRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -876,7 +858,6 @@ public void test151ModifyRoleAssignEntitlementRelativeEnforcement() throws Excep @Test public void test158ModifyRoleUnassignEntitlementRelativeEnforcement() throws Exception { final String TEST_NAME = "test158ModifyRoleUnassignEntitlementRelativeEnforcement"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestRoleEntitlement.class.getName() @@ -927,10 +908,9 @@ public void test158ModifyRoleUnassignEntitlementRelativeEnforcement() throws Exc @Test public void test160ModifyRolePropertyAndAssignEntitlement() throws Exception { final String TEST_NAME = "test160ModifyRolePropertyAndAssignEntitlement"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -989,10 +969,9 @@ public void test160ModifyRolePropertyAndAssignEntitlement() throws Exception { @Test public void test161ModifyRole() throws Exception { final String TEST_NAME = "test161ModifyRole"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1046,10 +1025,9 @@ public void test161ModifyRole() throws Exception { @Test public void test180RenameRole() throws Exception { final String TEST_NAME = "test180RenameRole"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.FULL); @@ -1109,10 +1087,9 @@ public void test180RenameRole() throws Exception { @Test public void test199DeleteRole() throws Exception { final String TEST_NAME = "test199DeleteRole"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1164,10 +1141,9 @@ public void test199DeleteRole() throws Exception { @Test public void test200AddRoleSwashbuckler() throws Exception { final String TEST_NAME = "test200AddRoleSwashbuckler"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1177,11 +1153,11 @@ public void test200AddRoleSwashbuckler() throws Exception { XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(roleDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar(); @@ -1230,10 +1206,9 @@ public void test200AddRoleSwashbuckler() throws Exception { @Test public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { final String TEST_NAME = "test210ModifyRoleSwashbucklerRiskLevel"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(AssignmentPolicyEnforcementType.RELATIVE); @@ -1242,11 +1217,11 @@ public void test210ModifyRoleSwashbucklerRiskLevel() throws Exception { .assertItems(PIRACY_COST_CENTER); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_SWASHBUCKLER_OID, RoleType.F_RISK_LEVEL, task, result, "99"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRoleAfter(ROLE_SWASHBUCKLER_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java index d7824ffb298..32e2c4e8228 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/importer/AbstractImportTest.java @@ -151,14 +151,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test000Integrity() { - displayTestTitle("test000Integrity"); assertNotNull(modelService); assertNotNull(repositoryService); } @Test public void test001ImportConnector() throws FileNotFoundException, ObjectNotFoundException, SchemaException { - displayTestTitle("test001ImportConnector"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test001ImportConnector"); @@ -198,7 +196,6 @@ public void test001ImportConnector() throws FileNotFoundException, ObjectNotFoun @Test public void test003ImportUsers() throws Exception { - displayTestTitle("test003ImportUsers"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test003ImportUsers"); @@ -259,7 +256,6 @@ public void test003ImportUsers() throws Exception { // Import the same thing again. Watch how it burns :-) @Test public void test004DuplicateImportUsers() throws Exception { - displayTestTitle("test004DuplicateImportUsers"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test004DuplicateImportUsers"); @@ -292,7 +288,6 @@ public void test004DuplicateImportUsers() throws Exception { // Import the same thing again, this time with overwrite option. This should go well. @Test public void test005ImportUsersWithOverwrite() throws Exception { - displayTestTitle("test005ImportUsersWithOverwrite"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test005ImportUsersWithOverwrite"); @@ -356,7 +351,6 @@ public void test005ImportUsersWithOverwrite() throws Exception { // Import the same thing again, with overwrite and also while keeping OIDs @Test public void test006ImportUsersWithOverwriteKeepOid() throws Exception { - displayTestTitle("test006ImportUsersWithOverwriteKeepOid"); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "test005ImportUsersWithOverwrite"); @@ -418,7 +412,6 @@ public void test006ImportUsersWithOverwriteKeepOid() throws Exception { @Test public void test020ImportTask() throws Exception { final String TEST_NAME = "test020ImportTask"; - displayTestTitle( TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -463,7 +456,6 @@ public void test020ImportTask() throws Exception { @Test public void test030ImportResource() throws Exception { final String TEST_NAME = "test030ImportResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -514,7 +506,6 @@ public void test030ImportResource() throws Exception { @Test public void test031ReimportResource() throws Exception { final String TEST_NAME = "test031ReimportResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -569,7 +560,6 @@ public void test031ReimportResource() throws Exception { @Test public void test032ImportResourceOidAndFilter() throws Exception { final String TEST_NAME = "test032ImportResourceOidAndFilter"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -623,7 +613,6 @@ public void test032ImportResourceOidAndFilter() throws Exception { @Test public void test033ImportResourceDummyRuntime() throws Exception { final String TEST_NAME = "test033ImportResourceDummyRuntime"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(AbstractImportTest.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -662,7 +651,6 @@ public void test033ImportResourceDummyRuntime() throws Exception { @Test public void test040ImportUserHermanNoEncryption() throws Exception { final String TEST_NAME = "test040ImportUserHermanNoEncryption"; - displayTestTitle(TEST_NAME); // GIVEN InternalsConfig.readEncryptionChecks = false; @@ -709,7 +697,6 @@ public void test040ImportUserHermanNoEncryption() throws Exception { @Test public void test050ImportUserHermanOverwriteFullProcessing() throws Exception { final String TEST_NAME = "test050ImportUserHermanOverwriteFullProcessing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -754,7 +741,6 @@ public void test050ImportUserHermanOverwriteFullProcessing() throws Exception { @Test public void test060ImportConstrainedWrongFullProcessing() throws Exception { final String TEST_NAME = "test060ImportConstrainedWrongFullProcessing"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -792,7 +778,6 @@ public void test060ImportConstrainedWrongFullProcessing() throws Exception { @Test public void test070ImportConstrainedWrong() throws Exception { final String TEST_NAME = "test070ImportConstrainedWrong"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); @@ -828,7 +813,6 @@ public void test070ImportConstrainedWrong() throws Exception { @Test public void test100GoodRefImport() throws Exception { final String TEST_NAME = "test100GoodRefImport"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." +TEST_NAME); @@ -861,7 +845,6 @@ public void test100GoodRefImport() throws Exception { @Test public void test200BadImport() throws Exception { final String TEST_NAME = "test200BadImport"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); @@ -893,7 +876,6 @@ public void test200BadImport() throws Exception { @Test public void test210ImportRoleOneLegacyDefault() throws Exception { final String TEST_NAME = "test210ImportRoleOneLegacyDefault"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); @@ -918,7 +900,6 @@ public void test210ImportRoleOneLegacyDefault() throws Exception { @Test public void test212ImportRoleOneLegacyCompat() throws Exception { final String TEST_NAME = "test212ImportRoleOneLegacyCompat"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = new OperationResult(AbstractImportTest.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java index c848740053c..687ebaf670e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractDirectManualResourceTest.java @@ -31,8 +31,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; @@ -100,12 +98,8 @@ public abstract class AbstractDirectManualResourceTest extends AbstractManualRes protected static final File ROLE_TWO_SEMI_MANUAL_DISABLE_SLOW_PROPOSED_FILE = new File(TEST_DIR, "role-two-semi-manual-disable-slow-proposed.xml"); protected static final String ROLE_TWO_SEMI_MANUAL_DISABLE_SLOW_PROPOSED_OID = "5ecd6fa6-a200-11e7-b0cb-af5e1792d327"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractDirectManualResourceTest.class); - private XMLGregorianCalendar roleTwoValidFromTimestamp; - protected String accountBarbossaOid; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -125,19 +119,18 @@ protected boolean isDirect() { @Test public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -203,9 +196,8 @@ public void test220ModifyUserWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -219,11 +211,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -292,9 +284,8 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { @Test public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -302,12 +293,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -383,9 +374,8 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { @Test public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -394,11 +384,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -471,20 +461,19 @@ public void test250RecomputeWillAfter5min() throws Exception { @Test public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.DISABLED, USER_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -530,9 +519,8 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willSecondLastCaseOid); @@ -540,11 +528,11 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -635,9 +623,8 @@ public void test260ClosePasswordChangeCaseAndRecomputeWill() throws Exception { @Test public void test270RecomputeWillAfter7min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter7min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT7M"); @@ -646,11 +633,11 @@ public void test270RecomputeWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -734,20 +721,19 @@ public void test270RecomputeWillAfter7min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") @@ -793,9 +779,8 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test274RecomputeWillAfter22min() throws Exception { final String TEST_NAME = "test292RecomputeWillAfter22min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); @@ -804,11 +789,11 @@ public void test274RecomputeWillAfter22min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -879,19 +864,18 @@ public void test274RecomputeWillAfter22min() throws Exception { @Test public void test280RecomputeWillAfter27min() throws Exception { final String TEST_NAME = "test280RecomputeWillAfter27min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = assertRepoShadow(accountWillOid) @@ -953,19 +937,18 @@ public void test280RecomputeWillAfter27min() throws Exception { @Test public void test290RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter32min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1016,9 +999,8 @@ public void test290RecomputeWillAfter32min() throws Exception { @Test public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertSteadyResources(); @@ -1026,11 +1008,11 @@ public void test300UnassignAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1093,17 +1075,16 @@ public void test300UnassignAccountWill() throws Exception { @Test public void test302RecomputeWill() throws Exception { final String TEST_NAME = "test302RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1164,9 +1145,8 @@ public void test302RecomputeWill() throws Exception { @Test public void test310CloseCaseAndReconcileWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1174,12 +1154,12 @@ public void test310CloseCaseAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1230,19 +1210,18 @@ protected void assertUnassignedShadow(ShadowAsserter shadowModelAsserter, boo @Test public void test320RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test320RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1284,23 +1263,22 @@ public void test320RecomputeWillAfter5min() throws Exception { @Test public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeprovisionWill(); displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(); // Reconcile is needed here. Recompute means noFetch which means that we won't // discover that an account is missing from backing store which means that the // quantum state won't collapse. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -1348,19 +1326,18 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { @Test public void test340RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test340RecomputeWillAfter25min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1390,19 +1367,18 @@ public void test340RecomputeWillAfter25min() throws Exception { @Test public void test342RecomputeWillAfter35min() throws Exception { final String TEST_NAME = "test342RecomputeWillAfter35min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT10M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1429,19 +1405,18 @@ public void test342RecomputeWillAfter35min() throws Exception { @Test public void test344RecomputeWillAfter165min() throws Exception { final String TEST_NAME = "test344RecomputeWillAfter165min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); UserAsserter userAfterAsserter = assertUserAfter(userWillOid); @@ -1467,13 +1442,10 @@ protected void assertDeprovisionedTimedOutUser(UserAsserter userAsserter, */ @Test public void test349CleanUp() throws Exception { - final String TEST_NAME = "test349CleanUp"; - displayTestTitle(TEST_NAME); - - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); } - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { // nothing to do here } @@ -1496,19 +1468,18 @@ public void test500AssignWillRoleOne() throws Exception { @Test public void test510UnassignWillRoleOne() throws Exception { final String TEST_NAME = "test510UnassignWillRoleOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1567,17 +1538,16 @@ public void test510UnassignWillRoleOne() throws Exception { @Test public void test512ReconcileWill() throws Exception { final String TEST_NAME = "test512ReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1638,9 +1608,8 @@ public void test512ReconcileWill() throws Exception { @Test public void test515CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test515CloseCasesAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1649,12 +1618,12 @@ public void test515CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -1739,19 +1708,18 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter @Test public void test516RecomputeWillAfter20min() throws Exception { final String TEST_NAME = "test516RecomputeWillAfter20min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1774,19 +1742,18 @@ public void test516RecomputeWillAfter20min() throws Exception { @Test public void test517RecomputeWillAfter50min() throws Exception { final String TEST_NAME = "test517RecomputeWillAfter50min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid); @@ -1811,19 +1778,18 @@ public void test517RecomputeWillAfter50min() throws Exception { @Test public void test518RecomputeWillAfter180min() throws Exception { final String TEST_NAME = "test518RecomputeWillAfter180min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userWillOid) @@ -1842,12 +1808,10 @@ public void test518RecomputeWillAfter180min() throws Exception { */ @Test public void test519CleanUp() throws Exception { - final String TEST_NAME = "test519CleanUp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); // Make sure that all pending operations are expired clockForward("PT1H"); @@ -1874,9 +1838,8 @@ public void test520AssignWillRoleOne() throws Exception { @Test public void test522AssignWillRoleTwoValidFrom() throws Exception { final String TEST_NAME = "test522AssignWillRoleTwoValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -1884,11 +1847,11 @@ public void test522AssignWillRoleTwoValidFrom() throws Exception { activationType.setValidFrom(roleTwoValidFromTimestamp); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userWillOid, getRoleTwoOid(), activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillOid = assertUserAfter(userWillOid) @@ -1908,22 +1871,21 @@ public void test522AssignWillRoleTwoValidFrom() throws Exception { @Test public void test524TwoHoursForRoleTwo() throws Exception { final String TEST_NAME = "test524TwoHoursForRoleTwo"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("PT2H5M"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1977,9 +1939,8 @@ public void test524TwoHoursForRoleTwo() throws Exception { @Test public void test525CloseCasesAndReconcileWill() throws Exception { final String TEST_NAME = "test525CloseCasesAndReconcileWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1988,12 +1949,12 @@ public void test525CloseCasesAndReconcileWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -2015,9 +1976,8 @@ public void test525CloseCasesAndReconcileWill() throws Exception { @Test public void test526UnassignWillBothRoles() throws Exception { final String TEST_NAME = "test526UnassignWillBothRoles"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(userWillOid); @@ -2025,12 +1985,12 @@ public void test526UnassignWillBothRoles() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2075,9 +2035,8 @@ protected void assertTest526Deltas(PrismObject shadowRepo, Operation @Test public void test528CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test528CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -2085,12 +2044,12 @@ public void test528CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -2134,12 +2093,10 @@ protected void assertTest528Deltas(PrismObject shadowRepo, Operation */ @Test public void test529CleanUp() throws Exception { - final String TEST_NAME = "test529CleanUp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); // Make sure that all pending operations are expired clockForward("PT3H"); @@ -2158,15 +2115,14 @@ public void test529CleanUp() throws Exception { @Test public void test800ImportShadowRefreshTask() throws Exception { final String TEST_NAME = "test800ImportShadowRefreshTask"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_SHADOW_REFRESH_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); } @@ -2175,7 +2131,7 @@ public void test800ImportShadowRefreshTask() throws Exception { public void test810AssignAccountWill() throws Exception { final String TEST_NAME = "test810AssignAccountWill"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(userWillOid) @@ -2197,9 +2153,8 @@ public void test810AssignAccountWill() throws Exception { @Test public void test820AssignAccountJack() throws Exception { final String TEST_NAME = "test820AssignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -2207,11 +2162,11 @@ public void test820AssignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -2235,9 +2190,8 @@ public void test820AssignAccountJack() throws Exception { @Test public void test830CloseCaseWillAndWaitForRefresh() throws Exception { final String TEST_NAME = "test830CloseCaseWillAndWaitForRefresh"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -2245,12 +2199,12 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_SHADOW_REFRESH_OID); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2263,19 +2217,18 @@ public void test830CloseCaseWillAndWaitForRefresh() throws Exception { @Test public void test840AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test840AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreProvisionWill(INTEREST_ONE); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter.forShadow(shadowModel, "model") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java index 0cf5d561b6d..5d527898428 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractGroupingManualResourceTest.java @@ -163,19 +163,18 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test220ModifyUserWillDisable() throws Exception { final String TEST_NAME = "test220ModifyUserWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -244,9 +243,8 @@ public void test220ModifyUserWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, @@ -260,11 +258,11 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertInProgress(result); @@ -274,7 +272,7 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { } protected void assertAccountWillAfterChangePasswordAndEnable(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -338,17 +336,16 @@ protected void assertAccountWillAfterChangePasswordAndEnable(final String TEST_N @Test public void test232RunPropagationBeforeInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertAccountWillAfterChangePasswordAndEnable(TEST_NAME); } @@ -360,9 +357,8 @@ public void test232RunPropagationBeforeInterval() throws Exception { @Test public void test235RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test235RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); @@ -370,11 +366,11 @@ public void test235RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -468,9 +464,8 @@ public void test235RunPropagationAfterInterval() throws Exception { @Test public void test240CloseCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -478,12 +473,12 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -498,9 +493,8 @@ public void test240CloseCaseAndReadAccountWill() throws Exception { @Test public void test250RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test250RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); @@ -509,11 +503,11 @@ public void test250RecomputeWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterChangePasswordAndEnableCaseClosed(TEST_NAME, null); @@ -526,9 +520,8 @@ public void test250RecomputeWillAfter5min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ff 7min. Refresh. Oldest delta over grace. But not expired yet. @@ -537,12 +530,12 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -584,21 +577,20 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test273GetAccountWill() throws Exception { final String TEST_NAME = "test273GetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ff 15min. Oldest delta should expire. clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ShadowAsserter shadowModelAsserter = ShadowAsserter.forShadow(shadowModel, "model") @@ -640,19 +632,18 @@ public void test273GetAccountWill() throws Exception { @Test public void test290RecomputeWillAfter15min() throws Exception { final String TEST_NAME = "test290RecomputeWillAfter15min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -700,19 +691,18 @@ public void test290RecomputeWillAfter15min() throws Exception { @Test public void test300UnassignAccountWill() throws Exception { final String TEST_NAME = "test300UnassignAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -776,9 +766,8 @@ public void test300UnassignAccountWill() throws Exception { @Test public void test302RunPropagationAfterInterval() throws Exception { final String TEST_NAME = "test302RunPropagationAfterInterval"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); @@ -786,11 +775,11 @@ public void test302RunPropagationAfterInterval() throws Exception { accountWillExecutionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); accountWillExecutionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -852,9 +841,8 @@ public void test302RunPropagationAfterInterval() throws Exception { @Test public void test310CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -862,12 +850,12 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -904,20 +892,19 @@ public void test310CloseCaseAndRecomputeWill() throws Exception { @Test public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeprovisionWill(); displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -953,9 +940,8 @@ public void test330UpdateBackingStoreAndRecomputeWill() throws Exception { @Test public void test349CleanUp() throws Exception { final String TEST_NAME = "test349CleanUp"; - displayTestTitle(TEST_NAME); - cleanupUser(TEST_NAME, userWillOid, USER_WILL_NAME, accountWillOid); + cleanupUser(userWillOid, USER_WILL_NAME, accountWillOid); } // TODO: test400: create -> modify -> propagation @@ -965,7 +951,7 @@ protected void assertUnassignedShadow(PrismObject shadow, Activation } protected void assertAccountWillAfterChangePasswordAndEnableCaseClosed(final String TEST_NAME, PrismObject shadowModel) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java index af9bafe83b3..271fe7c6c52 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/AbstractManualResourceTest.java @@ -69,8 +69,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; @@ -107,8 +105,6 @@ public abstract class AbstractManualResourceTest extends AbstractConfiguredModel public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass"); - private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class); - protected static final String NS_MANUAL_CONF = "http://midpoint.evolveum.com/xml/ns/public/connector/builtin-1/bundle/com.evolveum.midpoint.provisioning.ucf.impl.builtin/ManualConnector"; protected static final ItemName CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME = new ItemName(NS_MANUAL_CONF, "defaultAssignee"); @@ -267,7 +263,6 @@ protected boolean hasMultivalueInterests() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); @@ -299,9 +294,8 @@ public void test012TestConnection() throws Exception { } public void testConnection(final String TEST_NAME, boolean initialized) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is a schema, but no capabilities before test (pre-condition) @@ -324,11 +318,11 @@ public void testConnection(final String TEST_NAME, boolean initialized) throws E } // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(getResourceOid(), task); // THEN - displayThen(TEST_NAME); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -377,7 +371,6 @@ protected boolean nativeCapabilitiesEntered() { @Test public void test014Configuration() throws Exception { final String TEST_NAME = "test014Configuration"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); @@ -393,19 +386,12 @@ public void test014Configuration() throws Exception { PrismProperty propDefaultAssignee = configurationContainer.findProperty(CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME); assertNotNull("No defaultAssignee conf prop", propDefaultAssignee); -// assertNotNull("No configuration properties container", confingurationPropertiesContainer); -// PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition(); -// assertNotNull("No configuration properties container definition", confPropDef); - assertSteadyResources(); } @Test public void test016ParsedSchema() throws Exception { - final String TEST_NAME = "test016ParsedSchema"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -455,7 +441,6 @@ public void test017Capabilities() throws Exception { } public void testCapabilities(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName()+"."+TEST_NAME); @@ -505,9 +490,8 @@ public void test018ResourceCaching() throws Exception { } public void testResourceCaching(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceReadonlyBefore = modelService.getObject( @@ -516,19 +500,19 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resourceReadOnlyAgain = modelService.getObject( ResourceType.class, getResourceOid(), GetOperationOptions.createReadOnlyCollection(), task, result); assertSteadyResources(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resourceAgain = modelService.getObject( ResourceType.class, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // assertTrue("Resource instance changed", resourceBefore == resourceReadOnlyAgain); @@ -539,20 +523,19 @@ public void testResourceCaching(final String TEST_NAME) throws Exception { @Test public void test020ReimportResource() throws Exception { final String TEST_NAME = "test020ReimportResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType(); options.setOverwrite(true); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @@ -580,20 +563,19 @@ public void test028ResourceCaching() throws Exception { @Test public void test030ReimportResourceAgain() throws Exception { final String TEST_NAME = "test030ReimportResourceAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType(); options.setOverwrite(true); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importObjectsFromFile(getResourceFile(), options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @@ -601,19 +583,18 @@ public void test030ReimportResourceAgain() throws Exception { @Test public void test032UseResource() throws Exception { final String TEST_NAME = "test032UseResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), ShadowKindType.ACCOUNT, null, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found accounts", accounts); @@ -694,19 +675,18 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test101GetAccountWillFuture() throws Exception { final String TEST_NAME = "test101GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -728,17 +708,16 @@ public void test101GetAccountWillFuture() throws Exception { @Test public void test102RecomputeWill() throws Exception { final String TEST_NAME = "test102RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -752,19 +731,18 @@ public void test102RecomputeWill() throws Exception { @Test public void test103RunPropagation() throws Exception { final String TEST_NAME = "test103RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT2M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 1); @@ -779,18 +757,17 @@ public void test103RunPropagation() throws Exception { @Test public void test104RecomputeWill() throws Exception { final String TEST_NAME = "test104RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); @@ -807,16 +784,15 @@ public void test104RecomputeWill() throws Exception { public void test105RunPropagationAgain() throws Exception { final String TEST_NAME = "test105RunPropagationAgain"; - displayTestTitle(TEST_NAME); // GIVEN rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertAccountWillAfterAssign(TEST_NAME, USER_WILL_FULL_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -831,20 +807,19 @@ public void test105RunPropagationAgain() throws Exception { @Test public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreProvisionWill(INTEREST_ONE); displayBackingStore(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -876,19 +851,18 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { @Test public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Model shadow", shadowModel); @@ -924,9 +898,8 @@ public void test108GetAccountWillFuture() throws Exception { @Test public void test110CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -934,12 +907,12 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -957,16 +930,15 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { public void test114RunPropagation() throws Exception { final String TEST_NAME = "test114RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN rememberCounter(InternalCounters.CONNECTOR_MODIFICATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.CONNECTOR_MODIFICATION_COUNT, 0); assertWillAfterCreateCaseClosed(TEST_NAME, true); @@ -980,19 +952,18 @@ public void test114RunPropagation() throws Exception { @Test public void test120RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test120RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1023,19 +994,18 @@ public void test120RecomputeWillAfter5min() throws Exception { @Test public void test130RecomputeWillAfter25min() throws Exception { final String TEST_NAME = "test130RecomputeWillAfter25min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1066,19 +1036,18 @@ public void test130RecomputeWillAfter25min() throws Exception { @Test public void test132RecomputeWillAfter32min() throws Exception { final String TEST_NAME = "test132RecomputeWillAfter32min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT7M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(accountWillOid) @@ -1097,9 +1066,8 @@ public void test132RecomputeWillAfter32min() throws Exception { @Test public void test200ModifyUserWillFullname() throws Exception { final String TEST_NAME = "test200ModifyUserWillFullname"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1110,11 +1078,11 @@ public void test200ModifyUserWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userWillOid, UserType.F_FULL_NAME, task, result, createPolyString(USER_WILL_FULL_NAME_PIRATE)); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1128,17 +1096,16 @@ public void test200ModifyUserWillFullname() throws Exception { @Test public void test202RecomputeWill() throws Exception { final String TEST_NAME = "test202RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTION_PENDING); @@ -1149,17 +1116,16 @@ public void test202RecomputeWill() throws Exception { @Test public void test203RunPropagation() throws Exception { final String TEST_NAME = "test203RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN clockForward("PT2M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1169,17 +1135,16 @@ public void test203RunPropagation() throws Exception { @Test public void test204RecomputeWill() throws Exception { final String TEST_NAME = "test204RecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillAfterFullNameModification(TEST_NAME, PendingOperationExecutionStatusType.EXECUTING); @@ -1193,9 +1158,8 @@ public void test204RecomputeWill() throws Exception { @Test public void test206CloseCaseAndRecomputeWill() throws Exception { final String TEST_NAME = "test206CloseCaseAndRecomputeWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(willLastCaseOid); @@ -1203,11 +1167,11 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1271,19 +1235,18 @@ public void test206CloseCaseAndRecomputeWill() throws Exception { @Test public void test210RecomputeWillAfter5min() throws Exception { final String TEST_NAME = "test210RecomputeWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT5M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userWillOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -1331,20 +1294,19 @@ public void test210RecomputeWillAfter5min() throws Exception { @Test public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreUpdateWill(USER_WILL_FULL_NAME_PIRATE, INTEREST_ONE, ActivationStatusType.ENABLED, USER_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED); @@ -1393,19 +1355,18 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - setupPhantom(TEST_NAME); + setupPhantom(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_PHANTOM_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); // This should theoretically always return IN_PROGRESS, as there is // reconciliation operation going on. But due to various "peculiarities" @@ -1417,11 +1378,11 @@ public void test400PhantomAccount() throws Exception { } // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHANTOM_OID); display("User after", userAfter); @@ -1447,9 +1408,9 @@ public void test400PhantomAccount() throws Exception { assertSteadyResources(); } - protected void setupPhantom(final String TEST_NAME) throws Exception { + protected void setupPhantom() throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_PHANTOM_FILE); @@ -1467,30 +1428,29 @@ protected void setupPhantom(final String TEST_NAME) throws Exception { @Test public void test410AssignPhoenixAccount() throws Exception { final String TEST_NAME = "test410AssignPhoenixAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_PHOENIX_FILE); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1514,20 +1474,19 @@ public void test410AssignPhoenixAccount() throws Exception { @Test public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { final String TEST_NAME = "test412AddPhoenixToBackingStoreAndCloseTicket"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreAddPhoenix(); closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1553,19 +1512,18 @@ public void test412AddPhoenixToBackingStoreAndCloseTicket() throws Exception { @Test public void test413PhoenixLetOperationsExpire() throws Exception { final String TEST_NAME = "test413PhoenixLetOperationsExpire"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT1H"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_PHOENIX_OID); @@ -1591,28 +1549,27 @@ public void test413PhoenixLetOperationsExpire() throws Exception { @Test public void test414UnassignPhoenixAccount() throws Exception { final String TEST_NAME = "test414UnassignPhoenixAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1635,30 +1592,29 @@ public void test414UnassignPhoenixAccount() throws Exception { @Test public void test416PhoenixAccountUnassignCloseCase() throws Exception { final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1683,28 +1639,27 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { @Test public void test418AssignPhoenixAccountAgain() throws Exception { final String TEST_NAME = "test418AssignPhoenixAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -1768,15 +1723,13 @@ protected int getConcurrentTestRandomStartDelayRangeUnassign() { @Test public void test900SetUpRoles() throws Exception { final String TEST_NAME = "test900SetUpRoles"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; } // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); + Task task = getTestTask(); SystemConfigurationType systemConfiguration = getSystemConfiguration(); display("System config", systemConfiguration); @@ -1819,14 +1772,13 @@ protected String getRoleInterest(int i) { @Test public void test910ConcurrentRolesAssign() throws Exception { final String TEST_NAME = "test910ConcurrentRolesAssign"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; } // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); int numberOfCasesBefore = getObjectCount(CaseType.class); @@ -1837,19 +1789,19 @@ public void test910ConcurrentRolesAssign() throws Exception { final long TIMEOUT = 60000L; // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { login(userAdministrator); - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); assignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localTask.getResult()); }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeAssign()); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -1862,7 +1814,7 @@ public void test910ConcurrentRolesAssign() throws Exception { display("Repo shadow", shadowRepo); assertShadowNotDead(shadowRepo); - assertTest910ShadowRepo(shadowRepo, task, result); + assertTest910ShadowRepo(shadowRepo); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject shadowModel = modelService.getObject(ShadowType.class, accountDrakeOid, options, task, result); @@ -1871,7 +1823,7 @@ public void test910ConcurrentRolesAssign() throws Exception { // assertObjects(CaseType.class, numberOfCasesBefore + getConcurrentTestNumberOfThreads()); } - protected void assertTest910ShadowRepo(PrismObject shadowRepo, Task task, OperationResult result) throws Exception { + protected void assertTest910ShadowRepo(PrismObject shadowRepo) throws Exception { assertShadowNotDead(shadowRepo); ObjectDeltaType addPendingDelta = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { @@ -1898,14 +1850,13 @@ protected void assertTest910ShadowRepo(PrismObject shadowRepo, Task @Test public void test919ConcurrentRoleUnassign() throws Exception { final String TEST_NAME = "test919ConcurrentRoleUnassign"; - displayTestTitle(TEST_NAME); if (!are9xxTestsEnabled()) { displaySkip(TEST_NAME); return; } // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); int numberOfCasesBefore = getObjectCount(CaseType.class); @@ -1916,13 +1867,13 @@ public void test919ConcurrentRoleUnassign() throws Exception { final long TIMEOUT = 60000L; // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { display("Thread "+Thread.currentThread().getName()+" START"); login(userAdministrator); - Task localTask = createTask(TEST_NAME + ".local"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); unassignRole(USER_DRAKE_OID, getRoleOid(i), localTask, localResult); @@ -1934,7 +1885,7 @@ public void test919ConcurrentRoleUnassign() throws Exception { }, getConcurrentTestNumberOfThreads(), getConcurrentTestRandomStartDelayRangeUnassign()); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, TIMEOUT); PrismObject userAfter = getUser(USER_DRAKE_OID); @@ -2003,7 +1954,7 @@ protected void assertTest919ShadowFuture(PrismObject shadowModelFutu } protected void assertAccountWillAfterFullNameModification(final String TEST_NAME, PendingOperationExecutionStatusType executionStage) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result); @@ -2100,19 +2051,18 @@ protected void backingStoreAddPhoenix() throws IOException { } protected void assignWillRoleOne(final String TEST_NAME, String expectedFullName, PendingOperationExecutionStatusType executionStage) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userWillOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2197,7 +2147,7 @@ protected boolean caseShouldExist(PendingOperationExecutionStatusType executionS protected void assertAccountJackAfterAssign(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowRepo = repositoryService.getObject(ShadowType.class, accountJackOid, null, result); @@ -2233,7 +2183,7 @@ protected void assertAccountJackAfterAssign(final String TEST_NAME) throws Excep } protected void assertWillAfterCreateCaseClosed(final String TEST_NAME, boolean backingStoreUpdated) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowAsserter shadowRepoAsserter = assertRepoShadow(accountWillOid) @@ -2370,7 +2320,7 @@ private void assertManual(AbstractWriteCapabilityType cap) { assertEquals("Manual flag not set in capability "+cap, Boolean.TRUE, cap.isManual()); } - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { // nothing to do here } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java index b8df20c3fb6..7c530853a82 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestDummyItsmIntegration.java @@ -98,7 +98,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestDummyItsmIntegration.class.getName() + "." + TEST_NAME); @@ -121,17 +120,16 @@ public void test000Sanity() throws Exception { @Test public void test012TestConnection() throws Exception { final String TEST_NAME = "test012TestConnection"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_ITSM_OID, task); // THEN - displayThen(TEST_NAME); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); @@ -150,17 +148,16 @@ public void test012TestConnection() throws Exception { @Test public void test100AssignAccountToJack() throws Exception { final String TEST_NAME = "test100AssignAccountToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -180,19 +177,18 @@ public void test100AssignAccountToJack() throws Exception { @Test public void test102CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test102CloseTicketAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -207,17 +203,16 @@ public void test102CloseTicketAndRecomputeJack() throws Exception { @Test public void test104UnassignAccountFromJack() throws Exception { final String TEST_NAME = "test104UnassignAccountFromJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -238,9 +233,8 @@ public void test104UnassignAccountFromJack() throws Exception { @Test public void test108CloseTicketAndRecomputeJack() throws Exception { final String TEST_NAME = "test108CloseTicketAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); @@ -248,11 +242,11 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { dumpItsm(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -275,19 +269,18 @@ public void test108CloseTicketAndRecomputeJack() throws Exception { @Test public void test109LetItExpire() throws Exception { final String TEST_NAME = "test109LetItExpire"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT3H"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -300,19 +293,18 @@ public void test109LetItExpire() throws Exception { @Test public void test110AssignItsmAccountToJackCommunicationError() throws Exception { final String TEST_NAME = "test110AssignItsmAccountToJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertInProgress(result); @@ -336,9 +328,8 @@ public void test110AssignItsmAccountToJackCommunicationError() throws Exception @Test public void test111ReconcileJackFixed() throws Exception { final String TEST_NAME = "test111ReconcileJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Give consistency a time re-try operation again. @@ -350,12 +341,12 @@ public void test111ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -381,20 +372,19 @@ public void test111ReconcileJackFixed() throws Exception { @Test public void test112CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test112CloseTicketAndRecomputeJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -419,19 +409,18 @@ public void test112CloseTicketAndRecomputeJackCommunicationError() throws Except @Test public void test113RecomputeJackFixed() throws Exception { final String TEST_NAME = "test113RecomputeJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().clearFailureClass(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -454,19 +443,18 @@ public void test113RecomputeJackFixed() throws Exception { @Test public void test114UnassignAccountFromJackCommunicationError() throws Exception { final String TEST_NAME = "test114UnassignAccountFromJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_ITSM_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); DummyItsm.getInstance().clearFailureClass(); assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -507,9 +495,8 @@ public void test114UnassignAccountFromJackCommunicationError() throws Exception @Test public void test115ReconcileJackFixed() throws Exception { final String TEST_NAME = "test115ReconcileJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Give consistency a time re-try operation again. @@ -520,12 +507,12 @@ public void test115ReconcileJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastTicketIdentifier = assertInProgress(result); @@ -552,20 +539,19 @@ public void test115ReconcileJackFixed() throws Exception { @Test public void test117CloseTicketAndRecomputeJackCommunicationError() throws Exception { final String TEST_NAME = "test117CloseTicketAndRecomputeJackCommunicationError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeDummyTicket(jackLastTicketIdentifier); DummyItsm.getInstance().setFailureClass(CommunicationException.class); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); DummyItsm.getInstance().clearFailureClass(); assertPartialError(result); @@ -590,9 +576,8 @@ public void test117CloseTicketAndRecomputeJackCommunicationError() throws Except @Test public void test118RecomputeJackFixed() throws Exception { final String TEST_NAME = "test118RecomputeJackFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyItsm.getInstance().clearFailureClass(); @@ -601,12 +586,12 @@ public void test118RecomputeJackFixed() throws Exception { display("Repo shadow before", shadowRepoBefore); // WHEN - displayWhen(TEST_NAME); + when(); // This in fact should be a call to reconcile, not refresh directly (TODO: MID-4542) provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -632,19 +617,18 @@ public void test118RecomputeJackFixed() throws Exception { @Test public void test119LetItExpire() throws Exception { final String TEST_NAME = "test119LetItExpire"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT3H"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java index 2daf60c980b..bb63a51ae4b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManual.java @@ -117,9 +117,8 @@ protected int getNumberOfAccountAttributeDefinitions() { @Test public void test700AssignAccountJackExisting() throws Exception { final String TEST_NAME = "test700AssignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); if (accountJackOid != null) { @@ -135,11 +134,11 @@ public void test700AssignAccountJackExisting() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result, 2); assertNull("Unexpected ticket in result", result.getAsynchronousOperationReference()); @@ -177,9 +176,8 @@ public void test700AssignAccountJackExisting() throws Exception { @Test public void test710UnassignAccountJack() throws Exception { final String TEST_NAME = "test710UnassignAccountJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT5M"); @@ -187,11 +185,11 @@ public void test710UnassignAccountJack() throws Exception { accountJackReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); jackLastCaseOid = assertInProgress(result); @@ -233,9 +231,8 @@ public void test710UnassignAccountJack() throws Exception { @Test public void test712CloseCaseAndRecomputeJack() throws Exception { final String TEST_NAME = "test712CloseCaseAndRecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreDeleteJack(); @@ -245,12 +242,12 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { accountJackCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -291,20 +288,19 @@ public void test712CloseCaseAndRecomputeJack() throws Exception { @Test public void test717RecomputeJackAfter130min() throws Exception { final String TEST_NAME = "test717RecomputeJackAfter130min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clock.overrideDuration("PT130M"); // WHEN - displayWhen(TEST_NAME); + when(); // We need reconcile and not recompute here. We need to fetch the updated case status. reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); assertSuccess(result); @@ -321,9 +317,8 @@ public void test717RecomputeJackAfter130min() throws Exception { @Test public void test719CleanUp() throws Exception { final String TEST_NAME = "test719CleanUp"; - displayTestTitle(TEST_NAME); - cleanupUser(TEST_NAME, USER_JACK_OID, USER_JACK_USERNAME, accountJackOid); + cleanupUser(USER_JACK_OID, USER_JACK_USERNAME, accountJackOid); } @Override diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java index bce5a3883a1..f3f9117599b 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualDisable.java @@ -24,8 +24,6 @@ import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; @@ -43,8 +41,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestSemiManualDisable extends TestSemiManual { - private static final Trace LOGGER = TraceManager.getTrace(TestSemiManualDisable.class); - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -150,9 +146,8 @@ protected void assertWillUnassignPendingOperationCompleted(ShadowAsserter } @Override - protected void cleanupUser(final String TEST_NAME, String userOid, String username, String accountOid) throws Exception { - - Task task = createTask(TEST_NAME); + protected void cleanupUser(String userOid, String username, String accountOid) throws Exception { + Task task = createTask("cleanupUser"); OperationResult result = task.getResult(); backingStore.deleteAccount(username); @@ -175,31 +170,29 @@ protected void cleanupUser(final String TEST_NAME, String userOid, String userna @Test @Override public void test416PhoenixAccountUnassignCloseCase() throws Exception { - final String TEST_NAME = "test416PhoenixAccountUnassignCloseCase"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); closeCase(phoenixLastCaseOid); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_PHOENIX_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -221,29 +214,27 @@ public void test416PhoenixAccountUnassignCloseCase() throws Exception { @Test @Override public void test418AssignPhoenixAccountAgain() throws Exception { - final String TEST_NAME = "test418AssignPhoenixAccountAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_PHOENIX_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); phoenixLastCaseOid = assertInProgress(result); // Make sure the operation will be picked up by propagation task clockForward("PT3M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_PHOENIX_OID); display("User after", userAfter); @@ -298,9 +289,6 @@ protected void assertTest526Deltas(PrismObject shadowRepo, Operation protected void assertTest528Deltas(PrismObject shadowRepo, OperationResult result) { assertPendingOperationDeltas(shadowRepo, 3); - ObjectDeltaType deltaModify = null; - ObjectDeltaType deltaAdd = null; - ObjectDeltaType deltaDelete = null; for (PendingOperationType pendingOperation: shadowRepo.asObjectable().getPendingOperation()) { assertEquals("Wrong status in pending delta", OperationResultStatusType.SUCCESS, pendingOperation.getResultStatus()); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java index f491c6e778d..e18c11ba6af 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGrouping.java @@ -123,19 +123,18 @@ protected void assertShadowPassword(PrismObject shadow) { @Override public void test400PhantomAccount() throws Exception { final String TEST_NAME = "test400PhantomAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - setupPhantom(TEST_NAME); + setupPhantom(); // WHEN (mid1) - displayWhen(TEST_NAME, "mid1"); + when("mid1"); recomputeUser(USER_PHANTOM_OID, task, result); // THEN (mid1) - displayThen(TEST_NAME, "mid1"); + then("mid1"); String caseOid1 = assertInProgress(result); display("Case 1", caseOid1); // No case OID yet. The case would be created after propagation is run. @@ -156,7 +155,7 @@ public void test400PhantomAccount() throws Exception { clockForward("PT3M"); // WHEN (mid2) - displayWhen(TEST_NAME, "mid2"); + when("mid2"); // Existing account is detected now. Hence partial error. runPropagation(OperationResultStatusType.PARTIAL_ERROR); @@ -165,7 +164,7 @@ public void test400PhantomAccount() throws Exception { // fixed immediately. Instead there is a pending delta to fix the problem. // THEN (mid2) - displayThen(TEST_NAME, "mid2"); + then("mid2"); String caseOid2 = assertInProgress(result); display("Case 2", caseOid2); // No case OID yet. The case will be created after propagation is run. @@ -215,11 +214,11 @@ public void test400PhantomAccount() throws Exception { clockForward("PT20M"); // WHEN (final) - displayWhen(TEST_NAME, "final"); + when("final"); runPropagation(); // THEN - displayThen(TEST_NAME, "final"); + then("final"); String liveShadowOid = assertUser(USER_PHANTOM_OID, "final") .displayWithProjections() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java index aeaca01531f..bbff1af65b9 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/manual/TestSemiManualGroupingProposed.java @@ -76,9 +76,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test020ResourcesSanity() throws Exception { final String TEST_NAME = "test020ResourcesSanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> resources = repositoryService.searchObjects(ResourceType.class, null, null, result); @@ -120,9 +119,8 @@ protected void assertFinishedPropagationTask(Task finishedTask, OperationResultS @Test public void test500AssignBigmouthRoleOne() throws Exception { final String TEST_NAME = "test500AssignBigmouthRoleOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_BIGMOUTH_NAME, USER_BIGMOUTH_FULLNAME, true); @@ -130,11 +128,11 @@ public void test500AssignBigmouthRoleOne() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBigmouthOid, getRoleOneOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); bigmouthLastCaseOid = assertInProgress(result); @@ -177,19 +175,18 @@ public void test500AssignBigmouthRoleOne() throws Exception { @Test public void test502RunPropagation() throws Exception { final String TEST_NAME = "test502RunPropagation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT20M"); // WHEN - displayWhen(TEST_NAME); + when(); runPropagation(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PendingOperationExecutionStatusType executionStage = PendingOperationExecutionStatusType.EXECUTING; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java index 73844390a4f..46fa677c7d8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMapping.java @@ -170,8 +170,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); setDefaultObjectTemplate(UserType.COMPLEX_TYPE, USER_TYPE_CARTHESIAN, USER_TEMPLATE_CARTHESIAN_OID, initResult); - - setAutoTaskManagementEnabled(true); } /** @@ -180,16 +178,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ModifyUserAssignAccountDummyBlue() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -234,17 +232,17 @@ public void test100ModifyUserAssignAccountDummyBlue() throws Exception { @Test public void test101ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString(CAPTAIN_JACK_FULL_NAME)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -270,19 +268,19 @@ public void test101ModifyUserFullName() throws Exception { @Test public void test102ModifyUserFullNameRecon() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(CAPTAIN_JACK_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); modelService.executeChanges(deltas, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -310,8 +308,8 @@ public void test102ModifyUserFullNameRecon() throws Exception { @Test public void test104ModifyUserOrganizationalUnit() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -341,8 +339,8 @@ public void test104ModifyUserOrganizationalUnit() throws Exception { @Test public void test105ModifyAccountShip() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -384,8 +382,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test106ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -423,8 +421,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test107ModifyAccountShipAgain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -466,8 +464,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test108ModifyAccountShipDelete() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -510,8 +508,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePat @Test public void test110AssignBlueTitanic() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_JACK_OID, ROLE_BLUE_TITANIC_OID, task, result); @@ -529,8 +527,8 @@ public void test110AssignBlueTitanic() throws Exception { @Test public void test111Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -553,8 +551,8 @@ public void test111Recompute() throws Exception { @Test public void test112DisableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -580,8 +578,8 @@ public void test112DisableBlueTitanicAssignment() throws Exception { @Test public void test113Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -602,8 +600,8 @@ public void test113Recompute() throws Exception { @Test public void test114Reconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -625,8 +623,8 @@ public void test114Reconcile() throws Exception { @Test public void test115EnableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -649,8 +647,8 @@ public void test115EnableBlueTitanicAssignment() throws Exception { @Test public void test118UnassignBlueTitanic() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -678,8 +676,8 @@ public void test118UnassignBlueTitanic() throws Exception { @Test public void test120AssignBluePoetry() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, @@ -702,8 +700,8 @@ public void test120AssignBluePoetry() throws Exception { @Test public void test121Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -725,8 +723,8 @@ public void test121Recompute() throws Exception { @Test public void test122DisableBlueTitanicAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -755,8 +753,8 @@ public void test122DisableBlueTitanicAssignment() throws Exception { @Test public void test123Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -779,8 +777,8 @@ public void test123Recompute() throws Exception { @Test public void test124Reconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -804,8 +802,8 @@ public void test124Reconcile() throws Exception { @Test public void test125EnableBluePoetryAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -830,8 +828,8 @@ public void test125EnableBluePoetryAssignment() throws Exception { @Test public void test128UnassignBluePoetry() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -856,8 +854,8 @@ public void test128UnassignBluePoetry() throws Exception { @Test public void test129ModifyUserUnassignAccountBlue() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -895,8 +893,8 @@ public void test129ModifyUserUnassignAccountBlue() throws Exception { @Test public void test140AssignCobaltAccount() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -927,8 +925,8 @@ public void test140AssignCobaltAccount() throws Exception { @Test public void test141DestroyAndRecompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -958,8 +956,8 @@ public void test141DestroyAndRecompute() throws Exception { @Test public void test142DestroyAndReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -989,8 +987,8 @@ public void test142DestroyAndReconcile() throws Exception { @Test public void test143ClearAndRecompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1023,8 +1021,8 @@ public void test143ClearAndRecompute() throws Exception { @Test public void test150AssignCobaltNeverland() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(USER_JACK_OID, ROLE_COBALT_NEVERLAND_OID, task, result); @@ -1044,8 +1042,8 @@ public void test150AssignCobaltNeverland() throws Exception { @Test public void test151Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1067,8 +1065,8 @@ public void test151Recompute() throws Exception { @Test public void test152DisableCobalNeverlandAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1096,8 +1094,8 @@ public void test152DisableCobalNeverlandAssignment() throws Exception { @Test public void test153Recompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN recomputeUser(USER_JACK_OID, task, result); @@ -1119,8 +1117,8 @@ public void test153Recompute() throws Exception { @Test public void test154Reconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN reconcileUser(USER_JACK_OID, task, result); @@ -1143,8 +1141,8 @@ public void test154Reconcile() throws Exception { @Test public void test155DestroyAndRecompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, @@ -1174,8 +1172,8 @@ public void test155DestroyAndRecompute() throws Exception { @Test public void test156ClearAndRecompute() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_COBALT_NAME, ACCOUNT_JACK_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME @@ -1205,8 +1203,8 @@ public void test156ClearAndRecompute() throws Exception { @Test public void test157EnableCobaltNeverlandAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1231,8 +1229,8 @@ public void test157EnableCobaltNeverlandAssignment() throws Exception { @Test public void test158UnassignCobaltNeverland() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1255,8 +1253,8 @@ public void test158UnassignCobaltNeverland() throws Exception { @Test public void test159UnassignCobaltAccount() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -1281,8 +1279,8 @@ public void test159UnassignCobaltAccount() throws Exception { @Test public void test160ModifyUserAssignAccountDummyRed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1331,8 +1329,8 @@ public void test160ModifyUserAssignAccountDummyRed() throws Exception { @Test public void test161ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1362,8 +1360,8 @@ public void test161ModifyUserFullName() throws Exception { @Test public void test162ModifyUserOrganizationalUnit() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1393,8 +1391,8 @@ public void test162ModifyUserOrganizationalUnit() throws Exception { @Test public void test163ModifyAccountShip() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1407,11 +1405,11 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1437,8 +1435,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test164ModifyAccountShipReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1476,8 +1474,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test166ModifyAccountShipDelete() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1490,11 +1488,11 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1520,8 +1518,8 @@ accountOid, getDummyResourceController(RESOURCE_DUMMY_RED_NAME).getAttributePath @Test public void test168ModifyUserOrganization() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1554,8 +1552,8 @@ public void test168ModifyUserOrganization() throws Exception { @Test public void test178ModifyUserUnassignAccountRed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1610,8 +1608,8 @@ public void test178ModifyUserUnassignAccountRed() throws Exception { @Test public void test179DeleteAccountRed() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1654,8 +1652,8 @@ public void test179DeleteAccountRed() throws Exception { @Test public void test180ModifyUserAssignAccountDummyDefault() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -1704,8 +1702,8 @@ public void test180ModifyUserAssignAccountDummyDefault() throws Exception { @Test public void test181ModifyUserFullName() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1738,8 +1736,8 @@ public void test181ModifyUserFullName() throws Exception { @Test public void test182ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1769,8 +1767,8 @@ public void test182ModifyUserLocality() throws Exception { @Test public void test183ModifyAccountLocation() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1783,12 +1781,12 @@ public void test183ModifyAccountLocation() throws Exception { deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1814,8 +1812,8 @@ public void test183ModifyAccountLocation() throws Exception { @Test public void test184ModifyAccountLocationReplaceEmpty() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1853,8 +1851,8 @@ public void test184ModifyAccountLocationReplaceEmpty() throws Exception { @Test public void test185ModifyAccountLocationDelete() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1867,11 +1865,11 @@ public void test185ModifyAccountLocationDelete() throws Exception { deltas.add(accountDelta); // WHEN - displayWhen(); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(); + then(); assertPartialError(result); userJack = getUser(USER_JACK_OID); @@ -1892,8 +1890,8 @@ public void test185ModifyAccountLocationDelete() throws Exception { @Test public void test188ModifyUserRename() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); // WHEN @@ -1924,8 +1922,8 @@ public void test188ModifyUserRename() throws Exception { @Test public void test189ModifyUserUnassignAccountDummy() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); Collection> deltas = new ArrayList<>(); @@ -2020,15 +2018,15 @@ private void assertAccount(PrismObject userJack, String expectedFullNa @Test public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2051,8 +2049,8 @@ public void test200ModifyUserAssignAccountDummyCrimson() throws Exception { @Test public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2061,11 +2059,11 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2092,18 +2090,18 @@ public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception { @Test public void test204DummyCrimsonReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2135,8 +2133,8 @@ public void test204DummyCrimsonReconcile() throws Exception { @Test public void test206DummyCrimsonReconcileIOError() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2146,11 +2144,11 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertPartialError(result); @@ -2184,8 +2182,8 @@ public void test206DummyCrimsonReconcileIOError() throws Exception { @Test public void test208DummyCrimsonReconcileAgain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2193,11 +2191,11 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2227,8 +2225,8 @@ public void test208DummyCrimsonReconcileAgain() throws Exception { @Test public void test210ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2236,11 +2234,11 @@ public void test210ModifyUserLocality() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2270,8 +2268,8 @@ public void test210ModifyUserLocality() throws Exception { @Test public void test212ModifyUserLocalityRecon() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2279,7 +2277,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -2287,7 +2285,7 @@ public void test212ModifyUserLocalityRecon() throws Exception { modelService.executeChanges(deltas, options, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2317,8 +2315,8 @@ public void test212ModifyUserLocalityRecon() throws Exception { @Test public void test214ModifyUserLocalityIOError() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2330,11 +2328,11 @@ public void test214ModifyUserLocalityIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BOOTY_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2367,8 +2365,8 @@ public void test214ModifyUserLocalityIOError() throws Exception { @Test public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2382,11 +2380,11 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_GUYBRUSH_OID, USER_GUYBRUSH_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode(); @@ -2418,15 +2416,15 @@ public void test220NativeModifyDummyCrimsonThenChangePassword() throws Exception @Test public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2444,8 +2442,8 @@ public void test229ModifyUserUnassignAccountDummyCrimson() throws Exception { @Test public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // preconditions PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -2454,11 +2452,11 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_LIGHT_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2481,8 +2479,8 @@ public void test250ModifyUserAssignAccountDummyLightCrimson() throws Exception { @Test public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, @@ -2491,11 +2489,11 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2522,18 +2520,18 @@ public void test252NativeModifyDummyLightCrimsonThenReconcile() throws Exception @Test public void test254DummyLightCrimsonReconcile() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2566,8 +2564,8 @@ public void test254DummyLightCrimsonReconcile() throws Exception { @Test public void test256DummyLightCrimsonReconcileIOError() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); display("Dummy account before", dummyAccountBefore); @@ -2577,11 +2575,11 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); result.computeStatus(); TestUtil.assertPartialError(result); @@ -2615,8 +2613,8 @@ public void test256DummyLightCrimsonReconcileIOError() throws Exception { @Test public void test258DummyLightCrimsonReconcileAgain() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2624,11 +2622,11 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2658,8 +2656,8 @@ public void test258DummyLightCrimsonReconcileAgain() throws Exception { @Test public void test260ModifyUserLocality() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2667,11 +2665,11 @@ public void test260ModifyUserLocality() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2701,8 +2699,8 @@ public void test260ModifyUserLocality() throws Exception { @Test public void test262ModifyUserLocalityRecon() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2710,7 +2708,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { display("Dummy account before", dummyAccountBefore); // WHEN - displayWhen(); + when(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -2718,7 +2716,7 @@ public void test262ModifyUserLocalityRecon() throws Exception { modelService.executeChanges(deltas, options, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2748,8 +2746,8 @@ public void test262ModifyUserLocalityRecon() throws Exception { @Test public void test264ModifyUserLocalityIOError() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2761,11 +2759,11 @@ public void test264ModifyUserLocalityIOError() throws Exception { getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BOOTY_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2798,8 +2796,8 @@ public void test264ModifyUserLocalityIOError() throws Exception { @Test public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2813,11 +2811,11 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).setGetBreakMode(BreakMode.IO); // WHEN - displayWhen(); + when(); modifyUserChangePassword(USER_GUYBRUSH_OID, USER_GUYBRUSH_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(); + then(); assertSuccess(result, 1); // there's hidden PARTIAL_ERROR deep inside getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode(); @@ -2849,15 +2847,15 @@ public void test270NativeModifyDummyLightCrimsonThenChangePassword() throws Exce @Test public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_LIGHT_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2879,15 +2877,15 @@ public void test279ModifyUserUnassignAccountDummyLightCrimson() throws Exception @Test public void test300AssignGuybrushDummyYellow() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2913,15 +2911,15 @@ public void test300AssignGuybrushDummyYellow() throws Exception { @Test public void test302ModifyGuybrushLocality() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString("Forbidden dodecahedron")); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2941,15 +2939,15 @@ public void test302ModifyGuybrushLocality() throws Exception { @Test public void test309UnassignGuybrushDummyYellow() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2966,15 +2964,15 @@ public void test309UnassignGuybrushDummyYellow() throws Exception { @Test public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CUSTOM_FUNCTION_CRIMSON_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -2992,15 +2990,15 @@ public void test400ModifyUserAssignAccountDummyCrimsonCustomFunction() throws Ex @Test public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_SCABB_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -3019,15 +3017,15 @@ public void test401ModifyUserLocalityDummyCrisomCustomFunction() throws Exceptio @Test public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString(LOCALITY_BLOOD_ISLAND)); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -3054,8 +3052,8 @@ public void test402ModifyDrinkDummyCustomFunctionCrimson() throws Exception { @Test public void test420AssignAntinihilistToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3065,7 +3063,7 @@ public void test420AssignAntinihilistToJack() throws Exception { try { // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); } catch (ExpressionEvaluationException e) { @@ -3077,7 +3075,7 @@ public void test420AssignAntinihilistToJack() throws Exception { } // THEN - displayThen(); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3092,8 +3090,8 @@ public void test420AssignAntinihilistToJack() throws Exception { @Test public void test422AssignAccountAndAntinihilistToJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null); @@ -3103,11 +3101,11 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); assignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3123,8 +3121,8 @@ public void test422AssignAccountAndAntinihilistToJack() throws Exception { @Test public void test425UnassignAntinihilistFromJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3132,11 +3130,11 @@ public void test425UnassignAntinihilistFromJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); unassignRole(USER_JACK_OID, ROLE_ANTINIHILIST_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3152,8 +3150,8 @@ public void test425UnassignAntinihilistFromJack() throws Exception { @Test public void test427UnassignAccountFromJack() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); @@ -3161,11 +3159,11 @@ public void test427UnassignAccountFromJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3188,11 +3186,11 @@ public void test500AssignmentsCombinationSingle() throws Exception { .end(); // WHEN - displayWhen(); + when(); addObject(jim.asPrismObject()); // THEN - displayThen(); + then(); PrismObject userAfter = getUser(jim.getOid()); display("User after", userAfter); @@ -3205,17 +3203,17 @@ public void test500AssignmentsCombinationSingle() throws Exception { @Test public void test510AssignmentsCombinationCouple() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); // WHEN - displayWhen(); + when(); assignOrg(jim.getOid(), ORG_SAVE_ELAINE_OID, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(jim.getOid()); @@ -3229,13 +3227,13 @@ public void test510AssignmentsCombinationCouple() throws Exception { @Test public void test520DeleteUserAssignment() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject jim = findUserByUsername(USER_JIM_NAME); // WHEN - displayWhen(); + when(); AssignmentType orgAssignment = findAssignment(jim, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_DEFAULT); assertNotNull("org assignment not found", orgAssignment); PrismContainerValue orgAssignmentPcv = prismContext.itemFactory().createContainerValue(); @@ -3246,7 +3244,7 @@ public void test520DeleteUserAssignment() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); PrismObject userAfter = getUser(jim.getOid()); @@ -3260,16 +3258,16 @@ public void test520DeleteUserAssignment() throws Exception { @Test public void test600AddService() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "pwd1234"; // WHEN - displayWhen(); + when(); addObject(SERVICE_ROUTER, task, result); // THEN - displayThen(); + then(); assertSuccess(result); assertService(SERVICE_ROUTER.oid, "service") @@ -3290,15 +3288,15 @@ public void test600AddService() throws Exception { @Test public void test610ModifyServicePassword() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); final String NEW_PASSWORD = "dummy"; ProtectedStringType newPasswordProtected = new ProtectedStringType(); newPasswordProtected.setClearValue(NEW_PASSWORD); // WHEN - displayWhen(); + when(); ObjectDelta delta = deltaFor(ServiceType.class) .item(ServiceType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE) .replace(newPasswordProtected) @@ -3306,7 +3304,7 @@ public void test610ModifyServicePassword() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); assertSuccess(result); assertService(SERVICE_ROUTER.oid, "service") @@ -3327,8 +3325,8 @@ public void test610ModifyServicePassword() throws Exception { @Test public void test650ImportFromInboundPwdCopy() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "secret"; @@ -3338,12 +3336,12 @@ public void test650ImportFromInboundPwdCopy() throws Exception { resource.addAccount(bridge); // WHEN - displayWhen(); + when(); addObject(TASK_IMPORT_PWD_COPY, task, result); waitForTaskFinish(TASK_IMPORT_PWD_COPY.oid, true); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_BRIDGE_NAME, "service") .display() .assertLinks(1) @@ -3362,11 +3360,11 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { resource.getAccountByUsername(SERVICE_BRIDGE_NAME).setPassword(NEW_PASSWORD); // WHEN - displayWhen(); + when(); rerunTask(TASK_IMPORT_PWD_COPY.oid); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_BRIDGE_NAME, "service") .display() .assertLinks(1) @@ -3379,8 +3377,8 @@ public void test660ImportFromInboundPwdCopyModifyPassword() throws Exception { @Test public void test670ImportFromInboundPwdGenerate() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); final String PASSWORD = "secret-gw"; @@ -3390,12 +3388,12 @@ public void test670ImportFromInboundPwdGenerate() throws Exception { resource.addAccount(gateway); // WHEN - displayWhen(); + when(); addObject(TASK_IMPORT_PWD_GENERATE, task, result); waitForTaskFinish(TASK_IMPORT_PWD_GENERATE.oid, true); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_GATEWAY_NAME, "service") .display() .assertLinks(1) @@ -3419,11 +3417,11 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception resource.getAccountByUsername(SERVICE_GATEWAY_NAME).setPassword(NEW_PASSWORD); // WHEN - displayWhen(); + when(); rerunTask(TASK_IMPORT_PWD_GENERATE.oid); // THEN - displayThen(); + then(); assertServiceByName(SERVICE_GATEWAY_NAME, "service") .display() .assertLinks(1) @@ -3436,8 +3434,8 @@ public void test680ImportFromInboundPwdGenerateModifyPassword() throws Exception @Test public void test700TimedOutbound() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); UserType user = new UserType(prismContext) .name("test700") @@ -3446,11 +3444,11 @@ public void test700TimedOutbound() throws Exception { .end(); // WHEN - displayWhen(); + when(); String oid = addObject(user.asPrismObject(), task, result); // THEN - displayThen(); + then(); assertUser(oid, "user after") .display() .triggers() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java index d0e8271ad8e..9dded5516b8 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingAutoInbound.java @@ -64,10 +64,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportFromResource() throws Exception { final String TEST_NAME = "test100ImportFromResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = new DummyAccount(USER_HERMAN_USERNAME); @@ -79,18 +78,18 @@ public void test100ImportFromResource() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -113,21 +112,20 @@ public void test100ImportFromResource() throws Exception { @Test public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { final String TEST_NAME = "test110ModifyAccountTitleCraticAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "cratic"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -142,21 +140,20 @@ public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { @Test public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Exception { final String TEST_NAME = "test112ModifyAccountTitleDidacticGraphicAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "didactic", "graphic"); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -173,12 +170,11 @@ public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Except @Test public void test200ImportFromResourceAssociations() throws Exception { final String TEST_NAME = "test200ImportFromResourceAssociations"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.RELATIVE, false); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup dummyGroup = new DummyGroup(GROUP_DUMMY_TESTERS_NAME); @@ -191,18 +187,18 @@ public void test200ImportFromResourceAssociations() throws Exception { dummyGroup.addMember(USER_HERMAN_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -224,19 +220,18 @@ public void test200ImportFromResourceAssociations() throws Exception { @Test public void test300ModifyAccountDirectAssign() throws Exception { final String TEST_NAME = "test300ModifyAccountDirectAssign"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_ADMINS_OID); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -252,12 +247,11 @@ public void test300ModifyAccountDirectAssign() throws Exception { @Test public void test301removeUserFromAutoGroup() throws Exception { final String TEST_NAME = "test301removeUserFromAutoGroup"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup craticGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_CRATIC_NAME); @@ -270,18 +264,18 @@ public void test301removeUserFromAutoGroup() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 70000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -299,7 +293,6 @@ public void test301removeUserFromAutoGroup() throws Exception { @Test public void test402assignAutoGroupDirectly() throws Exception { final String TEST_NAME = "test402assignAutoGroupDirectly"; - displayTestTitle(TEST_NAME); DummyGroup craticGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_CRATIC_NAME); craticGroup.removeMember(USER_HERMAN_USERNAME); @@ -310,15 +303,15 @@ public void test402assignAutoGroupDirectly() throws Exception { assertDummyGroupMember(RESOURCE_DUMMY_AUTOGREEN_NAME, GROUP_DUMMY_TESTERS_NAME, USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyGroupMember(RESOURCE_DUMMY_AUTOGREEN_NAME, GROUP_DUMMY_TESTERS_NAME, USER_HERMAN_USERNAME); @@ -336,7 +329,6 @@ public void test402assignAutoGroupDirectly() throws Exception { @Test public void test403removeAllAssignments() throws Exception { final String TEST_NAME = "test403removeAllAssignments"; - displayTestTitle(TEST_NAME); DummyGroup testersGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_TESTERS_NAME); testersGroup.removeMember(USER_HERMAN_USERNAME); @@ -344,15 +336,15 @@ public void test403removeAllAssignments() throws Exception { DummyAccount hermanAccount = getDummyAccount(RESOURCE_DUMMY_AUTOGREEN_NAME, USER_HERMAN_USERNAME); hermanAccount.removeAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, Arrays.asList("graphic", "cratic")); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userHermanOid, ROLE_ADMINS_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -365,7 +357,6 @@ public void test403removeAllAssignments() throws Exception { @Test public void test404importAssociationAutotesters() throws Exception { final String TEST_NAME = "test404importAssociationAutotesters"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); @@ -376,22 +367,22 @@ public void test404importAssociationAutotesters() throws Exception { testersGroup.addMember(USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); @@ -403,19 +394,18 @@ public void test404importAssociationAutotesters() throws Exception { @Test public void test405assignRoleAutocraticDirectly() throws Exception { final String TEST_NAME = "test405assignRoleAutocraticDirectly"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -431,20 +421,19 @@ public void test405assignRoleAutocraticDirectly() throws Exception { @Test public void test406unassignRoleAutocraticDirectly() throws Exception { final String TEST_NAME = "test406unassignRoleAutocraticAutotestersDirectly"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userHermanOid, ROLE_AUTOCRATIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userHermanOid); @@ -460,7 +449,6 @@ public void test406unassignRoleAutocraticDirectly() throws Exception { @Test public void test407addHermanToTestersReconcile() throws Exception { final String TEST_NAME = "test407addHermanToTestersReconcile"; - displayTestTitle(TEST_NAME); assumeResourceAssigmentPolicy(RESOURCE_DUMMY_AUTOGREEN_OID, AssignmentPolicyEnforcementType.FULL, true); @@ -468,15 +456,15 @@ public void test407addHermanToTestersReconcile() throws Exception { craticGroup.addMember(USER_HERMAN_USERNAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userHermanOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); PrismObject userAfter = getUser(userHermanOid); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index 000c53a5047..7ee0521a493 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -7,9 +7,7 @@ package com.evolveum.midpoint.model.intest.mapping; import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.midpoint.audit.api.AuditEventStage; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.model.api.ModelExecuteOptions; import com.evolveum.midpoint.prism.PrismObject; @@ -23,10 +21,8 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; @@ -96,17 +92,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010SanitySchema() throws Exception { final String TEST_NAME = "test010SanitySchema"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); /// WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_TEA_GREEN_OID, task); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess(testResult); ResourceType resourceType = getDummyResourceType(RESOURCE_DUMMY_TEA_GREEN_NAME); @@ -124,18 +119,17 @@ public void test010SanitySchema() throws Exception { @Test public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyTeaGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); importSyncTask(); // THEN - displayThen(TEST_NAME); + then(); waitForSyncTaskStart(); } @@ -143,10 +137,9 @@ public void test100ImportLiveSyncTaskDummyTeaGreen() throws Exception { @Test public void test110AddDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -160,14 +153,14 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "water"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -205,14 +198,13 @@ public void test110AddDummyTeaGreenAccountMancomb() throws Exception { @Test public void test120ModifyMancombPhotoSource() throws Exception { final String TEST_NAME = "test120ModifyMancombPhotoSource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME) .getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -223,7 +215,7 @@ public void test120ModifyMancombPhotoSource() throws Exception { waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -241,14 +233,13 @@ public void test120ModifyMancombPhotoSource() throws Exception { @Test public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { final String TEST_NAME = "test130ModifyMancombPhotoSourceAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); // stop the task to avoid interference with the reconciliations suspendTask(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); @@ -265,7 +256,7 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -281,14 +272,13 @@ public void test130ModifyMancombPhotoSourceAndReconcile() throws Exception { @Test public void test140ModifyMancombPhotoInRepo() throws Exception { final String TEST_NAME = "test140ModifyMancombPhotoInRepo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -299,7 +289,7 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { executeChanges(delta, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); @@ -318,10 +308,9 @@ public void test140ModifyMancombPhotoInRepo() throws Exception { @Test public void test150UserReconcile() throws Exception { final String TEST_NAME = "test150UserReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -329,7 +318,7 @@ public void test150UserReconcile() throws Exception { //assertUsers(5); /// WHEN - displayWhen(TEST_NAME); + when(); PrismObject userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); assertNotNull("User mancomb has disappeared", userMancomb); @@ -337,7 +326,7 @@ public void test150UserReconcile() throws Exception { reconcileUser(userMancomb.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_TEA_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -377,14 +366,13 @@ public void test150UserReconcile() throws Exception { @Test public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test300DeleteDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump()); @@ -394,7 +382,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { waitForSyncTaskNextRun(); // THEN - displayThen(TEST_NAME); + then(); assertNoDummyAccount(RESOURCE_DUMMY_TEA_GREEN_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME); @@ -416,18 +404,17 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { @Test public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { final String TEST_NAME = "test399DeleteDummyTeaGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); deleteObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertNoObject(TaskType.class, TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID); } @@ -435,10 +422,9 @@ public void test399DeleteDummyTeaGreenAccountMancomb() throws Exception { @Test public void test400AddUserLeeloo() throws Exception { final String TEST_NAME = "test400AddUserLeeloo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -451,7 +437,7 @@ public void test400AddUserLeeloo() throws Exception { getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).addAccount(account); /// WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_TEA_GREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result); @@ -460,7 +446,7 @@ public void test400AddUserLeeloo() throws Exception { waitForTaskFinish(task, true); // THEN - displayThen(TEST_NAME); + then(); userLeelooOid = assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -489,20 +475,19 @@ public void test400AddUserLeeloo() throws Exception { @Test public void test402UserLeelooRecompute() throws Exception { final String TEST_NAME = "test402UserLeelooRecompute"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -523,20 +508,19 @@ public void test402UserLeelooRecompute() throws Exception { @Test public void test404UserLeelooReconcile() throws Exception { final String TEST_NAME = "test404UserLeelooReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_MULTIPASS) @@ -561,10 +545,9 @@ public void test404UserLeelooReconcile() throws Exception { @Test public void test410UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test410UserLeeloominaiReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME); @@ -573,12 +556,12 @@ public void test410UserLeeloominaiReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -604,20 +587,19 @@ public void test410UserLeeloominaiReconcile() throws Exception { @Test public void test412UserLeeloominaiRecompute() throws Exception { final String TEST_NAME = "test412UserLeeloominaiRecompute"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -638,20 +620,19 @@ public void test412UserLeeloominaiRecompute() throws Exception { @Test public void test414UserLeeloominaiReconcile() throws Exception { final String TEST_NAME = "test414UserLeeloominaiReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -676,10 +657,9 @@ public void test414UserLeeloominaiReconcile() throws Exception { @Test public void test420UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test420UserLeelooStrangeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).getAccountByUsername(ACCOUNT_LEELOO_USERNAME); @@ -688,12 +668,12 @@ public void test420UserLeelooStrangeReconcile() throws Exception { dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) @@ -720,20 +700,19 @@ public void test420UserLeelooStrangeReconcile() throws Exception { @Test public void test424UserLeelooStrangeReconcile() throws Exception { final String TEST_NAME = "test424UserLeelooStrangeReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); /// WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userLeelooOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_LEELOO_USERNAME) .assertFullName(ACCOUNT_LEELOO_FULL_NAME_LEELOOMINAI) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java index fe4b9d3ea08..482e0c5684a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMigration.java @@ -59,14 +59,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test050SanityLost1() throws Exception { final String TEST_NAME = "test050SanityLost1"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); // THEN - displayThen(TEST_NAME); + then(); assertShadow(shadowLost1Repo, "Repo shadow") .assertPrimaryIdentifierValue(null); @@ -79,17 +78,16 @@ public void test050SanityLost1() throws Exception { @Test public void test100RefreshTaskDefault() throws Exception { final String TEST_NAME = "test100RefreshTaskDefault"; - displayTestTitle(TEST_NAME); addObject(TASK_SHADOW_REFRESH_FILE); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskStart(TASK_SHADOW_REFRESH_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_OID, false); // THEN - displayThen(TEST_NAME); + then(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") @@ -104,17 +102,16 @@ public void test100RefreshTaskDefault() throws Exception { @Test public void test110RefreshTaskExplicitDummy() throws Exception { final String TEST_NAME = "test110RefreshTaskExplicitDummy"; - displayTestTitle(TEST_NAME); addObject(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_FILE); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskStart(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); waitForTaskFinish(TASK_SHADOW_REFRESH_EXPLICIT_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(); PrismObject shadowLost1Repo = getShadowRepo(SHADOW_ACCOUNT_DUMMY_LOST1_OID); assertShadow(shadowLost1Repo, "Repo shadow") diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java index aedbffae1aa..0afde18db71 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestMisc.java @@ -92,18 +92,17 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100GetRepositoryDiag() throws Exception { final String TEST_NAME = "test100GetRepositoryDiag"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, result); // THEN - displayThen(TEST_NAME); + then(); display("Diag", diag); assertSuccess(result); @@ -115,17 +114,16 @@ public void test100GetRepositoryDiag() throws Exception { @Test public void test110RepositorySelfTest() throws Exception { final String TEST_NAME = "test110RepositorySelfTest"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelDiagnosticService.repositorySelfTest(task); // THEN - displayThen(TEST_NAME); + then(); display("Repository self-test result", testResult); TestUtil.assertSuccess("Repository self-test result", testResult); @@ -135,19 +133,18 @@ public void test110RepositorySelfTest() throws Exception { @Test public void test200ExportUsers() throws Exception { final String TEST_NAME = "test200ExportUsers"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, null, SelectorOptions.createCollection(GetOperationOptions.createRaw()), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 6, users.size()); @@ -178,10 +175,9 @@ public void test200ExportUsers() throws Exception { @Test public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { final String TEST_NAME = "test210SearchUsersMatchingRulesPolystringNorm"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -191,11 +187,11 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -212,10 +208,9 @@ public void test210SearchUsersMatchingRulesPolystringNorm() throws Exception { @Test public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Exception { final String TEST_NAME = "test212SearchUsersMatchingRulesPolystringIgnoreCase"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -226,7 +221,7 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti try { // WHEN - displayWhen(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query, null, task, result); } catch (SystemException e) { @@ -242,10 +237,9 @@ public void test212SearchUsersMatchingRulesPolystringIgnoreCase() throws Excepti @Test public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { final String TEST_NAME = "test214SearchUsersMatchingRulesStringIgnoreCase"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -255,11 +249,11 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 1, users.size()); @@ -276,10 +270,9 @@ public void test214SearchUsersMatchingRulesStringIgnoreCase() throws Exception { @Test public void test216SearchUsersMatchingRulesStringNorm() throws Exception { final String TEST_NAME = "test216SearchUsersMatchingRulesStringNorm"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = queryFor(UserType.class) @@ -289,11 +282,11 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(); List> users = modelService.searchObjects(UserType.class, query,null , task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals("Unexpected number of users", 0, users.size()); @@ -306,18 +299,17 @@ public void test216SearchUsersMatchingRulesStringNorm() throws Exception { @Test public void test300RecomputeJack() throws Exception { final String TEST_NAME = "test300RecomputeJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -331,18 +323,17 @@ public void test300RecomputeJack() throws Exception { @Test public void test302UpdateKeyJack() throws Exception { final String TEST_NAME = "test302UpdateKeyJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, getExtensionPath(PIRACY_KEY), task, result, KEY); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -353,20 +344,19 @@ public void test302UpdateKeyJack() throws Exception { @Test public void test310AddUserClean() throws Exception { final String TEST_NAME = "test310AddUserClean"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_CLEAN_NAME, USER_CLEAN_GIVEN_NAME, USER_CLEAN_FAMILY_NAME, true); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); userCleanOid = userBefore.getOid(); @@ -382,18 +372,17 @@ public void test310AddUserClean() throws Exception { @Test public void test312UpdateBinaryIdClean() throws Exception { final String TEST_NAME = "test312UpdateBinaryIdClean"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userCleanOid, getExtensionPath(PIRACY_BINARY_ID), task, result, KEY); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(userCleanOid); @@ -407,17 +396,16 @@ public void test312UpdateBinaryIdClean() throws Exception { @Test public void test320DefaultRelations() throws Exception { final String TEST_NAME="test320DefaultRelations"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); List relations = modelInteractionService.getRelationDefinitions(); // THEN - displayThen(TEST_NAME); + then(); display("Relations", relations); assertRelationDef(relations, SchemaConstants.ORG_MANAGER, "RelationTypes.manager"); assertRelationDef(relations, SchemaConstants.ORG_OWNER, "RelationTypes.owner"); @@ -430,18 +418,17 @@ public void test320DefaultRelations() throws Exception { @Test public void test400ImportRoleWithFilters() throws Exception { final String TEST_NAME = "test400ImportRoleWithFilters"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importObjectsFromFile(ROLE_IMPORT_FILTERS_FILE, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getRole(ROLE_IMPORT_FILTERS_OID); @@ -455,10 +442,9 @@ public void test400ImportRoleWithFilters() throws Exception { @Test public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Exception { final String TEST_NAME = "test500AddHocProvisioningScriptAssignJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -466,11 +452,11 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -489,10 +475,9 @@ public void test500AddHocProvisioningScriptAssignJackResourceScripty() throws Ex @Test public void test502GetAccountJackResourceScripty() throws Exception { final String TEST_NAME = "test502GetAccountJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -501,11 +486,11 @@ public void test502GetAccountJackResourceScripty() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -522,10 +507,9 @@ public void test502GetAccountJackResourceScripty() throws Exception { @Test public void test504GetAccountJackResourceScriptyAgain() throws Exception { final String TEST_NAME = "test504GetAccountJackResourceScriptyAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -534,11 +518,11 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { String accountOid = getSingleLinkOid(userBefore); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject accountShadow = modelService.getObject(ShadowType.class, accountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAttribute(accountShadow.asObjectable(), @@ -560,10 +544,9 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception { @Test public void test506ModifyResourceGetAccountJackResourceScripty() throws Exception { final String TEST_NAME = "test506ModifyResourceGetAccountJackResourceScripty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -574,12 +557,12 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio display("Resource version before", resourceBefore.getVersion()); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(ResourceType.class, RESOURCE_SCRIPTY_OID, ResourceType.F_DESCRIPTION, null, task, result, "Whatever"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject resourceAfter = getObject(ResourceType.class, RESOURCE_SCRIPTY_OID); @@ -605,19 +588,18 @@ public void test506ModifyResourceGetAccountJackResourceScripty() throws Exceptio @Test public void test600jackAssignRoleShip() throws Exception { final String TEST_NAME = "test600jackAssignRoleShip"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 2); @@ -635,21 +617,20 @@ public void test600jackAssignRoleShip() throws Exception { @Test public void test601jackUnassignResourceAccount() throws Exception { final String TEST_NAME = "test601jackUnassignResourceAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); assertAssignments(userBefore, 2); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_SCRIPTY_OID, null); //THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -666,19 +647,18 @@ public void test601jackUnassignResourceAccount() throws Exception { @Test public void test602jackUnssigndRoleShip() throws Exception { final String TEST_NAME = "test602jackUnssigndRoleShip"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SHIP_OID); //THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User before", userAfter); assertAssignments(userAfter, 0); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java index 0ccfb204bb2..a29f8f769d0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/misc/TestUuidNonUniqueName.java @@ -12,41 +12,20 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.util.List; - -import javax.xml.transform.dom.DOMSource; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; - -import com.evolveum.midpoint.prism.PrismContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import org.w3c.dom.Document; import com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest; -import com.evolveum.midpoint.prism.Objectable; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismReference; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.RepositoryDiag; -import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Test with a resource that has unique primary identifier (ConnId UID), but non-unique secondary @@ -88,17 +67,16 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test010TestResourceConnection() throws Exception { final String TEST_NAME = "test010TestResourceConnection"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult result = modelService.testResource(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, task); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -109,18 +87,17 @@ public void test010TestResourceConnection() throws Exception { @Test public void test020RefinedSchema() throws Exception { final String TEST_NAME = "test020RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertResourceAfter(RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID) @@ -144,18 +121,17 @@ public void test020RefinedSchema() throws Exception { @Test public void test100AssignAccountToJackSparrow() throws Exception { final String TEST_NAME = "test100AssignAccountToJackSparrow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackSparrowUid = assertUserAfter(USER_JACK_OID) @@ -177,10 +153,9 @@ public void test100AssignAccountToJackSparrow() throws Exception { @Test public void test102GetAccountJackSparrow() throws Exception { final String TEST_NAME = "test102GetAccountJackSparrow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackSparrowOid = assertUserBefore(USER_JACK_OID) @@ -188,11 +163,11 @@ public void test102GetAccountJackSparrow() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackSparrowOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertShadow(shadow, "getObject") @@ -210,20 +185,19 @@ public void test102GetAccountJackSparrow() throws Exception { @Test public void test110AssignAccountToJackSkellington() throws Exception { final String TEST_NAME = "test110AssignAccountToJackSkellington"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertEquals(USER_SKELLINGTON_GIVEN_NAME, USER_JACK_GIVEN_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_SKELLINGTON_OID, RESOURCE_DUMMY_UUID_NONUNIQUE_NAME_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackSkellingtonUid = assertUserAfter(USER_SKELLINGTON_OID) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java index 5490c173d66..0478db721c0 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiAccount.java @@ -91,21 +91,21 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010ImportAccountsFromDummyMultiGreen() throws Exception { final String TEST_NAME = "test010ImportAccountsFromDummyMultiGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(); // No accounts on multigreen resource yet. No users should be created. assertUsers(getNumberOfUsers()); @@ -117,10 +117,10 @@ public void test010ImportAccountsFromDummyMultiGreen() throws Exception { @Test public void test020ImportPaulAtreides() throws Exception { final String TEST_NAME = "test020ImportPaulAtreides"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_PAUL_ATREIDES_USERNAME); @@ -134,11 +134,11 @@ public void test020ImportPaulAtreides() throws Exception { assertUsers(getNumberOfUsers()); // WHEN - displayWhen(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(); accountPaulOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -162,10 +162,10 @@ public void test020ImportPaulAtreides() throws Exception { @Test public void test100ImportMuadDib() throws Exception { final String TEST_NAME = "test100ImportMuadDib"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MUAD_DIB_USERNAME); @@ -178,11 +178,11 @@ public void test100ImportMuadDib() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(); accountMuaddibOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -217,20 +217,20 @@ public void test100ImportMuadDib() throws Exception { @Test public void test102ReconcileUserPaul() throws Exception { final String TEST_NAME = "test102ReconcileUserPaul"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); userPaulOid = findUserByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).getOid(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userPaulOid, task, result); // THEN - displayThen(TEST_NAME); + then(); accountMuaddibOid = assertUserAfter(userPaulOid) .displayWithProjections() @@ -270,10 +270,10 @@ public void test102ReconcileUserPaul() throws Exception { @Test public void test200ImportDuke() throws Exception { final String TEST_NAME = "test200ImportDuke"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_DUKE_USERNAME); @@ -287,11 +287,11 @@ public void test200ImportDuke() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(); accountDukeOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() @@ -338,10 +338,10 @@ public void test200ImportDuke() throws Exception { @Test public void test210ImportMahdi() throws Exception { final String TEST_NAME = "test210ImportMahdi"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount account = new DummyAccount(ACCOUNT_MAHDI_USERNAME); @@ -355,11 +355,11 @@ public void test210ImportMahdi() throws Exception { assertUsers(getNumberOfUsers() + 1); // WHEN - displayWhen(TEST_NAME); + when(); importMultiGreenAccounts(task, result); // THEN - displayThen(TEST_NAME); + then(); accountMahdiOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME) .displayWithProjections() diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java index 3e47ade9e49..14c0d929d51 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiConnectorResources.java @@ -6,31 +6,21 @@ */ package com.evolveum.midpoint.model.intest.multi; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.FailableRunnable; -import com.evolveum.midpoint.util.Holder; -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.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import java.io.File; -import java.util.List; import static org.testng.AssertJUnit.*; @@ -78,10 +68,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OPALINE_OID, task); @@ -98,10 +87,9 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignDummyOpaline() throws Exception { final String TEST_NAME = "test100JackAssignDummyOpaline"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java index 03fea3ecc77..8811e89d649 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/multi/TestMultiResource.java @@ -24,7 +24,6 @@ import com.evolveum.icf.dummy.resource.ConflictException; import com.evolveum.icf.dummy.resource.SchemaViolationException; import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.intest.password.AbstractPasswordTest; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.ObjectDeltaOperation; @@ -176,41 +175,36 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test110JackAssignRoleDummiesFull() throws Exception { - final String TEST_NAME = "test110JackAssignRoleDummiesFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackAssignRoleDummies(TEST_NAME); + jackAssignRoleDummies(); } @Test public void test113JackRenameFull() throws Exception { - final String TEST_NAME = "test113JackRenameFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackRename(TEST_NAME); + jackRename(); } @Test public void test114JackUnAssignRoleDummiesFull() throws Exception { - final String TEST_NAME = "test114JackUnAssignRoleDummiesFull"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - jackUnAssignRoleDummies(TEST_NAME); + jackUnAssignRoleDummies(); } // TODO: lavender resource with failure @Test public void test115JackAssignRoleDummiesFullErrorIvory() throws Exception { - final String TEST_NAME = "test115JackAssignRoleDummiesFullErrorIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackAssignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_NAME, true); + jackAssignRoleDummiesError(ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_NAME, true); } @Test public void test116JackUnAssignRoleDummiesFullErrorIvory() throws Exception { - final String TEST_NAME = "test116JackUnAssignRoleDummiesFullErrorIvory"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackUnassignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_OID); + jackUnassignRoleDummiesError(ROLE_DUMMIES_IVORY_OID, RESOURCE_DUMMY_IVORY_OID); } /** @@ -220,32 +214,28 @@ public void test116JackUnAssignRoleDummiesFullErrorIvory() throws Exception { */ @Test public void test117JackAssignRoleDummiesFullErrorBeige() throws Exception { - final String TEST_NAME = "test117JackAssignRoleDummiesFullErrorBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackAssignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_BEIGE_OID, RESOURCE_DUMMY_BEIGE_NAME, false); + jackAssignRoleDummiesError(ROLE_DUMMIES_BEIGE_OID, RESOURCE_DUMMY_BEIGE_NAME, false); } @Test public void test118JackUnAssignRoleDummiesFullErrorBeige() throws Exception { - final String TEST_NAME = "test118JackUnAssignRoleDummiesFullErrorBeige"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().setAddBreakMode(BreakMode.NETWORK); - jackUnassignRoleDummiesError(TEST_NAME, ROLE_DUMMIES_BEIGE_OID, null); + jackUnassignRoleDummiesError(ROLE_DUMMIES_BEIGE_OID, null); } @Test public void test120JackAssignRoleDummiesRelative() throws Exception { - final String TEST_NAME = "test120JackAssignRoleDummiesRelative"; - getDummyResource().resetBreakMode(); // Clean up user - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackAssignRoleDummies(TEST_NAME); + jackAssignRoleDummies(); } /** @@ -254,12 +244,11 @@ public void test120JackAssignRoleDummiesRelative() throws Exception { */ @Test public void test121JackTryDeleteAccount() throws Exception { - final String TEST_NAME = "test121JackTryDeleteAccount"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); // Clean up user - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); String accountJackDummyOid = getLinkRefOid(userJack, RESOURCE_DUMMY_OID); @@ -281,16 +270,14 @@ public void test121JackTryDeleteAccount() throws Exception { @Test public void test123JackRenameRelative() throws Exception { - final String TEST_NAME = "test123JackRenameRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackRename(TEST_NAME); + jackRename(); } @Test public void test129JackUnAssignRoleDummiesRelative() throws Exception { - final String TEST_NAME = "test129JackUnAssignRoleDummiesRelative"; assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - jackUnAssignRoleDummies(TEST_NAME); + jackUnAssignRoleDummies(); } /** @@ -298,10 +285,8 @@ public void test129JackUnAssignRoleDummiesRelative() throws Exception { */ @Test public void test200JackAssignDummyIvory() throws Exception { - final String TEST_NAME = "test200JackAssignDummyIvory"; - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -332,10 +317,8 @@ public void test200JackAssignDummyIvory() throws Exception { */ @Test public void test209JackUnAssignDummyIvory() throws Exception { - final String TEST_NAME = "test209JackUnAssignDummyIvory"; - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -364,11 +347,8 @@ public void test209JackUnAssignDummyIvory() throws Exception { */ @Test public void test210JackAssignDummyBeige() throws Exception { - final String TEST_NAME = "test210JackAssignDummyBeige"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -376,11 +356,11 @@ public void test210JackAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -402,11 +382,8 @@ public void test210JackAssignDummyBeige() throws Exception { */ @Test public void test219JackUnAssignDummyBeige() throws Exception { - final String TEST_NAME = "test219JackUnAssignDummyBeige"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -414,11 +391,11 @@ public void test219JackUnAssignDummyBeige() throws Exception { modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -437,11 +414,8 @@ public void test219JackUnAssignDummyBeige() throws Exception { */ @Test public void test220JackAssignDummyBeigeAndDefault() throws Exception { - final String TEST_NAME = "test220JackAssignDummyBeigeAndDefault"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -452,11 +426,11 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, true)); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -476,19 +450,16 @@ public void test220JackAssignDummyBeigeAndDefault() throws Exception { */ @Test public void test221JackRecompute() throws Exception { - final String TEST_NAME = "test221JackRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -510,22 +481,19 @@ public void test221JackRecompute() throws Exception { */ @Test public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { - final String TEST_NAME = "test223JackKillDefaultDummyAccounAndRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource().deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); display("dummy resource before", getDummyResource()); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -549,22 +517,19 @@ public void test223JackKillDefaultDummyAccounAndRecompute() throws Exception { */ @Test public void test224JackKillBeigeAccounAndRecompute() throws Exception { - final String TEST_NAME = "test224JackKillBeigeAccounAndRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource(RESOURCE_DUMMY_BEIGE_NAME).deleteAccountByName(ACCOUNT_JACK_DUMMY_USERNAME); display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -608,11 +573,8 @@ public void test224JackKillBeigeAccounAndRecompute() throws Exception { @Test public void test225ForceDeleteDeadShadow() throws Exception { - final String TEST_NAME = "test225ForceDeleteDeadShadow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String deadBeigeShadowOid = assertUserBefore(USER_JACK_OID) @@ -625,11 +587,11 @@ public void test225ForceDeleteDeadShadow() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); forceDeleteObject(ShadowType.class, deadBeigeShadowOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoShadow(deadBeigeShadowOid); @@ -663,11 +625,8 @@ public void test225ForceDeleteDeadShadow() throws Exception { */ @Test public void test226JackKillBothAccountsAndRecompute() throws Exception { - final String TEST_NAME = "test226JackKillBothAccountsAndRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertUserBefore(USER_JACK_OID) @@ -681,11 +640,11 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { display("beige dummy resource before", getDummyResource(RESOURCE_DUMMY_BEIGE_NAME)); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -741,23 +700,20 @@ public void test226JackKillBothAccountsAndRecompute() throws Exception { */ @Test public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exception { - final String TEST_NAME = "test227ModifyUserJackDefaultDummyBrokenSchemaViolation"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); getDummyResource().setModifyBreakMode(BreakMode.SCHEMA); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString("Cpt. Jack Sparrow")); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); assertUserAfter(USER_JACK_OID) @@ -809,22 +765,19 @@ public void test227ModifyUserJackDefaultDummyBrokenSchemaViolation() throws Exce */ @Test public void test228ModifyUserJackDefaultDummyNoError() throws Exception { - final String TEST_NAME = "test228ModifyUserJackDefaultDummyNoError"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestMultiResource.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); getDummyResource().resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -872,11 +825,8 @@ public void test228ModifyUserJackDefaultDummyNoError() throws Exception { */ @Test public void test229JackUnassignDummyBeigeAndDefault() throws Exception { - final String TEST_NAME = "test229JackUnassignDummyBeigeAndDefault"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); getDummyResource().resetBreakMode(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -885,11 +835,11 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { userDelta.addModification(createAssignmentModification(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, false)); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); String deadShadowOid = assertUserAfter(USER_JACK_OID) @@ -909,7 +859,7 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BEIGE_NAME, ACCOUNT_JACK_DUMMY_USERNAME); // CLEANUP - make sure we have clean slate for next tests - displayCleanup(TEST_NAME); + displayCleanup(contextName()); forceDeleteShadow(deadShadowOid); assertNoShadow(deadShadowOid); @@ -923,11 +873,8 @@ public void test229JackUnassignDummyBeigeAndDefault() throws Exception { */ @Test public void test250JackAssignDummyLavender() throws Exception { - final String TEST_NAME = "test250JackAssignDummyLavender"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -960,19 +907,17 @@ public void test250JackAssignDummyLavender() throws Exception { * The "dummies" role assigns two dummy resources that are in a dependency. The value of DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME is propagated from one * resource through the user to the other resource. If dependency does not work then no value is propagated. */ - public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + public void jackAssignRoleDummies() throws Exception { + Task task = createTask("jackAssignRoleDummies"); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1015,36 +960,35 @@ public void jackAssignRoleDummies(final String TEST_NAME) throws Exception { .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The crew of The Lost Souls"); } - public void jackRename(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); + public void jackRename() throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - jackRename(TEST_NAME, "jackie", "Jackie Sparrow", task, result); - jackRename(TEST_NAME, USER_JACK_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, task, result); + jackRename("jackie", "Jackie Sparrow", task, result); + jackRename(USER_JACK_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, task, result); } - public void jackRename(final String TEST_NAME, String toName, String toFullName, Task task, OperationResult result) throws Exception { - + public void jackRename(String toName, String toFullName, Task task, OperationResult result) + throws Exception { ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_JACK_OID, UserType.F_NAME, PrismTestUtil.createPolyString(toName)); objectDelta.addModificationReplaceProperty(UserType.F_FULL_NAME, PrismTestUtil.createPolyString(toFullName)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); PrismAsserts.assertPropertyValue(userJack, UserType.F_NAME, PrismTestUtil.createPolyString(toName)); PrismAsserts.assertPropertyValue(userJack, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(toFullName)); - assertAssignedRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_DUMMIES_OID, result); assertLinks(userJack, 4); assertDefaultDummyAccount(toName, toFullName, true); @@ -1073,22 +1017,20 @@ public void jackRename(final String TEST_NAME, String toName, String toFullName, assertDummyAccountAttribute(RESOURCE_DUMMY_BEIGE_NAME, toName, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The crew of The Lost Souls"); } - public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + public void jackUnAssignRoleDummies() throws Exception { + Task task = getTestTask(); OperationResult result = task.getResult(); List linkOidsBefore = assertUserBefore(USER_JACK_OID) - .links() + .links() .getOids(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_DUMMIES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -1111,24 +1053,23 @@ public void jackUnAssignRoleDummies(final String TEST_NAME) throws Exception { * The "dummies" role assigns two dummy resources that are in a dependency. The value of DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME is propagated from one * resource through the user to the other resource. If dependency does not work then no value is propagated. */ - public void jackAssignRoleDummiesError(final String TEST_NAME, String roleOid, String dummyResourceName, - boolean expectAccount) throws Exception { - displayTestTitle(TEST_NAME); + public void jackAssignRoleDummiesError( + String roleOid, String dummyResourceName, boolean expectAccount) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearJackOrganizationalUnit(task, result); assertUserBefore(USER_JACK_OID) - .assertAssignments(0) - .assertLinks(0); + .assertAssignments(0) + .assertLinks(0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, roleOid, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display(result); TestUtil.assertResultStatus(result, OperationResultStatus.IN_PROGRESS); @@ -1156,17 +1097,17 @@ private void clearJackOrganizationalUnit(Task task, OperationResult result) thro modifyUserReplace(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result); } - public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, String otherResourceOid) throws Exception { - displayTestTitle(TEST_NAME); + public void jackUnassignRoleDummiesError( + String roleOid, String otherResourceOid) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); UserAsserter userBeforeAsserter = assertUserBefore(USER_JACK_OID); String dummyShadowOid = userBeforeAsserter - .links() + .links() .by() - .resourceOid(RESOURCE_DUMMY_OID) + .resourceOid(RESOURCE_DUMMY_OID) .find() .resolveTarget() .assertConception() @@ -1183,11 +1124,11 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, } // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, roleOid, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display(result); // there is a failure while reading dummy account - it was not created @@ -1232,11 +1173,9 @@ public void jackUnassignRoleDummiesError(final String TEST_NAME, String roleOid, @Test public void test300AddAndAssignRelative() throws Exception { - final String TEST_NAME = "test300AddAndAssignRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Add default dummy account to jack without assigning it. @@ -1261,11 +1200,11 @@ public void test300AddAndAssignRelative() throws Exception { assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1292,19 +1231,17 @@ public void test300AddAndAssignRelative() throws Exception { @Test public void test310AddedAccountAndUnassignRelative() throws Exception { - final String TEST_NAME = "test310AddedAccountAndUnassignRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1333,19 +1270,17 @@ public void test310AddedAccountAndUnassignRelative() throws Exception { */ @Test public void test319UnassignDummyRelative() throws Exception { - final String TEST_NAME = "test319UnassignDummyRelative"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1369,18 +1304,16 @@ public void test319UnassignDummyRelative() throws Exception { */ @Test public void test350AddAccountLavender() throws Exception { - final String TEST_NAME = "test350AddAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); // WHEN try { - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1390,7 +1323,7 @@ public void test350AddAccountLavender() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1400,21 +1333,19 @@ public void test350AddAccountLavender() throws Exception { @Test public void test352AddAccountIvory() throws Exception { - final String TEST_NAME = "test352AddAccountIvory"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1424,21 +1355,19 @@ public void test352AddAccountIvory() throws Exception { @Test public void test354AddAccountBeige() throws Exception { - final String TEST_NAME = "test354AddAccountBeige"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1448,21 +1377,19 @@ public void test354AddAccountBeige() throws Exception { @Test public void test360AddAccountDummy() throws Exception { - final String TEST_NAME = "test360AddAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1475,21 +1402,19 @@ public void test360AddAccountDummy() throws Exception { */ @Test public void test362AddAccountLavender() throws Exception { - final String TEST_NAME = "test362AddAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1502,18 +1427,16 @@ public void test362AddAccountLavender() throws Exception { */ @Test public void test370DeleteAccountDummy() throws Exception { - final String TEST_NAME = "test370DeleteAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN try { - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1523,7 +1446,7 @@ public void test370DeleteAccountDummy() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1539,18 +1462,16 @@ public void test370DeleteAccountDummy() throws Exception { */ @Test public void test372UnlinkAccountDummy() throws Exception { - final String TEST_NAME = "test372UnlinkAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserUnlinkAccount(USER_JACK_OID, getDummyResourceObject()); // WHEN try { - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); AssertJUnit.fail("Unexpected success"); @@ -1560,7 +1481,7 @@ public void test372UnlinkAccountDummy() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject user = getUser(USER_JACK_OID); @@ -1572,20 +1493,18 @@ public void test372UnlinkAccountDummy() throws Exception { @Test public void test374DeleteAccountLavender() throws Exception { - final String TEST_NAME = "test374DeleteAccountLavender"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_LAVENDER_NAME); - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_JACK_OID); @@ -1601,20 +1520,18 @@ public void test374DeleteAccountLavender() throws Exception { */ @Test public void test376DeleteAccountDummy() throws Exception { - final String TEST_NAME = "test376DeleteAccountDummy"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteAccount(USER_JACK_OID, getDummyResourceObject()); - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1627,20 +1544,18 @@ public void test376DeleteAccountDummy() throws Exception { */ @Test public void test378DeleteAccountBeige() throws Exception { - final String TEST_NAME = "test378DeleteAccountBeige"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_BEIGE_NAME); - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1654,20 +1569,18 @@ public void test378DeleteAccountBeige() throws Exception { */ @Test public void test379DeleteAccountIvory() throws Exception { - final String TEST_NAME = "test379DeleteAccountIvory"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_IVORY_NAME); - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_LAVENDER_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1682,25 +1595,23 @@ public void test379DeleteAccountIvory() throws Exception { */ @Test public void test380AddAccountPeru() throws Exception { - final String TEST_NAME = "test380AddAccountPeru"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().resetBreakMode(); // precondition assertEncryptedUserPassword(USER_JACK_OID, USER_JACK_PASSWORD); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -1709,21 +1620,19 @@ public void test380AddAccountPeru() throws Exception { @Test public void test382AddAccountYellow() throws Exception { - final String TEST_NAME = "test382AddAccountYellow"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserAddDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_NAME); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -1745,11 +1654,8 @@ public void test382AddAccountYellow() throws Exception { */ @Test public void test385ModifyUserJackPasswordA() throws Exception { - final String TEST_NAME = "test385ModifyUserJackPasswordA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1778,20 +1684,18 @@ public void test385ModifyUserJackPasswordA() throws Exception { @Test public void test389DeleteAccountPeru() throws Exception { - final String TEST_NAME = "test389DeleteAccountPeru"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createModifyUserDeleteDummyAccount(USER_JACK_OID, RESOURCE_DUMMY_PERU_NAME); - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME); @@ -1805,13 +1709,10 @@ public void test389DeleteAccountPeru() throws Exception { @Test public void test400DavidAndGoliathAssignRole() throws Exception { - final String TEST_NAME = "test400DavidAndGoliathAssignRole"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_WORLD_NAME, USER_WORLD_FULL_NAME, true); @@ -1821,11 +1722,11 @@ public void test400DavidAndGoliathAssignRole() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); @@ -1891,24 +1792,21 @@ private void assertDavidGoliath(String userOid, String ou, String name, boolean @Test public void test401DavidAndGoliathModifyOu() throws Exception { - final String TEST_NAME = "test401DavidAndGoliathModifyOu"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_ORGANIZATIONAL_UNIT, task, result, PrismTestUtil.createPolyString("rock")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -1938,13 +1836,10 @@ public void test401DavidAndGoliathModifyOu() throws Exception { @Test public void test403DavidAndGoliathDisableUser() throws Exception { - final String TEST_NAME = "test403DavidAndGoliathDisableUser"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -1952,11 +1847,11 @@ public void test403DavidAndGoliathDisableUser() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, false, false, false); @@ -1977,24 +1872,21 @@ public void test403DavidAndGoliathDisableUser() throws Exception { @Test public void test404DavidAndGoliathEnableUser() throws Exception { - final String TEST_NAME = "test404DavidAndGoliathEnableUser"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -2015,13 +1907,10 @@ public void test404DavidAndGoliathEnableUser() throws Exception { @Test public void test405DavidAndGoliathDisableAccountDavid() throws Exception { - final String TEST_NAME = "test405DavidAndGoliathDisableAccountDavid"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2030,11 +1919,11 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2055,13 +1944,10 @@ public void test405DavidAndGoliathDisableAccountDavid() throws Exception { */ @Test public void test406DavidAndGoliathRecompute() throws Exception { - final String TEST_NAME = "test406DavidAndGoliathRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2069,11 +1955,11 @@ public void test406DavidAndGoliathRecompute() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, false, true); @@ -2085,13 +1971,10 @@ public void test406DavidAndGoliathRecompute() throws Exception { @Test public void test408DavidAndGoliathEnableAccountDavid() throws Exception { - final String TEST_NAME = "test408DavidAndGoliathEnableAccountDavid"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); @@ -2100,11 +1983,11 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountShadowReplace(accountDavidOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_WORLD_NAME, true, true, true); @@ -2122,24 +2005,21 @@ public void test408DavidAndGoliathEnableAccountDavid() throws Exception { @Test public void test410DavidAndGoliathRename() throws Exception { - final String TEST_NAME = "test410DavidAndGoliathRename"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_WORLD_NAME); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_FIELD_NAME)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2169,24 +2049,21 @@ public void test410DavidAndGoliathRename() throws Exception { @Test public void test419DavidAndGoliathUnassignRole() throws Exception { - final String TEST_NAME = "test419DavidAndGoliathUnassignRole"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); assertUserAfter(userBefore.getOid()) @@ -2213,13 +2090,10 @@ public void test419DavidAndGoliathUnassignRole() throws Exception { @Test public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { - final String TEST_NAME = "test420DavidAndGoliathAssignRoleGoliathDown"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2241,11 +2115,11 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); // explicitly recompute status here. It was computed before. // Inner errors are expected - but those should be pending on retry assertInProgress(result); @@ -2292,15 +2166,12 @@ public void test420DavidAndGoliathAssignRoleGoliathDown() throws Exception { */ @Test public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { - final String TEST_NAME = "test421DavidAndGoliathAssignRoleGoliathUpRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2309,7 +2180,7 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2347,9 +2218,6 @@ public void test421DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio */ @Test public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exception { - final String TEST_NAME = "test422DavidAndGoliathAssignRoleGoliathUpRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); @@ -2357,7 +2225,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2366,7 +2234,7 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2401,15 +2269,12 @@ public void test422DavidAndGoliathAssignRoleGoliathUpRecompute() throws Exceptio */ @Test public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exception { - final String TEST_NAME = "test423DavidAndGoliathAssignRoleGoliathUpReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2418,7 +2283,7 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "rock", USER_FIELD_NAME, true, true, true); @@ -2431,25 +2296,22 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio @Test public void test428DavidAndGoliathUnassignRole() throws Exception { - final String TEST_NAME = "test428DavidAndGoliathUnassignRole"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); dummyAuditService.clear(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); deadShadowOid = assertUserAfter(userBefore.getOid()) @@ -2483,9 +2345,6 @@ public void test428DavidAndGoliathUnassignRole() throws Exception { */ @Test public void test429ExpireDeadShadow() throws Exception { - final String TEST_NAME = "test429ExpireDeadShadow"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); @@ -2496,15 +2355,15 @@ public void test429ExpireDeadShadow() throws Exception { clockForward("P10D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBefore.getOid()) @@ -2520,13 +2379,10 @@ public void test429ExpireDeadShadow() throws Exception { @Test public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { - final String TEST_NAME = "test430DavidAndGoliathAssignRoleDavidDown"; - displayTestTitle(TEST_NAME); - // GIVEN assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_FIELD_NAME); @@ -2546,11 +2402,11 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); // assertInProgress(result); assertUserAfter(userBefore.getOid()) @@ -2578,19 +2434,14 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception { dummyAuditService.assertHasDelta(0,ChangeType.ADD, ShadowType.class); dummyAuditService.assertExecutionDeltas(1,1); dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, UserType.class); -// dummyAuditService.assertExecutionDeltas(2,1); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, UserType.class); } @Test public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exception { - final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep"; - displayTestTitle(TEST_NAME); - getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode(); getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // delete user and his roles which were added before @@ -2598,16 +2449,16 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce AssertJUnit.assertNotNull("User must not be null.", userWorld); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, userWorld.getOid() - ); + ObjectDelta delta = prismContext.deltaFactory().object() + .createDeleteDelta(UserType.class, userWorld.getOid()); Collection> deltas = new ArrayList<>(); deltas.add(delta); modelService.executeChanges(deltas, null, task, result); OperationResult deleteResult = new OperationResult("Check if user was deleted properly."); try { - repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult); - } catch (ObjectNotFoundException ex){ + repositoryService.getObject(UserType.class, userWorld.getOid(), null, deleteResult); + } catch (ObjectNotFoundException ex) { //this is OK, we deleted user before } @@ -2625,56 +2476,25 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); userBefore.findOrCreateContainer(UserType.F_ASSIGNMENT).add((PrismContainerValue) cval); - - -// userBefore.asObjectable().getAssignmentNew().add(cval.asContainerable()); - // this should add user and at the sate time assign the role fight..-> // the result of the operation have to be the same as in test 400 addObject(userBefore); dummyAuditService.clear(); - // WHEN - displayWhen(TEST_NAME); -// assignRole(userBefore.getOid(), ROLE_FIGHT_OID, task, result); - - // THEN - displayThen(TEST_NAME); + expect(); assertSuccess(result); assertDavidGoliath(userBefore.getOid(), "stone", USER_WORLD_NAME, true, true, true); // Check audit display("Audit", dummyAuditService); -// dummyAuditService.assertRecords(4); -// dummyAuditService.assertSimpleRecordSanity(); -// dummyAuditService.assertAnyRequestDeltas(); -// dummyAuditService.assertExecutionDeltas(0,3); -// dummyAuditService.asserHasDelta(0,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(0,ChangeType.ADD, ShadowType.class); -// dummyAuditService.assertExecutionDeltas(1,3); -// dummyAuditService.asserHasDelta(1,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(1,ChangeType.ADD, ShadowType.class); -// dummyAuditService.assertExecutionDeltas(2,2); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, UserType.class); -// dummyAuditService.asserHasDelta(2,ChangeType.MODIFY, ShadowType.class); -// dummyAuditService.assertExecutionSuccess(); -// -// // Have a closer look at the last shadow modify delta. Make sure there are no phantom changes. -// ObjectDeltaOperation executionDeltaOp = dummyAuditService.getExecutionDelta(2, ChangeType.MODIFY, ShadowType.class); -// ObjectDelta executionDelta = executionDeltaOp.getObjectDelta(); -// display("Last execution delta", executionDelta); -// PrismAsserts.assertModifications("Phantom changes in last delta:", executionDelta, 2); } @Test public void test500PrepareJack() throws Exception { - final String TEST_NAME = "test500PrepareJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2687,11 +2507,11 @@ public void test500PrepareJack() throws Exception { assertLinks(userBefore, 1); // WHEN - displayWhen(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2706,11 +2526,8 @@ public void test500PrepareJack() throws Exception { @Test public void test501JackAssignDummyDarkYellow() throws Exception { - final String TEST_NAME = "test501JackAssignDummyDarkYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2720,11 +2537,11 @@ public void test501JackAssignDummyDarkYellow() throws Exception { assertLinks(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2737,22 +2554,19 @@ public void test501JackAssignDummyDarkYellow() throws Exception { @Test public void test502JackAssignDummyDarkPeru() throws Exception { - final String TEST_NAME = "test502JackAssignDummyDarkPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2769,22 +2583,19 @@ public void test502JackAssignDummyDarkPeru() throws Exception { */ @Test public void test504JackUnassignDummyDarkPeru() throws Exception { - final String TEST_NAME = "test504JackUnassignDummyDarkPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2798,22 +2609,19 @@ public void test504JackUnassignDummyDarkPeru() throws Exception { @Test public void test507JackUnassignDummyDarkYellow() throws Exception { - final String TEST_NAME = "test507JackUnassignDummyDarkYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2827,22 +2635,19 @@ public void test507JackUnassignDummyDarkYellow() throws Exception { @Test public void test508JackDeleteDummyDarkYellowAccount() throws Exception { - final String TEST_NAME = "test508JackDeleteDummyDarkYellowAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_YELLOW_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2856,22 +2661,19 @@ public void test508JackDeleteDummyDarkYellowAccount() throws Exception { @Test public void test509JackDeleteDummyDarkPeruAccount() throws Exception { - final String TEST_NAME = "test509JackDeleteDummyDarkPeruAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); deleteUserAccount(USER_JACK_OID, RESOURCE_DUMMY_DARK_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2885,11 +2687,8 @@ public void test509JackDeleteDummyDarkPeruAccount() throws Exception { @Test public void test510JackAssignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test510JackAssignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2901,11 +2700,11 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2922,22 +2721,19 @@ public void test510JackAssignRoleDarkYellowPeru() throws Exception { */ @Test public void test519JackUnassignDarkRoleYellowPeru() throws Exception { - final String TEST_NAME = "test519JackUnassignDarkRoleYellowPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2951,11 +2747,8 @@ public void test519JackUnassignDarkRoleYellowPeru() throws Exception { @Test public void test520JackAssignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test520JackAssignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -2967,11 +2760,11 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { assertAssignments(userBefore, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_DARK_YELLOW_PERU_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2988,11 +2781,8 @@ public void test520JackAssignRoleDarkYellowPeru() throws Exception { */ @Test public void test529JackUnassignRoleDarkYellowPeru() throws Exception { - final String TEST_NAME = "test529JackUnassignRoleDarkYellowPeru"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -3000,11 +2790,11 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { AssignmentType currentAssignment = findAssignmentByTargetRequired(userBefore, ROLE_DARK_YELLOW_PERU_OID); // WHEN - displayWhen(TEST_NAME); + when(); unassign(UserType.class, USER_JACK_OID, currentAssignment.getId(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3015,5 +2805,4 @@ public void test529JackUnassignRoleDarkYellowPeru() throws Exception { assertDummyAccount(RESOURCE_DUMMY_DARK_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); assertDummyAccount(RESOURCE_DUMMY_DARK_PERU_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); } - } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java index 655111bbb69..aac4c28f7c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestAssignmentErrors.java @@ -42,7 +42,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; 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.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -105,8 +104,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010RefinedSchemaWhite() throws Exception { - final String TEST_NAME = "test010RefinedSchemaWhite"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -166,10 +163,9 @@ public void test010RefinedSchemaWhite() throws Exception { @Test public void test100UserJackAssignBlankAccount() throws Exception { final String TEST_NAME = "test100UserJackAssignBlankAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -209,10 +205,9 @@ public void test100UserJackAssignBlankAccount() throws Exception { @Test public void test101AddUserCharlesAssignBlankAccount() throws Exception { final String TEST_NAME = "test101AddUserCharlesAssignBlankAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); dummyAuditService.clear(); @@ -223,12 +218,12 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { ObjectDelta userDelta = DeltaFactory.Object.createAddDelta(userCharles); // WHEN - displayWhen(TEST_NAME); + when(); //we do not expect this to throw an exception. instead the fatal error in the result is excpected Collection> executedChanges = executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); // Even though the operation failed the addition of a user should be successful. Let's check if user was really added. @@ -252,10 +247,9 @@ public void test101AddUserCharlesAssignBlankAccount() throws Exception { @Test public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { final String TEST_NAME = "test200UserLemonheadAssignAccountBrokenNetwork"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -271,12 +265,12 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); // not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display(result); // account cannot be updated due to a network error. The operation was postponed, therefore // it is "in progress". @@ -331,10 +325,9 @@ public void test200UserLemonheadAssignAccountBrokenNetwork() throws Exception { @Test public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -358,14 +351,14 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); //not expected that it fails, instead the error in the result is expected modelService.executeChanges(deltas, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); } assertFailure(result); @@ -401,10 +394,9 @@ public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception { @Test public void test212UserSharptoothAssignAccountRecovery() throws Exception { final String TEST_NAME = "test212UserSharptoothAssignAccountRecovery"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -412,11 +404,11 @@ public void test212UserSharptoothAssignAccountRecovery() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userSharptoothOid, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -475,10 +467,9 @@ public void test215UserSharptoothChangePasswordGenericError() throws Exception { // } public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakMode breakMode, String oldPassword, String newPassword, OperationResultStatus expectedResultStatus) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); @@ -486,11 +477,11 @@ public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakM dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(userSharptoothOid, newPassword, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertStatus(result, expectedResultStatus); @@ -513,13 +504,12 @@ public void testUserSharptoothChangePasswordError(final String TEST_NAME, BreakM @Test public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exception { final String TEST_NAME = "test220UserAssignAccountDeletedShadowRecomputeSync"; - displayTestTitle(TEST_NAME); //GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_OID, null, USER_AFET_NAME, USER_AFET_FULLNAME); String shadowOidBefore = getSingleLinkOid(user); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -541,7 +531,7 @@ public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exceptio // ... and again ... - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN @@ -571,7 +561,6 @@ public void test220UserAssignAccountDeletedShadowRecomputeSync() throws Exceptio @Test public void test222UserAssignAccountDeletedShadowRecomputeNoSync() throws Exception { final String TEST_NAME = "test222UserAssignAccountDeletedShadowRecomputeNoSync"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_RED_OID, @@ -625,14 +614,13 @@ public void test222UserAssignAccountDeletedShadowRecomputeNoSync() throws Except @Test public void test224UserAssignAccountDeletedShadowRecomputeReducedSync() throws Exception { final String TEST_NAME = "test224UserAssignAccountDeletedShadowRecomputeReducedSync"; - displayTestTitle(TEST_NAME); //GIVEN PrismObject user = setupUserAssignAccountDeletedShadowRecompute(TEST_NAME, RESOURCE_DUMMY_YELLOW_OID, RESOURCE_DUMMY_YELLOW_NAME, USER_CFET_NAME, USER_CFET_FULLNAME); String shadowOidBefore = getSingleLinkOid(user); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -654,7 +642,7 @@ public void test224UserAssignAccountDeletedShadowRecomputeReducedSync() throws E // ... and again ... - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); // WHEN @@ -678,7 +666,7 @@ private PrismObject setupUserAssignAccountDeletedShadowRecompute(final String dummyResourceName, String userName, String userFullName) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); getDummyResource().resetBreakMode(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java index 3e833ae47e3..72fff14fd9f 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestBrokenResources.java @@ -163,10 +163,9 @@ public void postInitSystem(Task initTask, OperationResult initResult) throws Exc @Test public void test010TestResourceBroken() throws Exception { final String TEST_NAME = "test010TestResourceBroken"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -180,10 +179,9 @@ public void test010TestResourceBroken() throws Exception { @Test public void test020GetResourceBroken() throws Exception { final String TEST_NAME = "test020GetResourceBroken"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -211,10 +209,9 @@ public void test030ListResources() throws Exception { @Test public void test100GetAccountMurray() throws Exception { final String TEST_NAME = "test100GetAccountMurray"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -238,10 +235,9 @@ public void test100GetAccountMurray() throws Exception { @Test public void test101GetAccountMurrayNoFetch() throws Exception { final String TEST_NAME = "test101GetAccountMurrayNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -260,7 +256,6 @@ public void test101GetAccountMurrayNoFetch() throws Exception { @Test public void test102GetAccountMurrayRaw() throws Exception { - TestUtil.displayTestTitle(this, "test102GetAccountMurrayRaw"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test102GetAccountMurrayRaw"); @@ -283,7 +278,6 @@ public void test102GetAccountMurrayRaw() throws Exception { @Test public void test120SearchAccountByUsernameJack() throws Exception { - TestUtil.displayTestTitle(this, "test120SearchAccountByUsernameJack"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test120SearchAccountByUsernameJack"); @@ -308,7 +302,6 @@ public void test120SearchAccountByUsernameJack() throws Exception { @Test public void test210TestResourceNotFound() throws Exception { - TestUtil.displayTestTitle(this, "test210TestResourceNotFound"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test210TestResourceNotFound"); @@ -326,7 +319,6 @@ public void test210TestResourceNotFound() throws Exception { @Test public void test220GetResourceNotFound() throws Exception { final String TEST_NAME = "test220GetResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "."+TEST_NAME); @@ -369,7 +361,6 @@ public void test220GetResourceNotFound() throws Exception { @Test public void test221GetResourceNotFoundResolveConnector() throws Exception { final String TEST_NAME = "test221GetResourceNotFoundResolveConnector"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "."+TEST_NAME); @@ -401,7 +392,6 @@ public void test221GetResourceNotFoundResolveConnector() throws Exception { @Test public void test310TestResourceNoJars() throws Exception { - TestUtil.displayTestTitle(this, "test310TestResourceNoJars"); // GIVEN Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test310TestResourceNoJars"); @@ -417,10 +407,9 @@ public void test310TestResourceNoJars() throws Exception { @Test public void test320GetResourceNoJars() throws Exception { final String TEST_NAME = "test320GetResourceNoJars"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -443,10 +432,9 @@ public void test320GetResourceNoJars() throws Exception { @Test public void test350AddResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test350AddResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -475,10 +463,9 @@ public void test350AddResourceWrongConnectorOid() throws Exception { @Test public void test352AddResourceWrongConnectorOidRaw() throws Exception { final String TEST_NAME = "test352AddResourceWrongConnectorOidRaw"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -508,10 +495,9 @@ public void test352AddResourceWrongConnectorOidRaw() throws Exception { @Test public void test355AddResourceWrongConnectorOidRepo() throws Exception { final String TEST_NAME = "test355AddResourceWrongConnectorOidRepo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_WRONG_CONNECTOR_OID_FILE); @@ -527,10 +513,9 @@ public void test355AddResourceWrongConnectorOidRepo() throws Exception { @Test public void test358GetResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test358GetResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -553,10 +538,9 @@ public void test358GetResourceWrongConnectorOid() throws Exception { @Test public void test359DeleteResourceWrongConnectorOid() throws Exception { final String TEST_NAME = "test359DeleteResourceWrongConnectorOid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -578,10 +562,9 @@ public void test359DeleteResourceWrongConnectorOid() throws Exception { @Test public void test360AddResourceNoConfiguration() throws Exception { final String TEST_NAME = "test360AddResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(RESOURCE_DUMMY_NO_CONFIGURATION_FILE); @@ -602,10 +585,9 @@ public void test360AddResourceNoConfiguration() throws Exception { @Test public void test362GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test362GetResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -634,10 +616,9 @@ public void test368ListResources() throws Exception { @Test public void test369DeleteResourceNoConfiguration() throws Exception { final String TEST_NAME = "test369DeleteResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -664,10 +645,9 @@ public void test370ListResources() throws Exception { @Test public void test371ImportUnaccessibleResource() throws Exception { final String TEST_NAME = "test371ImportUnaccessibleResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -685,10 +665,9 @@ public void test371ImportUnaccessibleResource() throws Exception { @Test public void test372GetUnaccessibleResourceNoFetch() throws Exception { final String TEST_NAME = "test372GetUnaccessibleResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT); @@ -744,10 +723,9 @@ public void test375ListResources() throws Exception { } public void testListResources(final String TEST_NAME, int expectedNumber, Collection> options) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN (1) - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN (1) @@ -768,7 +746,7 @@ public void testListResources(final String TEST_NAME, int expectedNumber, Collec // GIVEN (2) resources.clear(); - task = createTask(TEST_NAME); + task = getTestTask(); result = task.getResult(); ResultHandler handler = new ResultHandler() { @@ -800,10 +778,9 @@ public boolean handle(PrismObject object, OperationResult parentRe @Test public void test377GetResourceNoConfiguration() throws Exception { final String TEST_NAME = "test377GetResourceNoConfiguration"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -833,21 +810,20 @@ public void test377GetResourceNoConfiguration() throws Exception { @Test public void test400AssignTwoResouresNotFound() throws Exception { final String TEST_NAME = "test400AssignTwoResoures"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); ObjectDelta userDelta = createAssignTwoResourcesDelta(RESOURCE_CSVFILE_NOTFOUND_OID); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("executeChanges result", result); assertPartialError(result); @@ -865,10 +841,9 @@ public void test400AssignTwoResouresNotFound() throws Exception { @Test public void test401AssignTwoResouresBroken() throws Exception { final String TEST_NAME = "test401AssignTwoResouresBroken"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); @@ -876,13 +851,13 @@ public void test401AssignTwoResouresBroken() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(userDelta, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); } @@ -909,10 +884,9 @@ private ObjectDelta createAssignTwoResourcesDelta(String badResourceOi @Test public void test500AssignResourceBlack() throws Exception { final String TEST_NAME = "test500AssignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -922,11 +896,11 @@ public void test500AssignResourceBlack() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -947,19 +921,18 @@ public void test500AssignResourceBlack() throws Exception { @Test public void test502ModifyUserEmployeeNumberNone() throws Exception { final String TEST_NAME = "test502ModifyUserEmployeeNumberNone"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "none"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -980,19 +953,18 @@ public void test502ModifyUserEmployeeNumberNone() throws Exception { @Test public void test509UnassignResourceBlack() throws Exception { final String TEST_NAME = "test509UnassignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1013,10 +985,9 @@ public void test509UnassignResourceBlack() throws Exception { @Test public void test510AssignResourceBlackError() throws Exception { final String TEST_NAME = "test510AssignResourceBlackError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1028,14 +999,14 @@ public void test510AssignResourceBlackError() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (GenericConnectorException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); } @@ -1060,19 +1031,18 @@ public void test510AssignResourceBlackError() throws Exception { @Test public void test512ReconcileUser() throws Exception { final String TEST_NAME = "test512ReconcileUser"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); // Errors deep inside the results are expected assertSuccess(result, 2); @@ -1092,23 +1062,22 @@ public void test512ReconcileUser() throws Exception { @Test public void test514ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test514ModifyUserEmployeeNumberRuntime"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); assertNotReached(); } catch (RuntimeException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1133,23 +1102,22 @@ public void test514ModifyUserEmployeeNumberRuntime() throws Exception { @Test public void test518UnassignResourceBlack() throws Exception { final String TEST_NAME = "test518UnassignResourceBlack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); try { // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result); assertNotReached(); } catch (RuntimeException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); assertEquals("Wrong exception message", "Booom! PowerFail script failed (runtime)", e.getMessage()); } @@ -1175,19 +1143,18 @@ public void test518UnassignResourceBlack() throws Exception { @Test public void test519ReconcileUser() throws Exception { final String TEST_NAME = "test519ReconcileUser"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1206,10 +1173,9 @@ public void test519ReconcileUser() throws Exception { @Test public void test520AssignResourceEbonyError() throws Exception { final String TEST_NAME = "test520AssignResourceEbonyError"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1220,11 +1186,11 @@ public void test520AssignResourceEbonyError() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_EBONY_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1247,19 +1213,18 @@ public void test520AssignResourceEbonyError() throws Exception { @Test public void test524ModifyUserEmployeeNumberRuntime() throws Exception { final String TEST_NAME = "test524ModifyUserEmployeeNumberRuntime"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_EMPLOYEE_NUMBER, task, result, DummyResource.POWERFAIL_ARG_ERROR_RUNTIME); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1280,10 +1245,9 @@ public void test524ModifyUserEmployeeNumberRuntime() throws Exception { @Test public void test528UnassignResourceEbony() throws Exception { final String TEST_NAME = "test528UnassignResourceEbony"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest5xx(); @@ -1293,11 +1257,11 @@ public void test528UnassignResourceEbony() throws Exception { .assertLinks(1); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_EBONY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertPartialError(result); @@ -1333,16 +1297,15 @@ public void test528UnassignResourceEbony() throws Exception { @Test public void test600GuybrushAssignAccountDummyViolet() throws Exception { final String TEST_NAME = "test600GuybrushAssignAccountDummyViolet"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); try { // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BROKEN_VIOLET_OID, null, task, result); assertNotReached(); @@ -1351,7 +1314,7 @@ public void test600GuybrushAssignAccountDummyViolet() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java index 8ae33fe2e75..2737cf9bdf1 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java @@ -24,7 +24,6 @@ import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType; @@ -64,7 +63,6 @@ public class TestModelWebServiceNegative extends AbstractInitializedModelIntegra @Test public void test100ModifyAccountExplicitType() throws Exception { final String TEST_NAME = "test100ModifyUserAddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); @@ -92,7 +90,6 @@ public void test100ModifyAccountExplicitType() throws Exception { @Test public void test110ModifyAccountImplicitType() throws Exception { final String TEST_NAME = "test110ModifyAccountImplicitType"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); @@ -117,7 +114,6 @@ public void test110ModifyAccountImplicitType() throws Exception { @Test public void test200ModifyAccountWrongExplicitType() throws Exception { final String TEST_NAME = "test200ModifyAccountWrongExplicitType"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java index 49e5a8cf117..c85598f81ba 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStruct.java @@ -121,7 +121,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010AddOrgStruct() throws Exception { final String TEST_NAME = "test010AddOrgStruct"; - displayTestTitle(TEST_NAME); // Dummy, just to be overridden in subclasses addOrgStruct(); @@ -134,7 +133,6 @@ protected void addOrgStruct() throws Exception { @Test public void test051OrgStructSanity() throws Exception { final String TEST_NAME = "test051OrgStructSanity"; - displayTestTitle(TEST_NAME); // WHEN assertMonkeyIslandOrgSanity(); @@ -143,10 +141,9 @@ public void test051OrgStructSanity() throws Exception { @Test public void test052RootOrgQuery() throws Exception { final String TEST_NAME = "test052RootOrgQuery"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createRootOrgQuery(prismContext); @@ -164,9 +161,8 @@ public void test052RootOrgQuery() throws Exception { @Test public void test100JackAssignOrgtarget() throws Exception { final String TEST_NAME = "test100JackAssignOrgtarget"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition @@ -193,9 +189,8 @@ public void test100JackAssignOrgtarget() throws Exception { @Test public void test101JackAssignScummBar() throws Exception { final String TEST_NAME = "test101JackAssignScummBar"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition @@ -220,9 +215,8 @@ public void test101JackAssignScummBar() throws Exception { @Test public void test102JackUnassignScummBar() throws Exception { final String TEST_NAME = "test102JackUnassignScummBar"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -246,9 +240,8 @@ public void test102JackUnassignScummBar() throws Exception { @Test public void test201JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test201JackAssignScummBarAndSaveElaine"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -278,9 +271,8 @@ public void test201JackAssignScummBarAndSaveElaine() throws Exception { @Test public void test202JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test202JackAssignMinistryOfOffense"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -300,9 +292,8 @@ public void test202JackAssignMinistryOfOffense() throws Exception { @Test public void test207JackUnAssignScummBar() throws Exception { final String TEST_NAME = "test207JackUnAssignScummBar"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -322,17 +313,16 @@ public void test207JackUnAssignScummBar() throws Exception { @Test public void test208JackUnassignAll() throws Exception { final String TEST_NAME = "test208JackUnassignAll"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAllReplace(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -349,9 +339,8 @@ public void test208JackUnassignAll() throws Exception { @Test public void test210JackAssignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test210JackAssignMinistryOfOffenseMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -380,9 +369,8 @@ public void test210JackAssignMinistryOfOffenseMember() throws Exception { @Test public void test211JackAssignMinistryOfOffenseMinister() throws Exception { final String TEST_NAME = "test211JackAssignMinistryOfOffenseMinister"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -408,9 +396,8 @@ public void test211JackAssignMinistryOfOffenseMinister() throws Exception { @Test public void test212JackUnassignMinistryOfOffenseMember() throws Exception { final String TEST_NAME = "test212JackUnassignMinistryOfOffenseMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -433,9 +420,8 @@ public void test212JackUnassignMinistryOfOffenseMember() throws Exception { @Test public void test213JackUnassignMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test213JackUnassignMinistryOfOffenseManager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -456,9 +442,8 @@ public void test213JackUnassignMinistryOfOffenseManager() throws Exception { @Test public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { final String TEST_NAME = "test220JackAssignMinistryOfOffenseMemberAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -485,9 +470,8 @@ public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception { @Test public void test221JackAssignScummBarAndSaveElaine() throws Exception { final String TEST_NAME = "test221JackAssignScummBarAndSaveElaine"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -516,9 +500,8 @@ public void test221JackAssignScummBarAndSaveElaine() throws Exception { @Test public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception { final String TEST_NAME = "test221JackChangeMinistryOfOffenseMemberToManager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -578,18 +561,17 @@ public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception @Test public void test230JackRecompute() throws Exception { final String TEST_NAME = "test230JackRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -604,9 +586,8 @@ public void test230JackRecompute() throws Exception { @Test public void test232JackDestroyRefsAndRecompute() throws Exception { final String TEST_NAME = "test232JackDestroyRefsAndRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearUserOrgAndRoleRefs(USER_JACK_OID); @@ -615,11 +596,11 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -638,9 +619,8 @@ public void test232JackDestroyRefsAndRecompute() throws Exception { @Test public void test234JackDestroyRefsAndLightRecompute() throws Exception { final String TEST_NAME = "test234JackDestroyRefsAndLightRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clearUserOrgAndRoleRefs(USER_JACK_OID); @@ -658,11 +638,11 @@ public void test234JackDestroyRefsAndLightRecompute() throws Exception { options.setReconcileFocus(true); // WHEN - displayWhen(TEST_NAME); + when(); modelService.recompute(UserType.class, USER_JACK_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRefs23x(); @@ -700,9 +680,8 @@ private Long findAssignmentIdForTarget(PrismObject user, String target @Test public void test300JackUnassignAllOrgs() throws Exception { final String TEST_NAME = "test300JackUnassignAllOrgs"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -713,11 +692,11 @@ public void test300JackUnassignAllOrgs() throws Exception { .createModifyDelta(USER_JACK_OID, modifications, UserType.class); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject userJack = getUser(USER_JACK_OID); display("User jack after", userJack); assertAssignedNoOrg(userJack); @@ -733,9 +712,8 @@ public void test300JackUnassignAllOrgs() throws Exception { @Test public void test301JackAssignMinistryOfOffense() throws Exception { final String TEST_NAME = "test301JackAssignMinistryOfOffense"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -759,9 +737,8 @@ public void test301JackAssignMinistryOfOffense() throws Exception { @Test public void test305JackConflictZeroAndMinus() throws Exception { final String TEST_NAME = "test305JackConflictZeroAndMinus"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -791,13 +768,12 @@ public void test305JackConflictZeroAndMinus() throws Exception { @Test public void test307JackConflictPlusAndMinus() throws Exception { final String TEST_NAME = "test307JackConflictPlusAndMinus"; - displayTestTitle(TEST_NAME); executeConflictPlusAndMinus(TEST_NAME); } protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -830,9 +806,8 @@ protected void executeConflictPlusAndMinus(String TEST_NAME) throws Exception { @Test public void test308JackUnassignRoleDefender() throws Exception { final String TEST_NAME = "test308JackUnassignRoleDefender"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -870,7 +845,6 @@ public void test308JackUnassignRoleDefender() throws Exception { @Test public void test309JackConflictPlusAndMinusAgain() throws Exception { final String TEST_NAME = "test309JackConflictPlusAndMinusAgain"; - displayTestTitle(TEST_NAME); executeConflictPlusAndMinus(TEST_NAME); } @@ -881,9 +855,8 @@ public void test309JackConflictPlusAndMinusAgain() throws Exception { @Test public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Exception { final String TEST_NAME = "test310JackConflictParentOrgRefAndAssignmentsAddOrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createObject(OrgType.class, "Cheaters"); @@ -892,13 +865,13 @@ public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Excepti try { // WHEN - displayWhen(TEST_NAME); + when(); addObject(orgBefore, task, result); assertNotReached(); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); display("Expected exception", e); assertFailure(result); } @@ -915,13 +888,12 @@ public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Excepti @Test public void test349DeleteJack() throws Exception { final String TEST_NAME = "test349DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } protected void executeDeleteJack(String TEST_NAME) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, USER_JACK_OID @@ -949,9 +921,8 @@ protected void executeDeleteJack(String TEST_NAME) throws ObjectAlreadyExistsExc @Test public void test350AddJackAsMinistryOfOffenseManager() throws Exception { final String TEST_NAME = "test350AddJackAsMinistryOfOffenseManager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = prismContext.parseObject(USER_JACK_FILE); @@ -999,9 +970,8 @@ public void test350AddJackAsMinistryOfOffenseManager() throws Exception { @Test public void test360ElaineAssignGovernor() throws Exception { final String TEST_NAME = "test360ElaineAssignGovernor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1036,9 +1006,8 @@ public void test360ElaineAssignGovernor() throws Exception { @Test public void test362ElaineAssignGovernmentMember() throws Exception { final String TEST_NAME = "test362ElaineAssignGovernmentMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1074,9 +1043,8 @@ public void test362ElaineAssignGovernmentMember() throws Exception { @Test public void test365GuybrushAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1118,9 +1086,8 @@ public void test365GuybrushAssignSwashbucklerMember() throws Exception { @Test public void test368GuybrushAssignSwashbucklerManager() throws Exception { final String TEST_NAME = "test368GuybrushAssignSwashbucklerManager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1164,9 +1131,8 @@ public void test368GuybrushAssignSwashbucklerManager() throws Exception { @Test public void test370BarbossaAssignOffenseMember() throws Exception { final String TEST_NAME = "test370BarbossaAssignOffenseMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1215,9 +1181,8 @@ public void test370BarbossaAssignOffenseMember() throws Exception { @Test public void test372HermanAssignSwashbucklerMember() throws Exception { final String TEST_NAME = "test365GuybrushAssignSwashbucklerMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userHerman = getUser(USER_HERMAN_OID); assertHasNoOrg(userHerman); @@ -1275,7 +1240,6 @@ public void test372HermanAssignSwashbucklerMember() throws Exception { @Test public void test399DeleteJack() throws Exception { final String TEST_NAME = "test399DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } @@ -1286,9 +1250,8 @@ public void test399DeleteJack() throws Exception { @Test public void test400AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OrgType minOffense = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID).asObjectable(); @@ -1315,9 +1278,8 @@ public void test400AddJackWithOrgUnit() throws Exception { @Test public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1351,9 +1313,8 @@ public void test402JackChangeMinistryOfOffenseMemberToManagerByAddingRemovingAss @Test public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment() throws Exception { final String TEST_NAME = "test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1385,7 +1346,6 @@ public void test404JackChangeMinistryOfOffenseManagerToMemberByAddingRemovingAss @Test public void test409DeleteJack() throws Exception { final String TEST_NAME = "test409DeleteJack"; - displayTestTitle(TEST_NAME); executeDeleteJack(TEST_NAME); } @@ -1397,9 +1357,8 @@ public void test409DeleteJack() throws Exception { @Test public void test410AddJackWithOrgUnit() throws Exception { final String TEST_NAME = "test400AddJackWithOrgUnit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); OrgType minOffense = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID).asObjectable(); @@ -1427,9 +1386,8 @@ public void test410AddJackWithOrgUnit() throws Exception { @Test public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment() throws Exception { final String TEST_NAME = "test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject jack = getUser(USER_JACK_OID); @@ -1469,9 +1427,8 @@ public void test412JackChangeMinistryOfOffenseMemberToManagerByModifyingAssignme @Test public void test420JackAssignTempOrg() throws Exception { final String TEST_NAME = "test420JackAssignTempOrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(ORG_TEMP_FILE); @@ -1493,19 +1450,18 @@ public void test420JackAssignTempOrg() throws Exception { @Test public void test425JackUnassignDeletedOrg() throws Exception { final String TEST_NAME = "test425JackUnassignDeletedOrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); deleteObject(OrgType.class, ORG_TEMP_OID, task, result); // WHEN - displayWhen(TEST_NAME); + when(); unassignOrg(USER_JACK_OID, ORG_TEMP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); result.computeStatus(); TestUtil.assertSuccess(result, 1); @@ -1522,9 +1478,8 @@ public void test425JackUnassignDeletedOrg() throws Exception { @Test public void test430JackAssignMetaroleOffender() throws Exception { final String TEST_NAME = "test430JackAssignMetaroleOffender"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -1558,9 +1513,8 @@ public void test430JackAssignMetaroleOffender() throws Exception { @Test public void test431JackAssignMetaroleOffenderAdmin() throws Exception { final String TEST_NAME = "test431JackAssignMetaroleOffenderAdmin"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -1587,9 +1541,8 @@ public void test431JackAssignMetaroleOffenderAdmin() throws Exception { @Test public void test437JackUnassignOffender() throws Exception { final String TEST_NAME = "test437JackUnassignOffender"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1615,9 +1568,8 @@ public void test437JackUnassignOffender() throws Exception { @Test public void test438JackUnassignOffenderAdmin() throws Exception { final String TEST_NAME = "test438JackUnassignOffenderAdmin"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1642,9 +1594,8 @@ public void test438JackUnassignOffenderAdmin() throws Exception { @Test public void test439JackCleanup() throws Exception { final String TEST_NAME = "test439JackCleanup"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1672,9 +1623,8 @@ public void test439JackCleanup() throws Exception { @Test public void test440JackModifyEmployeeTypeRolePirate() throws Exception { final String TEST_NAME = "test440JackModifyEmployeeTypeRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1682,11 +1632,11 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { assertNoAssignments(userBefore); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, task, result, "ROLE:Pirate"); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User after", userAfter); assertAssignments(userAfter, 1); @@ -1702,9 +1652,8 @@ public void test440JackModifyEmployeeTypeRolePirate() throws Exception { @Test public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { final String TEST_NAME = "test441JackModifyEmployeeTypeRoleCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1729,9 +1678,8 @@ public void test441JackModifyEmployeeTypeRoleCaptain() throws Exception { @Test public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { final String TEST_NAME = "test443JackModifyEmployeeTypeRoleNotExist"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1757,9 +1705,8 @@ public void test443JackModifyEmployeeTypeRoleNotExist() throws Exception { @Test public void test449JackModifyEmployeeTypeNull() throws Exception { final String TEST_NAME = "test449JackModifyEmployeeTypeNull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1780,9 +1727,8 @@ public void test449JackModifyEmployeeTypeNull() throws Exception { @Test public void test500JackEndPirate() throws Exception { final String TEST_NAME = "test500JackEndPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -1816,19 +1762,18 @@ public void test500JackEndPirate() throws Exception { @Test public void test510JackEndPirate() throws Exception { final String TEST_NAME = "test510JackEndPirate"; - displayTestTitle(TEST_NAME); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, "X.marks.the.SPOT", task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1849,7 +1794,6 @@ public void test510JackEndPirate() throws Exception { @Test public void test799DeleteJack() throws Exception { final String TEST_NAME = "test799DeleteJack"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java index dee2e7ed177..be3601033a4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructCaribbean.java @@ -75,17 +75,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddOrgCaribbean() throws Exception { final String TEST_NAME = "test100AddOrgCaribbean"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repoAddObjectsFromFile(ORG_CARIBBEAN_FILE, OrgType.class, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -111,17 +110,16 @@ public void test100AddOrgCaribbean() throws Exception { @Test public void test102RecomputeJamaica() throws Exception { final String TEST_NAME = "test102RecomputeJamaica"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -142,17 +140,16 @@ public void test102RecomputeJamaica() throws Exception { @Test public void test103ReconcileJamaica() throws Exception { final String TEST_NAME = "test103ReconcileJamaica"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_CARIBBEAN_JAMAICA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -173,17 +170,16 @@ public void test103ReconcileJamaica() throws Exception { @Test public void test104RecomputeGovernor() throws Exception { final String TEST_NAME = "test104RecomputeGovernor"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -204,17 +200,16 @@ public void test104RecomputeGovernor() throws Exception { @Test public void test105ReconcileGovernor() throws Exception { final String TEST_NAME = "test105ReconcileGovernor"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_GOVERNOR_OFFICE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -238,18 +233,17 @@ public void test105ReconcileGovernor() throws Exception { @Test public void test106RecomputeDoT() throws Exception { final String TEST_NAME = "test106RecomputeDoT"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, ModelExecuteOptions.createReconcileFocus(), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -275,17 +269,16 @@ public void test106RecomputeDoT() throws Exception { @Test public void test107ReconcileDoT() throws Exception { final String TEST_NAME = "test107ReconcileDoT"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileOrg(ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -315,17 +308,16 @@ public void test107ReconcileDoT() throws Exception { @Test public void test110RecomputeDoP() throws Exception { final String TEST_NAME = "test110RecomputeDoP"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.recompute(OrgType.class, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -350,7 +342,6 @@ public void test110RecomputeDoP() throws Exception { @Test public void test115AssignJackToDoP() throws Exception { final String TEST_NAME = "test115AssignJackToDoP"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -362,11 +353,11 @@ public void test115AssignJackToDoP() throws Exception { dumpFocus("User Jack before", userJackBefore); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_JACK_OID, ORG_CARIBBEAN_DEPARTMENT_OF_PEOPLE_OID, null); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -401,7 +392,6 @@ public void test115AssignJackToDoP() throws Exception { @Test public void test120AssignBarbossaDoTManager() throws Exception { final String TEST_NAME = "test120AssignBarbossaDoTManager"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -410,11 +400,11 @@ public void test120AssignBarbossaDoTManager() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_BARBOSSA_OID, ORG_CARIBBEAN_DEPARTMENT_OF_THINGS_OID, SchemaConstants.ORG_MANAGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -439,7 +429,6 @@ public void test120AssignBarbossaDoTManager() throws Exception { @Test public void test130AssignGibbsAsJacksDeputy() throws Exception { final String TEST_NAME = "test130AssignGibbsAsJacksDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -448,11 +437,11 @@ public void test130AssignGibbsAsJacksDeputy() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_GIBBS_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignDeputy(USER_GIBBS_OID, USER_JACK_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -479,7 +468,6 @@ public void test130AssignGibbsAsJacksDeputy() throws Exception { @Test public void test140AssignPintelAsBarbossasDeputy() throws Exception { final String TEST_NAME = "test140AssignPintelAsBarbossasDeputy"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -488,11 +476,11 @@ public void test140AssignPintelAsBarbossasDeputy() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_PINTEL_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignDeputy(USER_PINTEL_OID, USER_BARBOSSA_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java index 41ca1323d66..2ebf0861ee3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/orgstruct/TestOrgStructMeta.java @@ -140,7 +140,6 @@ protected void assertUserNoOrg(PrismObject user) throws Exception { @Test public void test800JackAssignScummBar() throws Exception { final String TEST_NAME = "test800JackAssignScummBar"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -168,7 +167,6 @@ public void test800JackAssignScummBar() throws Exception { @Test public void test802JackAssignOrganized() throws Exception { final String TEST_NAME = "test802JackAssignOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -197,7 +195,6 @@ public void test802JackAssignOrganized() throws Exception { @Test public void test804JackUnAssignOrganized() throws Exception { final String TEST_NAME = "test804JackUnAssignOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -225,7 +222,6 @@ public void test804JackUnAssignOrganized() throws Exception { @Test public void test809JackUnassignScummBar() throws Exception { final String TEST_NAME = "test809JackUnassignScummBar"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -252,7 +248,6 @@ public void test809JackUnassignScummBar() throws Exception { @Test public void test810JackAssignScummBarOrganized() throws Exception { final String TEST_NAME = "test810JackAssignScummBarOrganized"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -288,17 +283,16 @@ public void test810JackAssignScummBarOrganized() throws Exception { @Test public void test890AddFictionalOrg() throws Exception { final String TEST_NAME = "test890AddFictionalOrg"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(ORG_FICTIONAL_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject org = getObject(OrgType.class, ORG_FICTIONAL_OID); assertNotNull("No fictional org", org); display("Fictional org", org); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java index 36abce3b353..f6084f01349 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/AbstractPasswordTest.java @@ -11,17 +11,8 @@ import java.io.File; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -35,6 +26,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; @@ -46,13 +38,18 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.IntegrationTestTools; +import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractPasswordTest extends AbstractInitializedModelIntegrationTest { @@ -161,13 +158,11 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - AccountActivationNotifierType accountActivationNotifier = null; - SystemConfigurationType systemConfig = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value()).asObjectable(); + SystemConfigurationType systemConfig = getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value()).asObjectable(); IntegrationTestTools.displayXml("system config", systemConfig.asPrismObject()); - for (EventHandlerType handler: systemConfig.getNotificationConfiguration().getHandler()) { + for (EventHandlerType handler : systemConfig.getNotificationConfiguration().getHandler()) { display("Handler: ", handler); List accountActivationNotifiers = handler.getAccountActivationNotifier(); if (!accountActivationNotifiers.isEmpty()) { @@ -181,11 +176,8 @@ public void test000Sanity() throws Exception { @Test public void test010AddPasswordPolicy() throws Exception { - final String TEST_NAME = "test010AddPasswordPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -204,11 +196,8 @@ public void test010AddPasswordPolicy() throws Exception { @Test public void test012AddSecurityPolicy() throws Exception { - final String TEST_NAME = "test012AddSecurityPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -227,16 +216,10 @@ public void test012AddSecurityPolicy() throws Exception { @Test public void test050CheckJackPassword() throws Exception { - final String TEST_NAME = "test050CheckJackPassword"; - displayTestTitle(TEST_NAME); - // GIVEN, WHEN // this happens during test initialization when user-jack.xml is added // THEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - PrismObject userJack = getUser(USER_JACK_OID); display("User after change execution", userJack); assertUserJack(userJack, "Jack Sparrow"); @@ -245,25 +228,21 @@ public void test050CheckJackPassword() throws Exception { assertUserPassword(userJack, USER_JACK_PASSWORD, CredentialsStorageTypeType.ENCRYPTION); } - @Test public void test051ModifyUserJackPassword() throws Exception { - final String TEST_NAME = "test051ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -282,16 +261,14 @@ public void test051ModifyUserJackPassword() throws Exception { @Test public void test060CheckJackPasswordModelInteraction() throws Exception { - final String TEST_NAME = "test060CheckJackPasswordModelInteraction"; - displayTestTitle(TEST_NAME); - if (getPasswordStorageType() == CredentialsStorageTypeType.NONE) { // Nothing to check in this case return; } // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN, THEN @@ -316,22 +293,19 @@ public void test060CheckJackPasswordModelInteraction() throws Exception { @Test public void test070AddUserHerman() throws Exception { - final String TEST_NAME = "test070AddUserHerman"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_HERMAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -351,22 +325,19 @@ public void test070AddUserHerman() throws Exception { @Test public void test100JackAssignAccountDummy() throws Exception { - final String TEST_NAME = "test100JackAssignAccountDummy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -405,11 +376,8 @@ public void test100JackAssignAccountDummy() throws Exception { */ @Test public void test110ModifyUserJackPassword() throws Exception { - final String TEST_NAME = "test110ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -455,11 +423,8 @@ public void test110ModifyUserJackPassword() throws Exception { */ @Test public void test111ModifyAccountJackPassword() throws Exception { - final String TEST_NAME = "test111ModifyAccountJackPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -491,11 +456,8 @@ public void test111ModifyAccountJackPassword() throws Exception { */ @Test public void test112ModifyJackPasswordUserAndAccount() throws Exception { - final String TEST_NAME = "test112ModifyJackPasswordUserAndAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -536,17 +498,13 @@ public void test112ModifyJackPasswordUserAndAccount() throws Exception { assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); } - /** * Add red and ugly dummy resource to the mix. This would be fun. */ @Test public void test120JackAssignAccountDummyRedAndUgly() throws Exception { - final String TEST_NAME = "test120JackAssignAccountDummyRedAndUgly"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -573,17 +531,17 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userJack, USER_PASSWORD_4_CLEAR); - assertDummyPassword(USER_JACK_USERNAME, USER_PASSWORD_5_CLEAR); + assertDummyPassword(USER_JACK_USERNAME, USER_PASSWORD_5_CLEAR); - assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); + assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); - if (isPasswordEncryption()) { - assertAccountPasswordNotifications(2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); - } else { - assertSingleAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); - } + if (isPasswordEncryption()) { + assertAccountPasswordNotifications(2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_4_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); + } else { + assertSingleAccountPasswordNotification(RESOURCE_DUMMY_UGLY_NAME, USER_JACK_USERNAME, USER_JACK_EMPLOYEE_NUMBER); + } assertNoUserPasswordNotifications(); } @@ -593,11 +551,8 @@ public void test120JackAssignAccountDummyRedAndUgly() throws Exception { */ @Test public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { - final String TEST_NAME = "test121ModifyJackPasswordUserAndAccountRed"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -644,7 +599,7 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_1_CLEAR); } @@ -653,20 +608,19 @@ public void test121ModifyJackPasswordUserAndAccountRed() throws Exception { */ @Test public void test122ModifyAccountUglyJackPasswordBad() throws Exception { - final String TEST_NAME = "test122ModifyAccountUglyJackPasswordBad"; - displayTestTitle(TEST_NAME); prepareTest(); // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountChangePassword(accountJackUglyOid, "#badPassword!", task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER); @@ -675,7 +629,6 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { assertNoUserPasswordNotifications(); } - /** * Jack employee number is mapped to ugly resource password. * Change employee number to something that does NOT comply with ugly resource password policy. @@ -683,16 +636,13 @@ public void test122ModifyAccountUglyJackPasswordBad() throws Exception { */ @Test public void test125ModifyJackEmployeeNumberBad() throws Exception { - final String TEST_NAME = "test125ModifyJackEmployeeNumberBad"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, USER_JACK_EMPLOYEE_NUMBER_NEW_BAD); @@ -723,11 +673,8 @@ public void test125ModifyJackEmployeeNumberBad() throws Exception { */ @Test public void test128ModifyJackEmployeeNumberGood() throws Exception { - final String TEST_NAME = "test128ModifyJackEmployeeNumberGood"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -761,11 +708,8 @@ public void test128ModifyJackEmployeeNumberGood() throws Exception { */ @Test public void test130JackAssignAccountDummyBlack() throws Exception { - final String TEST_NAME = "test130JackAssignAccountDummyBlack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -788,7 +732,7 @@ public void test130JackAssignAccountDummyBlack() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -804,20 +748,18 @@ public void test130JackAssignAccountDummyBlack() throws Exception { */ @Test public void test132ModifyAccountBlackJackPasswordBad() throws Exception { - final String TEST_NAME = "test132ModifyAccountBlackJackPasswordBad"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + AbstractPasswordTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountChangePassword(accountJackBlackOid, USER_PASSWORD_A_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); assertDummyPasswordConditional(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); @@ -828,11 +770,8 @@ public void test132ModifyAccountBlackJackPasswordBad() throws Exception { @Test public void test139JackUnassignAccountDummyBlack() throws Exception { - final String TEST_NAME = "test139JackUnassignAccountDummyBlack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -854,7 +793,7 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -871,20 +810,17 @@ public void test139JackUnassignAccountDummyBlack() throws Exception { */ @Test public void test140JackAssignAccountDummyYellow() throws Exception { - final String TEST_NAME = "test140JackAssignAccountDummyYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJack = getUser(USER_JACK_OID); @@ -901,7 +837,7 @@ public void test140JackAssignAccountDummyYellow() throws Exception { assertUserPassword(userJack, USER_PASSWORD_1_CLEAR); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_1_CLEAR); assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd); @@ -919,22 +855,19 @@ public void test140JackAssignAccountDummyYellow() throws Exception { */ @Test public void test142ModifyUserJackPasswordAA() throws Exception { - final String TEST_NAME = "test142ModifyUserJackPasswordAA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -953,7 +886,7 @@ public void test142ModifyUserJackPasswordAA() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userJack, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -964,7 +897,7 @@ public void test142ModifyUserJackPasswordAA() throws Exception { displayUserPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_AA_CLEAR); } @@ -975,20 +908,17 @@ public void test142ModifyUserJackPasswordAA() throws Exception { */ @Test public void test150AssignMonkeyDummyAccount() throws Exception { - final String TEST_NAME = "test150AssignMonkeyDummyAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -999,7 +929,6 @@ public void test150AssignMonkeyDummyAccount() throws Exception { assertDummyAccount(null, USER_THREE_HEADED_MONKEY_NAME, USER_THREE_HEADED_MONKEY_FULL_NAME, true); } - /** * Three headed monkey has no credentials. No password, nothing. * Just three heads. @@ -1007,22 +936,19 @@ public void test150AssignMonkeyDummyAccount() throws Exception { */ @Test public void test152ModifyUserMonkeyPassword() throws Exception { - final String TEST_NAME = "test152ModifyUserMonkeyPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); lastPasswordChangeStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_1_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); lastPasswordChangeEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1039,20 +965,17 @@ public void test152ModifyUserMonkeyPassword() throws Exception { */ @Test public void test154ModifyUserMonkeyPasswordA() throws Exception { - final String TEST_NAME = "test154ModifyUserMonkeyPasswordA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_A_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1063,23 +986,20 @@ public void test154ModifyUserMonkeyPasswordA() throws Exception { @Test public void test200ApplyPasswordPolicyHistoryLength() throws Exception { - final String TEST_NAME = "test200ApplyPasswordPolicyHistoryLength"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, 3); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @@ -1091,11 +1011,8 @@ public void test200ApplyPasswordPolicyHistoryLength() throws Exception { */ @Test public void test204UnassignAccountRed() throws Exception { - final String TEST_NAME = "test204UnassignAccountRed"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1109,11 +1026,11 @@ public void test204UnassignAccountRed() throws Exception { .createDeleteDelta(ShadowType.class, accountJackRedOid); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta, shadowDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1129,7 +1046,7 @@ public void test204UnassignAccountRed() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userAfter, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -1147,11 +1064,8 @@ public void test204UnassignAccountRed() throws Exception { */ @Test public void test206ReconcileUserJack() throws Exception { - final String TEST_NAME = "test206ReconcileUserJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1176,7 +1090,7 @@ public void test206ReconcileUserJack() throws Exception { // User and default dummy account should have unchanged passwords assertUserPassword(userAfter, USER_PASSWORD_AA_CLEAR); - assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); + assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_AA_CLEAR); // this one is not changed assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD); @@ -1192,7 +1106,7 @@ public void test206ReconcileUserJack() throws Exception { */ @Test public void test210ModifyUserJackPasswordGood() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test210ModifyUserJackPasswordGood", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1202,11 +1116,8 @@ public void test210ModifyUserJackPasswordGood() throws Exception { */ @Test public void test212ReconcileUserJack() throws Exception { - final String TEST_NAME = "test212ReconcileUserJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1226,11 +1137,8 @@ public void test212ReconcileUserJack() throws Exception { */ @Test public void test214RecomputeUserJack() throws Exception { - final String TEST_NAME = "test214RecomputeUserJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1249,7 +1157,7 @@ public void test214RecomputeUserJack() throws Exception { */ @Test public void test220ModifyUserJackPasswordBadA() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test220ModifyUserJackPasswordBadA", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_1_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1260,11 +1168,8 @@ public void test220ModifyUserJackPasswordBadA() throws Exception { */ @Test public void test222ModifyUserJackPasswordBadContainer() throws Exception { - final String TEST_NAME = "test222ModifyUserJackPasswordBadContainer"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1275,7 +1180,7 @@ public void test222ModifyUserJackPasswordBadContainer() throws Exception { ObjectDelta objectDelta = prismContext.deltaFactory().object() .createModificationReplaceContainer(UserType.class, USER_JACK_OID, - ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD), + ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD), passwordType); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); @@ -1303,7 +1208,7 @@ public void test222ModifyUserJackPasswordBadContainer() throws Exception { */ @Test public void test224ModifyUserJackPasswordBadJack() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test224ModifyUserJackPasswordBadJack", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_JACK_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1313,7 +1218,7 @@ public void test224ModifyUserJackPasswordBadJack() throws Exception { */ @Test public void test226ModifyUserJackPasswordBadSparrow() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test226ModifyUserJackPasswordBadSparrow", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_SPARROW_CLEAR, USER_PASSWORD_VALID_1, USER_PASSWORD_AA_CLEAR); } @@ -1323,7 +1228,7 @@ public void test226ModifyUserJackPasswordBadSparrow() throws Exception { */ @Test public void test230ModifyUserJackPasswordGoodAgain() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test230ModifyUserJackPasswordGoodAgain", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1332,7 +1237,7 @@ public void test230ModifyUserJackPasswordGoodAgain() throws Exception { */ @Test public void test235ModifyUserJackPasswordGoodSameAsCurrent() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test235ModifyUserJackPasswordGoodSameAsCurrent", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_VALID_2, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1341,7 +1246,7 @@ public void test235ModifyUserJackPasswordGoodSameAsCurrent() throws Exception { */ @Test public void test236ModifyUserJackPasswordGoodInHistory() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test236ModifyUserJackPasswordGoodInHistory", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1350,7 +1255,7 @@ public void test236ModifyUserJackPasswordGoodInHistory() throws Exception { */ @Test public void test237ModifyUserJackPasswordBadInHistory() throws Exception { - doTestModifyUserJackPasswordFailureWithHistory("test237ModifyUserJackPasswordBadInHistory", + doTestModifyUserJackPasswordFailureWithHistory( USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_2, USER_PASSWORD_AA_CLEAR, USER_PASSWORD_VALID_1); } @@ -1361,7 +1266,7 @@ public void test237ModifyUserJackPasswordBadInHistory() throws Exception { */ @Test public void test240ModifyUserJackPasswordGoodAgainOverHistory() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test240ModifyUserJackPasswordGoodAgainOverHistory", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_3, USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_2); } @@ -1372,7 +1277,7 @@ public void test240ModifyUserJackPasswordGoodAgainOverHistory() throws Exception */ @Test public void test241ModifyUserJackPasswordGoodAgainOverHistoryAgain() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test241ModifyUserJackPasswordGoodAgainOverHistoryAgain", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_4, USER_PASSWORD_VALID_2, USER_PASSWORD_VALID_3); } @@ -1382,16 +1287,16 @@ public void test241ModifyUserJackPasswordGoodAgainOverHistoryAgain() throws Exce */ @Test public void test248ModifyUserJackPasswordGoodReuse() throws Exception { - doTestModifyUserJackPasswordSuccessWithHistory("test248ModifyUserJackPasswordGoodReuse", + doTestModifyUserJackPasswordSuccessWithHistory( USER_PASSWORD_VALID_1, USER_PASSWORD_VALID_3, USER_PASSWORD_VALID_4); } - private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NAME, - String newPassword, String... expectedPasswordHistory) throws Exception { - displayTestTitle(TEST_NAME); + private void doTestModifyUserJackPasswordSuccessWithHistory( + String newPassword, String... expectedPasswordHistory) + throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1410,16 +1315,16 @@ private void doTestModifyUserJackPasswordSuccessWithHistory(final String TEST_NA displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, newPassword); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_YELLOW_NAME, USER_JACK_USERNAME, newPassword); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_YELLOW_NAME, USER_JACK_USERNAME, newPassword); assertSingleUserPasswordNotification(USER_JACK_USERNAME, newPassword); } - private void doTestModifyUserJackPasswordFailureWithHistory(final String TEST_NAME, - String newPassword, String oldPassword, String... expectedPasswordHistory) throws Exception { - displayTestTitle(TEST_NAME); + private void doTestModifyUserJackPasswordFailureWithHistory( + String newPassword, String oldPassword, String... expectedPasswordHistory) + throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1471,11 +1376,8 @@ private void assertJackPasswordsWithHistory(String expectedCurrentPassword, Stri */ @Test public void test300TwoParentOrgRefs() throws Exception { - final String TEST_NAME = "test300TwoParentOrgRefs"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1534,11 +1436,8 @@ public void test300TwoParentOrgRefs() throws Exception { */ @Test public void test310PreparePasswordStrengthTests() throws Exception { - final String TEST_NAME = "test310PreparePasswordStrengthTests"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1547,12 +1446,12 @@ public void test310PreparePasswordStrengthTests() throws Exception { unassignOrg(USER_JACK_OID, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER, task, result); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_RED_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1578,8 +1477,8 @@ public void test310PreparePasswordStrengthTests() throws Exception { if (isPasswordEncryption()) { assertAccountPasswordNotifications(2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_1); } else { assertNoAccountPasswordNotifications(); @@ -1589,20 +1488,17 @@ public void test310PreparePasswordStrengthTests() throws Exception { @Test public void test312ChangeUserPassword() throws Exception { - final String TEST_NAME = "test312ChangeUserPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1631,13 +1527,13 @@ public void test312ChangeUserPassword() throws Exception { if (isPasswordEncryption()) { assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + // not BLUE, it already has a password } else { assertAccountPasswordNotifications(3); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_2); } assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_2); } @@ -1651,11 +1547,8 @@ public void test312ChangeUserPassword() throws Exception { */ @Test public void test314RemovePasswordFail() throws Exception { - final String TEST_NAME = "test314RemovePasswordFail"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1663,7 +1556,7 @@ public void test314RemovePasswordFail() throws Exception { try { // WHEN+THEN - displayWhen(TEST_NAME); + when(); try { modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); fail("unexpected success"); @@ -1679,7 +1572,7 @@ public void test314RemovePasswordFail() throws Exception { private void setPasswordMinOccurs(Integer value, Task task, OperationResult result) throws CommonException { ObjectDelta delta = prismContext.deltaFor(SecurityPolicyType.class) .item(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_MIN_OCCURS) - .replace(value) + .replace(value) .asObjectDeltaCast(getSecurityPolicyOid()); executeChanges(delta, null, task, result); } @@ -1689,20 +1582,17 @@ private void setPasswordMinOccurs(Integer value, Task task, OperationResult resu */ @Test public void test315RemovePassword() throws Exception { - final String TEST_NAME = "test315RemovePassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result /*, no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1737,20 +1627,17 @@ public void test315RemovePassword() throws Exception { */ @Test public void test316UserRecompute() throws Exception { - final String TEST_NAME = "test316UserRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1788,40 +1675,37 @@ public void test316UserRecompute() throws Exception { */ @Test public void test318ChangeUserPassword() throws Exception { - final String TEST_NAME = "test318ChangeUserPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_3, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = assertUserAfter(USER_JACK_OID) - .assertPassword(USER_PASSWORD_VALID_3, getPasswordStorageType()) - .assertLinks(4) - .getObject(); + .assertPassword(USER_PASSWORD_VALID_3, getPasswordStorageType()) + .assertLinks(4) + .getObject(); // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_3) - // Admin password reset, no runAs - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_3) + // Admin password reset, no runAs + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_3) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_3) + // and RED resource has no runAs capability + .assertLastModifier(null); // password mapping is weak assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_FULL_NAME, true); @@ -1833,27 +1717,24 @@ public void test318ChangeUserPassword() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_3); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_3); } @Test public void test320ChangeEmployeeNumber() throws Exception { - final String TEST_NAME = "test320ChangeEmployeeNumber"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result, "emp0000"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1874,20 +1755,17 @@ public void test320ChangeEmployeeNumber() throws Exception { @Test public void test330RemoveEmployeeNumber() throws Exception { - final String TEST_NAME = "test330RemoveEmployeeNumber"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_EMPLOYEE_NUMBER, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1913,17 +1791,14 @@ public void test330RemoveEmployeeNumber() throws Exception { */ @Test public void test340ModifyUserMonkeyPasswordAA() throws Exception { - final String TEST_NAME = "test340ModifyUserMonkeyPasswordAA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -1934,7 +1809,7 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1950,20 +1825,17 @@ public void test340ModifyUserMonkeyPasswordAA() throws Exception { */ @Test public void test341RecomputeMonkey() throws Exception { - final String TEST_NAME = "test341RecomputeMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -1979,20 +1851,17 @@ public void test341RecomputeMonkey() throws Exception { */ @Test public void test342ReconcileMonkey() throws Exception { - final String TEST_NAME = "test342ReconcileMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2008,11 +1877,8 @@ public void test342ReconcileMonkey() throws Exception { */ @Test public void test343ModifyUserMonkeyDescription() throws Exception { - final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2022,11 +1888,11 @@ public void test343ModifyUserMonkeyDescription() throws Exception { assertDummyAccount(null, USER_THREE_HEADED_MONKEY_NAME); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2045,21 +1911,18 @@ public void test343ModifyUserMonkeyDescription() throws Exception { */ @Test public void test344ModifyUserMonkeyLocality() throws Exception { - final String TEST_NAME = "test343ModifyUserMonkeyDescription"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Monkey Island")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2080,21 +1943,18 @@ public void test344ModifyUserMonkeyLocality() throws Exception { */ @Test public void test345AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2111,21 +1971,18 @@ public void test345AssignMonkeyAccountBlue() throws Exception { */ @Test public void test346UnassignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test346UnassignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2145,21 +2002,18 @@ public void test346UnassignMonkeyAccountBlue() throws Exception { */ @Test public void test347AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test347AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2174,21 +2028,18 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Test public void test348UnassignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test348UnassignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2209,20 +2060,17 @@ public void test348UnassignMonkeyAccountYellow() throws Exception { */ @Test public void test349AssignMonkeyPirate() throws Exception { - final String TEST_NAME = "test349AssignMonkeyPirate"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2245,20 +2093,17 @@ public void test349AssignMonkeyPirate() throws Exception { */ @Test public void test350DisableMonkey() throws Exception { - final String TEST_NAME = "test350DisableMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2281,20 +2126,17 @@ public void test350DisableMonkey() throws Exception { */ @Test public void test351EnableMonkey() throws Exception { - final String TEST_NAME = "test351EnableMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2317,20 +2159,17 @@ public void test351EnableMonkey() throws Exception { */ @Test public void test352UnassignMonkeyPirate() throws Exception { - final String TEST_NAME = "test352UnassignMonkeyPirate"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_THREE_HEADED_MONKEY_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2352,20 +2191,17 @@ public void test352UnassignMonkeyPirate() throws Exception { */ @Test public void test354ModifyUserMonkeyPasswordValid1() throws Exception { - final String TEST_NAME = "test354ModifyUserMonkeyPasswordValid1"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2381,20 +2217,17 @@ public void test354ModifyUserMonkeyPasswordValid1() throws Exception { */ @Test public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { - final String TEST_NAME = "test355ModifyUserMonkeyDescriptionAgain"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_DESCRIPTION, task, result, "Look behind you! A three-headed MONKEY!"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -2409,29 +2242,26 @@ public void test355ModifyUserMonkeyDescriptionAgain() throws Exception { */ @Test public void test400AddUserRappWithAssignment() throws Exception { - final String TEST_NAME = "test400AddUserRappWithAssignment"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_RAPP_FILE); AssignmentType assignmentType = createConstructionAssignment(RESOURCE_DUMMY_OID, null, null); UserType userBeforeType = userBefore.asObjectable(); userBeforeType - .fullName(createPolyStringType(USER_RAPP_FULLNAME)) - .emailAddress(USER_RAPP_EMAIL); // Make sure Rapp has e-mail address otherwise the notifications will not be sent to transport + .fullName(createPolyStringType(USER_RAPP_FULLNAME)) + .emailAddress(USER_RAPP_EMAIL); // Make sure Rapp has e-mail address otherwise the notifications will not be sent to transport userBeforeType.getAssignment().add(assignmentType); setPassword(userBefore, USER_PASSWORD_VALID_1); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2460,20 +2290,17 @@ public void test400AddUserRappWithAssignment() throws Exception { */ @Test public void test401UserRappRecompute() throws Exception { - final String TEST_NAME = "test401UserRappRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2502,11 +2329,8 @@ public void test401UserRappRecompute() throws Exception { */ @Test public void test402AssignRappDummyRed() throws Exception { - final String TEST_NAME = "test402AssignRappDummyRed"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2514,11 +2338,11 @@ public void test402AssignRappDummyRed() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_RED_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2567,11 +2391,8 @@ public void test402AssignRappDummyRed() throws Exception { */ @Test public void test403UserRappRecompute() throws Exception { - final String TEST_NAME = "test403UserRappRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2579,11 +2400,11 @@ public void test403UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2630,11 +2451,8 @@ public void test403UserRappRecompute() throws Exception { */ @Test public void test404InitializeRappDummyRed() throws Exception { - final String TEST_NAME = "test404InitializeRappDummyRed"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2645,11 +2463,11 @@ public void test404InitializeRappDummyRed() throws Exception { ObjectDelta shadowDelta = createAccountInitializationDelta(accountRedOid, USER_PASSWORD_VALID_1); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2696,11 +2514,8 @@ public void test404InitializeRappDummyRed() throws Exception { */ @Test public void test405UserRappRecompute() throws Exception { - final String TEST_NAME = "test405UserRappRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2708,11 +2523,11 @@ public void test405UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2760,11 +2575,8 @@ public void test405UserRappRecompute() throws Exception { */ @Test public void test410AssignRappDummyLifecycle() throws Exception { - final String TEST_NAME = "test410AssignRappDummyLifecycle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2772,11 +2584,11 @@ public void test410AssignRappDummyLifecycle() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_RAPP_OID, RESOURCE_DUMMY_LIFECYCLE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2795,7 +2607,6 @@ public void test410AssignRappDummyLifecycle() throws Exception { assertShadowLifecycle(accountShadowLifecycle, false); // assertShadowLifecycle(accountShadowLifecycle, SchemaConstants.LIFECYCLE_ACTIVE); - assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true); assertDummyPassword(RESOURCE_DUMMY_RED_NAME, USER_RAPP_USERNAME, USER_PASSWORD_VALID_1); assertUserPassword(userAfter, USER_PASSWORD_VALID_1); @@ -2808,11 +2619,8 @@ public void test410AssignRappDummyLifecycle() throws Exception { @Test public void test412InitializeRappDummyLifecycle() throws Exception { - final String TEST_NAME = "test412InitializeRappDummyLifecycle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2828,11 +2636,11 @@ public void test412InitializeRappDummyLifecycle() throws Exception { shadowDelta.addModificationReplaceProperty(ObjectType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2886,11 +2694,8 @@ public void test412InitializeRappDummyLifecycle() throws Exception { @Test public void test414UserRappRecompute() throws Exception { - final String TEST_NAME = "test414UserRappRecompute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2898,11 +2703,11 @@ public void test414UserRappRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_RAPP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -2957,11 +2762,8 @@ public void test414UserRappRecompute() throws Exception { @Test public void test416UserRappSubtypeWreck() throws Exception { - final String TEST_NAME = "test416UserRappSubtypeWreck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -2969,11 +2771,11 @@ public void test416UserRappSubtypeWreck() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_RAPP_OID, UserType.F_SUBTYPE, task, result, "WRECK"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_RAPP_OID); @@ -3034,11 +2836,8 @@ public void test416UserRappSubtypeWreck() throws Exception { */ @Test public void test420AddUserDrakeWithAssignment() throws Exception { - final String TEST_NAME = "test420AddUserDrakeWithAssignment"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_DRAKE_FILE); @@ -3048,16 +2847,16 @@ public void test420AddUserDrakeWithAssignment() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); String accountOid = assertUserAfter(USER_DRAKE_OID) .singleLink() - .getOid(); + .getOid(); assertRepoShadow(accountOid) // Lifecycle state is always proposed, even for encrypted passwords. @@ -3076,11 +2875,8 @@ public void test420AddUserDrakeWithAssignment() throws Exception { */ @Test public void test500JackAssignResourceSouvenir() throws Exception { - final String TEST_NAME = "test500JackAssignResourceSouvenir"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3100,11 +2896,11 @@ public void test500JackAssignResourceSouvenir() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3139,22 +2935,19 @@ public void test500JackAssignResourceSouvenir() throws Exception { */ @Test public void test502JackInitializeAccountSouvenir() throws Exception { - final String TEST_NAME = "test502JackInitializeAccountSouvenir"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackSouvenirOid, PASSWORD_ALLIGATOR); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3185,11 +2978,8 @@ public void test502JackInitializeAccountSouvenir() throws Exception { */ @Test public void test510JackAssignResourceMaverick() throws Exception { - final String TEST_NAME = "test510JackAssignResourceMaverick"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3201,11 +2991,11 @@ public void test510JackAssignResourceMaverick() throws Exception { assertUserPassword(userBefore, USER_PASSWORD_VALID_3); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3231,22 +3021,19 @@ public void test510JackAssignResourceMaverick() throws Exception { */ @Test public void test512JackInitializeAccountMaverickAlligator() throws Exception { - final String TEST_NAME = "test512JackInitializeAccountMaverick"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_ALLIGATOR); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3268,22 +3055,19 @@ public void test512JackInitializeAccountMaverickAlligator() throws Exception { */ @Test public void test514JackInitializeAccountMaverickCrododile() throws Exception { - final String TEST_NAME = "test514JackInitializeAccountMaverickCrododile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); ObjectDelta shadowDelta = createAccountInitializationDelta(accountJackMaverickOid, PASSWORD_CROCODILE); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(shadowDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3309,20 +3093,17 @@ public void test514JackInitializeAccountMaverickCrododile() throws Exception { */ @Test public void test516JackChangePasswordResourceMaverickAlligator() throws Exception { - final String TEST_NAME = "test516JackChangePasswordResourceMaverickAlligator"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3340,20 +3121,17 @@ public void test516JackChangePasswordResourceMaverickAlligator() throws Exceptio */ @Test public void test518JackChangePasswordResourceMaverickGiantLizard() throws Exception { - final String TEST_NAME = "test518JackChangePasswordResourceMaverickGiantLizard"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountChangePassword(accountJackMaverickOid, PASSWORD_GIANT_LIZARD, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3370,11 +3148,8 @@ public void test518JackChangePasswordResourceMaverickGiantLizard() throws Except */ @Test public void test530JackUnassignResourceSouvenir() throws Exception { - final String TEST_NAME = "test530JackUnassignResourceSouvenir"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3385,11 +3160,11 @@ public void test530JackUnassignResourceSouvenir() throws Exception { assertLinks(userBefore, 6); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_SOUVENIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3408,11 +3183,8 @@ public void test530JackUnassignResourceSouvenir() throws Exception { */ @Test public void test532JackChangePasswordResourceBlueAlligator() throws Exception { - final String TEST_NAME = "test532JackChangePasswordResourceBlueAlligator"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3423,11 +3195,11 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { accountJackBlueOid = assertAccount(userBefore, RESOURCE_DUMMY_BLUE_OID); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountChangePassword(accountJackBlueOid, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3448,20 +3220,17 @@ public void test532JackChangePasswordResourceBlueAlligator() throws Exception { */ @Test public void test535ModifyUserJackPasswordAlligator() throws Exception { - final String TEST_NAME = "test535ModifyUserJackPasswordAlligator"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, PASSWORD_ALLIGATOR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3479,11 +3248,8 @@ public void test535ModifyUserJackPasswordAlligator() throws Exception { */ @Test public void test539JackUnassignResourceMaverick() throws Exception { - final String TEST_NAME = "test539JackUnassignResourceMaverick"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3494,11 +3260,11 @@ public void test539JackUnassignResourceMaverick() throws Exception { assertLinks(userBefore, 5); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_MAVERICK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3515,7 +3281,7 @@ public void test539JackUnassignResourceMaverick() throws Exception { */ @Test public void test550JackManyPasswordChangesClear() throws Exception { - testJackManyPasswordChanges("test550JackManyPasswordChangesClear", "TesT550x", null); + testJackManyPasswordChanges("TesT550x", null); } /** @@ -3523,14 +3289,13 @@ public void test550JackManyPasswordChangesClear() throws Exception { */ @Test public void test552JackManyPasswordChangesEncrypted() throws Exception { - testJackManyPasswordChanges("test552JackManyPasswordChangesEncrypted", "TesT552x", CredentialsStorageTypeType.ENCRYPTION); + testJackManyPasswordChanges("TesT552x", CredentialsStorageTypeType.ENCRYPTION); } /** * MID-4507 */ - public void testJackManyPasswordChanges(final String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType) throws Exception { - displayTestTitle(TEST_NAME); + public void testJackManyPasswordChanges(String passwordPrefix, CredentialsStorageTypeType storageType) throws Exception { // GIVEN prepareTest(); @@ -3542,13 +3307,14 @@ public void testJackManyPasswordChanges(final String TEST_NAME, String passwordP assertLinks(userBefore, 4); for (int i = 1; i < 10; i++) { - testJackManyPasswordChangesAttempt(TEST_NAME, passwordPrefix, storageType, i); + testJackManyPasswordChangesAttempt(passwordPrefix, storageType, i); } - } - private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwordPrefix, CredentialsStorageTypeType storageType, int i) throws Exception { - Task task = createTask(TEST_NAME + "-" + i); + private void testJackManyPasswordChangesAttempt( + String passwordPrefix, CredentialsStorageTypeType storageType, int i) + throws Exception { + Task task = createTask("testJackManyPasswordChangesAttempt-" + i); OperationResult result = task.getResult(); String newPassword = passwordPrefix + i; @@ -3559,11 +3325,11 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor } // WHEN - displayWhen(TEST_NAME + "-" + i); - modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result, userPasswordPs); + when("iteration-" + i); + modifyUserReplace(USER_JACK_OID, PASSWORD_VALUE_PATH, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME + "-" + i); + then("iteration-" + i); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3578,16 +3344,13 @@ private void testJackManyPasswordChangesAttempt(String TEST_NAME, String passwor /** * Jack changing his own password. He does it as an admin * and there is no old password specified. RunAs should NOT be used. - * + *

* This also sets predictable password for next test. - * + *

* MID-4661 */ @Test public void test560ChangeJackPasswordSuperuser() throws Exception { - final String TEST_NAME = "test560ChangeJackPasswordSuperuser"; - displayTestTitle(TEST_NAME); - // GIVEN prepareTest(); @@ -3595,24 +3358,24 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertLastModifier(null); + .assertLastModifier(null); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_4, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3623,16 +3386,16 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_4) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_4) + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_4) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_4) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3640,37 +3403,34 @@ public void test560ChangeJackPasswordSuperuser() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_4); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_4); } /** * Self-service password change. User's own identity should be used * to change password on resource that have runAs capability. - * + *

* MID-4661 */ @Test public void test562ChangeJackPasswordSelfService() throws Exception { - final String TEST_NAME = "test562ChangeJackPasswordSelfService"; - displayTestTitle(TEST_NAME); - // GIVEN prepareTest(); // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_4) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_4) + .assertLastModifier(null); login(USER_JACK_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -3678,11 +3438,11 @@ public void test562ChangeJackPasswordSelfService() throws Exception { USER_PASSWORD_VALID_4, USER_PASSWORD_VALID_5); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3693,16 +3453,16 @@ public void test562ChangeJackPasswordSelfService() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_5) - .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); + .assertPassword(USER_PASSWORD_VALID_5) + .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_5) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_5) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3710,8 +3470,8 @@ public void test562ChangeJackPasswordSelfService() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_5); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_5); } @@ -3720,30 +3480,26 @@ public void test562ChangeJackPasswordSelfService() throws Exception { * Old password is (strangely) specified. * But as this is not user changing its own password then RunAs * should NOT be used. - * + *

* MID-4661 */ @Test public void test564ChangeJackPasswordAdmin() throws Exception { - final String TEST_NAME = "test564ChangeJackPasswordAdmin"; - displayTestTitle(TEST_NAME); - // GIVEN - prepareTest(); // preconditions assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + .displayWithProjections() + .assertLinks(4); assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_5) - .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); + .assertPassword(USER_PASSWORD_VALID_5) + .assertLastModifier(ACCOUNT_JACK_DUMMY_USERNAME); login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME, getSecurityContextPrincipal()); + Task task = createTask(getSecurityContextPrincipal()); task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); OperationResult result = task.getResult(); @@ -3751,11 +3507,11 @@ public void test564ChangeJackPasswordAdmin() throws Exception { USER_PASSWORD_VALID_5, USER_PASSWORD_VALID_6); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -3766,16 +3522,16 @@ public void test564ChangeJackPasswordAdmin() throws Exception { // default password mapping is normal assertDummyAccountByUsername(null, ACCOUNT_JACK_DUMMY_USERNAME) - .assertPassword(USER_PASSWORD_VALID_6) - .assertLastModifier(null); + .assertPassword(USER_PASSWORD_VALID_6) + .assertLastModifier(null); // RED password mapping is strong assertDummyAccountByUsername(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertEnabled() - .assertPassword(USER_PASSWORD_VALID_6) - // and RED resource has no runAs capability - .assertLastModifier(null); + .assertFullName(USER_JACK_FULL_NAME) + .assertEnabled() + .assertPassword(USER_PASSWORD_VALID_6) + // and RED resource has no runAs capability + .assertLastModifier(null); // BLUE password mapping is weak, we do not really care about password change here // we do not really care about ugly resource either @@ -3783,13 +3539,11 @@ public void test564ChangeJackPasswordAdmin() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); - // not BLUE, it already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME, USER_PASSWORD_VALID_6); + // not BLUE, it already has a password assertSingleUserPasswordNotification(USER_JACK_USERNAME, USER_PASSWORD_VALID_6); } - - protected ObjectDelta createAccountInitializationDelta(String accountOid, String newAccountPassword) { ObjectDelta shadowDelta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountOid); @@ -3850,7 +3604,7 @@ protected void assertShadowLifecycle(PrismObject shadow, String expe if (expectedLifecycle == null) { String actualLifecycle = shadow.asObjectable().getLifecycleState(); if (actualLifecycle != null && !SchemaConstants.LIFECYCLE_ACTIVE.equals(actualLifecycle)) { - fail("Expected default lifecycle for "+shadow+", but was "+actualLifecycle); + fail("Expected default lifecycle for " + shadow + ", but was " + actualLifecycle); } } else { PrismAsserts.assertPropertyValue(shadow, ObjectType.F_LIFECYCLE_STATE, expectedLifecycle); @@ -3872,11 +3626,8 @@ private void assertShadowPasswordMetadata(PrismObject shadow, */ @Test public void test900ModifyUserElainePassword() throws Exception { - final String TEST_NAME = "test900ModifyUserElainePassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3902,17 +3653,14 @@ public void test900ModifyUserElainePassword() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(3); assertHasAccountPasswordNotification(null, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); + assertHasAccountPasswordNotification(RESOURCE_DUMMY_BLUE_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_1); } @Test public void test902SetPasswordMinAge() throws Exception { - final String TEST_NAME = "test900SetPasswordMinAge"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3940,11 +3688,8 @@ public void test902SetPasswordMinAge() throws Exception { */ @Test public void test904ModifyUserElainePasswordAgain() throws Exception { - final String TEST_NAME = "test904ModifyUserElainePasswordAgain"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -3974,11 +3719,8 @@ public void test904ModifyUserElainePasswordAgain() throws Exception { @Test public void test906ModifyUserElainePasswordLater() throws Exception { - final String TEST_NAME = "test906ModifyUserElainePasswordLater"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4002,8 +3744,8 @@ public void test906ModifyUserElainePasswordLater() throws Exception { displayAccountPasswordNotifications(); assertAccountPasswordNotifications(2); assertHasAccountPasswordNotification(null, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); - assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); - // BLUE resource already has a password + assertHasAccountPasswordNotification(RESOURCE_DUMMY_RED_NAME, USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); + // BLUE resource already has a password assertSingleUserPasswordNotification(USER_ELAINE_USERNAME, USER_PASSWORD_VALID_3); } @@ -4013,11 +3755,8 @@ public void test906ModifyUserElainePasswordLater() throws Exception { */ @Test public void test910AddUserWithNoPasswordFail() throws Exception { - final String TEST_NAME = "test910AddUserWithNoPasswordFail"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4025,7 +3764,7 @@ public void test910AddUserWithNoPasswordFail() throws Exception { try { // WHEN+THEN - displayWhen(TEST_NAME); + when(); try { UserType user = new UserType(prismContext).name("passwordless"); addObject(user.asPrismObject(), task, result); @@ -4040,15 +3779,12 @@ public void test910AddUserWithNoPasswordFail() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test920AddCredentials() throws Exception { - final String TEST_NAME = "test920AddCredentials"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4065,7 +3801,7 @@ public void test920AddCredentials() throws Exception { value.setClearValue(PASSWORD_HELLO_WORLD); CredentialsType credentials = new CredentialsType(prismContext) .beginPassword() - .value(value) + .value(value) .end(); ObjectDelta objectDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_CREDENTIALS).add(credentials) @@ -4081,15 +3817,12 @@ public void test920AddCredentials() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test922ReplaceCredentials() throws Exception { - final String TEST_NAME = "test922ReplaceCredentials"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4106,7 +3839,7 @@ public void test922ReplaceCredentials() throws Exception { value.setClearValue(PASSWORD_HELLO_WORLD); CredentialsType credentials = new CredentialsType(prismContext) .beginPassword() - .value(value) + .value(value) .end(); ObjectDelta objectDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_CREDENTIALS).replace(credentials) @@ -4122,15 +3855,12 @@ public void test922ReplaceCredentials() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test924AddPassword() throws Exception { - final String TEST_NAME = "test924AddPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4160,15 +3890,12 @@ public void test924AddPassword() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test926ReplacePassword() throws Exception { - final String TEST_NAME = "test926ReplacePassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4198,15 +3925,12 @@ public void test926ReplacePassword() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test928AddPasswordValue() throws Exception { - final String TEST_NAME = "test928AddPasswordValue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4235,15 +3959,12 @@ public void test928AddPasswordValue() throws Exception { } /** - * MID-4593 + * MID-4593 */ @Test public void test929ReplacePasswordValue() throws Exception { - final String TEST_NAME = "test929ReplacePasswordValue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -4279,16 +4000,13 @@ public void test929ReplacePasswordValue() throws Exception { */ @Test public void test950RemoveGlobalPasswordPolicy() throws Exception { - final String TEST_NAME = "test950RemoveGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); applyPasswordPolicy(null, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), @@ -4301,7 +4019,7 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4318,21 +4036,18 @@ public void test950RemoveGlobalPasswordPolicy() throws Exception { */ @Test public void test952SetupOrgPolicy() throws Exception { - final String TEST_NAME = "test952SetupOrgPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); PrismObject securityPolicy = prismContext.createObject(SecurityPolicyType.class); securityPolicy.asObjectable() - .name("Ministry security policy") - .beginCredentials() + .name("Ministry security policy") + .beginCredentials() .beginPassword() - .valuePolicyRef(PASSWORD_POLICY_GLOBAL_OID, ValuePolicyType.COMPLEX_TYPE) - .historyLength(ORG_MINISTRY_OF_OFFENSE_PASSWORD_HISTORY_LENGTH); + .valuePolicyRef(PASSWORD_POLICY_GLOBAL_OID, ValuePolicyType.COMPLEX_TYPE) + .historyLength(ORG_MINISTRY_OF_OFFENSE_PASSWORD_HISTORY_LENGTH); ministrySecurityPolicyOid = addObject(securityPolicy, task, result); PrismReferenceValue securityPolicyRef = itemFactory().createReferenceValue(); @@ -4341,11 +4056,11 @@ public void test952SetupOrgPolicy() throws Exception { OrgType.F_SECURITY_POLICY_REF, task, result, securityPolicyRef); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_THREE_HEADED_MONKEY_OID, ORG_MINISTRY_OF_OFFENSE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject ministryPolicyAfter = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID); @@ -4367,17 +4082,14 @@ public void test952SetupOrgPolicy() throws Exception { */ @Test public void test954ModifyUserMonkeyPasswordAA() throws Exception { - final String TEST_NAME = "test954ModifyUserMonkeyPasswordAA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_AA_CLEAR, task, result); @@ -4388,7 +4100,7 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4403,21 +4115,18 @@ public void test954ModifyUserMonkeyPasswordAA() throws Exception { */ @Test public void test956ModifyUserJackPasswordAA() throws Exception { - final String TEST_NAME = "test956ModifyUserJackPasswordAA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_AA_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -4433,20 +4142,17 @@ public void test956ModifyUserJackPasswordAA() throws Exception { */ @Test public void test961RecomputeMonkey() throws Exception { - final String TEST_NAME = "test961RecomputeMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4462,20 +4168,17 @@ public void test961RecomputeMonkey() throws Exception { */ @Test public void test962ReconcileMonkey() throws Exception { - final String TEST_NAME = "test962ReconcileMonkey"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_THREE_HEADED_MONKEY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4491,21 +4194,18 @@ public void test962ReconcileMonkey() throws Exception { */ @Test public void test964ModifyUserMonkeyLocality() throws Exception { - final String TEST_NAME = "test964ModifyUserMonkeyLocality"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_THREE_HEADED_MONKEY_OID, UserType.F_LOCALITY, task, result, createPolyString("Scabb Island")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4526,21 +4226,18 @@ public void test964ModifyUserMonkeyLocality() throws Exception { */ @Test public void test965AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test965AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4561,21 +4258,18 @@ public void test965AssignMonkeyAccountBlue() throws Exception { */ @Test public void test966AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -4595,32 +4289,29 @@ public void test966AssignMonkeyAccountYellow() throws Exception { */ @Test public void test970ReapplyGlobalPasswordPolicy() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // preconditions - assertUserBefore(USER_JACK_OID) - .displayWithProjections() - .assertLinks(4); + assertUserBefore(USER_JACK_OID) + .displayWithProjections() + .assertLinks(4); - // Make sure that no global password policy is applied by setting some insane passwords + // Make sure that no global password policy is applied by setting some insane passwords modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_LLL_CLEAR); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_A_CLEAR); // WHEN - displayWhen(TEST_NAME); + when(); applyPasswordPolicy(PASSWORD_POLICY_GLOBAL_OID, getSecurityPolicyOid(), task, result); modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), ItemPath.create(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, GLOBAL_POLICY_NEW_PASSWORD_HISTORY_LENGTH); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject securityPolicyAfter = getObject(SecurityPolicyType.class, getSecurityPolicyOid()); @@ -4639,16 +4330,13 @@ public void test970ReapplyGlobalPasswordPolicy() throws Exception { */ @Test public void test972ChangePasswordJack() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_2); @@ -4669,7 +4357,7 @@ public void test972ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_VALID_1); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @@ -4682,16 +4370,13 @@ public void test972ChangePasswordJack() throws Exception { */ @Test public void test974ChangePasswordJack() throws Exception { - final String TEST_NAME = "test970ReapplyGlobalPasswordPolicy"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_1); modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); @@ -4712,18 +4397,16 @@ public void test974ChangePasswordJack() throws Exception { modifyUserChangePassword(USER_THREE_HEADED_MONKEY_OID, USER_PASSWORD_VALID_2); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - } - private void modifyUserChangePasswordPolicyViolation(String userOid, String newPassword) throws CommonException { Task task = createTask("modifyUserChangePasswordPolicyViolation"); OperationResult result = task.getResult(); try { modifyUserChangePassword(userOid, newPassword, task, result); - fail("Change of password '"+newPassword+"' succeeded for user "+userOid+", expected failure"); + fail("Change of password '" + newPassword + "' succeeded for user " + userOid + ", expected failure"); } catch (PolicyViolationException e) { assertFailure(result); } @@ -4741,7 +4424,7 @@ protected PrismObject getBlueShadow(PrismObject userAfter) Collection> options = getOperationOptionsBuilder() .item(SchemaConstants.PATH_PASSWORD_VALUE).retrieve() .build(); - PrismObject shadow = modelService.getObject(ShadowType.class, accountBlueOid, options , task, result); + PrismObject shadow = modelService.getObject(ShadowType.class, accountBlueOid, options, task, result); result.computeStatus(); TestUtil.assertSuccess("getObject(Account) result not success", result); display("Blue shadow", shadow); @@ -4757,15 +4440,15 @@ protected void assertCachedResourcePassword(PrismObject shadow, Stri if (expectedPassword == null && credentials == null) { return; } - assertNotNull("Missing credentendials in repo shadow "+shadow, credentials); + assertNotNull("Missing credentendials in repo shadow " + shadow, credentials); PasswordType passwordType = credentials.getPassword(); if (expectedPassword == null && passwordType == null) { return; } - assertNotNull("Missing password credential in repo shadow "+shadow, passwordType); + assertNotNull("Missing password credential in repo shadow " + shadow, passwordType); ProtectedStringType protectedStringType = passwordType.getValue(); - assertNotNull("No password value in repo shadow "+shadow, protectedStringType); - assertProtectedString("Wrong password value in repo shadow "+shadow, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); + assertNotNull("No password value in repo shadow " + shadow, protectedStringType); + assertProtectedString("Wrong password value in repo shadow " + shadow, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); } private void assertPasswordCreateMetadata(PrismObject user) { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java index d0f17aeb03b..bfaf30dd3c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefault.java @@ -15,8 +15,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -54,11 +52,8 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc */ @Test public void test202ReconcileUserJack() throws Exception { - final String TEST_NAME = "test202ReconcileUserJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -66,11 +61,11 @@ public void test202ReconcileUserJack() throws Exception { assertLinks(userBefore, 4); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java index 3a2aa70bbdb..568bc8c4301 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/password/TestPasswordDefaultHashing.java @@ -17,7 +17,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -66,11 +65,8 @@ protected void assertShadowLifecycle(PrismObject shadow, boolean foc */ @Test public void test202ReconcileUserJack() throws Exception { - final String TEST_NAME = "test202ReconcileUserJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(AbstractPasswordTest.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -126,7 +122,6 @@ protected void assert31xBluePasswordAfterPasswordChange(PrismObject us protected void assertAccountActivationNotification(String dummyResourceName, String username) { checkDummyTransportMessages(NOTIFIER_ACCOUNT_ACTIVATION_NAME, 1); String body = getDummyTransportMessageBody(NOTIFIER_ACCOUNT_ACTIVATION_NAME, 0); - //String expectedPrefix = getExpectedAccountPasswordNotificationBodyPrefix(dummyResourceName, username); if (!body.contains("activat")) { fail("Activation not mentioned in "+dummyResourceName+" dummy account activation notification message : "+body); } @@ -145,21 +140,18 @@ protected void assertAccountActivationNotification(String dummyResourceName, Str @Test @Override public void test345AssignMonkeyAccountBlue() throws Exception { - final String TEST_NAME = "test345AssignMonkeyAccountBlue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -171,7 +163,7 @@ public void test345AssignMonkeyAccountBlue() throws Exception { assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_THREE_HEADED_MONKEY_NAME); // CLEANUP - displayCleanup(TEST_NAME); + displayCleanup(contextName()); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result); @@ -194,21 +186,18 @@ public void test345AssignMonkeyAccountBlue() throws Exception { @Test @Override public void test347AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test347AssignMonkeyYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); @@ -221,7 +210,7 @@ public void test347AssignMonkeyAccountYellow() throws Exception { assertNoDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_THREE_HEADED_MONKEY_NAME); // CLEANUP - displayCleanup(TEST_NAME); + displayCleanup(contextName()); unassignAccountFromUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); @@ -245,21 +234,18 @@ public void test347AssignMonkeyAccountYellow() throws Exception { @Test @Override public void test966AssignMonkeyAccountYellow() throws Exception { - final String TEST_NAME = "test966AssignMonkeyAccountYellow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_THREE_HEADED_MONKEY_OID, RESOURCE_DUMMY_YELLOW_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_THREE_HEADED_MONKEY_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java index 8b043c8458c..0d55ea714ea 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/AbstractPersonaTest.java @@ -58,18 +58,17 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100AssignRolePersonaAdminToJack() throws Exception { final String TEST_NAME = "test100AssignRolePersonaAdminToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -95,18 +94,17 @@ public void test100AssignRolePersonaAdminToJack() throws Exception { @Test public void test102RecomputeUserJack() throws Exception { final String TEST_NAME = "test102RecomputeUserJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -115,18 +113,17 @@ public void test102RecomputeUserJack() throws Exception { @Test public void test103ReconcileUserJack() throws Exception { final String TEST_NAME = "test103ReconcileUserJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -135,18 +132,17 @@ public void test103ReconcileUserJack() throws Exception { @Test public void test104RecomputeJackAdminPersona() throws Exception { final String TEST_NAME = "test104RecomputeJackAdminPersona"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userJackAdminPersonaOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -155,18 +151,17 @@ public void test104RecomputeJackAdminPersona() throws Exception { @Test public void test105ReconcileJackAdminPersona() throws Exception { final String TEST_NAME = "test105ReconcileJackAdminPersona"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userJackAdminPersonaOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserJack11x(); @@ -192,18 +187,17 @@ private void assertUserJack11x() throws Exception { @Test public void test120ModifyJackGivenName() throws Exception { final String TEST_NAME = "test120ModifyJackGivenName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString(USER_JACK_GIVEN_NAME_NEW)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -230,20 +224,19 @@ public void test120ModifyJackGivenName() throws Exception { @Test public void test140ModifyUserJackPassword() throws Exception { final String TEST_NAME = "test140ModifyUserJackPassword"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -265,10 +258,9 @@ public void test140ModifyUserJackPassword() throws Exception { @Test public void test142ModifyPersonaPassword() throws Exception { final String TEST_NAME = "test142ModifyPersonaPassword"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -277,11 +269,11 @@ public void test142ModifyPersonaPassword() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_3_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -306,10 +298,9 @@ protected void assertPersonaAfterPersonaPasswordChange(PrismObject per @Test public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -318,11 +309,11 @@ public void test145ModifyPersonaPasswordBack() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -347,18 +338,17 @@ public void test145ModifyPersonaPasswordBack() throws Exception { @Test public void test199UnassignRolePersonaAdminFromJack() throws Exception { final String TEST_NAME = "test199UnassignRolePersonaAdminFromJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java index ad89ef9032b..cdeb66a56fe 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/persona/TestPersonaPassword.java @@ -70,10 +70,9 @@ protected void assertPersonaAfterUserPasswordChange(PrismObject person @Override public void test145ModifyPersonaPasswordBack() throws Exception { final String TEST_NAME = "test145ModifyPersonaPasswordBack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -83,7 +82,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); modifyUserChangePassword(personaBefore.getOid(), USER_PASSWORD_2_CLEAR, task, result); @@ -94,7 +93,7 @@ public void test145ModifyPersonaPasswordBack() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java index 20a68ae9f19..72cbcf99b77 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAssignmentValidity.java @@ -49,9 +49,8 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100JackAssignRolePirateValidTo() throws Exception { final String TEST_NAME = "test100JackAssignRolePirateValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -64,11 +63,11 @@ public void test100JackAssignRolePirateValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -91,19 +90,18 @@ public void test100JackAssignRolePirateValidTo() throws Exception { @Test public void test102Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -123,9 +121,8 @@ public void test102Forward15min() throws Exception { @Test public void test104JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test104JackAssignRolePirateAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -134,11 +131,11 @@ public void test104JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -159,17 +156,16 @@ public void test104JackAssignRolePirateAgain() throws Exception { @Test public void test106JackUnassignRolePirateValid() throws Exception { final String TEST_NAME = "test106JackUnassignRolePirateValid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -198,9 +194,8 @@ public void test109JackUnassignAll() throws Exception { @Test public void test110JackAssignRolePirateValidToRaw() throws Exception { final String TEST_NAME = "test110JackAssignRolePirateValidToRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -213,12 +208,12 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -238,20 +233,19 @@ public void test110JackAssignRolePirateValidToRaw() throws Exception { @Test public void test111RecomputeJack() throws Exception { final String TEST_NAME = "test111RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -272,19 +266,18 @@ public void test111RecomputeJack() throws Exception { @Test public void test112Forward15min() throws Exception { final String TEST_NAME = "test102Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -304,9 +297,8 @@ public void test112Forward15min() throws Exception { @Test public void test114JackAssignRolePirateAgain() throws Exception { final String TEST_NAME = "test114JackAssignRolePirateAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -315,11 +307,11 @@ public void test114JackAssignRolePirateAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -348,9 +340,8 @@ public void test119JackUnassignAll() throws Exception { @Test public void test120JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test120JackAssignRoleSailorValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -363,11 +354,11 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -390,19 +381,18 @@ public void test120JackAssignRoleSailorValidTo() throws Exception { @Test public void test122Forward15min() throws Exception { final String TEST_NAME = "test122Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -422,9 +412,8 @@ public void test122Forward15min() throws Exception { @Test public void test124JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test124JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -433,11 +422,11 @@ public void test124JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -467,9 +456,8 @@ public void test129JackUnassignAll() throws Exception { @Test public void test130JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test130JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -482,12 +470,12 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -507,20 +495,19 @@ public void test130JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test131RecomputeJack() throws Exception { final String TEST_NAME = "test131RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -541,19 +528,18 @@ public void test131RecomputeJack() throws Exception { @Test public void test132Forward15min() throws Exception { final String TEST_NAME = "test132Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -573,9 +559,8 @@ public void test132Forward15min() throws Exception { @Test public void test134JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test134JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -584,11 +569,11 @@ public void test134JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -618,9 +603,8 @@ public void test139JackUnassignAll() throws Exception { @Test public void test140JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test140JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -633,12 +617,12 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -659,17 +643,16 @@ public void test140JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test142Forward15min() throws Exception { final String TEST_NAME = "test142Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); clockForward("PT15M"); // do NOT recompute // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -688,9 +671,8 @@ public void test142Forward15min() throws Exception { @Test public void test144JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test144JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -699,11 +681,11 @@ public void test144JackAssignRoleSailorAgain() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -731,20 +713,19 @@ public void test149JackUnassignAll() throws Exception { @Test public void test150JackAssignRolePirate() throws Exception { final String TEST_NAME = "test150JackAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -767,9 +748,8 @@ public void test150JackAssignRolePirate() throws Exception { @Test public void test151JackAssignRoleSailorValidTo() throws Exception { final String TEST_NAME = "test151JackAssignRoleSailorValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -780,11 +760,11 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -809,19 +789,18 @@ public void test151JackAssignRoleSailorValidTo() throws Exception { @Test public void test153Forward15min() throws Exception { final String TEST_NAME = "test153Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -843,20 +822,19 @@ public void test153Forward15min() throws Exception { @Test public void test154JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test154JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -882,20 +860,19 @@ public void test159JackUnassignAll() throws Exception { @Test public void test160JackAssignRolePirate() throws Exception { final String TEST_NAME = "test160JackAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -917,9 +894,8 @@ public void test160JackAssignRolePirate() throws Exception { @Test public void test161JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test161JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -932,12 +908,12 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { ModelExecuteOptions options = ModelExecuteOptions.createRaw(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -963,9 +939,8 @@ public void test161JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test162RecomputeJack() throws Exception { final String TEST_NAME = "test162RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -976,11 +951,11 @@ public void test162RecomputeJack() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1005,19 +980,18 @@ public void test162RecomputeJack() throws Exception { @Test public void test163Forward15min() throws Exception { final String TEST_NAME = "test163Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1039,20 +1013,19 @@ public void test163Forward15min() throws Exception { @Test public void test164JackAssignRoleSailorAgain() throws Exception { final String TEST_NAME = "test164JackAssignRoleSailorAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1078,20 +1051,19 @@ public void test169JackUnassignAll() throws Exception { @Test public void test170JackAssignRolePirate() throws Exception { final String TEST_NAME = "test170JackAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1113,9 +1085,8 @@ public void test170JackAssignRolePirate() throws Exception { @Test public void test171JackAssignRoleWeakSingerValidTo() throws Exception { final String TEST_NAME = "test171JackAssignRoleWeakSingerValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1126,11 +1097,11 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1155,19 +1126,18 @@ public void test171JackAssignRoleWeakSingerValidTo() throws Exception { @Test public void test173Forward15min() throws Exception { final String TEST_NAME = "test173Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1190,20 +1160,19 @@ public void test173Forward15min() throws Exception { @Test public void test174JackAssignRoleSingerAgain() throws Exception { final String TEST_NAME = "test174JackAssignRoleSingerAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1230,9 +1199,8 @@ public void test179JackUnassignAll() throws Exception { @Test public void test180JackAssignRoleSailorValidToRaw() throws Exception { final String TEST_NAME = "test180JackAssignRoleSailorValidToRaw"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1243,12 +1211,12 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { activationType.setValidTo(jackPirateValidTo); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, ModelExecuteOptions.createRaw(), result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1268,20 +1236,19 @@ public void test180JackAssignRoleSailorValidToRaw() throws Exception { @Test public void test182Forward15minAndAssignRaw() throws Exception { final String TEST_NAME = "test142Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, null, true, ModelExecuteOptions.createRaw(), result); // THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); @@ -1297,20 +1264,19 @@ public void test182Forward15minAndAssignRaw() throws Exception { @Test public void test184RecomputeJack() throws Exception { final String TEST_NAME = "test184RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1336,9 +1302,8 @@ public void test189JackUnassignAll() throws Exception { @Test public void test200JackAssignCurrentPirateFutureSailor() throws Exception { final String TEST_NAME = "test200JackAssignCurrentPirateFutureSailor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1348,12 +1313,12 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1373,20 +1338,19 @@ public void test200JackAssignCurrentPirateFutureSailor() throws Exception { @Test public void test202RecomputeJack() throws Exception { final String TEST_NAME = "test202RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1404,20 +1368,19 @@ public void test202RecomputeJack() throws Exception { @Test public void test204ReconcileJack() throws Exception { final String TEST_NAME = "test204ReconcileJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1442,9 +1405,8 @@ public void test209JackUnassignAll() throws Exception { @Test public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { final String TEST_NAME = "test210JackAssignCurrentPirateFutureRichSailor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1454,12 +1416,12 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1479,20 +1441,19 @@ public void test210JackAssignCurrentPirateFutureRichSailor() throws Exception { @Test public void test212RecomputeJack() throws Exception { final String TEST_NAME = "test212RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1510,20 +1471,19 @@ public void test212RecomputeJack() throws Exception { @Test public void test214ReconcileJack() throws Exception { final String TEST_NAME = "test214ReconcileJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1546,9 +1506,8 @@ public void test219JackUnassignAll() throws Exception { @Test public void test220JackAssignFutureRichSailor() throws Exception { final String TEST_NAME = "test220JackAssignFutureRichSailor"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignAll(TEST_NAME); @@ -1560,11 +1519,11 @@ public void test220JackAssignFutureRichSailor() throws Exception { activationType.setValidFrom(getTimestamp("P1M")); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1590,9 +1549,8 @@ public void test229JackUnassignAll() throws Exception { @Test public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { final String TEST_NAME = "test230JackAssignRoleStrongRichSailorValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1605,14 +1563,14 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_STRONG_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1635,19 +1593,18 @@ public void test230JackAssignRoleStrongRichSailorValidTo() throws Exception { @Test public void test232Forward15min() throws Exception { final String TEST_NAME = "test232Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1673,9 +1630,8 @@ public void test239JackUnassignAll() throws Exception { @Test public void test240JackAssignRoleRichSailorValidTo() throws Exception { final String TEST_NAME = "test240JackAssignRoleRichSailorValidTo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1688,14 +1644,14 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); // beware of the order: weapon is weak and is set differently by role (cutlass) and resource (from user extension: pistol, mouth) // the assert expects cutlass, so the pirate role assignment must go first assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); assignRole(USER_JACK_OID, ROLE_RICH_SAILOR_OID, activationType, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1718,19 +1674,18 @@ public void test240JackAssignRoleRichSailorValidTo() throws Exception { @Test public void test242Forward15min() throws Exception { final String TEST_NAME = "test242Forward15min"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT15M"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1755,9 +1710,8 @@ public void test249JackUnassignAll() throws Exception { @Test public void test250JackAssignFocusExistsResource() throws Exception { final String TEST_NAME = "test250JackAssignFocusExistsResource"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1768,14 +1722,14 @@ public void test250JackAssignFocusExistsResource() throws Exception { AssignmentType assignment = ObjectTypeUtil.createAssignmentTo(resourceDummyFocusExists, prismContext).activation(activation); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(assignment) .asObjectDeltaCast(USER_JACK_OID); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1792,20 +1746,19 @@ public void test250JackAssignFocusExistsResource() throws Exception { @Test public void test252RecomputeJack() throws Exception { final String TEST_NAME = "test252RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1822,20 +1775,19 @@ public void test252RecomputeJack() throws Exception { @Test public void test254ReconcileJack() throws Exception { final String TEST_NAME = "test254ReconcileJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1924,20 +1876,19 @@ private void assertJackDummyPirateSingerAccount() throws Exception { } private void unassignAll(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignAll(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java index 452c3910a6a..46a6a598f28 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestAutoassign.java @@ -10,18 +10,14 @@ import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleManagementConfigurationType; @@ -85,10 +81,9 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test100ModifyUnitWorker() throws Exception { final String TEST_NAME = "test100ModifyUnitWorker"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -119,10 +114,9 @@ public void test100ModifyUnitWorker() throws Exception { @Test public void test109ModifyUniNull() throws Exception { final String TEST_NAME = "test109ModifyUniNull"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -148,10 +142,9 @@ public void test109ModifyUniNull() throws Exception { @Test public void test110ModifyUnitSleepwalker() throws Exception { final String TEST_NAME = "test110ModifyUnitSleepwalker"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -189,10 +182,9 @@ public void test110ModifyUnitSleepwalker() throws Exception { @Test public void test112ModifyUnitSleeperToWorker() throws Exception { final String TEST_NAME = "test112ModifyUnitSleeperToWorker"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = prismContext.deltaFactory().object().createModificationAddProperty(UserType.class, @@ -226,10 +218,9 @@ public void test112ModifyUnitSleeperToWorker() throws Exception { @Test public void test114ModifyUnitAddSleeper() throws Exception { final String TEST_NAME = "test114ModifyUnitAddSleeper"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java index 1758c41ce5d..7c0dbc41837 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestMetaMeta.java @@ -101,10 +101,9 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test050AddMetaMeta() throws Exception { final String TEST_NAME = "test050AddMetaMeta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -137,10 +136,9 @@ public void test050AddMetaMeta() throws Exception { @Test public void test100AddGreeks() throws Exception { final String TEST_NAME = "test100AddGreeks"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -156,10 +154,9 @@ public void test100AddGreeks() throws Exception { @Test public void test110AddRomans() throws Exception { final String TEST_NAME = "test110AddRomans"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -175,10 +172,9 @@ public void test110AddRomans() throws Exception { @Test public void test200CreateAlpha() throws Exception { final String TEST_NAME = "test200CreateAlpha"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -195,10 +191,9 @@ public void test200CreateAlpha() throws Exception { @Test public void test202CreateBeta() throws Exception { final String TEST_NAME = "test202CreateBeta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -214,10 +209,9 @@ public void test202CreateBeta() throws Exception { @Test public void test210CreateA() throws Exception { final String TEST_NAME = "test210CreateA"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -236,10 +230,9 @@ public void test210CreateA() throws Exception { @Test public void test300AssignAlphaToJack() throws Exception { final String TEST_NAME = "test300AssignAlphaToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -256,10 +249,9 @@ public void test300AssignAlphaToJack() throws Exception { @Test public void test309UnassignAlphaFromJack() throws Exception { final String TEST_NAME = "test309UnassignAlphaFromJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -285,10 +277,9 @@ public void test309UnassignAlphaFromJack() throws Exception { @Test public void test310AssignAToJack() throws Exception { final String TEST_NAME = "test310AssignAToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -308,10 +299,9 @@ public void test310AssignAToJack() throws Exception { @Test public void test312AssignBetaToJack() throws Exception { final String TEST_NAME = "test312AssignBetaToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -328,10 +318,9 @@ public void test312AssignBetaToJack() throws Exception { @Test public void test319UnassignBetaAFromJack() throws Exception { final String TEST_NAME = "test319UnassignBetaAFromJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta focusDelta = createAssignmentFocusDelta(UserType.class, USER_JACK_OID, getGroupRoleOid(GROUP_BETA_NAME), RoleType.COMPLEX_TYPE, null, (Consumer)null, false); @@ -359,10 +348,9 @@ public void test319UnassignBetaAFromJack() throws Exception { @Test public void test900LegacyAddMetaMeta() throws Exception { final String TEST_NAME = "test900LegacyAddMetaMeta"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -395,10 +383,9 @@ public void test900LegacyAddMetaMeta() throws Exception { @Test public void test910LegacyAddMetaLegacyOne() throws Exception { final String TEST_NAME = "test910LegacyAddMetaLegacyOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -432,10 +419,9 @@ public void test910LegacyAddMetaLegacyOne() throws Exception { @Test public void test920LegacyCreateGroupOne() throws Exception { final String TEST_NAME = "test920LegacyCreateGroupOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject roleBefore = createObject(RoleType.class, GROUP_ONE_NAME); RoleType roleType = roleBefore.asObjectable(); @@ -473,10 +459,9 @@ public void test920LegacyCreateGroupOne() throws Exception { @Test public void test930LegacyAssignGroupOneToJack() throws Exception { final String TEST_NAME = "test930LegacyAssignGroupOneToJack"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java index aeebe2b6f81..5469a6bd64e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestRbac.java @@ -6,25 +6,14 @@ */ package com.evolveum.midpoint.model.intest.rbac; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.notifications.api.transports.Message; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.util.QNameUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -37,6 +26,16 @@ import com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget; import com.evolveum.midpoint.model.api.context.EvaluatedConstruction; import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.notifications.api.transports.Message; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismProperty; +import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.delta.DeltaSetTriple; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -49,14 +48,15 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestRbac extends AbstractRbacTest { @@ -80,9 +80,8 @@ public void initSystem(Task initTask, OperationResult initResult) @Test public void test000SanityRolePirate() throws Exception { final String TEST_NAME = "test000SanityRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -99,9 +98,8 @@ public void test000SanityRolePirate() throws Exception { @Test public void test001SanityRoleProjectOmnimanager() throws Exception { final String TEST_NAME = "test001SanityRoleProjectOmnimanager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -120,9 +118,8 @@ public void test001SanityRoleProjectOmnimanager() throws Exception { @Test public void test010SearchRequestableRoles() throws Exception { final String TEST_NAME = "test010SearchRequestableRoles"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = prismContext.queryFor(RoleType.class) @@ -141,9 +138,8 @@ public void test010SearchRequestableRoles() throws Exception { @Test public void test101JackAssignRolePirate() throws Exception { final String TEST_NAME = "test101JackAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -155,7 +151,7 @@ public void test101JackAssignRolePirate() throws Exception { assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -163,7 +159,7 @@ public void test101JackAssignRolePirate() throws Exception { display("User jack after", userAfter); assertModifyMetadata(userAfter, startTs, endTs); - AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertCreateMetadata(assignmentType, startTs, endTs); assertEffectiveActivation(assignmentType, ActivationStatusType.ENABLED); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); @@ -192,31 +188,30 @@ protected ModelExecuteOptions getDefaultOptions() { @Test public void test102JackModifyUserLocality() throws Exception { final String TEST_NAME = "test102JackModifyUserLocality"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); - XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); + XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, getDefaultOptions(), task, result, createPolyString(LOCALITY_TORTUGA)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + AssignmentType assignmentType = assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -234,16 +229,15 @@ public void test102JackModifyUserLocality() throws Exception { @Test public void test110UnAssignRolePirate() throws Exception { final String TEST_NAME = "test110UnAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -257,10 +251,9 @@ public void test110UnAssignRolePirate() throws Exception { @Test public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception { final String TEST_NAME = "test120JackAssignRolePirateWhileAlreadyHasAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_FILE); @@ -277,7 +270,7 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception ObjectDelta delta = prismContext.deltaFactory().object() .createModificationAddReference(UserType.class, USER_JACK_OID, - UserType.F_LINK_REF, account); + UserType.F_LINK_REF, account); Collection> deltas = MiscSchemaUtil.createCollection(delta); // We need to switch off the enforcement for this operation. Otherwise we won't be able to create the account @@ -290,16 +283,16 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "rum"); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -320,15 +313,12 @@ public void test120JackAssignRolePirateWhileAlreadyHasAccount() throws Exception } - - @Test public void test121JackAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test121JackAssignAccountImplicitIntent"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition (simplified) @@ -359,10 +349,9 @@ public void test121JackAssignAccountImplicitIntent() throws Exception { @Test public void test122JackAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test122JackAssignAccountExplicitIntent"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Precondition (simplified) @@ -393,9 +382,8 @@ public void test122JackAssignAccountExplicitIntent() throws Exception { @Test public void test127UnAssignAccountImplicitIntent() throws Exception { final String TEST_NAME = "test127UnAssignAccountImplicitIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -422,9 +410,8 @@ public void test127UnAssignAccountImplicitIntent() throws Exception { @Test public void test128UnAssignAccountExplicitIntent() throws Exception { final String TEST_NAME = "test128UnAssignAccountExplicitIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -451,9 +438,8 @@ public void test128UnAssignAccountExplicitIntent() throws Exception { @Test public void test129UnAssignRolePirate() throws Exception { final String TEST_NAME = "test129UnAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -474,9 +460,8 @@ public void test129UnAssignRolePirate() throws Exception { @Test public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test130JackAssignRolePirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -495,7 +480,7 @@ public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -512,9 +497,8 @@ public void test130JackAssignRolePirateWithSeaInAssignment() throws Exception { @Test public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test132JackUnAssignRolePirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -545,9 +529,8 @@ public void test132JackUnAssignRolePirateWithSeaInAssignment() throws Exception @Test public void test134JackAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test134JackAssignRoleAdriaticPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -559,7 +542,7 @@ public void test134JackAssignRoleAdriaticPirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_ADRIATIC_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -579,9 +562,8 @@ public void test134JackAssignRoleAdriaticPirate() throws Exception { @Test public void test135PreviewChangesEmptyDelta() throws Exception { final String TEST_NAME = "test135PreviewChangesEmptyDelta"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(USER_JACK_OID); ObjectDelta delta = user.createModifyDelta(); @@ -612,9 +594,8 @@ public void test135PreviewChangesEmptyDelta() throws Exception { @Test public void test136JackUnAssignRoleAdriaticPirate() throws Exception { final String TEST_NAME = "test136JackUnAssignRoleAdriaticPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -639,9 +620,8 @@ public void test136JackUnAssignRoleAdriaticPirate() throws Exception { @Test public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test137JackAssignRoleAdriaticPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -660,7 +640,7 @@ public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exce PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ADRIATIC_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_ADRIATIC_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); @@ -677,9 +657,8 @@ public void test137JackAssignRoleAdriaticPirateWithSeaInAssignment() throws Exce @Test public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -707,9 +686,8 @@ public void test139JackUnAssignRoleAdriaticPirateWithSeaInAssignment() throws Ex @Test public void test144JackAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test144JackAssignRoleBlackSeaPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -720,7 +698,7 @@ public void test144JackAssignRoleBlackSeaPirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_BLACK_SEA_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -738,9 +716,8 @@ public void test144JackAssignRoleBlackSeaPirate() throws Exception { @Test public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { final String TEST_NAME = "test146JackUnAssignRoleBlackSeaPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -761,9 +738,8 @@ public void test146JackUnAssignRoleBlackSeaPirate() throws Exception { @Test public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test147JackAssignRoleBlackSeaPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -782,7 +758,7 @@ public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exce PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_BLACK_SEA_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_BLACK_SEA_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -800,9 +776,8 @@ public void test147JackAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exce @Test public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Exception { final String TEST_NAME = "test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismContainer extension = getAssignmentExtensionInstance(); @@ -830,24 +805,23 @@ public void test149JackUnAssignRoleBlackSeaPirateWithSeaInAssignment() throws Ex @Test public void test154JackAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test154JackAssignRoleIndianOceanPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_INDIAN_OCEAN_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Result", result); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_INDIAN_OCEAN_PIRATE_OID, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -865,9 +839,8 @@ public void test154JackAssignRoleIndianOceanPirate() throws Exception { @Test public void test156JackUnAssignRoleIndianOceanPirate() throws Exception { final String TEST_NAME = "test156JackUnAssignRoleIndianOceanPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -885,7 +858,6 @@ public void test156JackUnAssignRoleIndianOceanPirate() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } - /** * Approver relation is not supposed to give any role privileges. * MID-3580 @@ -939,9 +911,8 @@ public void test169JackUnassignRolePirateComplicated() throws Exception { } public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -951,21 +922,21 @@ public void testJackAssignRolePirateRelationNoPrivs(final String TEST_NAME, QNam assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN (1) - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN (1) - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); // WHEN (2) - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN (2) - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackAssignRolePirateRelationNoPrivs(relation); @@ -982,9 +953,8 @@ private void assertJackAssignRolePirateRelationNoPrivs(QName relation) throws Ex } public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QName relation) throws Exception { - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -996,7 +966,7 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, relation, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -1017,9 +987,8 @@ public void testJackUnassignRolePirateRelationNoPrivs(final String TEST_NAME, QN @Test public void test200ImportRoleAllTreasure() throws Exception { final String TEST_NAME = "test200ImportRoleAllTreasure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1040,9 +1009,8 @@ public void test200ImportRoleAllTreasure() throws Exception { @Test public void test202JackAssignRoleAllTreasure() throws Exception { final String TEST_NAME = "test202JackAssignRoleAllTreasure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1057,7 +1025,7 @@ public void test202JackAssignRoleAllTreasure() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID); assertDelegatedRef(userAfter); @@ -1074,9 +1042,8 @@ public void test202JackAssignRoleAllTreasure() throws Exception { @Test public void test204AddGoldTreasureAndRecomputeJack() throws Exception { final String TEST_NAME = "test204AddGoldTreasureAndRecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(ROLE_TREASURE_GOLD_FILE); @@ -1089,7 +1056,7 @@ public void test204AddGoldTreasureAndRecomputeJack() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID); assertDelegatedRef(userAfter); @@ -1105,9 +1072,8 @@ public void test204AddGoldTreasureAndRecomputeJack() throws Exception { @Test public void test206JackAssignRoleAllLoot() throws Exception { final String TEST_NAME = "test206JackAssignRoleAllLoot"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1118,7 +1084,7 @@ public void test206JackAssignRoleAllLoot() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID, ROLE_ALL_LOOT_OID, ROLE_LOOT_DIAMONDS_OID); @@ -1132,9 +1098,8 @@ public void test206JackAssignRoleAllLoot() throws Exception { @Test public void test208JackUnassignRoleAllLoot() throws Exception { final String TEST_NAME = "test208JackUnassignRoleAllLoot"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1145,7 +1110,7 @@ public void test208JackUnassignRoleAllLoot() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_TREASURE_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_TREASURE_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID); assertDelegatedRef(userAfter); @@ -1158,9 +1123,8 @@ public void test208JackUnassignRoleAllLoot() throws Exception { @Test public void test209JackUnassignRoleAllTreasure() throws Exception { final String TEST_NAME = "test209JackUnassignRoleAllTreasure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1179,12 +1143,11 @@ public void test209JackUnassignRoleAllTreasure() throws Exception { /** * MID-3966 */ - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void test210JackAssignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test210JackAssignRoleAllYouCanGet"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1195,7 +1158,7 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_ALL_YOU_CAN_GET_OID, task, result); + assertAssignedRole(userAfter, ROLE_ALL_YOU_CAN_GET_OID); assertRoleMembershipRef(userAfter, ROLE_ALL_YOU_CAN_GET_OID, ROLE_TREASURE_BRONZE_OID, ROLE_TREASURE_SILVER_OID, ROLE_TREASURE_GOLD_OID, ROLE_LOOT_DIAMONDS_OID); @@ -1206,12 +1169,11 @@ public void test210JackAssignRoleAllYouCanGet() throws Exception { "Silver treasure", "Bronze treasure", "Golden treasure", "Diamond loot"); } - @Test(enabled=false) // MID-3966 + @Test(enabled = false) // MID-3966 public void test219JackUnassignRoleAllYouCanGet() throws Exception { final String TEST_NAME = "test219JackUnassignRoleAllYouCanGet"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1234,12 +1196,11 @@ public void test219JackUnassignRoleAllYouCanGet() throws Exception { @Test public void test501JackAssignRolePirate() throws Exception { final String TEST_NAME = "test501JackAssignRolePirate"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1251,7 +1212,7 @@ public void test501JackAssignRolePirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1271,27 +1232,26 @@ public void test501JackAssignRolePirate() throws Exception { @Test public void test502JackModifyUserLocality() throws Exception { final String TEST_NAME = "test502JackModifyUserLocality"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // gossip is a tolerant attribute. Make sure there there is something to tolerate - DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); - jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, - EXISTING_GOSSIP); + DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME); + jackDummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + EXISTING_GOSSIP); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, getDefaultOptions(), task, result, createPolyString("Isla de Muerta")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1311,9 +1271,8 @@ public void test502JackModifyUserLocality() throws Exception { @Test public void test510UnAssignRolePirate() throws Exception { final String TEST_NAME = "test510UnAssignRolePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1340,9 +1299,8 @@ public void test510UnAssignRolePirate() throws Exception { @Test public void test511DeleteAccount() throws Exception { final String TEST_NAME = "test511DeleteAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); @@ -1372,12 +1330,11 @@ public void test511DeleteAccount() throws Exception { @Test public void test520JackAssignRolePirate() throws Exception { final String TEST_NAME = "test520JackAssignRolePirate"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1389,7 +1346,7 @@ public void test520JackAssignRolePirate() throws Exception { PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1405,15 +1362,14 @@ public void test520JackAssignRolePirate() throws Exception { @Test public void test521JackUnassignRolePirateDeleteAccount() throws Exception { final String TEST_NAME = "test521JackUnassignRolePirateDeleteAccount"; - displayTestTitle(TEST_NAME); // IMPORTANT: Changing the assignment policy assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, false)); ObjectDelta userDelta = prismContext.deltaFactory().object() .createModifyDelta(USER_JACK_OID, modifications, UserType.class); @@ -1441,17 +1397,16 @@ public void test521JackUnassignRolePirateDeleteAccount() throws Exception { @Test public void test530JackAssignRoleCleric() throws Exception { final String TEST_NAME = "test530JackAssignRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN assignRole(USER_JACK_OID, ROLE_CLERIC_OID, getDefaultOptions(), task, result); // THEN - assertAssignedRole(USER_JACK_OID, ROLE_CLERIC_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_CLERIC_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Holy man"); } @@ -1459,10 +1414,9 @@ public void test530JackAssignRoleCleric() throws Exception { @Test public void test532JackModifyAssignmentRoleCleric() throws Exception { final String TEST_NAME = "test532JackModifyAssignmentRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getObject(UserType.class, USER_JACK_OID); @@ -1473,17 +1427,17 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { UserType.class, USER_JACK_OID, itemPath, "soul"); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(assignmentDelta), getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_CLERIC_OID, task, result); + assertAssignedRole(userAfter, ROLE_CLERIC_OID); assertRoleMembershipRef(userAfter, ROLE_CLERIC_OID); assertDelegatedRef(userAfter); @@ -1494,10 +1448,9 @@ public void test532JackModifyAssignmentRoleCleric() throws Exception { @Test public void test539JackUnAssignRoleCleric() throws Exception { final String TEST_NAME = "test539JackUnAssignRoleCleric"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getObject(UserType.class, USER_JACK_OID); @@ -1508,11 +1461,11 @@ public void test539JackUnAssignRoleCleric() throws Exception { UserType.class, USER_JACK_OID, UserType.F_ASSIGNMENT, assignmentType); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(assignmentDelta, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1531,23 +1484,22 @@ public void test539JackUnAssignRoleCleric() throws Exception { @Test public void test540JackAssignRoleWannabe() throws Exception { final String TEST_NAME = "test540JackAssignRoleWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter); assertDelegatedRef(userAfter); @@ -1561,23 +1513,22 @@ public void test540JackAssignRoleWannabe() throws Exception { @Test public void test541JackRemoveHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test541JackRemoveHonorificSuffixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter); assertDelegatedRef(userAfter); @@ -1590,23 +1541,22 @@ public void test541JackRemoveHonorificSuffixWannabe() throws Exception { @Test public void test542JackModifySubtypeWannabe() throws Exception { final String TEST_NAME = "test542JackModifySubtypeWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_SUBTYPE, getDefaultOptions(), task, result, "wannabe"); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1620,23 +1570,22 @@ public void test542JackModifySubtypeWannabe() throws Exception { @Test public void test543JackRemoveHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test543JackRemoveHonorificPrefixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1649,24 +1598,23 @@ public void test543JackRemoveHonorificPrefixWannabe() throws Exception { @Test public void test544JackSetHonorificSuffixWannabe() throws Exception { final String TEST_NAME = "test544JackSetHonorificSuffixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_SUFFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("PhD.")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID, ROLE_HONORABLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1681,24 +1629,23 @@ public void test544JackSetHonorificSuffixWannabe() throws Exception { @Test public void test545JackRestoreHonorificPrefixWannabe() throws Exception { final String TEST_NAME = "test545JackRestoreHonorificPrefixWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, getDefaultOptions(), task, result, PrismTestUtil.createPolyString("captain")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_WANNABE_OID, task, result); + assertAssignedRole(userAfter, ROLE_WANNABE_OID); assertRoleMembershipRef(userAfter, ROLE_WANNABE_OID, ROLE_HONORABLE_WANNABE_OID); assertDelegatedRef(userAfter); @@ -1712,18 +1659,17 @@ public void test545JackRestoreHonorificPrefixWannabe() throws Exception { @Test public void test549JackUnassignRoleWannabe() throws Exception { final String TEST_NAME = "test549JackUnassignRoleWannabe"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WANNABE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -1738,10 +1684,9 @@ public void test549JackUnassignRoleWannabe() throws Exception { @Test public void test600JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test600JackAssignRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -1751,17 +1696,17 @@ public void test600JackAssignRoleJudge() throws Exception { assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_JUDGE_OID, task, result); + assertAssignedRole(userAfter, ROLE_JUDGE_OID); assertRoleMembershipRef(userAfter, ROLE_JUDGE_OID); assertDelegatedRef(userAfter); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Honorable Justice"); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "mouth", "pistol"); @@ -1775,10 +1720,9 @@ public void test600JackAssignRoleJudge() throws Exception { @Test public void test602JackAssignRolePirate() throws Exception { final String TEST_NAME = "test602JackAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1793,13 +1737,13 @@ public void test602JackAssignRolePirate() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_JUDGE_OID, task, result); + assertAssignedRole(userAfter, ROLE_JUDGE_OID); assertRoleMembershipRef(userAfter, ROLE_JUDGE_OID); assertDelegatedRef(userAfter); @@ -1811,27 +1755,26 @@ public void test602JackAssignRolePirate() throws Exception { @Test public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { final String TEST_NAME = "test605JackUnAssignRoleJudgeAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_JUDGE_OID, RoleType.COMPLEX_TYPE, null, null, false); userDelta.addModification(createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PIRATE_OID, task, result); + assertAssignedRole(userAfter, ROLE_PIRATE_OID); assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID); assertDelegatedRef(userAfter); @@ -1849,18 +1792,17 @@ public void test605JackUnAssignRoleJudgeAssignRolePirate() throws Exception { @Test public void test609JackUnAssignRolePirate() throws Exception { final String TEST_NAME = "test609JackUnAssignRolePirate"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1870,10 +1812,9 @@ public void test609JackUnAssignRolePirate() throws Exception { @Test public void test610ElaineAssignRoleGovernor() throws Exception { final String TEST_NAME = "test610ElaineAssignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_ELAINE_OID); @@ -1885,17 +1826,17 @@ public void test610ElaineAssignRoleGovernor() throws Exception { assignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = getUser(USER_ELAINE_OID); display("User after", userAfter); - assertAssignedRole(userAfter, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(userAfter, ROLE_GOVERNOR_OID); assertRoleMembershipRef(userAfter, ROLE_GOVERNOR_OID); assertDelegatedRef(userAfter); - assertAssignedRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, result); assertDefaultDummyAccount(ACCOUNT_ELAINE_DUMMY_USERNAME, ACCOUNT_ELAINE_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_ELAINE_DUMMY_USERNAME, "title", "Her Excellency Governor"); @@ -1908,10 +1849,9 @@ public void test610ElaineAssignRoleGovernor() throws Exception { @Test public void test612JackAssignRoleGovernor() throws Exception { final String TEST_NAME = "test612JackAssignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1926,7 +1866,7 @@ public void test612JackAssignRoleGovernor() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1945,10 +1885,9 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { } final String TEST_NAME = "test613JackAssignRoleGovernorAsApprover"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -1963,7 +1902,7 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(USER_JACK_OID); @@ -1979,10 +1918,9 @@ public void test613JackAssignRoleGovernorAsApprover() throws Exception { @Test public void test620LemonheadAssignRoleCanibal() throws Exception { final String TEST_NAME = "test620LemonheadAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_LEMONHEAD_NAME, USER_LEMONHEAD_FULLNAME, true); @@ -1992,14 +1930,14 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 0); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_LEMONHEAD_NAME, USER_LEMONHEAD_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_LEMONHEAD_NAME, "title", "Voracious Cannibal"); @@ -2010,10 +1948,9 @@ public void test620LemonheadAssignRoleCanibal() throws Exception { @Test public void test622SharptoothAssignRoleCanibal() throws Exception { final String TEST_NAME = "test622SharptoothAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME, true); @@ -2023,14 +1960,14 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 1); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_SHARPTOOTH_NAME, "title", "Voracious Cannibal"); @@ -2041,10 +1978,9 @@ public void test622SharptoothAssignRoleCanibal() throws Exception { @Test public void test624RedskullAssignRoleCanibal() throws Exception { final String TEST_NAME = "test624RedskullAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); @@ -2054,14 +1990,14 @@ public void test624RedskullAssignRoleCanibal() throws Exception { assertAssignees(ROLE_CANNIBAL_OID, 2); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(user.getOid(), ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_REDSKULL_NAME, "title", "Voracious Cannibal"); @@ -2072,10 +2008,9 @@ public void test624RedskullAssignRoleCanibal() throws Exception { @Test public void test625BignoseAssignRoleCanibal() throws Exception { final String TEST_NAME = "test625BignoseAssignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_BIGNOSE_NAME, USER_BIGNOSE_FULLNAME, true); @@ -2086,7 +2021,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2097,7 +2032,7 @@ public void test625BignoseAssignRoleCanibal() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); assertNoAssignments(user.getOid()); @@ -2109,20 +2044,19 @@ public void test625BignoseAssignRoleCanibal() throws Exception { @Test public void test627SharptoothUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test627SharptoothUnassignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 3); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userSharptoothOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoAssignments(userSharptoothOid); @@ -2135,17 +2069,16 @@ public void test627SharptoothUnassignRoleCanibal() throws Exception { @Test public void test628RedskullUnassignRoleCanibal() throws Exception { final String TEST_NAME = "test628RedskullUnassignRoleCanibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); try { // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userRedskullOid, ROLE_CANNIBAL_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); @@ -2156,10 +2089,10 @@ public void test628RedskullUnassignRoleCanibal() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); - assertAssignedRole(userRedskullOid, ROLE_CANNIBAL_OID, task, result); + assertAssignedRole(userRedskullOid, ROLE_CANNIBAL_OID, result); assertDefaultDummyAccount(USER_REDSKULL_NAME, USER_REDSKULL_FULLNAME, true); assertDefaultDummyAccountAttribute(USER_REDSKULL_NAME, "title", "Voracious Cannibal"); @@ -2175,10 +2108,9 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test630RappAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2187,7 +2119,7 @@ public void test630RappAssignRoleCannibalAsOwner() throws Exception { assignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2205,10 +2137,9 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test632RappUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2216,7 +2147,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); // null namespace to test no-namespace "owner" relation unassignRole(USER_RAPP_OID, ROLE_CANNIBAL_OID, QNameUtil.nullNamespace(SchemaConstants.ORG_OWNER), getDefaultOptions(), task, result); @@ -2228,7 +2159,7 @@ public void test632RappUnassignRoleCannibalAsOwner() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2246,10 +2177,9 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test634BignoseAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2259,11 +2189,11 @@ public void test634BignoseAssignRoleCannibalAsOwner() throws Exception { assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(1) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER); @@ -2282,10 +2212,9 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { } final String TEST_NAME = "test636BignoseUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2295,11 +2224,11 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertNone(); assertAssignees(ROLE_CANNIBAL_OID, 2); @@ -2309,10 +2238,9 @@ public void test636BignoseUnassignRoleCannibalAsOwner() throws Exception { @Test public void test649ElaineUnassignRoleGovernor() throws Exception { final String TEST_NAME = "test649ElaineUnassignRoleGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_ELAINE_OID); @@ -2321,11 +2249,11 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { assertAssignees(ROLE_GOVERNOR_OID, 1); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_ELAINE_OID, ROLE_GOVERNOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_ELAINE_OID); @@ -2338,26 +2266,25 @@ public void test649ElaineUnassignRoleGovernor() throws Exception { @Test public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test650BignoseAssignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); assertUserBefore(userBignoseOid) - .assignments() - .assertNone(); + .assignments() + .assertNone(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(1) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER); } @@ -2365,22 +2292,21 @@ public void test650BignoseAssignRoleCannibalAsOwner() throws Exception { @Test public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { final String TEST_NAME = "test651BignoseAssignRoleCannibalAsApprover"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(2) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER); @@ -2392,22 +2318,21 @@ public void test651BignoseAssignRoleCannibalAsApprover() throws Exception { @Test public void test655BignoseAssignRoleCannibal() throws Exception { final String TEST_NAME = "test655BignoseAssignRoleCannibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(3) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) @@ -2417,22 +2342,21 @@ public void test655BignoseAssignRoleCannibal() throws Exception { @Test public void test656BignoseUnassignRoleCannibal() throws Exception { final String TEST_NAME = "test656BignoseUnassignRoleCannibal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBignoseOid, ROLE_CANNIBAL_OID, SchemaConstants.ORG_DEFAULT, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertAssignments(2) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_OWNER) .assertRole(ROLE_CANNIBAL_OID, SchemaConstants.ORG_APPROVER); @@ -2441,13 +2365,12 @@ public void test656BignoseUnassignRoleCannibal() throws Exception { @Test public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { final String TEST_NAME = "test658BignoseUnassignRoleCannibalAsOwner"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - Collection> modifications = new ArrayList<>(); + Collection> modifications = new ArrayList<>(); modifications.add((createAssignmentModification(ROLE_CANNIBAL_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_OWNER, null, null, false))); modifications.add((createAssignmentModification(ROLE_CANNIBAL_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER, null, null, false))); ObjectDelta userDelta = prismContext.deltaFactory().object() @@ -2457,35 +2380,34 @@ public void test658BignoseUnassignRoleCannibalAsOwner() throws Exception { executeChanges(userDelta, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(userBignoseOid) - .assignments() + .assignments() .assertNone(); } @Test public void test700JackAssignRoleJudge() throws Exception { final String TEST_NAME = "test700JackModifyJudgeRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "title", "Honorable Justice"); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, "weapon", "mouth", "pistol"); @@ -2494,10 +2416,9 @@ public void test700JackAssignRoleJudge() throws Exception { @Test public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception { final String TEST_NAME = "test701JackModifyJudgeDeleteConstructionRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2505,17 +2426,17 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, true, getDefaultOptions(), task); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2525,10 +2446,9 @@ public void test701JackModifyJudgeDeleteConstructionRecompute() throws Exception @Test public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Exception { final String TEST_NAME = "test702JackModifyJudgeAddInducementHonorabilityRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2536,17 +2456,17 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); - modifyRoleAddInducementTarget(ROLE_JUDGE_OID, ROLE_HONORABILITY_OID, true, getDefaultOptions(), task); + when(); + modifyRoleAddInducementTarget(ROLE_JUDGE_OID, ROLE_HONORABILITY_OID, true, getDefaultOptions()); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_JUDGE_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2561,10 +2481,9 @@ public void test702JackModifyJudgeAddInducementHonorabilityRecompute() throws Ex @Test public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws Exception { final String TEST_NAME = "test703JackModifyJudgeDeleteInducementHonorabilityRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2575,11 +2494,11 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws display("Role judge", roleJudge); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2597,21 +2516,20 @@ public void test703JackModifyJudgeDeleteInducementHonorabilityRecompute() throws @Test public void test709JackUnAssignRoleJudge() throws Exception { final String TEST_NAME = "test709JackUnAssignRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_JUDGE_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2622,10 +2540,9 @@ public void test709JackUnAssignRoleJudge() throws Exception { @Test public void test710JackAssignRoleEmpty() throws Exception { final String TEST_NAME = "test710JackAssignRoleEmpty"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2633,25 +2550,24 @@ public void test710JackAssignRoleEmpty() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } @Test public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exception { final String TEST_NAME = "test712JackModifyEmptyRoleAddInducementPirateRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2659,17 +2575,17 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); - modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, true, getDefaultOptions(), task); + when(); + modifyRoleAddInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, true, getDefaultOptions()); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertInProgressOrSuccess(result); assertTrue("task is not persistent", task.isPersistent()); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); waitForTaskFinish(task.getOid(), true); @@ -2681,10 +2597,9 @@ public void test712JackModifyEmptyRoleAddInducementPirateRecompute() throws Exce @Test public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws Exception { final String TEST_NAME = "test714JackModifyEmptyRoleDeleteInducementPirateRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2693,15 +2608,15 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E modifyRoleDeleteInducementTarget(ROLE_EMPTY_OID, ROLE_PIRATE_OID, getDefaultOptions()); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_EMPTY_OID, result); assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); } @@ -2709,21 +2624,20 @@ public void test714JackModifyEmptyRoleDeleteInducementPirateRecompute() throws E @Test public void test719JackUnAssignRoleEmpty() throws Exception { final String TEST_NAME = "test719JackUnAssignRoleEmpty"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_EMPTY_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2734,10 +2648,9 @@ public void test719JackUnAssignRoleEmpty() throws Exception { @Test public void test720JackAssignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test720JackAssignRoleGovernorTenantRef"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2747,15 +2660,15 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(USER_JACK_OID, ROLE_GOVERNOR_OID, task, result); + assertAssignedRole(USER_JACK_OID, ROLE_GOVERNOR_OID, result); assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true); assertDefaultDummyAccountAttribute(ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Her Excellency Governor of Scumm Bar"); @@ -2766,10 +2679,9 @@ public void test720JackAssignRoleGovernorTenantRef() throws Exception { @Test public void test729JackUnassignRoleGovernorTenantRef() throws Exception { final String TEST_NAME = "test729JackUnassignRoleGovernorTenantRef"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -2779,11 +2691,11 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignParametricRole(USER_JACK_OID, ROLE_GOVERNOR_OID, null, ORG_SCUMM_BAR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2799,27 +2711,26 @@ public void test729JackUnassignRoleGovernorTenantRef() throws Exception { @Test public void test750JackAssignRoleOmnimanager() throws Exception { final String TEST_NAME = "test750JackAssignRoleOmnimanager"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID); assertHasOrg(userAfter, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_MANAGER); assertHasOrg(userAfter, ORG_KIDNAP_AND_MARRY_ELAINE_OID, SchemaConstants.ORG_MANAGER); @@ -2831,30 +2742,29 @@ public void test750JackAssignRoleOmnimanager() throws Exception { @Test public void test755AddProjectAndRecomputeJack() throws Exception { final String TEST_NAME = "test755AddProjectAndRecomputeJack"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - assertAssignedRole(userBefore, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userBefore, ROLE_PROJECT_OMNINAMAGER_OID); addObject(ORG_PROJECT_RECLAIM_BLACK_PEARL_FILE); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, ModelExecuteOptions.createReconcile(getDefaultOptions()), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); display("User jack after", userAfter); - assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID, task, result); + assertAssignedRole(userAfter, ROLE_PROJECT_OMNINAMAGER_OID); assertHasOrg(userAfter, ORG_SAVE_ELAINE_OID, SchemaConstants.ORG_MANAGER); assertHasOrg(userAfter, ORG_KIDNAP_AND_MARRY_ELAINE_OID, SchemaConstants.ORG_MANAGER); @@ -2867,21 +2777,20 @@ public void test755AddProjectAndRecomputeJack() throws Exception { @Test public void test759JackUnassignRoleOmnimanager() throws Exception { final String TEST_NAME = "test759JackUnassignRoleOmnimanager"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_PROJECT_OMNINAMAGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2899,10 +2808,9 @@ public void test759JackUnassignRoleOmnimanager() throws Exception { @Test public void test760JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test760JackAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2915,11 +2823,11 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, false); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2936,10 +2844,9 @@ public void test760JackAssignRoleWeakGossiper() throws Exception { @Test public void test761JackRecompute() throws Exception { final String TEST_NAME = "test761JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2949,11 +2856,11 @@ public void test761JackRecompute() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -2970,10 +2877,9 @@ public void test761JackRecompute() throws Exception { @Test public void test762JackReconcile() throws Exception { final String TEST_NAME = "test762JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -2983,11 +2889,11 @@ public void test762JackReconcile() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -3004,9 +2910,8 @@ public void test762JackReconcile() throws Exception { @Test public void test763PreviewChanges() throws Exception { final String TEST_NAME = "test763PreviewChanges"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -3019,11 +2924,11 @@ public void test763PreviewChanges() throws Exception { ); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext context = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Preview context", context); @@ -3064,10 +2969,9 @@ public void test763PreviewChanges() throws Exception { @Test public void test764JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test764JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3076,11 +2980,11 @@ public void test764JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3104,10 +3008,9 @@ public void test764JackAssignRoleSailor() throws Exception { @Test public void test765JackRecompute() throws Exception { final String TEST_NAME = "test765JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3115,11 +3018,11 @@ public void test765JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3143,10 +3046,9 @@ public void test765JackRecompute() throws Exception { @Test public void test766JackReconcile() throws Exception { final String TEST_NAME = "test766JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3154,11 +3056,11 @@ public void test766JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3184,10 +3086,9 @@ public void test766JackReconcile() throws Exception { @Test public void test767JackUnAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test767JackUnAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3195,11 +3096,11 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3222,10 +3123,9 @@ public void test767JackUnAssignRoleWeakGossiper() throws Exception { @Test public void test768JackRecompute() throws Exception { final String TEST_NAME = "test768JackRecompute"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3233,11 +3133,11 @@ public void test768JackRecompute() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3260,10 +3160,9 @@ public void test768JackRecompute() throws Exception { @Test public void test769JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test762JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3271,11 +3170,11 @@ public void test769JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3295,10 +3194,9 @@ public void test769JackUnAssignRoleSailor() throws Exception { @Test public void test770JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test770JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3306,11 +3204,11 @@ public void test770JackAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3335,10 +3233,9 @@ public void test770JackAssignRoleSailor() throws Exception { @Test public void test772JackAssignRoleGossiper() throws Exception { final String TEST_NAME = "test772JackAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3346,11 +3243,11 @@ public void test772JackAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3376,10 +3273,9 @@ public void test772JackAssignRoleGossiper() throws Exception { @Test public void test774JackUnAssignRoleSailor() throws Exception { final String TEST_NAME = "test774JackUnAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3387,11 +3283,11 @@ public void test774JackUnAssignRoleSailor() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3411,10 +3307,9 @@ public void test774JackUnAssignRoleSailor() throws Exception { @Test public void test775JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test775JackUnAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3422,11 +3317,11 @@ public void test775JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3439,7 +3334,6 @@ public void test775JackUnAssignRoleGossiper() throws Exception { } - /** * Assign both roles together (weak and normal). * MID-2850 @@ -3447,17 +3341,15 @@ public void test775JackUnAssignRoleGossiper() throws Exception { @Test public void test778JackAssignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test778JackAssignRoleGossiperAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); userDelta.addModification(createAssignmentModification(ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, @@ -3465,11 +3357,11 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3494,17 +3386,15 @@ public void test778JackAssignRoleGossiperAndSailor() throws Exception { @Test public void test779JackUnassignRoleGossiperAndSailor() throws Exception { final String TEST_NAME = "test779JackUnassignRoleGossiperAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, false); userDelta.addModification(createAssignmentModification(ROLE_SAILOR_OID, RoleType.COMPLEX_TYPE, @@ -3512,11 +3402,11 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3535,10 +3425,9 @@ public void test779JackUnassignRoleGossiperAndSailor() throws Exception { @Test public void test780JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3549,11 +3438,11 @@ public void test780JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3573,10 +3462,9 @@ public void test780JackAssignRoleWeakSinger() throws Exception { @Test public void test781JackAssignRoleWeakGossiper() throws Exception { final String TEST_NAME = "test781JackAssignRoleWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3587,11 +3475,11 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3611,10 +3499,9 @@ public void test781JackAssignRoleWeakGossiper() throws Exception { @Test public void test782JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test782JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3623,11 +3510,11 @@ public void test782JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3654,10 +3541,9 @@ public void test782JackAssignRoleSailor() throws Exception { @Test public void test783JackUnassignRoleSailor() throws Exception { final String TEST_NAME = "test783JackUnassignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3666,11 +3552,11 @@ public void test783JackUnassignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_SINGER_OID); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3689,10 +3575,9 @@ public void test783JackUnassignRoleSailor() throws Exception { @Test public void test784JackUnAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test784JackUnAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3702,11 +3587,11 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3726,10 +3611,9 @@ public void test784JackUnAssignRoleWeakSinger() throws Exception { @Test public void test785JackUnAssignRoleGossiper() throws Exception { final String TEST_NAME = "test785JackUnAssignRoleGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3737,11 +3621,11 @@ public void test785JackUnAssignRoleGossiper() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3761,17 +3645,15 @@ public void test785JackUnAssignRoleGossiper() throws Exception { @Test public void test786JackAssignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test786JackAssignRoleGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); userDelta.addModification(createAssignmentModification(ROLE_WEAK_SINGER_OID, RoleType.COMPLEX_TYPE, @@ -3779,11 +3661,11 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3803,17 +3685,15 @@ public void test786JackAssignRoleGossiperAndSinger() throws Exception { @Test public void test788JackUnassignRoleGossiperAndSinger() throws Exception { final String TEST_NAME = "test788JackUnassignRoleGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User jack before", userBefore); - ObjectDelta userDelta = createAssignmentUserDelta(USER_JACK_OID, ROLE_WEAK_GOSSIPER_OID, RoleType.COMPLEX_TYPE, null, null, null, false); userDelta.addModification(createAssignmentModification(ROLE_WEAK_SINGER_OID, RoleType.COMPLEX_TYPE, @@ -3821,11 +3701,11 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3845,10 +3725,9 @@ public void test788JackUnassignRoleGossiperAndSinger() throws Exception { @Test public void test790JackAssignRoleWeakSinger() throws Exception { final String TEST_NAME = "test780JackAssignRoleWeakSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3859,11 +3738,11 @@ public void test790JackAssignRoleWeakSinger() throws Exception { assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_WEAK_SINGER_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3885,10 +3764,9 @@ public void test790JackAssignRoleWeakSinger() throws Exception { @Test public void test791JackSwitchRolesGossiperAndSinger() throws Exception { final String TEST_NAME = "test791JackSwitchRolesGossiperAndSinger"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3904,11 +3782,11 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3928,10 +3806,9 @@ public void test791JackSwitchRolesGossiperAndSinger() throws Exception { @Test public void test792JackAssignRoleSailor() throws Exception { final String TEST_NAME = "test792JackAssignRoleSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3940,11 +3817,11 @@ public void test792JackAssignRoleSailor() throws Exception { assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SAILOR_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3973,10 +3850,9 @@ public void test792JackAssignRoleSailor() throws Exception { @Test public void test793JackSwitchRolesSingerAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -3990,11 +3866,11 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4020,10 +3896,9 @@ public void test793JackSwitchRolesSingerAndGossiper() throws Exception { @Test public void test794JackSwitchRolesSailorAndGossiper() throws Exception { final String TEST_NAME = "test793JackSwitchRolesSingerAndGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4037,11 +3912,11 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4061,10 +3936,9 @@ public void test794JackSwitchRolesSailorAndGossiper() throws Exception { @Test public void test795JackSwitchRolesSingerAndSailor() throws Exception { final String TEST_NAME = "test795JackSwitchRolesSingerAndSailor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4078,11 +3952,11 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4108,10 +3982,9 @@ public void test795JackSwitchRolesSingerAndSailor() throws Exception { @Test public void test796JackSwitchRolesSailorAndGovernor() throws Exception { final String TEST_NAME = "test796JackSwitchRolesSailorAndGovernor"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4125,11 +3998,11 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4156,10 +4029,9 @@ public void test796JackSwitchRolesSailorAndGovernor() throws Exception { @Test public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { final String TEST_NAME = "test799JackUnassignGovernorAndWeakGossiper"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4173,11 +4045,11 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4192,22 +4064,21 @@ public void test799JackUnassignGovernorAndWeakGossiper() throws Exception { @Test public void test800ModifyRoleImmutable() throws Exception { final String TEST_NAME = "test800ModifyRoleImmutable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4223,21 +4094,20 @@ public void test800ModifyRoleImmutable() throws Exception { @Test public void test802AddGlobalImmutableRole() throws Exception { final String TEST_NAME = "test802AddGlobalImmutableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_GLOBAL_FILE); display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4249,22 +4119,21 @@ public void test802AddGlobalImmutableRole() throws Exception { @Test public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { final String TEST_NAME = "test804ModifyRoleImmutableGlobalIdentifier"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4277,22 +4146,21 @@ public void test804ModifyRoleImmutableGlobalIdentifier() throws Exception { @Test public void test805ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test805ModifyRoleImmutableGlobalDescription"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4309,21 +4177,20 @@ public void test805ModifyRoleImmutableGlobalDescription() throws Exception { @Test public void test812AddGlobalImmutableDescriptionRole() throws Exception { final String TEST_NAME = "test812AddGlobalImmutableDescriptionRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_FILE); display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4338,20 +4205,19 @@ public void test812AddGlobalImmutableDescriptionRole() throws Exception { @Test public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Exception { final String TEST_NAME = "test814ModifyRoleImmutableDescriptionGlobalIdentifier"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); final String NEW_VALUE = "whatever"; modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_IDENTIFIER, getDefaultOptions(), task, result, NEW_VALUE); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4363,22 +4229,21 @@ public void test814ModifyRoleImmutableDescriptionGlobalIdentifier() throws Excep @Test public void test815ModifyRoleImmutableGlobalDescription() throws Exception { final String TEST_NAME = "test815ModifyRoleImmutableGlobalDescription"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_IMMUTABLE_DESCRIPTION_GLOBAL_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4390,10 +4255,9 @@ public void test815ModifyRoleImmutableGlobalDescription() throws Exception { @Test public void test826AddNonCreateableRole() throws Exception { final String TEST_NAME = "test826AddNonCreateableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_NON_CREATEABLE_FILE); @@ -4401,13 +4265,13 @@ public void test826AddNonCreateableRole() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4418,17 +4282,16 @@ public void test826AddNonCreateableRole() throws Exception { @Test public void test826bAddCreateableRole() throws Exception { final String TEST_NAME = "test826bAddCreateableRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_CREATEABLE_FILE); display("Role before", role); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4443,10 +4306,9 @@ public void test826bAddCreateableRole() throws Exception { @Test public void test827AddImmutableAssignRole() throws Exception { final String TEST_NAME = "test827AddImmutableAssignRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = PrismTestUtil.parseObject(ROLE_IMMUTABLE_ASSIGN_FILE); @@ -4454,13 +4316,13 @@ public void test827AddImmutableAssignRole() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4476,19 +4338,18 @@ public void test827AddImmutableAssignRole() throws Exception { @Test public void test828ModifyUntouchableMetarole() throws Exception { final String TEST_NAME = "test828ModifyUntouchableMetarole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_META_UNTOUCHABLE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "Touche!"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4499,19 +4360,18 @@ public void test828ModifyUntouchableMetarole() throws Exception { @Test public void test830ModifyRoleJudge() throws Exception { final String TEST_NAME = "test830ModifyRoleJudge"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(RoleType.class, ROLE_JUDGE_OID, RoleType.F_DESCRIPTION, getDefaultOptions(), task, result, "whatever"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4522,10 +4382,9 @@ public void test830ModifyRoleJudge() throws Exception { @Test public void test840AssignRoleNonAssignable() throws Exception { final String TEST_NAME = "test840AssignRoleNonAssignable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -4534,13 +4393,13 @@ public void test840AssignRoleNonAssignable() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_NON_ASSIGNABLE_OID, getDefaultOptions(), task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4553,10 +4412,9 @@ public void test840AssignRoleNonAssignable() throws Exception { @Test public void test850JackAssignRoleBloodyFool() throws Exception { final String TEST_NAME = "test850JackAssignRoleBloodyFool"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4564,11 +4422,11 @@ public void test850JackAssignRoleBloodyFool() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BLOODY_FOOL_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4591,10 +4449,9 @@ public void test850JackAssignRoleBloodyFool() throws Exception { @Test public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { final String TEST_NAME = "test855JackModifyFoolMetaroleDeleteInducement"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4603,11 +4460,11 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { assertInducements(roleBefore, 2); // WHEN - displayWhen(TEST_NAME); + when(); modifyRoleDeleteInducement(ROLE_META_FOOL_OID, 10002L, false, getDefaultOptions(), task); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4619,10 +4476,9 @@ public void test855JackModifyFoolMetaroleDeleteInducement() throws Exception { @Test public void test857JackReconcile() throws Exception { final String TEST_NAME = "test857JackReconcile"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4630,11 +4486,11 @@ public void test857JackReconcile() throws Exception { display("User jack before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -4660,23 +4516,22 @@ public void test857JackReconcile() throws Exception { @Test public void test870AssignRoleScreaming() throws Exception { final String TEST_NAME = "test870AssignRoleScreaming"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); notificationManager.setDisabled(false); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); display("user jack", userJackBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SCREAMING_OID, getDefaultOptions(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userJackAfter = getUser(USER_JACK_OID); @@ -4691,17 +4546,16 @@ public void test870AssignRoleScreaming() throws Exception { /** * MID-4132: the global policy rules immutable-user-from-pluto-XXX selection is based on current object state * (not the new one) so it is _not_ selected in the primary state. - * + *

* So, this test basically confirms the behavior described in MID-4132. * If this behavior changes, so should this test. */ @Test public void test880GlobalRuleOnChange() throws Exception { final String TEST_NAME = "test880GlobalRuleOnChange"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJackBefore = getUser(USER_JACK_OID); @@ -4713,27 +4567,26 @@ public void test880GlobalRuleOnChange() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); executeChangesAssertSuccess(delta, getDefaultOptions(), task, result); } @Test(enabled = false) // MID-4856 public void test890DeleteRoleUndeletable() throws Exception { final String TEST_NAME = "test890DeleteRoleUndeletable"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(RoleType.class, ROLE_UNDELETABLE_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); } @@ -4742,20 +4595,19 @@ public void test890DeleteRoleUndeletable() throws Exception { @Test // MID-4856 public void test892DeleteRoleUndeletableGlobal() throws Exception { final String TEST_NAME = "test892DeleteRoleUndeletableGlobal"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(RoleType.class, ROLE_UNDELETABLE_GLOBAL_OID, task, result); AssertJUnit.fail("Unexpected success"); } catch (PolicyViolationException e) { // THEN - displayThen(TEST_NAME); + then(); System.out.println("Got expected exception: " + e.getMessage()); result.computeStatus(); TestUtil.assertFailure(result); @@ -4765,10 +4617,9 @@ public void test892DeleteRoleUndeletableGlobal() throws Exception { @Test public void test900ModifyDetectingRole() throws Exception { final String TEST_NAME = "test900ModifyDetectingRole"; - displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -4776,14 +4627,14 @@ public void test900ModifyDetectingRole() throws Exception { display("Role before", roleBefore); // WHEN - displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(RoleType.class) .item(RoleType.F_NAME).replace(PolyString.fromOrig("modified")) .asObjectDeltaCast(ROLE_DETECTING_MODIFICATIONS_OID); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java index 3913af56336..bbad6e9095e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/rbac/TestSegregationOfDuties.java @@ -187,9 +187,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test110SimpleExclusion1() throws Exception { final String TEST_NAME = "test110SimpleExclusion1"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -220,9 +219,8 @@ public void test110SimpleExclusion1() throws Exception { @Test public void test120SimpleExclusion2() throws Exception { final String TEST_NAME = "test120SimpleExclusion2"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -245,9 +243,8 @@ public void test120SimpleExclusion2() throws Exception { @Test public void test130SimpleExclusionBoth1() throws Exception { final String TEST_NAME = "test130SimpleExclusionBoth1"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -270,9 +267,8 @@ public void test130SimpleExclusionBoth1() throws Exception { @Test public void test140SimpleExclusionBoth2() throws Exception { final String TEST_NAME = "test140SimpleExclusionBoth2"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -295,9 +291,8 @@ public void test140SimpleExclusionBoth2() throws Exception { @Test public void test150SimpleExclusionBothBidirectional1() throws Exception { final String TEST_NAME = "test150SimpleExclusionBothBidirectional1"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -320,9 +315,8 @@ public void test150SimpleExclusionBothBidirectional1() throws Exception { @Test public void test160SimpleExclusionBothBidirectional2() throws Exception { final String TEST_NAME = "test160SimpleExclusionBothBidirectional2"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -345,9 +339,8 @@ public void test160SimpleExclusionBothBidirectional2() throws Exception { @Test public void test171SimpleExclusion1WithPolicyException() throws Exception { final String TEST_NAME = "test171SimpleExclusion1WithPolicyException"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); @@ -367,9 +360,8 @@ public void test171SimpleExclusion1WithPolicyException() throws Exception { @Test public void test172SimpleExclusion2WithPolicyException() throws Exception { final String TEST_NAME = "test172SimpleExclusion2WithPolicyException"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, null, getJudgeExceptionBlock(ROLE_PIRATE_NAME), task, result); @@ -389,9 +381,8 @@ public void test172SimpleExclusion2WithPolicyException() throws Exception { @Test public void test173SimpleExclusion3WithPolicyException() throws Exception { final String TEST_NAME = "test173SimpleExclusion3WithPolicyException"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -411,9 +402,8 @@ public void test173SimpleExclusion3WithPolicyException() throws Exception { @Test public void test174SimpleExclusion4WithPolicyException() throws Exception { final String TEST_NAME = "test174SimpleExclusion4WithPolicyException"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, null, getJudgeExceptionBlock(ROLE_PIRATE_NAME), task, result); @@ -438,9 +428,8 @@ public void test174SimpleExclusion4WithPolicyException() throws Exception { @Test public void test180JudgeExceptionalPirateAndThief() throws Exception { final String TEST_NAME = "test180JudgeExceptionalPirateAndThief"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_JUDGE_OID, task, result); @@ -478,9 +467,8 @@ private Consumer getJudgeExceptionBlock(String excludedRoleName) @Test public void test190DifferentRelations() throws Exception { final String TEST_NAME = "test190DifferentRelations"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -502,9 +490,8 @@ public void test190DifferentRelations() throws Exception { @Test public void test193BothRelationsApprover() throws Exception { final String TEST_NAME = "test193BothRelationsApprover"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -526,9 +513,8 @@ public void test193BothRelationsApprover() throws Exception { @Test public void test194MemberAndManager() throws Exception { final String TEST_NAME = "test194MemberAndManager"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Collection> modifications = new ArrayList<>(); @@ -557,18 +543,17 @@ public void test194MemberAndManager() throws Exception { @Test public void test200GuybrushAssignRoleGold() throws Exception { final String TEST_NAME = "test200GuybrushAssignRoleGold"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_GOLD_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -591,18 +576,17 @@ public void test200GuybrushAssignRoleGold() throws Exception { @Test public void test202GuybrushAssignRoleSilver() throws Exception { final String TEST_NAME = "test202GuybrushAssignRoleSilver"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_SILVER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -626,18 +610,17 @@ public void test202GuybrushAssignRoleSilver() throws Exception { @Test public void test204GuybrushAssignRoleSailor() throws Exception { final String TEST_NAME = "test204GuybrushAssignRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -662,18 +645,17 @@ public void test204GuybrushAssignRoleSailor() throws Exception { @Test public void test206GuybrushAssignRoleBronze() throws Exception { final String TEST_NAME = "test206GuybrushAssignRoleBronze"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -697,18 +679,17 @@ public void test206GuybrushAssignRoleBronze() throws Exception { @Test public void test208GuybrushUnassignRoleBronze() throws Exception { final String TEST_NAME = "test208GuybrushUnassignRoleSilver"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_PRIZE_BRONZE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -730,18 +711,17 @@ public void test208GuybrushUnassignRoleBronze() throws Exception { @Test public void test209GuybrushUnassignRoleSailor() throws Exception { final String TEST_NAME = "test209GuybrushUnassignRoleSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_SAILOR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -761,14 +741,13 @@ public void test209GuybrushUnassignRoleSailor() throws Exception { @Test public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { final String TEST_NAME = "test209aGuybrushAssignRoleGoldAndSilverEnforced"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_PRIZE_GOLD_ENFORCED_OID, ObjectTypes.ROLE, prismContext), @@ -794,14 +773,13 @@ public void test209aGuybrushAssignRoleGoldAndSilverEnforced() throws Exception { @Test public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { final String TEST_NAME = "test209bGuybrushAssignRoleGoldAndSilver"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_PRIZE_GOLD_OID, ObjectTypes.ROLE, prismContext), @@ -827,18 +805,17 @@ public void test209bGuybrushAssignRoleGoldAndSilver() throws Exception { @Test public void test210GuybrushAssignRoleRed() throws Exception { final String TEST_NAME = "test210GuybrushAssignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -859,18 +836,17 @@ public void test210GuybrushAssignRoleRed() throws Exception { @Test public void test212GuybrushAssignRoleGreen() throws Exception { final String TEST_NAME = "test212GuybrushAssignRoleGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_GREEN_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -892,18 +868,17 @@ public void test212GuybrushAssignRoleGreen() throws Exception { @Test public void test214GuybrushAssignRoleColorNone() throws Exception { final String TEST_NAME = "test214GuybrushAssignRoleColorNone"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_NONE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -923,18 +898,17 @@ public void test214GuybrushAssignRoleColorNone() throws Exception { @Test public void test216GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test216GuybrushAssignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -953,18 +927,17 @@ public void test216GuybrushAssignRoleBlue() throws Exception { @Test public void test219GuybrushUnassignRoleBlue() throws Exception { final String TEST_NAME = "test219GuybrushUnassignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -981,18 +954,17 @@ public void test219GuybrushUnassignRoleBlue() throws Exception { @Test public void test220GuybrushAssignRoleBlue() throws Exception { final String TEST_NAME = "test220GuybrushAssignRoleBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_BLUE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1014,10 +986,9 @@ public void test220GuybrushAssignRoleBlue() throws Exception { @Test public void test221GuybrushDestroyAndRecompute() throws Exception { final String TEST_NAME = "test221GuybrushDestroyAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1028,11 +999,11 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1055,10 +1026,9 @@ public void test221GuybrushDestroyAndRecompute() throws Exception { @Test public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { final String TEST_NAME = "test222GuybrushDestroyAndAssignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_GUYBRUSH_OID); @@ -1069,11 +1039,11 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result, 2); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1093,18 +1063,17 @@ public void test222GuybrushDestroyAndAssignRoleRed() throws Exception { @Test public void test229GuybrushUnassignRoleRed() throws Exception { final String TEST_NAME = "test229GuybrushUnassignRoleRed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_COLOR_RED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1124,14 +1093,13 @@ public void test229GuybrushUnassignRoleRed() throws Exception { @Test public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { final String TEST_NAME = "test230GuybrushAssignRoleRedAndBlueAndGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(ROLE_COLOR_RED_OID, ObjectTypes.ROLE, prismContext), @@ -1158,18 +1126,17 @@ public void test230GuybrushAssignRoleRedAndBlueAndGreen() throws Exception { @Test public void test240GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test240GuybrushAssignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1183,10 +1150,9 @@ public void test240GuybrushAssignRoleExecutiveOne() throws Exception { @Test public void test242GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test242GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1202,18 +1168,17 @@ public void test242GuybrushAssignRoleControllingOne() throws Exception { @Test public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test244GuybrushAssignRoleExecutiveTwo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1228,10 +1193,9 @@ public void test244GuybrushAssignRoleExecutiveTwo() throws Exception { @Test public void test245GuybrushAssignRoleControllingTwo() throws Exception { final String TEST_NAME = "test245GuybrushAssignRoleControllingTwo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1249,18 +1213,17 @@ public void test245GuybrushAssignRoleControllingTwo() throws Exception { @Test public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test246GuybrushUnassignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1274,10 +1237,9 @@ public void test246GuybrushUnassignRoleExecutiveOne() throws Exception { @Test public void test247GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test247GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1295,18 +1257,17 @@ public void test247GuybrushAssignRoleControllingOne() throws Exception { @Test public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { final String TEST_NAME = "test249GuybrushUnassignRoleExecutiveTwo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EXECUTIVE_2_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1323,18 +1284,17 @@ public void test249GuybrushUnassignRoleExecutiveTwo() throws Exception { @Test public void test250GuybrushAssignRoleControllingOne() throws Exception { final String TEST_NAME = "test250GuybrushAssignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1348,10 +1308,9 @@ public void test250GuybrushAssignRoleControllingOne() throws Exception { @Test public void test252GuybrushAssignRoleExecutiveOne() throws Exception { final String TEST_NAME = "test252GuybrushAssignRoleExecutiveOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1367,18 +1326,17 @@ public void test252GuybrushAssignRoleExecutiveOne() throws Exception { @Test public void test259GuybrushUnassignRoleControllingOne() throws Exception { final String TEST_NAME = "test259GuybrushUnassignRoleControllingOne"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CONTROLLING_1_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1392,18 +1350,17 @@ public void test259GuybrushUnassignRoleControllingOne() throws Exception { @Test public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { final String TEST_NAME = "test800ApplyGlobalPolicyRulesExclusion"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_EXCLUSION_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1414,18 +1371,17 @@ public void test800ApplyGlobalPolicyRulesExclusion() throws Exception { @Test public void test810GuybrushAssignRoleCitizenSk() throws Exception { final String TEST_NAME = "test810GuybrushAssignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1436,10 +1392,9 @@ public void test810GuybrushAssignRoleCitizenSk() throws Exception { @Test public void test812GuybrushAssignRoleCitizenUs() throws Exception { final String TEST_NAME = "test812GuybrushAssignRoleCitizenUs"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1455,18 +1410,17 @@ public void test812GuybrushAssignRoleCitizenUs() throws Exception { @Test public void test814GuybrushAssignRoleEmpty() throws Exception { final String TEST_NAME = "test814GuybrushAssignRoleEmpty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1478,18 +1432,17 @@ public void test814GuybrushAssignRoleEmpty() throws Exception { @Test public void test818GuybrushUnassignRoleCitizenSk() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CITIZEN_SK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1503,18 +1456,17 @@ public void test818GuybrushUnassignRoleCitizenSk() throws Exception { @Test public void test819GuybrushUnassignRoleEmpty() throws Exception { final String TEST_NAME = "test818GuybrushUnassignRoleCitizenSk"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_EMPTY_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1529,18 +1481,17 @@ public void test819GuybrushUnassignRoleEmpty() throws Exception { @Test public void test820GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test820GuybrushAssignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1555,18 +1506,17 @@ public void test820GuybrushAssignRoleCriminal() throws Exception { @Test public void test822GuybrushAssignRoleMinister() throws Exception { final String TEST_NAME = "test822GuybrushAssignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1580,18 +1530,17 @@ public void test822GuybrushAssignRoleMinister() throws Exception { @Test public void test826GuybrushUnassignRoleCriminal() throws Exception { final String TEST_NAME = "test826GuybrushUnassignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1603,18 +1552,17 @@ public void test826GuybrushUnassignRoleCriminal() throws Exception { @Test public void test829GuybrushUnassignRoleMinister() throws Exception { final String TEST_NAME = "test829GuybrushUnassignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_GUYBRUSH_OID, ROLE_MINISTER_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1626,18 +1574,17 @@ public void test829GuybrushUnassignRoleMinister() throws Exception { @Test public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { final String TEST_NAME = "test900ApplyGlobalPolicyRulesSoDApproval"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); transplantGlobalPolicyRulesAdd(CONFIG_WITH_GLOBAL_RULES_SOD_APPROVAL_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); List globalPolicyRules = getSystemConfiguration().getGlobalPolicyRule(); @@ -1653,18 +1600,17 @@ public void test900ApplyGlobalPolicyRulesSoDApproval() throws Exception { @Test public void test920GuybrushAssignRoleCriminal() throws Exception { final String TEST_NAME = "test920GuybrushAssignRoleCriminal"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_CRIMINAL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -1683,21 +1629,20 @@ public void test920GuybrushAssignRoleCriminal() throws Exception { @Test public void test922GuybrushPreviewAssignRoleMinister() throws Exception { final String TEST_NAME = "test922GuybrushPreviewAssignRoleMinister"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = createAssignmentAssignmentHolderDelta(UserType.class, USER_GUYBRUSH_OID, ROLE_MINISTER_OID, RoleType.COMPLEX_TYPE, null, null, null, true); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Preview context", modelContext); @@ -1761,18 +1706,17 @@ private EvaluatedPolicyRule getEvaluatedPolicyRule(Collection userAfter = getUser(USER_GUYBRUSH_OID); @@ -1791,9 +1735,8 @@ public void test929GuybrushUnassignRoleCriminal() throws Exception { @Test(enabled = false) public void test950JackSelfExclusion() throws Exception { final String TEST_NAME = "test950JackSelfExclusion"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -1823,9 +1766,8 @@ public void test950JackSelfExclusion() throws Exception { @Test public void test952JackSelfExclusionManagerMember() throws Exception { final String TEST_NAME = "test952JackSelfExclusionManagerMember"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // This should go well @@ -1854,9 +1796,8 @@ public void test952JackSelfExclusionManagerMember() throws Exception { @Test public void test960JimGoldByMapping() throws Exception { final String TEST_NAME = "test960JimGoldByMapping"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -1869,12 +1810,12 @@ public void test960JimGoldByMapping() throws Exception { addObject(jim.asPrismObject()); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(jim.getOid(), ROLE_PRIZE_GOLD_BY_MAPPING_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1890,7 +1831,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u try { // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userOid, roleOid, task, result); assertNotReached(); @@ -1899,7 +1840,7 @@ private PrismObject assignRolePolicyFailure(String TEST_NAME, String u System.out.println("Got expected exception: " + e.getMessage()); // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java index d8a71676fe5..47309a9d71e 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/scripting/TestScriptingBasic.java @@ -147,10 +147,9 @@ protected File getSystemConfigurationFile() { @Test public void test100EmptySequence() throws Exception { final String TEST_NAME = "test100EmptySequence"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExpressionSequenceType sequence = new ExpressionSequenceType(); @@ -167,10 +166,9 @@ public void test100EmptySequence() throws Exception { @Test public void test110EmptyPipeline() throws Exception { final String TEST_NAME = "test110EmptyPipeline"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExpressionPipelineType pipeline = new ExpressionPipelineType(); @@ -187,7 +185,6 @@ public void test110EmptyPipeline() throws Exception { @Test public void test112Echo() throws Exception { final String TEST_NAME = "test112Echo"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -210,10 +207,9 @@ public void test112Echo() throws Exception { @Test public void test120Log() throws Exception { final String TEST_NAME = "test120Log"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty logAction = parseAnyData(LOG_FILE); @@ -244,10 +240,9 @@ private T parseRealValue(File file) throws IOException, SchemaException { @Test public void test200SearchUser() throws Exception { final String TEST_NAME = "test200SearchUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_FILE); @@ -265,10 +260,9 @@ public void test200SearchUser() throws Exception { @Test public void test202SearchUserWithExpressions() throws Exception { final String TEST_NAME = "test202SearchUserWithExpressions"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ExecuteScriptType executeScript = prismContext.parserFor(SEARCH_FOR_USERS_WITH_EXPRESSIONS_FILE).parseRealValue(); VariablesMap variables = new VariablesMap(); @@ -292,10 +286,9 @@ public void test202SearchUserWithExpressions() throws Exception { @Test public void test205SearchForResources() throws Exception { final String TEST_NAME = "test205SearchForResources"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_RESOURCES_FILE); @@ -312,10 +305,9 @@ public void test205SearchForResources() throws Exception { @Test public void test206SearchForRoles() throws Exception { final String TEST_NAME = "test206SearchForRoles"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_ROLES_FILE); @@ -332,10 +324,9 @@ public void test206SearchForRoles() throws Exception { @Test public void test210SearchForShadows() throws Exception { final String TEST_NAME = "test210SearchForShadows"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_SHADOWS_FILE); @@ -353,10 +344,9 @@ public void test210SearchForShadows() throws Exception { @Test public void test215SearchForShadowsNoFetch() throws Exception { final String TEST_NAME = "test215SearchForShadowsNoFetch"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_SHADOWS_NOFETCH_FILE); @@ -374,10 +364,9 @@ public void test215SearchForShadowsNoFetch() throws Exception { @Test public void test220SearchForUsersAccounts() throws Exception { final String TEST_NAME = "test220SearchForUsersAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_FILE); @@ -395,10 +384,9 @@ public void test220SearchForUsersAccounts() throws Exception { @Test public void test225SearchForUsersAccountsNoFetch() throws Exception { final String TEST_NAME = "test225SearchForUsersAccountsNoFetch"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_NOFETCH_FILE); @@ -416,10 +404,9 @@ public void test225SearchForUsersAccountsNoFetch() throws Exception { @Test public void test300DisableJack() throws Exception { final String TEST_NAME = "test300DisableJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(DISABLE_JACK_FILE); @@ -438,10 +425,9 @@ public void test300DisableJack() throws Exception { @Test public void test310EnableJack() throws Exception { final String TEST_NAME = "test310EnableJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ENABLE_JACK_FILE); @@ -460,10 +446,9 @@ public void test310EnableJack() throws Exception { @Test public void test320DeleteAndAddJack() throws Exception { final String TEST_NAME = "test320DeleteAndAddJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(DELETE_AND_ADD_JACK_FILE); @@ -482,10 +467,9 @@ public void test320DeleteAndAddJack() throws Exception { @Test public void test330ModifyJack() throws Exception { final String TEST_NAME = "test330ModifyJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(MODIFY_JACK_FILE); @@ -504,10 +488,9 @@ public void test330ModifyJack() throws Exception { @Test public void test340ModifyJackBack() throws Exception { final String TEST_NAME = "test340ModifyJackBack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(MODIFY_JACK_BACK_FILE); @@ -526,10 +509,9 @@ public void test340ModifyJackBack() throws Exception { @Test public void test350RecomputeJack() throws Exception { final String TEST_NAME = "test350RecomputeJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(RECOMPUTE_JACK_FILE); @@ -547,10 +529,9 @@ public void test350RecomputeJack() throws Exception { @Test public void test360AssignToJack() throws Exception { final String TEST_NAME = "test360AssignToJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_JACK_FILE); @@ -572,7 +553,6 @@ public void test360AssignToJack() throws Exception { @Test public void test370AssignToJackInBackground() throws Exception { final String TEST_NAME = "test370AssignToJackInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -597,7 +577,6 @@ public void test370AssignToJackInBackground() throws Exception { @Test public void test380DisableJackInBackgroundSimple() throws Exception { final String TEST_NAME = "test380DisableJackInBackgroundSimple"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -623,10 +602,9 @@ public void test380DisableJackInBackgroundSimple() throws Exception { @Test public void test390AssignToWill() throws Exception { final String TEST_NAME = "test390AssignToWill"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_WILL_FILE); @@ -646,10 +624,9 @@ public void test390AssignToWill() throws Exception { @Test public void test391UnassignFromWill() throws Exception { final String TEST_NAME = "test391UnassignFromJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_FILE); @@ -671,10 +648,9 @@ public void test391UnassignFromWill() throws Exception { @Test public void test392UnassignFromWill2() throws Exception { final String TEST_NAME = "test392UnassignFromWill2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_2_FILE); @@ -696,10 +672,9 @@ public void test392UnassignFromWill2() throws Exception { @Test public void test393UnassignFromWill3() throws Exception { final String TEST_NAME = "test393UnassignFromWill3"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(UNASSIGN_FROM_WILL_3_FILE); @@ -721,12 +696,11 @@ public void test393UnassignFromWill3() throws Exception { @Test public void test394AssignToWill2() throws Exception { final String TEST_NAME = "test394AssignToWill2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN QName customRelation = new QName("http://midpoint.evolveum.com/xml/ns/samples/piracy", "piracy:captain"); - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(ASSIGN_TO_WILL_2_FILE); @@ -758,10 +732,9 @@ public void test394AssignToWill2() throws Exception { @Test public void test400PurgeSchema() throws Exception { final String TEST_NAME = "test400PurgeSchema"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(PURGE_DUMMY_BLACK_SCHEMA_FILE); @@ -793,10 +766,9 @@ public void test400PurgeSchema() throws Exception { @Test public void test410TestResource() throws Exception { final String TEST_NAME = "test410TestResource"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(TEST_DUMMY_RESOURCE_FILE); @@ -816,10 +788,9 @@ public void test410TestResource() throws Exception { @Test public void test420NotificationAboutJack() throws Exception { final String TEST_NAME = "test420NotificationAboutJack"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(NOTIFICATION_ABOUT_JACK_FILE); prepareNotifications(); @@ -844,10 +815,9 @@ public void test420NotificationAboutJack() throws Exception { @Test public void test430NotificationAboutJackType2() throws Exception { final String TEST_NAME = "test430NotificationAboutJackType2"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(NOTIFICATION_ABOUT_JACK_TYPE2_FILE); prepareNotifications(); @@ -877,10 +847,9 @@ public void test430NotificationAboutJackType2() throws Exception { @Test public void test500ScriptingUsers() throws Exception { final String TEST_NAME = "test500ScriptingUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SCRIPTING_USERS_FILE); @@ -909,10 +878,9 @@ public void test500ScriptingUsers() throws Exception { @Test public void test505ScriptingUsersInBackground() throws Exception { final String TEST_NAME = "test505ScriptingUsersInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_FILE).parseRealValue(); @@ -954,10 +922,9 @@ public void test505ScriptingUsersInBackground() throws Exception { @Test public void test507ScriptingUsersInBackgroundAssign() throws Exception { final String TEST_NAME = "test507ScriptingUsersInBackgroundAssign"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_ASSIGN_FILE).parseRealValue(); @@ -993,10 +960,9 @@ public void test507ScriptingUsersInBackgroundAssign() throws Exception { @Test public void test510GeneratePasswords() throws Exception { final String TEST_NAME = "test510GeneratePasswords"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(GENERATE_PASSWORDS_FILE); @@ -1035,7 +1001,6 @@ public void test510GeneratePasswords() throws Exception { @Test public void test520GeneratePasswordsFullInput() throws Exception { final String TEST_NAME = "test520GeneratePasswordsFullInput"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1061,7 +1026,6 @@ public void test520GeneratePasswordsFullInput() throws Exception { @Test public void test530GeneratePasswordsReally() throws Exception { final String TEST_NAME = "test530GeneratePasswordsReally"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1103,10 +1067,9 @@ private void checkPassword(PipelineItem item, String userOid) @Test public void test540SearchUserResolveNamesForRoleMembershipRef() throws Exception { final String TEST_NAME = "test540SearchUserResolveNamesForRoleMembershipRef"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_RESOLVE_NAMES_FOR_ROLE_MEMBERSHIP_REF_FILE); @@ -1129,10 +1092,9 @@ public void test540SearchUserResolveNamesForRoleMembershipRef() throws Exception @Test public void test545SearchUserResolveRoleMembershipRef() throws Exception { final String TEST_NAME = "test545SearchUserResolveRoleMembershipRef"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismProperty expression = parseAnyData(SEARCH_FOR_USERS_RESOLVE_ROLE_MEMBERSHIP_REF_FILE); @@ -1155,7 +1117,6 @@ public void test545SearchUserResolveRoleMembershipRef() throws Exception { @Test public void test550UseVariables() throws Exception { final String TEST_NAME = "test550UseVariables"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1186,10 +1147,9 @@ public void test550UseVariables() throws Exception { @Test public void test560StartTaskFromTemplate() throws Exception { final String TEST_NAME = "test560StartTaskFromTemplate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); repoAddObjectFromFile(SCRIPTING_USERS_IN_BACKGROUND_TASK_FILE, result); @@ -1235,10 +1195,9 @@ public void test560StartTaskFromTemplate() throws Exception { @Test public void test570IterativeScriptingTask() throws Exception { final String TEST_NAME = "test570IterativeScriptingTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String taskOid = repoAddObjectFromFile(SCRIPTING_USERS_IN_BACKGROUND_ITERATIVE_TASK_FILE, result).getOid(); @@ -1257,10 +1216,9 @@ public void test570IterativeScriptingTask() throws Exception { @Test(enabled = false) // probably obsolete public void test575ResumeTask() throws Exception { final String TEST_NAME = "test570ResumeTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(DOT_CLASS + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -1291,7 +1249,6 @@ public void test575ResumeTask() throws Exception { @Test public void test600ModifyJackPasswordInBackground() throws Exception { final String TEST_NAME = "test600ModifyJackPasswordInBackground"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME); @@ -1326,7 +1283,6 @@ public void test600ModifyJackPasswordInBackground() throws Exception { @Test public void test610ModifyJackPasswordImportingTask() throws Exception { final String TEST_NAME = "test610ModifyJackPasswordImportingTask"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task opTask = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); @@ -1365,7 +1321,6 @@ public void test610ModifyJackPasswordImportingTask() throws Exception { @Test public void test620ModifyJackPasswordViaExecuteChangesAsynchronously() throws Exception { final String TEST_NAME = "test620ModifyJackPasswordViaExecuteChangesAsynchronously"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task opTask = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java index e6581d957ae..df25b1bac44 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/AbstractSecurityTest.java @@ -8,7 +8,6 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertFalse; @@ -526,7 +525,6 @@ protected int getNumberOfRoles() { @Test public void test010SanitySelf() throws Exception { final String TEST_NAME = "test010SanitySelf"; - TestUtil.displayTestTitle(this, TEST_NAME); assertLoggedInUsername(USER_ADMINISTRATOR_USERNAME); // WHEN @@ -550,7 +548,6 @@ public void test010SanitySelf() throws Exception { @Test public void test020SanityArchetypedRoles() throws Exception { final String TEST_NAME = "test020SanityArchetypedRoles"; - TestUtil.displayTestTitle(this, TEST_NAME); assertLoggedInUsername(USER_ADMINISTRATOR_USERNAME); // WHEN, THEN @@ -1102,7 +1099,7 @@ protected void assertCanSearchRoleMembers(String roleOid, boolean expectedResult } protected void assertCanSearch(String message, Class resultType, Class objectType, String objectOid, boolean includeSpecial, ObjectQuery query, boolean expectedResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertCanSearch"); + Task task = createPlainTask("assertCanSearch"); OperationResult result = task.getResult(); String opName = "canSearch("+message+")"; logAttempt(opName); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java index 1303d147a98..db98a3d791c 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityAdvanced.java @@ -6,24 +6,26 @@ */ package com.evolveum.midpoint.model.intest.security; +import static org.testng.AssertJUnit.*; + import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; +import com.evolveum.midpoint.prism.PrismContainer; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismObjectDefinition; +import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.TypeFilter; @@ -40,22 +42,13 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; - -import static org.testng.AssertJUnit.*; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestSecurityAdvanced extends AbstractSecurityTest { @@ -167,12 +160,11 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -190,13 +182,12 @@ public void test000Sanity() throws Exception { * Simple end-user password change. But clear Jack's credentials before * the change. Make sure all password metadata is set correctly. * This also sets the stage for following persona tests. - * + *

* MID-4830 */ @Test public void test080AutzJackEndUserPassword() throws Exception { final String TEST_NAME = "test080AutzJackEndUserPassword"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -217,13 +208,13 @@ public void test080AutzJackEndUserPassword() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow("set jack's password", - (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result) ); + (task, result) -> modifyUserSetPassword(USER_JACK_OID, "nbusr123", task, result)); // THEN - displayThen(TEST_NAME); + then(); XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); @@ -240,14 +231,13 @@ public void test080AutzJackEndUserPassword() throws Exception { @Test public void test100AutzJackPersonaManagement() throws Exception { final String TEST_NAME = "test100AutzJackPersonaManagement"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PERSONA_MANAGEMENT_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -267,14 +257,13 @@ public void test100AutzJackPersonaManagement() throws Exception { @Test public void test102AutzLechuckPersonaManagement() throws Exception { final String TEST_NAME = "test102AutzLechuckPersonaManagement"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_LECHUCK_OID, 1); assignRole(USER_LECHUCK_OID, ROLE_PERSONA_MANAGEMENT_OID); login(USER_LECHUCK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -298,17 +287,16 @@ public void test102AutzLechuckPersonaManagement() throws Exception { @Test public void test110AutzJackPersonaAdmin() throws Exception { final String TEST_NAME = "test110AutzJackAddPersonaAdmin"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PERSONA_MANAGEMENT_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow("assign application role 1 to jack", - (task,result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); + (task, result) -> assignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); PrismObject userJack = assertGetAllow(UserType.class, USER_JACK_OID); display("User jack after persona assign", userJack); @@ -329,7 +317,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { assertSearch(OrgType.class, null, 0); assertAllow("modify jack givenName", - (task,result) -> modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, + (task, result) -> modifyUserReplace(USER_JACK_OID, UserType.F_GIVEN_NAME, task, result, createPolyString(USER_JACK_GIVEN_NAME_NEW))); userJack = assertGetAllow(UserType.class, USER_JACK_OID); @@ -339,7 +327,7 @@ public void test110AutzJackPersonaAdmin() throws Exception { assertEquals("Wrong jack persona givenName after change", USER_JACK_GIVEN_NAME_NEW, personaJack.asObjectable().getGivenName().getOrig()); assertAllow("unassign application role 1 to jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, task, result)); userJack = assertGetAllow(UserType.class, USER_JACK_OID); assertPersonaLinks(userJack, 0); @@ -355,7 +343,6 @@ public void test110AutzJackPersonaAdmin() throws Exception { @Test public void test120AutzJackDelagator() throws Exception { final String TEST_NAME = "test120AutzJackDelagator"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_DELEGATOR_OID); @@ -365,7 +352,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS); assertAddDeny(); @@ -380,24 +367,18 @@ public void test120AutzJackDelagator() throws Exception { assertNoAssignments(userBarbossa); assertDeny("assign business role to jack", - (task, result) -> { - assignRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, task, result); - }); + (task, result) -> assignRole(USER_JACK_OID, ROLE_BUSINESS_1_OID, task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); // Wrong direction. It should NOT work. assertDeny("delegate from Barbossa to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -418,7 +399,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -428,13 +409,11 @@ public void test120AutzJackDelagator() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -446,7 +425,7 @@ public void test120AutzJackDelagator() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -455,14 +434,10 @@ public void test120AutzJackDelagator() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } @@ -475,7 +450,6 @@ public void test120AutzJackDelagator() throws Exception { @Test public void test122AutzJackDelagatorValidity() throws Exception { final String TEST_NAME = "test122AutzJackDelagatorValidity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_DELEGATOR_OID); @@ -485,7 +459,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -502,10 +476,8 @@ public void test122AutzJackDelagatorValidity() throws Exception { // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -527,7 +499,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -556,7 +528,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -571,7 +543,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -580,17 +552,14 @@ public void test122AutzJackDelagatorValidity() throws Exception { assertModifyDeny(); assertDeleteDeny(); - login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -602,7 +571,7 @@ public void test122AutzJackDelagatorValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -611,14 +580,10 @@ public void test122AutzJackDelagatorValidity() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } @@ -631,7 +596,6 @@ public void test122AutzJackDelagatorValidity() throws Exception { @Test public void test124AutzJackDelagatorPlusValidity() throws Exception { final String TEST_NAME = "test124AutzJackDelagatorPlusValidity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_DELEGATOR_PLUS_OID); @@ -641,7 +605,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -658,10 +622,8 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { // Good direction assertAllow("delegate to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); display("Jack delegator", userJack); @@ -683,7 +645,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active yet. No access. @@ -712,7 +674,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadAllow(NUMBER_OF_ALL_USERS); @@ -741,7 +703,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); // Delegation is not active any more. No access. @@ -750,17 +712,14 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { assertModifyDeny(); assertDeleteDeny(); - login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Jack"); assertAllow("undelegate from Barbossa", - (task, result) -> { - unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, - assignment -> assignment.setActivation(activationType), task, result); - }); + (task, result) -> unassignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, + assignment -> assignment.setActivation(activationType), task, result)); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 1); @@ -772,7 +731,7 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { login(USER_BARBOSSA_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); display("Logged in as Barbossa"); assertReadDeny(); @@ -781,23 +740,17 @@ public void test124AutzJackDelagatorPlusValidity() throws Exception { assertDeleteDeny(); assertDeny("delegate to Jack", - (task, result) -> { - assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result); - }); + (task, result) -> assignDeputy(USER_JACK_OID, USER_BARBOSSA_OID, task, result)); assertDeny("delegate from Jack to Barbossa", - (task, result) -> { - assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result); - }); + (task, result) -> assignDeputy(USER_BARBOSSA_OID, USER_JACK_OID, task, result)); assertGlobalStateUntouched(); } - @Test public void test150AutzJackApproverUnassignRoles() throws Exception { final String TEST_NAME = "test150AutzJackApproverUnassignRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID); @@ -810,7 +763,7 @@ public void test150AutzJackApproverUnassignRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -842,7 +795,6 @@ public void test150AutzJackApproverUnassignRoles() throws Exception { @Test public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { final String TEST_NAME = "test151AutzJackApproverUnassignRolesAndRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID); @@ -852,7 +804,7 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertGetAllow(RoleType.class, ROLE_PERSONA_ADMIN_OID); // no assignment @@ -875,7 +827,6 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { // The appr-read-users authorization is maySkipOnSearch and the readonly role allows read. assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); - assert15xCommon(); } @@ -886,7 +837,6 @@ public void test151AutzJackApproverUnassignRolesAndRead() throws Exception { @Test public void test154AutzJackApproverRead() throws Exception { final String TEST_NAME = "test154AutzJackApproverRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_BASIC_ITEMS_OID); @@ -895,7 +845,7 @@ public void test154AutzJackApproverRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -925,18 +875,18 @@ public void test154AutzJackApproverRead() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 0); assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -952,7 +902,6 @@ public void test154AutzJackApproverRead() throws Exception { @Test public void test155AutzJackApproverSelf() throws Exception { final String TEST_NAME = "test155AutzJackApproverSelf"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -961,7 +910,7 @@ public void test155AutzJackApproverSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(RoleType.class, ROLE_ORDINARY_OID); assertGetDeny(RoleType.class, ROLE_PERSONA_ADMIN_OID); @@ -989,16 +938,16 @@ public void test155AutzJackApproverSelf() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 0); assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, PrismTestUtil.createPolyString("Captain")); @@ -1010,7 +959,6 @@ public void test155AutzJackApproverSelf() throws Exception { @Test public void test157AutzJackReadRoleMembers() throws Exception { final String TEST_NAME = "test157AutzJackReadRoleMembers"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_ROLE_MEMBERS_OID); @@ -1018,7 +966,7 @@ public void test157AutzJackReadRoleMembers() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1048,11 +996,11 @@ public void test157AutzJackReadRoleMembers() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, true); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1063,7 +1011,6 @@ public void test157AutzJackReadRoleMembers() throws Exception { @Test public void test158AutzJackReadRoleMembersWrong() throws Exception { final String TEST_NAME = "test158AutzJackReadRoleMembersWrong"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_ROLE_MEMBERS_WRONG_OID); @@ -1071,7 +1018,7 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1101,11 +1048,11 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, true); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1116,7 +1063,6 @@ public void test158AutzJackReadRoleMembersWrong() throws Exception { @Test public void test159AutzJackReadRoleMembersNone() throws Exception { final String TEST_NAME = "test159AutzJackReadRoleMembersNone"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_ROLE_MEMBERS_NONE_OID); @@ -1124,7 +1070,7 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject roleOrdinary = assertGetAllow(RoleType.class, ROLE_ORDINARY_OID); assertNoRoleMembershipRef(roleOrdinary); @@ -1154,11 +1100,11 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { assertCanSearchRoleMembers(ROLE_UNINTERESTING_OID, false); assertDeny("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1166,7 +1112,7 @@ public void test159AutzJackReadRoleMembersNone() throws Exception { assertGlobalStateUntouched(); } - private void assert15xCommon() throws Exception { + private void assert15xCommon() throws Exception { // list ordinary role members, this is allowed assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 2); @@ -1184,25 +1130,25 @@ private void assert15xCommon() throws Exception { assertCanSearchRoleMembers(ROLE_APPROVER_UNASSIGN_ROLES_OID, false); assertAllow("unassign ordinary role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_ORDINARY_OID, task, result)); assertSearch(UserType.class, createMembersQuery(UserType.class, ROLE_ORDINARY_OID), 1); // Jack is not approver of uninteresting role, so this should be denied assertDeny("unassign uninteresting role from cobb", - (task,result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result)); // Jack is not approver of uninteresting role, so this should be denied // - even though Rum Rogers is a member of a role that jack is an approver of assertDeny("unassign uninteresting role from rum", - (task,result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); + (task, result) -> unassignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result)); assertDeny("unassign approver role from jack", - (task,result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); + (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPROVER_UNASSIGN_ROLES_OID, task, result)); // Lechuck is not a member of ordinary role assertDeny("unassign ordinary role from lechuck", - (task,result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); + (task, result) -> unassignRole(USER_LECHUCK_OID, ROLE_ORDINARY_OID, task, result)); assertAddDeny(); assertModifyDeny(); @@ -1219,7 +1165,6 @@ private void assert15xCommon() throws Exception { @Test public void test200AutzJackModifyOrgunit() throws Exception { final String TEST_NAME = "test200AutzJackModifyOrgunit"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_SELF_MODIFY_ORGUNIT_OID); @@ -1229,7 +1174,7 @@ public void test200AutzJackModifyOrgunit() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1280,7 +1225,6 @@ public void test200AutzJackModifyOrgunit() throws Exception { @Test public void test202AutzJackModifyOrgunitAndAssignRole() throws Exception { final String TEST_NAME = "test202AutzJackModifyOrgunitAndAssignRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READ_SELF_MODIFY_ORGUNIT_OID); @@ -1291,7 +1235,7 @@ public void test202AutzJackModifyOrgunitAndAssignRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertAddDeny(); @@ -1355,7 +1299,6 @@ public void test202AutzJackModifyOrgunitAndAssignRole() throws Exception { @Test public void test220AutzJackRoleExpressionNoConstCenter() throws Exception { final String TEST_NAME = "test220AutzJackRoleExpressionNoConstCenter"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EXPRESSION_READ_ROLES_OID); @@ -1365,7 +1308,7 @@ public void test220AutzJackRoleExpressionNoConstCenter() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(); assertAddDeny(); @@ -1395,12 +1338,11 @@ public void test220AutzJackRoleExpressionNoConstCenter() throws Exception { @Test public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception { final String TEST_NAME = "test222AutzJackRoleExpressionConstCenterBusiness"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EXPRESSION_READ_ROLES_OID); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_COST_CENTER, task, result, "business"); @@ -1409,7 +1351,7 @@ public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(); assertAddDeny(); @@ -1438,7 +1380,6 @@ public void test222AutzJackRoleExpressionConstCenterBusiness() throws Exception @Test public void test230AttorneyCaribbeanUnlimited() throws Exception { final String TEST_NAME = "test230AttorneyCaribbeanUnlimited"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ATTORNEY_CARIBBEAN_UNLIMITED_OID); @@ -1452,14 +1393,14 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1505,7 +1446,6 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { assertGlobalStateUntouched(); } - /** * Attorney for subordinate employees, but Jack has no org. * MID-4072, MID-4205 @@ -1513,7 +1453,6 @@ public void test230AttorneyCaribbeanUnlimited() throws Exception { @Test public void test232ManagerAttorneyNoOrg() throws Exception { final String TEST_NAME = "test232ManagerAttorneyNoOrg"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ATTORNEY_MANAGER_WORKITEMS_OID); @@ -1525,14 +1464,14 @@ public void test232ManagerAttorneyNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1563,7 +1502,6 @@ public void test232ManagerAttorneyNoOrg() throws Exception { @Test public void test234ManagerAttorneyRum() throws Exception { final String TEST_NAME = "test234ManagerAttorneyRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ATTORNEY_MANAGER_WORKITEMS_OID); @@ -1572,14 +1510,14 @@ public void test234ManagerAttorneyRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1630,7 +1568,6 @@ public void test234ManagerAttorneyRum() throws Exception { @Test public void test235ManagerAttorneyRumRogersEntitled() throws Exception { final String TEST_NAME = "test234ManagerAttorneyRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ATTORNEY_MANAGER_WORKITEMS_OID); @@ -1641,14 +1578,14 @@ public void test235ManagerAttorneyRumRogersEntitled() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1699,7 +1636,6 @@ public void test235ManagerAttorneyRumRogersEntitled() throws Exception { @Test public void test236ManagerAttorneyCaribbeanRum() throws Exception { final String TEST_NAME = "test236ManagerAttorneyCaribbeanRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ATTORNEY_CARIBBEAN_UNLIMITED_OID); @@ -1712,14 +1648,14 @@ public void test236ManagerAttorneyCaribbeanRum() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); assertModifyDeny(); assertDeleteDeny(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectFilter donorFilterAll = modelInteractionService.getDonorFilter(UserType.class, null, null, task, result); @@ -1781,7 +1717,6 @@ public void test236ManagerAttorneyCaribbeanRum() throws Exception { @Test public void test250AssignRequestableSelfOtherApporver() throws Exception { final String TEST_NAME = "test250AssignRequestableSelfOtherApporver"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_SELF_REQUESTABLE_ANY_APPROVER_OID); @@ -1792,7 +1727,7 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1846,25 +1781,25 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { assertAssignableRoleSpecification(userJack) .assertSize(3) .relationDefault() - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertEq(RoleType.F_REQUESTABLE, true) - .end() - .end() - .end() + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertEq(RoleType.F_REQUESTABLE, true) + .end() + .end() + .end() .relation(SchemaConstants.ORG_APPROVER) - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertNull() - .end() - .end() - .end() + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertNull() + .end() + .end() + .end() .relation(SchemaConstants.ORG_OWNER) - .filter() - .type(RoleType.COMPLEX_TYPE) - .assertNull() - .end() - .end(); + .filter() + .type(RoleType.COMPLEX_TYPE) + .assertNull() + .end() + .end(); assertGlobalStateUntouched(); } @@ -1875,7 +1810,6 @@ public void test250AssignRequestableSelfOtherApporver() throws Exception { @Test public void test252AssignRequestableSelfOtherApporverEmptyDelta() throws Exception { final String TEST_NAME = "test252AssignRequestableSelfOtherApporverEmptyDelta"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_SELF_REQUESTABLE_ANY_APPROVER_OID); @@ -1886,7 +1820,7 @@ public void test252AssignRequestableSelfOtherApporverEmptyDelta() throws Excepti login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1947,7 +1881,6 @@ public void test252AssignRequestableSelfOtherApporverEmptyDelta() throws Excepti @Test public void test254AssignUnassignRequestableSelf() throws Exception { final String TEST_NAME = "test254AssignUnassignRequestableSelf"; - displayTestTitle(TEST_NAME); // GIVENds cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UNASSIGN_SELF_REQUESTABLE_OID); @@ -1956,7 +1889,7 @@ public void test254AssignUnassignRequestableSelf() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -1984,7 +1917,6 @@ public void test254AssignUnassignRequestableSelf() throws Exception { @Test public void test256AssignUnassignRequestableSelfEmptyDelta() throws Exception { final String TEST_NAME = "test256AssignUnassignRequestableSelfEmptyDelta"; - displayTestTitle(TEST_NAME); // GIVENds cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_UNASSIGN_SELF_REQUESTABLE_OID); @@ -1993,7 +1925,7 @@ public void test256AssignUnassignRequestableSelfEmptyDelta() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertAddDeny(); @@ -2021,14 +1953,13 @@ public void test256AssignUnassignRequestableSelfEmptyDelta() throws Exception { @Test public void test260AutzJackLimitedRoleAdministrator() throws Exception { final String TEST_NAME = "test260AutzJackLimitedRoleAdministrator"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_ROLE_ADMINISTRATOR_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2159,7 +2090,6 @@ public void test260AutzJackLimitedRoleAdministrator() throws Exception { @Test public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() throws Exception { final String TEST_NAME = "test260AutzJackLimitedRoleAdministrator"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_ROLE_ADMINISTRATOR_OID); @@ -2167,7 +2097,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -2178,7 +2108,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t assertAllow("assign application role to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 3); @@ -2189,7 +2119,7 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t assertAllow("unassign application role from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); // check ROLE_LIMITED_ROLE_ADMINISTRATOR_OID authorizations @@ -2286,14 +2216,13 @@ public void test262AutzJackLimitedRoleAdministratorAndAssignApplicationRoles() t @Test public void test264AutzJackLimitedReadRoleAdministrator() throws Exception { final String TEST_NAME = "test264AutzJackLimitedReadRoleAdministrator"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_READ_ROLE_ADMINISTRATOR_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2388,14 +2317,13 @@ public void test264AutzJackLimitedReadRoleAdministrator() throws Exception { @Test public void test266AutzJackRoleAdministrator() throws Exception { final String TEST_NAME = "test266AutzJackRoleAdministrator"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ROLE_ADMINISTRATOR_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2443,19 +2371,16 @@ public void test266AutzJackRoleAdministrator() throws Exception { assertGlobalStateUntouched(); } - - @Test public void test270AutzJackModifyPolicyException() throws Exception { final String TEST_NAME = "test270AutzJackModifyPolicyException"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MODIFY_POLICY_EXCEPTION_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2506,14 +2431,13 @@ public void test270AutzJackModifyPolicyException() throws Exception { @Test public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { final String TEST_NAME = "test272AutzJackModifyPolicyExceptionFirstRule"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MODIFY_POLICY_EXCEPTION_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2554,7 +2478,7 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { (task, result) -> { ObjectDelta roleDelta = prismContext.deltaFactory().object() .createModificationDeleteContainer(RoleType.class, ROLE_EMPTY_OID, - RoleType.F_POLICY_EXCEPTION, idOnlyPolicyException3); + RoleType.F_POLICY_EXCEPTION, idOnlyPolicyException3); roleDelta.addModificationReplaceProperty(RoleType.F_DESCRIPTION, "whatever"); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); }); @@ -2570,8 +2494,6 @@ public void test272AutzJackModifyPolicyExceptionFirstRule() throws Exception { @Test public void test274AutzJackModifyPolicyExceptionSituation() throws Exception { - final String TEST_NAME = "test274AutzJackModifyPolicyExceptionSituation"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MODIFY_POLICY_EXCEPTION_SITUATION_OID); @@ -2600,7 +2522,6 @@ public void test274AutzJackModifyPolicyExceptionSituation() throws Exception { assertDeny("delete policyException (3)", (task, result) -> modifyRoleDeletePolicyException(ROLE_EMPTY_OID, idOnlyPolicyException3, task, result)); - assertGlobalStateUntouched(); } @@ -2610,7 +2531,6 @@ public void test274AutzJackModifyPolicyExceptionSituation() throws Exception { @Test public void test280AutzJackModifyPolicyExceptionAndAssignOrg() throws Exception { final String TEST_NAME = "test280AutzJackModifyPolicyExceptionAndAssignOrg"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_ROLE_ADMINISTRATOR_OID); @@ -2618,7 +2538,7 @@ public void test280AutzJackModifyPolicyExceptionAndAssignOrg() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2647,14 +2567,13 @@ public void test280AutzJackModifyPolicyExceptionAndAssignOrg() throws Exception @Test public void test282AutzJackModifyPolicyExceptionAndAssignOrgDeny() throws Exception { final String TEST_NAME = "test282AutzJackModifyPolicyExceptionAndAssignOrgDeny"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_ROLE_ADMINISTRATOR_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2681,14 +2600,13 @@ public void test282AutzJackModifyPolicyExceptionAndAssignOrgDeny() throws Except @Test public void test283AutzJackModifyPolicyAssignOrg() throws Exception { final String TEST_NAME = "test283AutzJackModifyPolicyAssignOrg"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_ORG_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertReadDenyRaw(); @@ -2708,8 +2626,13 @@ public void test283AutzJackModifyPolicyAssignOrg() throws Exception { assertGlobalStateUntouched(); } - protected void modifyRoleAddExclusionAndAssignOrg(String roleOid, String excludedRoleOid, String orgOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = createAssignmentAssignmentHolderDelta(RoleType.class, roleOid, orgOid, OrgType.COMPLEX_TYPE, null, null, null, true); + protected void modifyRoleAddExclusionAndAssignOrg( + String roleOid, String excludedRoleOid, String orgOid, Task task, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = createAssignmentAssignmentHolderDelta( + RoleType.class, roleOid, orgOid, OrgType.COMPLEX_TYPE, null, null, null, true); PolicyRuleType exclusionPolicyRule = createExclusionPolicyRule(excludedRoleOid); AssignmentType assignment = new AssignmentType(); assignment.setPolicyRule(exclusionPolicyRule); @@ -2720,7 +2643,6 @@ protected void modifyRoleAddExclusionAndAssignOrg(String roleOid, String exclude @Test public void test300AutzJackExceptAssignment() throws Exception { final String TEST_NAME = "test300AutzJackExceptAssignment"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_EXCEPT_ASSIGNMENT_OID); @@ -2728,7 +2650,7 @@ public void test300AutzJackExceptAssignment() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2784,7 +2706,6 @@ public void test300AutzJackExceptAssignment() throws Exception { @Test public void test302AutzJackExceptAdministrativeStatus() throws Exception { final String TEST_NAME = "test302AutzJackExceptAdministrativeStatus"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_EXCEPT_ADMINISTRATIVE_STATUS_OID); @@ -2792,7 +2713,7 @@ public void test302AutzJackExceptAdministrativeStatus() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -2853,7 +2774,6 @@ public void test302AutzJackExceptAdministrativeStatus() throws Exception { @Test public void test304AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws Exception { final String TEST_NAME = "test304AutzJackPropExceptAssignmentReadSomeModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); @@ -2862,7 +2782,7 @@ public void test304AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = assertAlmostFullJackRead(2); PrismAsserts.assertPropertyValue(userJack, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED); @@ -2911,7 +2831,6 @@ public void test304AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws E @Test public void test306AutzJackPropExceptAssignmentExceptAdministrativeStatus() throws Exception { final String TEST_NAME = "test306AutzJackPropExceptAssignmentExceptAdministrativeStatus"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_EXCEPT_ADMINISTRATIVE_STATUS_OID); @@ -2920,7 +2839,7 @@ public void test306AutzJackPropExceptAssignmentExceptAdministrativeStatus() thro login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = assertAlmostFullJackRead(2); // read of administrativeStatus is not allowed be either role @@ -2969,7 +2888,6 @@ public void test306AutzJackPropExceptAssignmentExceptAdministrativeStatus() thro @Test public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws Exception { final String TEST_NAME = "test308AutzJackPropExceptAssignmentAssignApplicationRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_APPLICATION_ROLES_OID); @@ -2978,7 +2896,7 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -3028,7 +2946,7 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E assertAllow("assign application 1 role to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 3); @@ -3039,15 +2957,15 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E assertAllow("unassign application 1 role from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result) - ); + ); userJack = getUser(USER_JACK_OID); assertAssignments(userJack, 2); assertAssignableRoleSpecification(getUser(USER_JACK_OID)) .relationDefault() - .filter() - .assertClass(TypeFilter.class); + .filter() + .assertClass(TypeFilter.class); assertAllowRequestAssignmentItems(USER_JACK_OID, ROLE_APPLICATION_1_OID, SchemaConstants.PATH_ASSIGNMENT_TARGET_REF, @@ -3064,7 +2982,6 @@ public void test308AutzJackPropExceptAssignmentAssignApplicationRoles() throws E @Test public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Exception { final String TEST_NAME = "test310AutzJackPropSubtypeDenyEscapingZoneOfControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_SUBTYPE_OID); @@ -3072,22 +2989,22 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti login(USER_JACK_USERNAME); assertUserBefore(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); // WHEN - displayWhen(TEST_NAME); + when(); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); // WHEN - displayThen(TEST_NAME); + then(); assertUserAfter(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); assertGlobalStateUntouched(); } @@ -3100,7 +3017,6 @@ public void test310AutzJackPropSubtypeDenyEscapingZoneOfControl() throws Excepti @Test public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Exception { final String TEST_NAME = "test312AutzJackPropSubtypeAllowEscapingZoneOfControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_SUBTYPE_ESCAPE_OID); @@ -3108,24 +3024,24 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except login(USER_JACK_USERNAME); assertUserBefore(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype(USER_JACK_SUBTYPE); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype(USER_JACK_SUBTYPE); // WHEN - displayWhen(TEST_NAME); + when(); assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, "escape again"); assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_SUBTYPE, USER_JACK_SUBTYPE); // WHEN - displayThen(TEST_NAME); + then(); assertUserAfter(USER_JACK_OID) - .assertName(USER_JACK_USERNAME) - .assertFullName(USER_JACK_FULL_NAME) - .assertSubtype("escape"); + .assertName(USER_JACK_USERNAME) + .assertFullName(USER_JACK_FULL_NAME) + .assertSubtype("escape"); assertGlobalStateUntouched(); } @@ -3135,8 +3051,6 @@ public void test312AutzJackPropSubtypeAllowEscapingZoneOfControl() throws Except */ @Test public void test320AutzJackGuybrushValutDweller() throws Exception { - final String TEST_NAME = "test320AutzJackGuybrushValutDweller"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assertNoDummyAccount(RESOURCE_DUMMY_VAULT_NAME, USER_GUYBRUSH_USERNAME); @@ -3146,7 +3060,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userBuybrush = getUser(USER_GUYBRUSH_OID); display("Guybrush(1)", userBuybrush); @@ -3156,7 +3070,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { assertAllow("assign vault dweller role to guybrush", (task, result) -> assignRole(USER_GUYBRUSH_OID, ROLE_VAULT_DWELLER_OID, task, result) - ); + ); userBuybrush = getUser(USER_GUYBRUSH_OID); display("Guybrush(2)", userBuybrush); @@ -3171,7 +3085,7 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { assertAllow("unassign vault dweller role from guybrush", (task, result) -> unassignRole(USER_GUYBRUSH_OID, ROLE_VAULT_DWELLER_OID, task, result) - ); + ); userBuybrush = getUser(USER_GUYBRUSH_OID); assertAssignments(userBuybrush, 1); @@ -3183,13 +3097,12 @@ public void test320AutzJackGuybrushValutDweller() throws Exception { /** * We can get any users, but we can search only the CAPTAINs. - * + *

* MID-4860, MID-4654, MID-4859 */ @Test public void test330AutzJackEndUserWithPrivacy() throws Exception { final String TEST_NAME = "test330AutzJackEndUserWithPrivacy"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assertNoDummyAccount(RESOURCE_DUMMY_VAULT_NAME, USER_GUYBRUSH_USERNAME); @@ -3198,7 +3111,7 @@ public void test330AutzJackEndUserWithPrivacy() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = assertGetAllow(UserType.class, USER_JACK_OID); display("Jack", userJack); @@ -3230,13 +3143,12 @@ public void test330AutzJackEndUserWithPrivacy() throws Exception { * Superuser role should allow everything. Adding another role with any (allow) * authorizations should not limit superuser. Not even if those authorizations * are completely loony. - * + *

* MID-4931 */ @Test public void test340AutzJackSuperUserAndExecRead() throws Exception { final String TEST_NAME = "test340AutzJackSuperUserAndExecRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3251,7 +3163,7 @@ public void test340AutzJackSuperUserAndExecRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertSearch(UserType.class, createOrgSubtreeQuery(ORG_MINISTRY_OF_OFFENSE_OID), USER_LECHUCK_OID, USER_GUYBRUSH_OID, userCobbOid, USER_ESTEVAN_OID); assertSearch(UserType.class, createOrgSubtreeAndNameQuery(ORG_MINISTRY_OF_OFFENSE_OID, USER_GUYBRUSH_USERNAME), USER_GUYBRUSH_OID); @@ -3264,13 +3176,12 @@ public void test340AutzJackSuperUserAndExecRead() throws Exception { /** * Checks whether resource operationalState authorization works. - * + *

* MID-5168, MID-3749 */ @Test public void test350AutzJackResourceRead() throws Exception { final String TEST_NAME = "test350AutzJackResourceRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3279,7 +3190,7 @@ public void test350AutzJackResourceRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); @@ -3291,18 +3202,17 @@ public void test350AutzJackResourceRead() throws Exception { /** * Just to be sure we do not throw away empty PC/PCVs when not necessary. - * + *

* MID-5168, MID-3749 */ @Test public void test360AutzAdminResourceRead() throws Exception { final String TEST_NAME = "test350AutzAdminResourceRead"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = getObject(ResourceType.class, RESOURCE_DUMMY_VAULT_OID); @@ -3326,14 +3236,16 @@ private ObjectQuery createOrgSubtreeAndNameQuery(String orgOid, String name) { .build(); } - private void modifyJackValidTo() throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("modifyJackValidTo"); + private void modifyJackValidTo() + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("modifyJackValidTo"); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, task, result, JACK_VALID_TO_LONG_AHEAD); assertSuccess(result); } - private PrismObject assertAlmostFullJackRead(int expectedTargetAssignments) throws Exception { PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -3342,85 +3254,37 @@ private PrismObject assertAlmostFullJackRead(int expectedTargetAssignm PrismAsserts.assertPropertyValue(userJack, UserType.F_GIVEN_NAME, createPolyString(USER_JACK_GIVEN_NAME)); PrismAsserts.assertPropertyValue(userJack, SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS, ActivationStatusType.ENABLED); assertAssignmentsWithTargets(userJack, expectedTargetAssignments); - -// assertJackEditSchemaReadSomeModifySome(userJack); - return userJack; } - -// @Test -// public void test302AutzJackPropExceptAssignmentReadSomeModifySomeUser() throws Exception { -// final String TEST_NAME = "test216AutzJackPropReadSomeModifySomeUser"; -// displayTestTitle(TEST_NAME); -// // GIVEN -// cleanupAutzTest(USER_JACK_OID); -// assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); -// assignRole(USER_JACK_OID, ROLE_PROP_EXCEPT_ASSIGNMENT_OID); -// login(USER_JACK_USERNAME); -// -// // WHEN -// displayWhen(TEST_NAME); -// -// PrismObject userJack = getUser(USER_JACK_OID); -// display("Jack", userJack); -// assertUserJackReadSomeModifySome(userJack, 1); -// assertJackEditSchemaReadSomeModifySome(userJack); -// -// PrismObject userGuybrush = findUserByUsername(USER_GUYBRUSH_USERNAME); -// display("Guybrush", userGuybrush); -// assertNull("Unexpected Guybrush", userGuybrush); -// -// assertAddDeny(); -// -// assertModifyAllow(UserType.class, USER_JACK_OID, UserType.F_FULL_NAME, createPolyString("Captain Jack Sparrow")); -// assertModifyAllow(UserType.class, USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, -// JACK_VALID_FROM_LONG_AGO); -// assertModifyDeny(UserType.class, USER_GUYBRUSH_OID, UserType.F_DESCRIPTION, "Pirate wannabe"); -// -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Captain")); -// assertModifyDeny(UserType.class, USER_GUYBRUSH_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Pirate")); -// assertModifyDeny(UserType.class, USER_BARBOSSA_OID, UserType.F_HONORIFIC_PREFIX, createPolyString("Mutinier")); -// -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_COST_CENTER, "V3RYC0STLY"); -// assertModifyDeny(UserType.class, USER_JACK_OID, UserType.F_ORGANIZATION, createPolyString("Brethren of the Coast")); -// -// assertDeleteDeny(); -// -// assertGlobalStateUntouched(); -// } - - private PolicyExceptionType assertPolicyException(PrismObject role, String expectedRuleName, String expectedPolicySituation) { List policyExceptions = role.asObjectable().getPolicyException(); - assertEquals("Wrong size of policyException container in "+role, 1, policyExceptions.size()); + assertEquals("Wrong size of policyException container in " + role, 1, policyExceptions.size()); PolicyExceptionType policyException = policyExceptions.get(0); - assertEquals("Wrong rule name in "+role, expectedRuleName, policyException.getRuleName()); - assertEquals("Wrong situation in "+role, expectedPolicySituation, policyException.getPolicySituation()); + assertEquals("Wrong rule name in " + role, expectedRuleName, policyException.getRuleName()); + assertEquals("Wrong situation in " + role, expectedPolicySituation, policyException.getPolicySituation()); return policyException; } - private AssignmentType assertExclusion(PrismObject roleExclusion, String excludedRoleOid) { PrismContainer assignmentContainer = roleExclusion.findContainer(RoleType.F_ASSIGNMENT); - assertNotNull("No assignment container in "+roleExclusion, assignmentContainer); - assertEquals("Wrong size of assignment container in "+roleExclusion, 1, assignmentContainer.size()); + assertNotNull("No assignment container in " + roleExclusion, assignmentContainer); + assertEquals("Wrong size of assignment container in " + roleExclusion, 1, assignmentContainer.size()); AssignmentType exclusionAssignment = assignmentContainer.getValue().asContainerable(); PolicyRuleType exclusionPolicyRule = exclusionAssignment.getPolicyRule(); - assertNotNull("No policy rule in "+roleExclusion, exclusionPolicyRule); + assertNotNull("No policy rule in " + roleExclusion, exclusionPolicyRule); PolicyConstraintsType exclusionPolicyConstraints = exclusionPolicyRule.getPolicyConstraints(); - assertNotNull("No policy rule constraints in "+roleExclusion, exclusionPolicyConstraints); + assertNotNull("No policy rule constraints in " + roleExclusion, exclusionPolicyConstraints); List exclusionExclusionPolicyConstraints = exclusionPolicyConstraints.getExclusion(); - assertEquals("Wrong size of exclusion policy constraints in "+roleExclusion, 1, exclusionExclusionPolicyConstraints.size()); + assertEquals("Wrong size of exclusion policy constraints in " + roleExclusion, 1, exclusionExclusionPolicyConstraints.size()); ExclusionPolicyConstraintType exclusionPolicyConstraint = exclusionExclusionPolicyConstraints.get(0); - assertNotNull("No exclusion policy constraint in "+roleExclusion, exclusionPolicyConstraint); + assertNotNull("No exclusion policy constraint in " + roleExclusion, exclusionPolicyConstraint); ObjectReferenceType targetRef = exclusionPolicyConstraint.getTargetRef(); - assertNotNull("No targetRef in exclusion policy constraint in "+roleExclusion, targetRef); - assertEquals("Wrong OID targetRef in exclusion policy constraint in "+roleExclusion, excludedRoleOid, targetRef.getOid()); + assertNotNull("No targetRef in exclusion policy constraint in " + roleExclusion, targetRef); + assertEquals("Wrong OID targetRef in exclusion policy constraint in " + roleExclusion, excludedRoleOid, targetRef.getOid()); return exclusionAssignment; } - @Override protected void cleanupAutzTest(String userOid, int expectedAssignments) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException { super.cleanupAutzTest(userOid, expectedAssignments); @@ -3450,19 +3314,15 @@ private void assertDeputySearchAssignmentTarget(String delegatorOid, String... e assertSearch(UserType.class, query, expectedDeputyOids); } - @Override protected void cleanupAutzTest(String userOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException { super.cleanupAutzTest(userOid); - Task task = taskManager.createTaskInstance(TestSecurityAdvanced.class.getName() + ".cleanupAutzTest"); + Task task = createPlainTask("cleanupAutzTest"); OperationResult result = task.getResult(); cleanupDelete(RoleType.class, ROLE_EXCLUSION_PIRATE_OID, task, result); } - - - } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java index 1c85a89ea9b..8415dd4df18 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityBasic.java @@ -80,7 +80,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test200AutzJackNoRole() throws Exception { final String TEST_NAME = "test200AutzJackNoRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -95,14 +94,13 @@ public void test200AutzJackNoRole() throws Exception { @Test public void test201AutzJackSuperuserRole() throws Exception { final String TEST_NAME = "test201AutzJackSuperuserRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertSuperuserAccess(NUMBER_OF_ALL_USERS); assertGlobalStateUntouched(); @@ -111,7 +109,6 @@ public void test201AutzJackSuperuserRole() throws Exception { @Test public void test202AutzJackReadonlyRole() throws Exception { final String TEST_NAME = "test202AutzJackReadonlyRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_OID); @@ -138,7 +135,6 @@ public void test202AutzJackReadonlyRole() throws Exception { @Test public void test202rAutzJackReadonlyReqRole() throws Exception { final String TEST_NAME = "test202rAutzJackReadonlyReqRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_REQ_OID); @@ -161,7 +157,6 @@ public void test202rAutzJackReadonlyReqRole() throws Exception { @Test public void test202eAutzJackReadonlyExecRole() throws Exception { final String TEST_NAME = "test202eAutzJackReadonlyExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_EXEC_OID); @@ -181,7 +176,6 @@ public void test202eAutzJackReadonlyExecRole() throws Exception { @Test public void test202reAutzJackReadonlyReqExecRole() throws Exception { final String TEST_NAME = "test202reAutzJackReadonlyReqExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_OID); @@ -202,7 +196,6 @@ public void test202reAutzJackReadonlyReqExecRole() throws Exception { @Test public void test203AutzJackReadonlyDeepRole() throws Exception { final String TEST_NAME = "test203AutzJackReadonlyDeepRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_DEEP_OID); @@ -223,7 +216,6 @@ public void test203AutzJackReadonlyDeepRole() throws Exception { @Test public void test203eAutzJackReadonlyDeepExecRole() throws Exception { final String TEST_NAME = "test203eAutzJackReadonlyDeepExecRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_READONLY_DEEP_OID); @@ -242,7 +234,6 @@ public void test203eAutzJackReadonlyDeepExecRole() throws Exception { @Test public void test204AutzJackSelfRole() throws Exception { final String TEST_NAME = "test204AutzJackSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -251,7 +242,7 @@ public void test204AutzJackSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -297,7 +288,6 @@ public void test204AutzJackSelfRole() throws Exception { @Test public void test204aAutzJackCaseObjectSelfRole() throws Exception { final String TEST_NAME = "test204aAutzJackCaseObjectSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -305,7 +295,7 @@ public void test204aAutzJackCaseObjectSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -351,7 +341,6 @@ public void test204aAutzJackCaseObjectSelfRole() throws Exception { @Test public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { final String TEST_NAME = "test204bAutzJackCaseAssigneeSelfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_OID); @@ -359,7 +348,7 @@ public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -405,7 +394,6 @@ public void test204bAutzJackCaseAssigneeSelfRole() throws Exception { @Test public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception { final String TEST_NAME = "test204cAutzJackCaseAssigneeSelfWithDelegatesRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_DELEGABLE_OID); @@ -416,7 +404,7 @@ public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception login(USER_DEPUTY_1_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_1_OID); @@ -470,7 +458,6 @@ public void test204cAutzJackCaseAssigneeSelfWithDelegatesRole() throws Exception @Test public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() throws Exception { final String TEST_NAME = "test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_DELEGABLE_OID); @@ -481,7 +468,7 @@ public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() thro login(USER_DEPUTY_2_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_DEPUTY_2_OID); @@ -535,14 +522,13 @@ public void test204dAutzJackCaseAssigneeSelfWithNonWorkItemsDelegatesRole() thro @Test public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { final String TEST_NAME = "test205AutzJackObjectFilterModifyCaribbeanfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_MODIFY_CARIBBEAN_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -561,14 +547,13 @@ public void test205AutzJackObjectFilterModifyCaribbeanfRole() throws Exception { @Test public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { final String TEST_NAME = "test207AutzJackObjectFilterCaribbeanfRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_CARIBBEAN_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -600,14 +585,13 @@ public void test207AutzJackObjectFilterCaribbeanRole() throws Exception { @Test public void test207rAutzJackObjectFilterCaribbeanRole() throws Exception { final String TEST_NAME = "test207rAutzJackObjectFilterCaribbeanRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_OBJECT_FILTER_CARIBBEAN_RAW_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -654,14 +638,13 @@ public void test208sAutzJackReadSomeRoles() throws Exception { } public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, roleOid); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(); assertReadDenyRaw(); @@ -694,7 +677,6 @@ public void testAutzJackReadSomeRoles(final String TEST_NAME, String roleOid) th @Test public void test209AutzJackSuperuserAndGuiAccessRole() throws Exception { final String TEST_NAME = "test209AutzJackSuperuserAndGuiAccessRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SUPERUSER_OID); @@ -713,14 +695,13 @@ public void test209AutzJackSuperuserAndGuiAccessRole() throws Exception { @Test public void test210AutzJackPropReadAllModifySome() throws Exception { final String TEST_NAME = "test210AutzJackPropReadAllModifySome"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); assertReadDenyRaw(); @@ -751,14 +732,13 @@ public void test210AutzJackPropReadAllModifySome() throws Exception { @Test public void test211AutzJackPropReadAllModifySomeUser() throws Exception { final String TEST_NAME = "test211AutzJackPropReadAllModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -800,14 +780,13 @@ public void test211AutzJackPropReadAllModifySomeUser() throws Exception { @Test public void test212AutzJackPropReadAllModifySomeUserPartial() throws Exception { final String TEST_NAME = "test212AutzJackPropReadAllModifySomeUserPartial"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_ALL_MODIFY_SOME_USER_PARTIAL_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -879,7 +858,6 @@ public void test215reAutzJackPropReadSomeModifySomeReqExec() throws Exception { @Test public void test216AutzJackPropReadSomeModifySomeUser() throws Exception { final String TEST_NAME = "test216AutzJackPropReadSomeModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_USER_OID); @@ -894,7 +872,6 @@ public void test216AutzJackPropReadSomeModifySomeUser() throws Exception { @Test public void test217AutzJackPropGetSearchSomeModifySomeUser() throws Exception { final String TEST_NAME = "test217AutzJackPropGetSearchSomeModifySomeUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_GET_SEARCH_SOME_MODIFY_SOME_USER_OID); @@ -906,7 +883,7 @@ public void test217AutzJackPropGetSearchSomeModifySomeUser() throws Exception { private void doReadSomeModifySomeUser(final String TEST_NAME) throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userJack = getUser(USER_JACK_OID); display("Jack", userJack); @@ -937,14 +914,13 @@ private void doReadSomeModifySomeUser(final String TEST_NAME) throws Exception { } public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String roleOid) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, roleOid); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadSomeModifySome(1); @@ -954,14 +930,13 @@ public void testAutzJackPropReadSomeModifySome(final String TEST_NAME, String ro @Test public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { final String TEST_NAME = "test218AutzJackPropReadSomeModifySomeExecAll"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_EXEC_ALL_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); @@ -1034,7 +1009,6 @@ public void test218AutzJackPropReadSomeModifySomeExecAll() throws Exception { @Test public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { final String TEST_NAME = "test219AutzJackPropReadSomeModifySomeFullName"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_READ_SOME_MODIFY_SOME_FULLNAME_OID); @@ -1042,7 +1016,7 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); @@ -1062,7 +1036,7 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { .item(UserType.F_GIVEN_NAME).replace(createPolyString("Jackie")) .asObjectDelta(USER_JACK_OID); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN: preview changes @@ -1195,14 +1169,13 @@ public void test219AutzJackPropReadSomeModifySomeFullName() throws Exception { @Test public void test220AutzJackPropDenyModifySome() throws Exception { final String TEST_NAME = "test220AutzJackPropDenyModifySome"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_PROP_DENY_MODIFY_SOME_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(); @@ -1261,14 +1234,13 @@ public void test220AutzJackPropDenyModifySome() throws Exception { @Test public void test230AutzJackMasterMinistryOfRum() throws Exception { final String TEST_NAME = "test230AutzJackMasterMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_MASTER_MINISTRY_OF_RUM_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(3); assertAddDeny(); @@ -1293,14 +1265,13 @@ public void test230AutzJackMasterMinistryOfRum() throws Exception { @Test public void test232AutzJackReadOrgMinistryOfRum() throws Exception { final String TEST_NAME = "test232AutzJackReadOrgMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ORG_READ_ORGS_MINISTRY_OF_RUM_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(0); assertAddDeny(); @@ -1325,7 +1296,6 @@ public void test232AutzJackReadOrgMinistryOfRum() throws Exception { @Test public void test240AutzJackManagerFullControlNoOrg() throws Exception { final String TEST_NAME = "test240AutzJackManagerFullControlNoOrg"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1338,7 +1308,7 @@ public void test240AutzJackManagerFullControlNoOrg() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadDeny(0); assertAddDeny(); @@ -1376,7 +1346,6 @@ public void test240AutzJackManagerFullControlNoOrg() throws Exception { @Test public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Exception { final String TEST_NAME = "test241AutzJackManagerFullControlMemberMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1390,7 +1359,7 @@ public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Except login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xMember(accountOid, true); @@ -1403,7 +1372,6 @@ public void test241AutzJackManagerFullControlMemberMinistryOfRum() throws Except @Test public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Exception { final String TEST_NAME = "test242AutzJackManagerFullControlManagerMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1419,7 +1387,7 @@ public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Excep login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xManager(TEST_NAME, true); @@ -1432,7 +1400,6 @@ public void test242AutzJackManagerFullControlManagerMinistryOfRum() throws Excep @Test public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() throws Exception { final String TEST_NAME = "test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1451,7 +1418,7 @@ public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() th login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xManagerDefense(TEST_NAME, true); @@ -1464,7 +1431,6 @@ public void test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense() th @Test public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exception { final String TEST_NAME = "test245AutzJackManagerUserAdminMemberMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1478,7 +1444,7 @@ public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exceptio login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xMember(accountOid, false); @@ -1491,7 +1457,6 @@ public void test245AutzJackManagerUserAdminMemberMinistryOfRum() throws Exceptio @Test public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Exception { final String TEST_NAME = "test246AutzJackManagerUserAdminManagerMinistryOfRum"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1507,7 +1472,7 @@ public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Excepti login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xManager(TEST_NAME, false); @@ -1520,7 +1485,6 @@ public void test246AutzJackManagerUserAdminManagerMinistryOfRum() throws Excepti @Test public void test247AutzJackManagerUserAdminManagerMinistryOfRumAndDefense() throws Exception { final String TEST_NAME = "test243AutzJackManagerFullControlManagerMinistryOfRumAndDefense"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1537,7 +1501,7 @@ public void test247AutzJackManagerUserAdminManagerMinistryOfRumAndDefense() thro login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertJack24xManagerDefense(TEST_NAME, false); @@ -1765,7 +1729,6 @@ private void assertJack24xManagerDefense(String TEST_NAME, boolean fullControl) @Test public void test250AutzJackSelfAccountsRead() throws Exception { final String TEST_NAME = "test250AutzJackSelfAccountsRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -1784,7 +1747,7 @@ public void test250AutzJackSelfAccountsRead() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1842,7 +1805,6 @@ public void test250AutzJackSelfAccountsRead() throws Exception { @Test public void test255AutzJackSelfAccountsReadWrite() throws Exception { final String TEST_NAME = "test255AutzJackSelfAccountsReadWrite"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_READ_WRITE_OID); @@ -1853,7 +1815,7 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1872,7 +1834,7 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, task.getResult()); display("Refined objectclass def", rOcDef); assertAttributeFlags(rOcDef, SchemaConstants.ICFS_UID, true, false, false); @@ -1908,7 +1870,6 @@ public void test255AutzJackSelfAccountsReadWrite() throws Exception { @Test public void test256AutzJackSelfAccountsPartialControl() throws Exception { final String TEST_NAME = "test256AutzJackSelfAccountsPartialControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_OID); @@ -1919,7 +1880,7 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -1939,7 +1900,7 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, result); display("Refined objectclass def", rOcDef); @@ -1991,7 +1952,6 @@ public void test256AutzJackSelfAccountsPartialControl() throws Exception { @Test public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception { final String TEST_NAME = "test258AutzJackSelfAccountsPartialControlPassword"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_PASSWORD_OID); @@ -2002,7 +1962,7 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2022,7 +1982,7 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); RefinedObjectClassDefinition rOcDef = modelInteractionService.getEditObjectClassDefinition(shadow, getDummyResourceObject(), null, task, result); display("Refined objectclass def", rOcDef); @@ -2055,7 +2015,6 @@ public void test258AutzJackSelfAccountsPartialControlPassword() throws Exception @Test public void test259AutzJackSelfAccountsPartialControl() throws Exception { final String TEST_NAME = "test259AutzJackSelfAccountsPartialControl"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_ACCOUNTS_PARTIAL_CONTROL_PASSWORD_OID); @@ -2066,7 +2025,7 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2086,7 +2045,7 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { PrismObject shadow = getObject(ShadowType.class, accountOid); display("Jack's shadow", shadow); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObjectDefinition rOcDef = modelInteractionService.getEditObjectDefinition(shadow, null, task, result); shadow.applyDefinition(rOcDef, true); @@ -2126,7 +2085,6 @@ public void test259AutzJackSelfAccountsPartialControl() throws Exception { @Test public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { final String TEST_NAME = "test260AutzJackObjectFilterLocationShadowRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_FILTER_OBJECT_USER_LOCATION_SHADOWS_OID); @@ -2135,7 +2093,7 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); @@ -2176,7 +2134,7 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { displayCleanup(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_JACK_DUMMY_RED_FILE); account.setOid(accountRedOid); ObjectDelta userDelta = prismContext.deltaFactory().object() @@ -2198,7 +2156,6 @@ public void test260AutzJackObjectFilterLocationShadowRole() throws Exception { @Test public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws Exception { final String TEST_NAME = "test261AutzJackObjectFilterLocationCreateUserShadowRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -2208,13 +2165,13 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); // WHEN - displayWhen(TEST_NAME); + when(); assertAllow("add user angelica", (task, result) -> addObject(USER_ANGELICA_FILE, task, result)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); // user jack seemingly has no rights to search for angelika @@ -2230,7 +2187,6 @@ public void test261AutzAngelicaObjectFilterLocationCreateUserShadowRole() throws @Test public void test270AutzJackAssignApplicationRoles() throws Exception { final String TEST_NAME = "test270AutzJackAssignApplicationRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_APPLICATION_ROLES_OID); @@ -2240,7 +2196,7 @@ public void test270AutzJackAssignApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2285,7 +2241,6 @@ public void test270AutzJackAssignApplicationRoles() throws Exception { @Test public void test272AutzJackAssignAnyRoles() throws Exception { final String TEST_NAME = "test272AutzJackAssignAnyRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_ANY_ROLES_OID); @@ -2295,7 +2250,7 @@ public void test272AutzJackAssignAnyRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2345,7 +2300,6 @@ public void test272AutzJackAssignAnyRoles() throws Exception { @Test public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { final String TEST_NAME = "test273AutzJackRedyAssignmentExceptionRules"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_ANY_ROLES_OID); @@ -2355,7 +2309,7 @@ public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2399,7 +2353,6 @@ public void test273AutzJackRedyAssignmentExceptionRules() throws Exception { @Test public void test274AutzJackAssignNonApplicationRoles() throws Exception { final String TEST_NAME = "test274AutzJackAssignNonApplicationRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_NON_APPLICATION_ROLES_OID); @@ -2409,7 +2362,7 @@ public void test274AutzJackAssignNonApplicationRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2447,7 +2400,6 @@ public void test274AutzJackAssignNonApplicationRoles() throws Exception { @Test public void test275aAutzJackAssignRequestableRoles() throws Exception { final String TEST_NAME = "test275aAutzJackAssignRequestableRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2457,7 +2409,7 @@ public void test275aAutzJackAssignRequestableRoles() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2502,7 +2454,6 @@ public void test275aAutzJackAssignRequestableRoles() throws Exception { @Test public void test275bAutzJackAssignRequestableOrgs() throws Exception { final String TEST_NAME = "test275bAutzJackAssignRequestableOrgs"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_END_USER_REQUESTABLE_ABSTRACTROLES_OID); @@ -2512,7 +2463,7 @@ public void test275bAutzJackAssignRequestableOrgs() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); assertAssignedRole(user, ROLE_END_USER_REQUESTABLE_ABSTRACTROLES_OID); @@ -2547,7 +2498,6 @@ public void test275bAutzJackAssignRequestableOrgs() throws Exception { @Test public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exception { final String TEST_NAME = "test275cAutzJackAssignRequestableRolesAndInduceAnything"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2558,7 +2508,7 @@ public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exce login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2604,7 +2554,6 @@ public void test275cAutzJackAssignRequestableRolesAndInduceAnyRole() throws Exce @Test public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { final String TEST_NAME = "test276AutzJackAssignRequestableRolesWithOrgRef"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2614,7 +2563,7 @@ public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2658,7 +2607,6 @@ public void test276AutzJackAssignRequestableRolesWithOrgRef() throws Exception { @Test public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws Exception { final String TEST_NAME = "test277AutzJackAssignRequestableRolesWithOrgRefSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2668,7 +2616,7 @@ public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws E login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2741,7 +2689,6 @@ public void test277AutzJackAssignRequestableRolesWithOrgRefSecondTime() throws E @Test public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws Exception { final String TEST_NAME = "test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2751,7 +2698,7 @@ public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2810,7 +2757,6 @@ public void test278AutzJackAssignRequestableRolesWithOrgRefTweakedDelta() throws @Test public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exception { final String TEST_NAME = "test279AutzJackAssignRequestableRolesWithTenantRef"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_ASSIGN_REQUESTABLE_ROLES_OID); @@ -2820,7 +2766,7 @@ public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exceptio login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -2864,7 +2810,6 @@ public void test279AutzJackAssignRequestableRolesWithTenantRef() throws Exceptio @Test public void test280AutzJackEndUser() throws Exception { final String TEST_NAME = "test280AutzJackEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -2879,7 +2824,7 @@ public void test280AutzJackEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID, SelectorOptions.createCollection(GetOperationOptions.createRaw())); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -2952,7 +2897,6 @@ public void test280AutzJackEndUser() throws Exception { @Test public void test281AutzJackEndUserSecondTime() throws Exception { final String TEST_NAME = "test281AutzJackEndUserSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -2963,7 +2907,7 @@ public void test281AutzJackEndUserSecondTime() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); assertAssignments(user, 1); @@ -3018,7 +2962,6 @@ private void assertCredentialsPolicy(PrismObject user) throws ObjectNo @Test public void test282AutzJackEndUserAndModify() throws Exception { final String TEST_NAME = "test282AutzJackEndUserAndModify"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3030,7 +2973,7 @@ public void test282AutzJackEndUserAndModify() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3059,7 +3002,6 @@ public void test282AutzJackEndUserAndModify() throws Exception { @Test public void test283AutzJackModifyAndEndUser() throws Exception { final String TEST_NAME = "test283AutzJackModifyAndEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3072,7 +3014,7 @@ public void test283AutzJackModifyAndEndUser() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); assertAddDeny(); @@ -3094,7 +3036,6 @@ public void test283AutzJackModifyAndEndUser() throws Exception { @Test public void test285AutzJackEndUserAndAdd() throws Exception { final String TEST_NAME = "test285AutzJackEndUserAndAdd"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3106,7 +3047,7 @@ public void test285AutzJackEndUserAndAdd() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertReadAllow(NUMBER_OF_ALL_USERS + 1); @@ -3128,7 +3069,6 @@ public void test285AutzJackEndUserAndAdd() throws Exception { @Test public void test295AutzJackAssignOrgRelation() throws Exception { final String TEST_NAME = "test295AutzJackAssignOrgRelation"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); @@ -3138,7 +3078,7 @@ public void test295AutzJackAssignOrgRelation() throws Exception { login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); ObjectFilter jackAssignableRoleFilter = assertAssignableRoleSpecification(getUser(USER_JACK_OID)) .relationDefault() @@ -3169,7 +3109,6 @@ public void test295AutzJackAssignOrgRelation() throws Exception { @Test public void test300AutzAnonymous() throws Exception { final String TEST_NAME = "test300AutzAnonymous"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3184,7 +3123,6 @@ public void test300AutzAnonymous() throws Exception { @Test public void test310AutzJackNoRolePrivileged() throws Exception { final String TEST_NAME = "test310AutzJackNoRolePrivileged"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3215,7 +3153,6 @@ public void test310AutzJackNoRolePrivileged() throws Exception { @Test public void test312AutzAnonymousPrivileged() throws Exception { final String TEST_NAME = "test312AutzAnonymousPrivileged"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3246,7 +3183,6 @@ public void test312AutzAnonymousPrivileged() throws Exception { @Test public void test313AutzAnonymousPrivilegedRestore() throws Exception { final String TEST_NAME = "test313AutzAnonymousPrivilegedRestore"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); PrismObject userJack = getUser(USER_JACK_OID); @@ -3269,7 +3205,6 @@ public void test313AutzAnonymousPrivilegedRestore() throws Exception { @Test public void test360AutzJackAuditorRole() throws Exception { final String TEST_NAME = "test360AutzJackAuditorRole"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_AUDITOR_OID); @@ -3295,14 +3230,13 @@ public void test360AutzJackAuditorRole() throws Exception { @Test public void test370AutzJackLimitedUserAdmin() throws Exception { final String TEST_NAME = "test370AutzJackLimitedUserAdmin"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_LIMITED_USER_ADMIN_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_JACK_OID); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); @@ -3323,14 +3257,13 @@ public void test370AutzJackLimitedUserAdmin() throws Exception { @Test public void test380AutzJackSelfTaskOwner() throws Exception { final String TEST_NAME = "test380AutzJackSelfTaskOwner"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_SELF_TASK_OWNER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java index 79bfa181677..0f03b6409da 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMedium.java @@ -54,12 +54,11 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -79,14 +78,13 @@ public void test000Sanity() throws Exception { @Test public void test100AutzEmployeeManager() throws Exception { final String TEST_NAME = "test100AutzEmployeeManager"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_MANAGER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetDeny(UserType.class, USER_JACK_OID); assertGetDeny(UserType.class, USER_GUYBRUSH_OID); @@ -110,14 +108,13 @@ public void test100AutzEmployeeManager() throws Exception { @Test public void test102AutzEmployeeManagerAddEmployee() throws Exception { final String TEST_NAME = "test102AutzEmployeeManagerAddEmployee"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_MANAGER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertAddAllow(USER_EMPLOYEE_FRED_FILE); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java index 92f5fabe5af..1449864b2ee 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityMultitenant.java @@ -212,12 +212,11 @@ protected int getNumberOfRoles() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); assertSearch(UserType.class, null, NUMBER_OF_ALL_USERS); assertSearch(RoleType.class, null, getNumberOfRoles()); @@ -241,18 +240,17 @@ public void test000Sanity() throws Exception { @Test public void test010ImportOrgstruct() throws Exception { final String TEST_NAME = "test010ImportOrgstruct"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectsFromFileNotRaw(ORG_MULTITENANT_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -378,14 +376,13 @@ public void test010ImportOrgstruct() throws Exception { @Test public void test100AutzLetoRead() throws Exception { final String TEST_NAME = "test100AutzLetoRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertGetAllow(UserType.class, USER_LETO_ATREIDES_OID); @@ -409,7 +406,7 @@ public void test100AutzLetoRead() throws Exception { assertSearch(OrgType.class, null, ORG_ATREIDES_OID, ORG_CALADAN_OID); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -420,14 +417,13 @@ public void test100AutzLetoRead() throws Exception { @Test public void test102AutzLetoAdd() throws Exception { final String TEST_NAME = "test102AutzLetoAdd"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertAddAllow(USER_DUNCAN_FILE); @@ -439,7 +435,7 @@ public void test102AutzLetoAdd() throws Exception { assertAddDeny(USER_DMURR_FILE); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -465,14 +461,13 @@ public void test102AutzLetoAdd() throws Exception { @Test public void test104AutzLetoModify() throws Exception { final String TEST_NAME = "test104AutzLetoModify"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertModifyAllow(UserType.class, USER_PAUL_ATREIDES_OID, UserType.F_LOCALITY, createPolyString("Arrakis")); @@ -484,7 +479,7 @@ public void test104AutzLetoModify() throws Exception { assertModifyDeny(UserType.class, USER_EDRIC_OID, UserType.F_LOCALITY, createPolyString("Whatever")); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -497,14 +492,13 @@ public void test104AutzLetoModify() throws Exception { @Test public void test106AutzLetoAddResourceTask() throws Exception { final String TEST_NAME = "test106AutzLetoAddResourceTask"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertAddDummyResourceAllow(RESOURCE_DUMMY_CASTLE_CALADAN_FILE); @@ -516,7 +510,7 @@ public void test106AutzLetoAddResourceTask() throws Exception { assertAddDummyResourceDeny(RESOURCE_DUMMY_JUNCTION_FILE); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -543,14 +537,13 @@ private void assertAddDummyResourceDeny(File file) throws SchemaException, IOExc @Test public void test109AutzLetoDelete() throws Exception { final String TEST_NAME = "test109AutzLetoDelete"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertDeleteAllow(UserType.class, USER_DUNCAN_OID); @@ -562,7 +555,7 @@ public void test109AutzLetoDelete() throws Exception { assertDeleteDeny(UserType.class, USER_DMURR_OID); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -573,14 +566,13 @@ public void test109AutzLetoDelete() throws Exception { @Test public void test110AutzLetoAddOrgs() throws Exception { final String TEST_NAME = "test110AutzLetoAddOrgs"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertAddAllow(ORG_ARRAKIS_FILE); @@ -593,7 +585,7 @@ public void test110AutzLetoAddOrgs() throws Exception { assertAddDeny(ORG_JUNCTION_FILE); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); @@ -628,14 +620,13 @@ public void test110AutzLetoAddOrgs() throws Exception { @Test public void test112AutzLetoProtectTenant() throws Exception { final String TEST_NAME = "test112AutzLetoProtectTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Matching tenant assertAddDeny(ORG_ATREIDES_SUBTENANT_FILE); @@ -686,7 +677,7 @@ public void test112AutzLetoProtectTenant() throws Exception { assertDeleteDeny(OrgType.class, ORG_GUILD_OID); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -698,14 +689,13 @@ public void test112AutzLetoProtectTenant() throws Exception { @Test public void test114AutzLetoKeepWithinTenant() throws Exception { final String TEST_NAME = "test114AutzLetoKeepWithinTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertAddAllow(ROLE_ATREIDES_GUARD_FILE); @@ -750,7 +740,7 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { (task, result) -> unassignOrg(OrgType.class, ORG_CASTLE_CALADAN_OID, ORG_CALADAN_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -761,14 +751,13 @@ public void test114AutzLetoKeepWithinTenant() throws Exception { @Test public void test116AutzLetoProtectTenantAdminRole() throws Exception { final String TEST_NAME = "test114AutzLetoKeepWithinTenant"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_LETO_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertAddDeny(ROLE_ATREIDES_HACKER_FILE); @@ -808,7 +797,7 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { RoleType.F_POLICY_EXCEPTION, task, result, policyException)); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -819,7 +808,6 @@ public void test116AutzLetoProtectTenantAdminRole() throws Exception { @Test public void test118AutzLetoBusinessRoles() throws Exception { final String TEST_NAME = "test118AutzLetoBusinessRoles"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -828,7 +816,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertAddAllow(ROLE_ATREIDES_GUARD_FILE); // WHEN - displayWhen(TEST_NAME); + when(); assertAddAllow(ROLE_ATREIDES_SWORDMASTER_FILE); @@ -847,7 +835,7 @@ public void test118AutzLetoBusinessRoles() throws Exception { assertDeleteAllow(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -859,7 +847,6 @@ public void test118AutzLetoBusinessRoles() throws Exception { @Test public void test120AutzPaulEndUser() throws Exception { final String TEST_NAME = "test120AutzPaulEndUser"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -868,7 +855,7 @@ public void test120AutzPaulEndUser() throws Exception { login(USER_PAUL_ATREIDES_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Requestable role assertAllow("assign guard to paul", @@ -887,7 +874,7 @@ public void test120AutzPaulEndUser() throws Exception { (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_CORRINO_EMPEROR_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -895,7 +882,6 @@ public void test120AutzPaulEndUser() throws Exception { @Test public void test122AutzDuncanRoleManager() throws Exception { final String TEST_NAME = "test122AutzDuncanRoleManager"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); @@ -905,7 +891,7 @@ public void test122AutzDuncanRoleManager() throws Exception { login(USER_DUNCAN_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertDeny("assign guard to paul", (task, result) -> assignRole(USER_PAUL_ATREIDES_OID, ROLE_ATREIDES_GUARD_OID, task, result)); @@ -929,7 +915,7 @@ public void test122AutzDuncanRoleManager() throws Exception { (task, result) -> induceOrg(RoleType.class, ROLE_ATREIDES_SWORDMASTER_OID, ORG_CALADAN_OID, task, result)); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } @@ -945,14 +931,13 @@ public void test122AutzDuncanRoleManager() throws Exception { @Test public void test130AutzEdricRead() throws Exception { final String TEST_NAME = "test120AutzEdricRead"; - displayTestTitle(TEST_NAME); // GIVEN cleanupAutzTest(null); login(USER_EDRIC_NAME); // WHEN - displayWhen(TEST_NAME); + when(); // Wrong tenant assertGetDeny(UserType.class, USER_LETO_ATREIDES_OID); @@ -970,7 +955,7 @@ public void test130AutzEdricRead() throws Exception { assertSearch(OrgType.class, null, 0); // THEN - displayThen(TEST_NAME); + then(); assertGlobalStateUntouched(); } diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java index da0a7a0e4a5..93c14b2ce37 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/security/TestSecurityPrincipal.java @@ -40,7 +40,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010GetUserAdministrator() throws Exception { final String TEST_NAME = "test010GetUserAdministrator"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -58,7 +57,6 @@ public void test010GetUserAdministrator() throws Exception { @Test public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -78,7 +76,6 @@ public void test050GetUserJack() throws Exception { @Test public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -101,7 +98,6 @@ public void test051GetUserBarbossa() throws Exception { @Test public void test052GetUserGuybrush() throws Exception { final String TEST_NAME = "test052GetUserGuybrush"; - displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN @@ -123,7 +119,6 @@ public void test052GetUserGuybrush() throws Exception { @Test public void test060GuybrushConditionalRoleFalse() throws Exception { final String TEST_NAME = "test060GuybrushConditionalRoleFalse"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); assignRole(USER_GUYBRUSH_OID, ROLE_CONDITIONAL_OID); @@ -151,21 +146,20 @@ public void test060GuybrushConditionalRoleFalse() throws Exception { @Test public void test061GuybrushConditionalRoleTrue() throws Exception { final String TEST_NAME = "test061GuybrushConditionalRoleTrue"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_SUBTYPE, task, result, "special"); resetAuthentication(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("wrong username", USER_GUYBRUSH_USERNAME, principal.getUsername()); assertEquals("wrong oid", USER_GUYBRUSH_OID, principal.getOid()); @@ -183,7 +177,6 @@ public void test061GuybrushConditionalRoleTrue() throws Exception { @Test public void test062GuybrushConditionalRoleUnassign() throws Exception { final String TEST_NAME = "test062GuybrushConditionalRoleUnassign"; - displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CONDITIONAL_OID); @@ -209,10 +202,9 @@ public void test062GuybrushConditionalRoleUnassign() throws Exception { @Test public void test100JackRolePirate() throws Exception { final String TEST_NAME = "test100JackRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -243,10 +235,9 @@ public void test100JackRolePirate() throws Exception { @Test public void test109JackUnassignRolePirate() throws Exception { final String TEST_NAME = "test109JackUnassignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); @@ -274,21 +265,20 @@ public void test109JackUnassignRolePirate() throws Exception { @Test public void test110GuybrushRoleNicePirate() throws Exception { final String TEST_NAME = "test110GuybrushRoleNicePirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_NICE_PIRATE_OID, task, result); resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 2, principal.getAuthorities().size()); @@ -299,21 +289,20 @@ public void test110GuybrushRoleNicePirate() throws Exception { @Test public void test111GuybrushRoleCaptain() throws Exception { final String TEST_NAME = "test111GuybrushRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_GUYBRUSH_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 3, principal.getAuthorities().size()); @@ -324,10 +313,9 @@ public void test111GuybrushRoleCaptain() throws Exception { @Test public void test119GuybrushUnassignRoles() throws Exception { final String TEST_NAME = "test119GuybrushUnassignRoles"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); unassignRole(USER_JACK_OID, ROLE_CAPTAIN_OID, task, result); @@ -335,11 +323,11 @@ public void test119GuybrushUnassignRoles() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); assertEquals("Wrong number of authorizations", 0, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); @@ -352,7 +340,6 @@ public void test119GuybrushUnassignRoles() throws Exception { @Test public void test120JackRoleIndirectPirate() throws Exception { final String TEST_NAME = "test120JackRoleIndirectPirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); @@ -365,11 +352,11 @@ public void test120JackRoleIndirectPirate() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); @@ -385,7 +372,6 @@ public void test120JackRoleIndirectPirate() throws Exception { @Test public void test122JackOrgIndirectPirate() throws Exception { final String TEST_NAME = "test122JackOrgIndirectPirate"; - displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); @@ -398,11 +384,11 @@ public void test122JackOrgIndirectPirate() throws Exception { resetAuthentication(); // WHEN - displayWhen(TEST_NAME); + when(); MidPointPrincipal principal = focusProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); // THEN - displayThen(TEST_NAME); + then(); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java index cfa017da3bc..39693ba4aee 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractInboundSyncTest.java @@ -30,7 +30,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -94,18 +93,18 @@ protected int getNumberOfExtraDummyUsers() { @Test public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyEmerald"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(resourceDummyEmerald); } @@ -113,10 +112,10 @@ public void test100ImportLiveSyncTaskDummyEmerald() throws Exception { @Test public void test110AddDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyEmeraldAccountMancomb"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -134,7 +133,7 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, gossip); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -143,7 +142,7 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); @@ -171,10 +170,10 @@ public void test110AddDummyEmeraldAccountMancomb() throws Exception { @Test public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { final String TEST_NAME = "test120ModifyDummyEmeraldAccountMancombSeepbad"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -185,7 +184,7 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepbad"); @@ -194,7 +193,7 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -226,10 +225,10 @@ public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception { @Test public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { final String TEST_NAME = "test122ModifyDummyEmeraldAccountMancombSeepNULL"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -240,7 +239,7 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb SeepNULL"); @@ -249,7 +248,7 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -281,10 +280,10 @@ public void test122ModifyDummyEmeraldAccountMancombSeepNULL() throws Exception { @Test public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { final String TEST_NAME = "test124ModifyDummyEmeraldAccountMancombSeepevil"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -295,7 +294,7 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepevil"); @@ -304,7 +303,7 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -336,10 +335,10 @@ public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception { @Test public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exception { final String TEST_NAME = "test126ModifyDummyEmeraldAccountMancombTitlePirate"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -350,7 +349,7 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate"); @@ -359,7 +358,7 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -392,10 +391,10 @@ public void test126ModifyDummyEmeraldAccountMancombTitlePirate() throws Exceptio @Test public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exception { final String TEST_NAME = "test127ModifyDummyEmeraldAccountMancombTitlePirateNull"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -406,7 +405,7 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -415,7 +414,7 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -448,10 +447,10 @@ public void test127ModifyDummyEmeraldAccountMancombTitlePirateNull() throws Exce @Test public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { final String TEST_NAME = "test129ModifyDummyEmeraldAccountMancombSeepgood"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -462,7 +461,7 @@ public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood"); @@ -471,7 +470,7 @@ public void test129ModifyDummyEmeraldAccountMancombSeepgood() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountAfter); @@ -513,10 +512,10 @@ public void test180NoChange() throws Exception { @Test public void test300AddDummyEmeraldAccountPosixUser() throws Exception { final String TEST_NAME = "test300AddDummyEmeraldAccountPosixUser"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -533,7 +532,7 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_GID_NUMBER, Collections.singleton(10001)); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -542,7 +541,7 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountPosixUser = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald); display("Account posixuser", accountPosixUser); @@ -571,10 +570,10 @@ public void test300AddDummyEmeraldAccountPosixUser() throws Exception { @Test public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exception { final String TEST_NAME = "test310ModifyDummyEmeraldAccountPosixUserUidNumber"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -585,7 +584,7 @@ public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exceptio DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_UID_NUMBER, 1002); @@ -594,7 +593,7 @@ public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exceptio waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald); display("Account posixuser", accountAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java index c482e2ef321..3b4ecc9aab3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractObjTemplateSyncTest.java @@ -14,7 +14,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -109,18 +108,18 @@ protected int getWaitTimeout() { @Test public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyByzantine"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - Task task = createTask(AbstractObjTemplateSyncTest.class.getName() + "." + TEST_NAME); + AbstractObjTemplateSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importSyncTask(resourceDummyByzantine); // THEN - TestUtil.displayThen(TEST_NAME); + then(); waitForSyncTaskStart(resourceDummyByzantine); } @@ -129,10 +128,10 @@ public void test100ImportLiveSyncTaskDummyByzantine() throws Exception { @Test public void test110AddDummyByzantineAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyByzantineAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractObjTemplateSyncTest.class.getName() + "." + TEST_NAME); + AbstractObjTemplateSyncTest.class.getName(); + Task task = getTestTask(); rememberTimeBeforeSync(); prepareNotifications(); @@ -149,7 +148,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { account.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, gossip); /// WHEN - displayWhen(TEST_NAME); + when(); display("Adding dummy account", account.debugDump()); @@ -158,7 +157,7 @@ public void test110AddDummyByzantineAccountMancomb() throws Exception { waitForSyncTaskNextRun(resourceDummyByzantine); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyByzantine); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java index c41bcf6e275..3693fdd6e0d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/AbstractSynchronizationStoryTest.java @@ -105,18 +105,18 @@ protected boolean isReconciliation() { @Test public void test100ImportLiveSyncTaskDummyGreen() throws Exception { final String TEST_NAME = "test100ImportLiveSyncTaskDummyGreen"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); } @@ -124,10 +124,10 @@ public void test100ImportLiveSyncTaskDummyGreen() throws Exception { @Test public void test110AddDummyGreenAccountMancomb() throws Exception { final String TEST_NAME = "test110AddDummyGreenAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -143,14 +143,14 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account mancomb", accountMancomb); @@ -191,18 +191,18 @@ public void test110AddDummyGreenAccountMancomb() throws Exception { @Test public void test200ImportLiveSyncTaskDummyBlue() throws Exception { final String TEST_NAME = "test200ImportLiveSyncTaskDummyBlue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); importSyncTask(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); } @@ -213,23 +213,23 @@ public void test200ImportLiveSyncTaskDummyBlue() throws Exception { @Test public void test210AddDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test210AddDummyGreenAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -265,16 +265,16 @@ public void test210AddDummyGreenAccountWally() throws Exception { @Test public void test220AddDummyBlueAccountWally() throws Exception { final String TEST_NAME = "test220AddDummyBlueAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change @@ -288,7 +288,7 @@ public void test220AddDummyBlueAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), result); @@ -329,16 +329,16 @@ public void test220AddDummyBlueAccountWally() throws Exception { @Test public void test315AddDummyBlueAccountMancomb() throws Exception { final String TEST_NAME = "test315AddDummyBlueAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).addAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", "Melee Island"); // Wait for sync task to pick up the change @@ -351,7 +351,7 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); // THEN - displayThen(TEST_NAME); + then(); // The ckecks are simplified here because the developer has a lazy mood :-) assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME, "Mancomb Seepgood", true); @@ -386,18 +386,18 @@ public void test315AddDummyBlueAccountMancomb() throws Exception { @Test public void test350ImportLiveSyncTaskDummyDefault() throws Exception { final String TEST_NAME = "test350ImportLiveSyncTaskDummyDefault"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); /// WHEN - displayWhen(TEST_NAME); + when(); importSyncTask(getDummyResourceObject()); // THEN - displayThen(TEST_NAME); + then(); waitForSyncTaskStart(getDummyResourceObject()); @@ -414,10 +414,10 @@ public void test350ImportLiveSyncTaskDummyDefault() throws Exception { @Test public void test360ModifyUserAddDummyDefaultAccount() throws Exception { final String TEST_NAME = "test360ModifyUserAddDummyDefaultAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); @@ -428,11 +428,11 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); /// WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -482,7 +482,7 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { // DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); // // /// WHEN -// displayWhen(TEST_NAME); +// when(); // wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Wally Bloodnose"); //// wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Cola"); // @@ -498,7 +498,7 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { // waitForSyncTaskNextRun(resourceDummy); // // // THEN -// displayThen(TEST_NAME); +// then(); // // PrismObject userWally = findUserByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); // display("User wally", userWally); @@ -530,10 +530,10 @@ public void test360ModifyUserAddDummyDefaultAccount() throws Exception { @Test public void test370ModifyDummyGreenAccountWally() throws Exception { final String TEST_NAME = "test370ModifyDummyGreenAccountWally"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); repoAddObjectFromFile(USER_TEMPLATE_SYNC_FILENAME, result); @@ -545,7 +545,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(); wallyDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Wally B. Feed"); // Wait for sync task to pick up the change @@ -560,7 +560,7 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject()); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -616,10 +616,10 @@ public void test370ModifyDummyGreenAccountWally() throws Exception { @Test public void test380ModifyUserWallyFullName() throws Exception { final String TEST_NAME = "test380ModifyUserWallyFullName"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -627,7 +627,7 @@ public void test380ModifyUserWallyFullName() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userWallyOid, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("Bloodnose")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -643,7 +643,7 @@ public void test380ModifyUserWallyFullName() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -686,10 +686,10 @@ public void test380ModifyUserWallyFullName() throws Exception { @Test public void test382ModifyUserWallyLocality() throws Exception { final String TEST_NAME = "test382ModifyUserWallyLocality"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -697,7 +697,7 @@ public void test382ModifyUserWallyLocality() throws Exception { DummyAccount wallyDummyAccount = getDummyResource(RESOURCE_DUMMY_GREEN_NAME).getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); /// WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userWallyOid, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Plunder island")); // Wait for sync tasks to pick up the change and have some chance to screw things @@ -713,7 +713,7 @@ public void test382ModifyUserWallyLocality() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -767,16 +767,16 @@ public void test382ModifyUserWallyLocality() throws Exception { @Test public void test400DeleteDummyDefaultAccount() throws Exception { final String TEST_NAME = "test400DeleteDummyDefaultAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); display("Dummy (default) resource", getDummyResource().debugDump()); @@ -787,7 +787,7 @@ public void test400DeleteDummyDefaultAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -836,15 +836,15 @@ public void test400DeleteDummyDefaultAccount() throws Exception { @Test public void test410DeleteDummyGreenAccount() throws Exception { final String TEST_NAME = "test410DeleteDummyGreenAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareNotifications(); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).deleteAccountByName(ACCOUNT_WALLY_DUMMY_USERNAME); // Make sure we have steady state @@ -853,7 +853,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); dumpSyncTaskTree(getDummyResourceObject(), result); dumpSyncTaskTree(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), result); @@ -901,7 +901,7 @@ public void test410DeleteDummyGreenAccount() throws Exception { waitForSyncTaskNextRun(getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME)); } - assertNoShadow(ACCOUNT_WALLY_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), task, result); + assertNoShadow(ACCOUNT_WALLY_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_BLUE_NAME), result); assertUsers(7 + getNumberOfExtraDummyUsers()); @@ -931,24 +931,24 @@ public void test410DeleteDummyGreenAccount() throws Exception { @Test public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { final String TEST_NAME = "test510AddDummyGreenAccountWallyUserTemplate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); assumeUserTemplate(USER_TEMPLATE_SYNC_OID, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME).asObjectable(), null, result); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResourceController(RESOURCE_DUMMY_GREEN_NAME).addAccount(ACCOUNT_WALLY_DUMMY_USERNAME, "Wally Feed", "Scabb Island"); // Wait for sync task to pick up the change waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountWallyGreen = checkWallyAccount(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME), getDummyResource(RESOURCE_DUMMY_GREEN_NAME), "green", "Wally Feed"); assertShadowOperationalData(accountWallyGreen, SynchronizationSituationType.LINKED); @@ -975,10 +975,10 @@ public void test510AddDummyGreenAccountWallyUserTemplate() throws Exception { @Test public void test600AddDummyGreenAccountCalypso() throws Exception { final String TEST_NAME = "test600AddDummyGreenAccountCalypso"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -992,14 +992,14 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountShadow = findAccountByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME, getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account calypso", accountShadow); @@ -1021,10 +1021,10 @@ public void test600AddDummyGreenAccountCalypso() throws Exception { @Test public void test700AddDummyGreenAccountXjojo() throws Exception { final String TEST_NAME = "test700AddDummyGreenAccountXjojo"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -1038,14 +1038,14 @@ public void test700AddDummyGreenAccountXjojo() throws Exception { account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Scabb Island"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(account); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountAfter = findAccountByUsername("Xjojo", getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); display("Account after", accountAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java index e912e4716b4..f46bdf4fead 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestImportRecon.java @@ -326,7 +326,6 @@ protected void loginImportUser() throws CommonException { @Test public void test001SanityAzure() throws Exception { final String TEST_NAME = "test001SanityAzure"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceAzure); @@ -345,7 +344,6 @@ public void test001SanityAzure() throws Exception { @Test public void test002SanityAzureRefined() throws Exception { final String TEST_NAME = "test002SanityAzureRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummyAzureType, prismContext); @@ -362,10 +360,9 @@ public void test002SanityAzureRefined() throws Exception { @Test public void test100ImportStanFromResourceDummy() throws Exception { final String TEST_NAME = "test100ImportStanFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -377,11 +374,11 @@ public void test100ImportStanFromResourceDummy() throws Exception { loginImportUser(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_STAN_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); display(result); assertSuccess(result); @@ -411,10 +408,9 @@ public void test100ImportStanFromResourceDummy() throws Exception { @Test public void test150ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test150ImportFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -434,11 +430,11 @@ public void test150ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -447,7 +443,7 @@ public void test150ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); @@ -481,10 +477,9 @@ public void test150ImportFromResourceDummy() throws Exception { @Test public void test155ImportFromResourceDummyAgain() throws Exception { final String TEST_NAME = "test155ImportFromResourceDummyAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -494,11 +489,11 @@ public void test155ImportFromResourceDummyAgain() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -507,7 +502,7 @@ public void test155ImportFromResourceDummyAgain() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 3); @@ -541,10 +536,9 @@ public void test155ImportFromResourceDummyAgain() throws Exception { @Test public void test160ImportFromResourceDummyLime() throws Exception { final String TEST_NAME = "test160ImportFromResourceDummyLime"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -563,11 +557,11 @@ public void test160ImportFromResourceDummyLime() throws Exception { loginImportUser(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -576,7 +570,7 @@ public void test160ImportFromResourceDummyLime() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -614,10 +608,9 @@ public void test160ImportFromResourceDummyLime() throws Exception { @Test public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws Exception { final String TEST_NAME = "test162ImportFromResourceDummyLimeRappOrganizationScummBar"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -642,11 +635,11 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -655,7 +648,7 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -698,10 +691,9 @@ public void test162ImportFromResourceDummyLimeRappOrganizationScummBar() throws @Test public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exception { final String TEST_NAME = "test164ImportFromResourceDummyLimeRappOrganizationNull"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -728,11 +720,11 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, new QName(RESOURCE_DUMMY_LIME_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -741,7 +733,7 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(task.getResult()); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); @@ -779,12 +771,11 @@ public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exce @Test public void test200ReconcileDummy() throws Exception { final String TEST_NAME = "test200ReconcileDummy"; - displayTestTitle(TEST_NAME); // GIVEN loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -822,16 +813,16 @@ public void test200ReconcileDummy() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -901,10 +892,9 @@ public void test200ReconcileDummy() throws Exception { @Test public void test210ReconcileDummyBroken() throws Exception { final String TEST_NAME = "test210ReconcileDummyBroken"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -922,12 +912,12 @@ public void test210ReconcileDummyBroken() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource)", users); @@ -973,10 +963,9 @@ public void test210ReconcileDummyBroken() throws Exception { @Test public void test219ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test219ReconcileDummyFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -989,12 +978,12 @@ public void test219ReconcileDummyFixed() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1053,10 +1042,9 @@ public void test219ReconcileDummyFixed() throws Exception { @Test public void test220ReconcileDummyBrokenGuybrush() throws Exception { final String TEST_NAME = "test220ReconcileDummyBrokenGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1075,12 +1063,12 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconciliation (broken resource account)", users); @@ -1128,10 +1116,9 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception { @Test public void test229ReconcileDummyFixed() throws Exception { final String TEST_NAME = "test229ReconcileDummyFixed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1145,12 +1132,12 @@ public void test229ReconcileDummyFixed() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 0); @@ -1211,10 +1198,9 @@ public void test229ReconcileDummyFixed() throws Exception { @Test public void test230ReconcileDummyRename() throws Exception { final String TEST_NAME = "test230ReconcileDummyRename"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1236,12 +1222,12 @@ public void test230ReconcileDummyRename() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_OID); waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 6); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 0, 1); @@ -1335,10 +1321,9 @@ private void addReconScripts(Collection scripts, String @Test public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { final String TEST_NAME = "test300ReconcileDummyAzureAddAccountOtis"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1353,15 +1338,15 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_AZURE_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1400,10 +1385,9 @@ public void test300ReconcileDummyAzureAddAccountOtis() throws Exception { @Test public void test310ReconcileDummyAzureAgain() throws Exception { final String TEST_NAME = "test310ReconcileDummyAzureAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1417,15 +1401,15 @@ public void test310ReconcileDummyAzureAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_AZURE_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -1467,10 +1451,9 @@ public void test310ReconcileDummyAzureAgain() throws Exception { @Test public void test320ReconcileDummyAzureDeleteOtis() throws Exception { final String TEST_NAME = "test320ReconcileDummyAzureDeleteOtis"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1487,15 +1470,15 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1540,10 +1523,9 @@ public void test320ReconcileDummyAzureDeleteOtis() throws Exception { @Test public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { final String TEST_NAME = "test330ReconcileDummyAzureAddAccountRapp"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1562,15 +1544,15 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1637,10 +1619,9 @@ public void test330ReconcileDummyAzureAddAccountRapp() throws Exception { @Test public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { final String TEST_NAME = "test332ModifyUserRappAndReconcileDummyAzure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1670,15 +1651,15 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1721,10 +1702,9 @@ public void test332ModifyUserRappAndReconcileDummyAzure() throws Exception { @Test public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Exception { final String TEST_NAME = "test334AssignRoleCorpseToRappAndReconcileDummyAzure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1745,15 +1725,15 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1790,10 +1770,9 @@ public void test334AssignRoleCorpseToRappAndReconcileDummyAzure() throws Excepti @Test public void test339ReconcileDummyAzureDeleteRapp() throws Exception { final String TEST_NAME = "test339ReconcileDummyAzureDeleteRapp"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); getDummyResource().setBreakMode(BreakMode.NONE); @@ -1816,15 +1795,15 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_AZURE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1867,10 +1846,9 @@ public void test339ReconcileDummyAzureDeleteRapp() throws Exception { @Test public void test400ReconcileDummyLimeAddAccount() throws Exception { final String TEST_NAME = "test400ReconcileDummyLimeAddAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1883,15 +1861,15 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_LIME_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -1921,10 +1899,9 @@ public void test400ReconcileDummyLimeAddAccount() throws Exception { @Test public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test401ReconcileDummyLimeKateOnlyEmpty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1939,11 +1916,11 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1971,10 +1948,9 @@ public void test401ReconcileDummyLimeKateOnlyEmpty() throws Exception { @Test public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { final String TEST_NAME = "test402ReconcileDummyLimeKateOnlyGrog"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -1988,11 +1964,11 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2019,10 +1995,9 @@ public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception { @Test public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { final String TEST_NAME = "test403ReconcileDummyLimeKateOnlyNoValue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2037,11 +2012,11 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2066,10 +2041,9 @@ public void test403ReconcileDummyLimeKateOnlyNoValue() throws Exception { @Test public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { final String TEST_NAME = "test404ReconcileDummyLimeKateOnlyRum"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2083,11 +2057,11 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2114,10 +2088,9 @@ public void test404ReconcileDummyLimeKateOnlyRum() throws Exception { @Test public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { final String TEST_NAME = "test405ReconcileDummyLimeKateOnlyEmpty"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2131,11 +2104,11 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2162,10 +2135,9 @@ public void test405ReconcileDummyLimeKateOnlyEmpty() throws Exception { @Test public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { final String TEST_NAME = "test406ReconcileDummyLimeKateOnlyEmptyAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2176,11 +2148,11 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2205,10 +2177,9 @@ public void test406ReconcileDummyLimeKateOnlyEmptyAgain() throws Exception { @Test public void test410ReconcileDummyLimeKatePassword() throws Exception { final String TEST_NAME = "test410ReconcileDummyLimeKatePassword"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2222,11 +2193,11 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(ACCOUNT_CAPSIZE_NAME); @@ -2252,10 +2223,9 @@ public void test410ReconcileDummyLimeKatePassword() throws Exception { @Test public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { final String TEST_NAME = "test420ReconcileDummyLimeDeleteLinkedAccount"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2267,15 +2237,15 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_LIME_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_LIME_OID, false); - displayThen(TEST_NAME); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after reconcile", users); @@ -2306,10 +2276,9 @@ public void test420ReconcileDummyLimeDeleteLinkedAccount() throws Exception { @Test public void test500ImportTAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test500ImportTAugustusFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2325,11 +2294,11 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_TAUGUSTUS_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); loginAdministrator(); @@ -2372,10 +2341,9 @@ public void test500ImportTAugustusFromResourceDummy() throws Exception { @Test public void test502ImportAugustusFromResourceDummy() throws Exception { final String TEST_NAME = "test502ImportAugustusFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2395,11 +2363,11 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(ACCOUNT_AUGUSTUS_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); loginAdministrator(); @@ -2442,10 +2410,9 @@ public void test502ImportAugustusFromResourceDummy() throws Exception { @Test public void test510ImportFromResourceDummy() throws Exception { final String TEST_NAME = "test510ImportFromResourceDummy"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -2482,11 +2449,11 @@ public void test510ImportFromResourceDummy() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); @@ -2495,7 +2462,7 @@ public void test510ImportFromResourceDummy() throws Exception { waitForTaskFinish(task, true, 40000); // THEN - displayThen(TEST_NAME); + then(); TestUtil.assertSuccess(task.getResult()); // First fetch: search in import handler @@ -2540,10 +2507,9 @@ public void test510ImportFromResourceDummy() throws Exception { @Test public void test520ReconResourceDummyFilter() throws Exception { final String TEST_NAME = "test520ReconResourceDummyFilter"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); // Preconditions @@ -2555,7 +2521,7 @@ public void test520ReconResourceDummyFilter() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); // runPrivileged is necessary for TestImportReconAuthorizations as importObjectFromFile() is using raw operations runPrivileged(() -> { try { @@ -2575,23 +2541,22 @@ public void test520ReconResourceDummyFilter() throws Exception { @Test public void test600SearchAllDummyAccounts() throws Exception { final String TEST_NAME = "test600SearchAllDummyAccounts"; - displayTestTitle(TEST_NAME); // GIVEN loginAdministrator(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(RESOURCE_DUMMY_NAMESPACE, "AccountObjectClass"), prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2603,10 +2568,9 @@ public void test600SearchAllDummyAccounts() throws Exception { @Test public void test610SearchDummyAccountsNameSubstring() throws Exception { final String TEST_NAME = "test610SearchDummyAccountsNameSubstring"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = @@ -2617,11 +2581,11 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { .build(); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2633,10 +2597,9 @@ public void test610SearchDummyAccountsNameSubstring() throws Exception { @Test public void test900DeleteDummyShadows() throws Exception { final String TEST_NAME = "test900DeleteDummyShadows"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -2645,16 +2608,16 @@ public void test900DeleteDummyShadows() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_DUMMY_SHADOWS_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_DUMMY_SHADOWS_OID, true, 20000); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_SHADOWS_OID); @@ -2679,10 +2642,9 @@ public void test900DeleteDummyShadows() throws Exception { @Test public void test910DeleteDummyAccounts() throws Exception { final String TEST_NAME = "test910DeleteDummyAccounts"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Preconditions @@ -2691,16 +2653,16 @@ public void test910DeleteDummyAccounts() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_DUMMY_ACCOUNTS_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_DUMMY_ACCOUNTS_OID, true, 20000); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2); PrismObject deleteTask = getTask(TASK_DELETE_DUMMY_ACCOUNTS_OID); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java index 97631ef76bf..43f832182c5 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundLiveSyncTask.java @@ -19,12 +19,10 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * @author semancik @@ -62,10 +60,10 @@ protected String getSyncTaskOid(PrismObject resource) { @Override public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -74,14 +72,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java index 176c9392779..6526d66f8b4 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestInboundReconTask.java @@ -20,7 +20,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -66,10 +65,10 @@ protected String getSyncTaskOid(PrismObject resource) { @Override public void test180NoChange() throws Exception { final String TEST_NAME = "test180NoChange"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); rememberTimeBeforeSync(); @@ -79,12 +78,12 @@ public void test180NoChange() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); @@ -109,10 +108,10 @@ public void test180NoChange() throws Exception { @Override public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { final String TEST_NAME = "test199DeleteDummyEmeraldAccountMancomb"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractInboundSyncTest.class.getName() + "." + TEST_NAME); + AbstractInboundSyncTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -121,14 +120,14 @@ public void test199DeleteDummyEmeraldAccountMancomb() throws Exception { assertUsers(7); /// WHEN - displayWhen(TEST_NAME); + when(); dummyResourceEmerald.deleteAccountByName(ACCOUNT_MANCOMB_DUMMY_USERNAME); waitForSyncTaskNextRun(resourceDummyEmerald); // THEN - displayThen(TEST_NAME); + then(); PrismObject accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald); display("Account mancomb", accountMancomb); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java index 98be34e88f5..0420f24253a 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTask.java @@ -78,13 +78,13 @@ protected String getSyncTaskOid(PrismObject resource) { @Test public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { final String TEST_NAME = "test800DeletingNotUpdatedShadowDummyGreen"; - displayTestTitle(TEST_NAME); String ACCOUNT_JACK_DUMMY_USERNAME = "jack"; String ACCOUNT_CAROL_DUMMY_USERNAME = "carol"; // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberTimeBeforeSync(); prepareNotifications(); @@ -100,7 +100,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { accountJack.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas"); /// WHEN - displayWhen(TEST_NAME); + when(); getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(accountJack); waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)); @@ -112,7 +112,7 @@ public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception { rerunTask(TASK_DELETE_NOT_UPDATED_SHADOWS_OID); // THEN - displayThen(TEST_NAME); + then(); PrismObject userCarol = findUserByUsername(ACCOUNT_CAROL_DUMMY_USERNAME); display("User carol", userCarol); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java index 338206ba6e1..9bcbaa572e3 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestLiveSyncTaskMechanics.java @@ -148,23 +148,23 @@ private String getUserName(int i, boolean precise) { @Test public void test100SuspendWhileIcfSync() throws Exception { final String TEST_NAME = "test100SuspendWhileIcfSync"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Resource gives out changes slowly now. interruptedSyncResource.getDummyResource().setOperationDelayOffset(2000); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_RESOURCE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_OID, 10000); // THEN - displayThen(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_OID, result); @@ -179,23 +179,23 @@ public void test100SuspendWhileIcfSync() throws Exception { @Test public void test105SuspendWhileIcfSyncImprecise() throws Exception { final String TEST_NAME = "test105SuspendWhileIcfSyncImprecise"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); // Resource gives out changes slowly now. interruptedSyncImpreciseResource.getDummyResource().setOperationDelayOffset(500); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_RESOURCE_IMPRECISE_OID, false, 2000, true); // starts the task boolean suspended = suspendTask(TASK_SLOW_RESOURCE_IMPRECISE_OID, 5000); // THEN - displayThen(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_RESOURCE_IMPRECISE_OID, result); @@ -214,10 +214,10 @@ public void test105SuspendWhileIcfSyncImprecise() throws Exception { @Test public void test110SuspendWhileProcessing() throws Exception { final String TEST_NAME = "test110SuspendWhileProcessing"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -228,14 +228,14 @@ public void test110SuspendWhileProcessing() throws Exception { DummyInterruptedSyncResource.delay = 100; // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_MODEL_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_OID, 5000); // THEN - displayThen(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_OID, result); @@ -270,10 +270,10 @@ public void test110SuspendWhileProcessing() throws Exception { @Test public void test115SuspendWhileProcessingImprecise() throws Exception { final String TEST_NAME = "test115SuspendWhileProcessingImprecise"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -284,14 +284,14 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 100; // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextStart(TASK_SLOW_MODEL_IMPRECISE_OID, false, 2000, true); // starts the task Thread.sleep(4000); boolean suspended = suspendTask(TASK_SLOW_MODEL_IMPRECISE_OID, 5000); // THEN - displayThen(TEST_NAME); + then(); assertTrue("Task was not suspended", suspended); Task taskAfter = taskManager.getTaskWithResult(TASK_SLOW_MODEL_IMPRECISE_OID, result); @@ -314,10 +314,10 @@ public void test115SuspendWhileProcessingImprecise() throws Exception { @Test public void test120Batched() throws Exception { final String TEST_NAME = "test120Batched"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -329,12 +329,12 @@ public void test120Batched() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(24, true); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -344,12 +344,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 10); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -359,12 +359,12 @@ public void test120Batched() throws Exception { assertObjects(UserType.class, query, 20); // WHEN 3 (with error) - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_BATCHED_OID, false, 10000, true); // THEN 3 (with error) - displayThen(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -382,10 +382,10 @@ public void test120Batched() throws Exception { @Test public void test125BatchedImprecise() throws Exception { final String TEST_NAME = "test125BatchedImprecise"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -396,7 +396,7 @@ public void test125BatchedImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.delay = 0; // WHEN - displayWhen(TEST_NAME); + when(); try { waitForTaskNextRun(TASK_BATCHED_IMPRECISE_OID, false, 10000, true); @@ -406,7 +406,7 @@ public void test125BatchedImprecise() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_BATCHED_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -429,10 +429,10 @@ public void test125BatchedImprecise() throws Exception { @Test public void test130Error() throws Exception { final String TEST_NAME = "test130Error"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -444,12 +444,12 @@ public void test130Error() throws Exception { DummyInterruptedSyncResource.errorOn = getUserName(ERROR_ON, true); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -466,12 +466,12 @@ public void test130Error() throws Exception { // Another run - should fail the same // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -490,10 +490,10 @@ public void test130Error() throws Exception { @Test public void test135ErrorImprecise() throws Exception { final String TEST_NAME = "test135ErrorImprecise"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_I); @@ -505,7 +505,7 @@ public void test135ErrorImprecise() throws Exception { DummyInterruptedSyncImpreciseResource.errorOn = getUserName(ERROR_ON, false); // WHEN - displayWhen(TEST_NAME); + when(); try { waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); @@ -515,7 +515,7 @@ public void test135ErrorImprecise() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -534,12 +534,12 @@ public void test135ErrorImprecise() throws Exception { // Another run - should fail the same // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_ERROR_IMPRECISE_OID, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); taskAfter = taskManager.getTaskWithResult(TASK_ERROR_IMPRECISE_OID, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -557,10 +557,10 @@ public void test135ErrorImprecise() throws Exception { @Test public void test140DryRun() throws Exception { final String TEST_NAME = "test140DryRun"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -572,12 +572,12 @@ public void test140DryRun() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_DRY_RUN.oid, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN.oid, result); displayTaskWithOperationStats("Task after", taskAfter); @@ -596,10 +596,10 @@ public void test140DryRun() throws Exception { @Test public void test150DryRunWithUpdate() throws Exception { final String TEST_NAME = "test150DryRunWithUpdate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME); + AbstractSynchronizationStoryTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = getStartsWithQuery(USER_P); @@ -611,12 +611,12 @@ public void test150DryRunWithUpdate() throws Exception { DummyInterruptedSyncResource.errorOn = null; // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRun(TASK_DRY_RUN_WITH_UPDATE.oid, false, 10000, true); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = taskManager.getTaskWithResult(TASK_DRY_RUN_WITH_UPDATE.oid, result); displayTaskWithOperationStats("Task after", taskAfter); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java index a1e9afa6135..12889136655 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelDiscovery.java @@ -195,7 +195,6 @@ protected PrismObject getDefaultActor() { @Test public void test001Sanity() throws Exception { final String TEST_NAME = "test001Sanity"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceSteelBlue); @@ -214,7 +213,6 @@ public void test001Sanity() throws Exception { @Test public void test002SanityRefined() throws Exception { final String TEST_NAME = "test002SanityRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaSteelBlue = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummySteelBlueType, prismContext); @@ -231,10 +229,9 @@ public void test002SanityRefined() throws Exception { @Test public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -258,11 +255,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -271,7 +268,7 @@ public void test100Synchronize() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java index 324b0cede32..c17274ea029 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestParallelSynchronization.java @@ -165,7 +165,6 @@ protected PrismObject getDefaultActor() { @Test public void test001SanityAzure() throws Exception { final String TEST_NAME = "test001SanityAzure"; - displayTestTitle(TEST_NAME); display("Dummy resource azure", dummyResourceSteelBlue); @@ -181,7 +180,6 @@ public void test001SanityAzure() throws Exception { @Test public void test002SanityAzureRefined() throws Exception { final String TEST_NAME = "test002SanityAzureRefined"; - displayTestTitle(TEST_NAME); // WHEN RefinedResourceSchema refinedSchemaAzure = RefinedResourceSchemaImpl.getRefinedSchema(resourceDummySteelBlueType, prismContext); @@ -195,10 +193,9 @@ public void test002SanityAzureRefined() throws Exception { @Test public void test100Synchronize() throws Exception { final String TEST_NAME = "test100Synchronize"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -217,11 +214,11 @@ public void test100Synchronize() throws Exception { rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); if (DISTRIBUTION == Distribution.MULTITHREADED) { waitForTaskFinish(getSyncTaskOid(), true, 600000); @@ -230,7 +227,7 @@ public void test100Synchronize() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java index d45a58ab122..88eebcf36c7 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestProgressReporting.java @@ -62,8 +62,6 @@ public class TestProgressReporting extends AbstractInitializedModelIntegrationTe public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - setAutoTaskManagementEnabled(true); - interruptedSyncResource = new DummyInterruptedSyncResource(); interruptedSyncResource.init(dummyResourceCollection, initTask, initResult); @@ -84,8 +82,8 @@ public void test110ReconciliationSuspensionMultiNode() throws Exception { } private void executeReconciliation(TestResource reconciliationTask, String accountPrefix, int workers) throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN for (int i = 0; i < USERS; i++) { @@ -164,8 +162,8 @@ public void test160RecomputationSuspensionMultiNode() throws Exception { } private void executeRecomputation(TestResource recomputationTask, String rolePrefix, int workers) throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN System.out.println("Importing roles."); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java index a3bd43018e6..45d2eb41393 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestRecomputeTask.java @@ -87,17 +87,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti addObject(ARCHETYPE_TASK_RECOMPUTATION, initTask, initResult); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); - - setAutoTaskManagementEnabled(true); - -// DebugUtil.setDetailedDebugDump(true); } @Test public void test100RecomputeAll() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(6); @@ -175,7 +171,7 @@ public void test100RecomputeAll() throws Exception { TestUtil.assertSuccess(result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_FILE); dummyAuditService.clear(); @@ -183,12 +179,12 @@ public void test100RecomputeAll() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -257,8 +253,8 @@ private void displayRoles(Task task, OperationResult result) throws ObjectNotFou @Test public void test110RecomputeSome() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(7); @@ -269,12 +265,12 @@ public void test110RecomputeSome() throws Exception { TestUtil.assertSuccess(result); // Now do something evil, remove "red" construction from judge role - modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, false, null, null); + modifyRoleDeleteInducement(ROLE_JUDGE_OID, 1111L, false, null, getTestTask()); displayRoles(task, result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_CAPTAIN_FILE); dummyAuditService.clear(); @@ -282,12 +278,12 @@ public void test110RecomputeSome() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_CAPTAIN_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_CAPTAIN_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -313,8 +309,8 @@ public void test110RecomputeSome() throws Exception { @Test public void test120RecomputeByExpression() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareNotifications(); // Preconditions @@ -326,7 +322,7 @@ public void test120RecomputeByExpression() throws Exception { TestUtil.assertSuccess(result); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_FILE); dummyAuditService.clear(); @@ -334,12 +330,12 @@ public void test120RecomputeByExpression() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); @@ -372,8 +368,8 @@ public void test120RecomputeByExpression() throws Exception { @Test public void test130RecomputeLight() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // Preconditions assertUsers(7); @@ -405,7 +401,7 @@ public void test130RecomputeLight() throws Exception { rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(); + when(); addTask(TASK_USER_RECOMPUTE_LIGHT_FILE); dummyAuditService.clear(); @@ -413,12 +409,12 @@ public void test130RecomputeLight() throws Exception { waitForTaskStart(TASK_USER_RECOMPUTE_LIGHT_OID, false); // WHEN - displayWhen(); + when(); waitForTaskFinish(TASK_USER_RECOMPUTE_LIGHT_OID, true, 40000); // THEN - displayThen(); + then(); List> users = modelService.searchObjects(UserType.class, null, null, task, result); display("Users after recompute", users); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java index c35d864cd24..9a937271afa 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestUuid.java @@ -121,10 +121,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test200ReconcileDummyUuid() throws Exception { final String TEST_NAME = "test200ReconcileDummyUuid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -136,16 +136,16 @@ public void test200ReconcileDummyUuid() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_UUID_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECONCILE_DUMMY_UUID_OID, false); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 0, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -171,10 +171,10 @@ public void test200ReconcileDummyUuid() throws Exception { @Test public void test210ReconcileDummyUuidAddAugustus() throws Exception { final String TEST_NAME = "test210ReconcileDummyUuidAddAugustus"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -191,16 +191,16 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -239,10 +239,10 @@ public void test210ReconcileDummyUuidAddAugustus() throws Exception { @Test public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { final String TEST_NAME = "test220ReconcileDummyUuidDeleteAddAugustus"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -272,16 +272,16 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 1); List> users = modelService.searchObjects(UserType.class, null, null, task, result); @@ -329,10 +329,10 @@ public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception { @Test public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Exception { final String TEST_NAME = "test230ReconcileDummyUuidDeleteAugustusAddAugustina"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME); + TestUuid.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); @@ -360,16 +360,16 @@ public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Excepti reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECONCILE_DUMMY_UUID_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(taskBefore, true); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 2); List> users = modelService.searchObjects(UserType.class, null, null, task, result); diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java index ff0656c078b..2a56e031ceb 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/sync/TestValidityRecomputeTask.java @@ -83,10 +83,9 @@ protected String getValidityScannerTaskFileName() { @Test public void test100ImportValidityScannerTask() throws Exception { final String TEST_NAME = "test100ImportValidityScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Pretend that the user was added a long time ago @@ -101,14 +100,14 @@ public void test100ImportValidityScannerTask() throws Exception { XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(getValidityScannerTaskFileName()); waitForValidityTaskStart(); waitForValidityTaskFinish(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_VALIDITY_SCANNER_OID, startCal, endCal); @@ -120,10 +119,9 @@ public void test100ImportValidityScannerTask() throws Exception { @Test public void test110JackAssignJudgeDisabled() throws Exception { final String TEST_NAME = "test110JackAssignJudgeDisabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -135,10 +133,9 @@ public void test110JackAssignJudgeDisabled() throws Exception { @Test public void test111JackAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test111JackAssignJudgeNotYetValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -152,10 +149,9 @@ public void test111JackAssignJudgeNotYetValid() throws Exception { @Test public void test112JackAssignJudgeAfterValidity() throws Exception { final String TEST_NAME = "test112JackAssignJudgeAfterValidity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -169,10 +165,9 @@ public void test112JackAssignJudgeAfterValidity() throws Exception { @Test public void test115JackAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test115JackAssignJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -184,10 +179,9 @@ public void test115JackAssignJudgeEnabled() throws Exception { @Test public void test115JackAssignJudgeValid() throws Exception { final String TEST_NAME = "test115JackAssignJudgeValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -204,20 +198,20 @@ public void test115JackAssignJudgeValid() throws Exception { private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType activationType, Task task, OperationResult result) throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_JACK_USERNAME); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_JACK_USERNAME); PrismObject user = getUser(USER_JACK_OID); @@ -236,19 +230,19 @@ private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType private void testJackAssignRoleJudgeInvalid(final String TEST_NAME, ActivationType activationType, Task task, OperationResult result) throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_JACK_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_JACK_USERNAME); assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME); @@ -274,10 +268,9 @@ private void assert11xUserOk(PrismObject user) { @Test public void test120JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test120JackDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -288,12 +281,12 @@ public void test120JackDisableAssignmentJudge() throws Exception { AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -306,22 +299,21 @@ public void test120JackDisableAssignmentJudge() throws Exception { @Test public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test122JackReplaceNullAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -331,22 +323,21 @@ public void test122JackReplaceNullAdministrativeStatusAssignmentJudge() throws E @Test public void test123JackDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test123JackDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -356,22 +347,21 @@ public void test123JackDisableAssignmentJudge() throws Exception { @Test public void test124JackEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test124JackEnableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_JACK_OID, judgeAssignment.getId(), ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -381,24 +371,23 @@ public void test124JackEnableAssignmentJudge() throws Exception { @Test public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test125JackDeleteAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectDeleteProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -408,24 +397,23 @@ public void test125JackDeleteAdministrativeStatusAssignmentJudge() throws Except @Test public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception { final String TEST_NAME = "test126JackAddAdministrativeStatusAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectAddProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -435,10 +423,9 @@ public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception @Test public void test127JackDeleteActivationAssignmentJudge() throws Exception { final String TEST_NAME = "test127JackDeleteActivationAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -447,13 +434,13 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectDeleteContainer(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION), task, result, activationType); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -463,10 +450,9 @@ public void test127JackDeleteActivationAssignmentJudge() throws Exception { @Test public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { final String TEST_NAME = "test128JackAssignmentJudgeValidToSetInvalid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertDummyAccount(null, USER_JACK_USERNAME); @@ -477,13 +463,13 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { activationType.setValidTo(validTo); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceContainer(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION), task, result, activationType); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -493,10 +479,9 @@ public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception { @Test public void test129JackAssignmentJudgeValidToSetValid() throws Exception { final String TEST_NAME = "test129JackAssignmentJudgeValidToSetValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assertNoDummyAccount(null, USER_JACK_USERNAME); @@ -505,13 +490,13 @@ public void test129JackAssignmentJudgeValidToSetValid() throws Exception { validTo.add(XmlTypeConverter.createDuration(60*60*1000)); // one hour ahead // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, ItemPath.create(UserType.F_ASSIGNMENT, judgeAssignment.getId(), AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO), task, result, validTo); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); display("User after", user); assertDummyAccount(null, USER_JACK_USERNAME); @@ -536,10 +521,9 @@ private AssignmentType getJudgeAssignment(String userOid) throws ObjectNotFoundE @Test public void test130BarbossaAssignJudgeEnabled() throws Exception { final String TEST_NAME = "test130BarbossaAssignJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -550,19 +534,19 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -582,29 +566,28 @@ public void test130BarbossaAssignJudgeEnabled() throws Exception { @Test public void test131BarbossaAssignSailorEnabled() throws Exception { final String TEST_NAME = "test131BarbossaAssignSailorEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_SAILOR_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -624,29 +607,28 @@ public void test131BarbossaAssignSailorEnabled() throws Exception { @Test public void test132BarbossaDisableAssignmentJudge() throws Exception { final String TEST_NAME = "test132BarbossaDisableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertNoDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -665,29 +647,28 @@ public void test132BarbossaDisableAssignmentJudge() throws Exception { @Test public void test133BarbossaDisableAssignmentSailor() throws Exception { final String TEST_NAME = "test133BarbossaDisableAssignmentSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -701,25 +682,24 @@ public void test133BarbossaDisableAssignmentSailor() throws Exception { @Test public void test134BarbossaEnableAssignmentJudge() throws Exception { final String TEST_NAME = "test134BarbossaEnableAssignmentJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -739,25 +719,24 @@ public void test134BarbossaEnableAssignmentJudge() throws Exception { @Test public void test135BarbossaEnableAssignmentSailor() throws Exception { final String TEST_NAME = "test135BarbossaEnableAssignmentSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -777,10 +756,9 @@ public void test135BarbossaEnableAssignmentSailor() throws Exception { @Test public void test136BarbossaDisableBothAssignments() throws Exception { final String TEST_NAME = "test136BarbossaDisableBothAssignments"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -797,19 +775,19 @@ public void test136BarbossaDisableBothAssignments() throws Exception { ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -823,10 +801,9 @@ public void test136BarbossaDisableBothAssignments() throws Exception { @Test public void test137BarbossaEnableBothAssignments() throws Exception { final String TEST_NAME = "test137BarbossaEnableBothAssignments"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -849,19 +826,19 @@ public void test137BarbossaEnableBothAssignments() throws Exception { ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(null, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(null, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -884,10 +861,9 @@ public void test137BarbossaEnableBothAssignments() throws Exception { @Test public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { final String TEST_NAME = "test139BarbossaDisableBothAssignmentsUnassign"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_JUDGE_OID); @@ -932,19 +908,19 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { display("Unassign delta", objectDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); user = getUser(USER_BARBOSSA_OID); @@ -964,10 +940,9 @@ public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception { @Test public void test140BarbossaAssignRedJudgeEnabled() throws Exception { final String TEST_NAME = "test140BarbossaAssignRedJudgeEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // preconditions @@ -982,19 +957,19 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1014,29 +989,28 @@ public void test140BarbossaAssignRedJudgeEnabled() throws Exception { @Test public void test141BarbossaAssignRedSailorEnabled() throws Exception { final String TEST_NAME = "test141BarbossaAssignRedSailorEnabled"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); activationType.setAdministrativeStatus(ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1056,29 +1030,28 @@ public void test141BarbossaAssignRedSailorEnabled() throws Exception { @Test public void test142BarbossaDisableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test142BarbossaDisableAssignmentRedJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1097,29 +1070,28 @@ public void test142BarbossaDisableAssignmentRedJudge() throws Exception { @Test public void test143BarbossaDisableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test143BarbossaDisableAssignmentRedSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1137,25 +1109,24 @@ public void test143BarbossaDisableAssignmentRedSailor() throws Exception { @Test public void test144BarbossaEnableAssignmentRedJudge() throws Exception { final String TEST_NAME = "test144BarbossaEnableAssignmentRedJudge"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1175,25 +1146,24 @@ public void test144BarbossaEnableAssignmentRedJudge() throws Exception { @Test public void test145BarbossaEnableAssignmentRedSailor() throws Exception { final String TEST_NAME = "test145BarbossaEnableAssignmentRedSailor"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1213,10 +1183,9 @@ public void test145BarbossaEnableAssignmentRedSailor() throws Exception { @Test public void test146BarbossaDisableBothRedAssignments() throws Exception { final String TEST_NAME = "test146BarbossaDisableBothRedAssignments"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1239,19 +1208,19 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1269,10 +1238,9 @@ public void test146BarbossaDisableBothRedAssignments() throws Exception { @Test public void test147BarbossaEnableBothRedAssignments() throws Exception { final String TEST_NAME = "test147BarbossaEnableBothRedAssignments"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1295,19 +1263,19 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { ActivationStatusType.ENABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true); assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, @@ -1330,10 +1298,9 @@ public void test147BarbossaEnableBothRedAssignments() throws Exception { @Test public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception { final String TEST_NAME = "test149BarbossaDisableBothRedAssignmentsUnassign"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID); @@ -1375,20 +1342,20 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception display("Unassign delta", objectDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccount(null, USER_BARBOSSA_USERNAME); // to be on the safe side // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false); assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME); @@ -1410,10 +1377,9 @@ public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception @Test public void test190HermanGoesInvalid() throws Exception { final String TEST_NAME = "test190HermanGoesInvalid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); @@ -1428,11 +1394,11 @@ public void test190HermanGoesInvalid() throws Exception { clock.override(validTo); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); waitForValidityNextRunAssertSuccess(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); // THEN XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); @@ -1447,23 +1413,23 @@ public void test190HermanGoesInvalid() throws Exception { @Test public void test200ImportTriggerScannerTask() throws Exception { final String TEST_NAME = "test200ImportTriggerScannerTask"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TestTriggerTask.class.getName() + "." + TEST_NAME); + TestTriggerTask.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar startCal = clock.currentTimeXMLGregorianCalendar(); /// WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_TRIGGER_SCANNER_FILE); waitForTaskStart(TASK_TRIGGER_SCANNER_OID, false); waitForTaskFinish(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); XMLGregorianCalendar endCal = clock.currentTimeXMLGregorianCalendar(); assertLastScanTimestamp(TASK_TRIGGER_SCANNER_OID, startCal, endCal); @@ -1477,19 +1443,18 @@ public void test200ImportTriggerScannerTask() throws Exception { @Test public void test205AccountRedElaineDisable() throws Exception { final String TEST_NAME = "test205AccountRedElaineDisable"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAccountShadowReplace(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject accountShadow = getShadowModel(ACCOUNT_SHADOW_ELAINE_DUMMY_RED_OID); @@ -1503,7 +1468,6 @@ public void test205AccountRedElaineDisable() throws Exception { @Test public void test210JackAssignAndUnassignAccountRed() throws Exception { final String TEST_NAME = "test210JackAssignAndUnassignAccountRed"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME); @@ -1561,7 +1525,6 @@ public void test210JackAssignAndUnassignAccountRed() throws Exception { @Test public void test215JackDummyAccountDeleteAfterMonth() throws Exception { final String TEST_NAME = "test215JackDummyAccountDeleteAfterMonth"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME); @@ -1572,13 +1535,13 @@ public void test215JackDummyAccountDeleteAfterMonth() throws Exception { time.add(XmlTypeConverter.createDuration(true, 0, 1, 1, 0, 0, 0)); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); clock.override(time); waitForTaskNextRunAssertSuccess(TASK_TRIGGER_SCANNER_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME); } @@ -1586,7 +1549,6 @@ public void test215JackDummyAccountDeleteAfterMonth() throws Exception { @Test public void test220AddDrake() throws Exception { final String TEST_NAME = "test220AddDrake"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); display("Start", start); @@ -1630,7 +1592,7 @@ public void test220AddDrake() throws Exception { display("Drake before", userDrake); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(userDrake); @@ -1652,7 +1614,6 @@ public void test220AddDrake() throws Exception { @Test public void test222Drake4DaysBeforeValidFrom() throws Exception { final String TEST_NAME = "test222Drake4DaysBeforeValidFrom"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidFrom.clone(); start.add(XmlTypeConverter.createDuration(false, 0, 0, 4, 0, 0, 0)); @@ -1680,7 +1641,6 @@ public void test222Drake4DaysBeforeValidFrom() throws Exception { @Test public void test224Drake1DaysAfterValidFrom() throws Exception { final String TEST_NAME = "test224Drake1DaysAfterValidFrom"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidFrom.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 1, 0, 0, 0)); @@ -1707,7 +1667,6 @@ public void test224Drake1DaysAfterValidFrom() throws Exception { @Test public void test226Drake1DayBeforeValidTo() throws Exception { final String TEST_NAME = "test226Drake1DayBeforeValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(false, 0, 0, 1, 0, 0, 0)); @@ -1734,7 +1693,6 @@ public void test226Drake1DayBeforeValidTo() throws Exception { @Test public void test228Drake1DayAfterValidTo() throws Exception { final String TEST_NAME = "test228Drake1DayAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 1, 0, 0, 0)); @@ -1762,7 +1720,6 @@ public void test228Drake1DayAfterValidTo() throws Exception { @Test public void test230Drake20DaysAfterValidTo() throws Exception { final String TEST_NAME = "test230Drake20DaysAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 20, 0, 0, 0)); @@ -1790,7 +1747,6 @@ public void test230Drake20DaysAfterValidTo() throws Exception { @Test public void test232Drake40DaysAfterValidTo() throws Exception { final String TEST_NAME = "test232Drake40DaysAfterValidTo"; - displayTestTitle(TEST_NAME); XMLGregorianCalendar start = (XMLGregorianCalendar) drakeValidTo.clone(); start.add(XmlTypeConverter.createDuration(true, 0, 0, 40, 0, 0, 0)); @@ -1819,7 +1775,6 @@ public void test232Drake40DaysAfterValidTo() throws Exception { @Test public void test250CheckAccountRedElaine() throws Exception { final String TEST_NAME = "test250CheckAccountRedElaine"; - displayTestTitle(TEST_NAME); // GIVEN @@ -1838,10 +1793,9 @@ public void test250CheckAccountRedElaine() throws Exception { @Test public void test300HermanAssignJudgeNotYetValid() throws Exception { final String TEST_NAME = "test300HermanAssignJudgeNotYetValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ActivationType activationType = new ActivationType(); @@ -1855,21 +1809,20 @@ public void test300HermanAssignJudgeNotYetValid() throws Exception { display("Assignment validTo", judgeAssignmentValidTo); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_HERMAN_OID, ROLE_JUDGE_OID, activationType, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertNoDummyAccount(null, USER_HERMAN_USERNAME); } @Test public void test310HermanAssignJudgeBecomesValid() throws Exception { final String TEST_NAME = "test310HermanAssignJudgeBecomesValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = getUser(USER_HERMAN_OID); @@ -1889,10 +1842,9 @@ public void test310HermanAssignJudgeBecomesValid() throws Exception { @Test public void test315HermanAssignJudgeBecomesInValid() throws Exception { final String TEST_NAME = "test315HermanAssignJudgeBecomesInValid"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); XMLGregorianCalendar start = (XMLGregorianCalendar) judgeAssignmentValidTo.clone(); diff --git a/model/model-test/pom.xml b/model/model-test/pom.xml index 956b4e839e0..2d83ff38c0c 100644 --- a/model/model-test/pom.xml +++ b/model/model-test/pom.xml @@ -28,7 +28,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT com.evolveum.midpoint.infra 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 adaf8f4b605..a3e480d1912 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 @@ -1,6684 +1,6508 @@ -/* - * Copyright (c) 2010-2019 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.test; - -import static com.evolveum.midpoint.prism.PrismObject.asObjectableList; -import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.xml.bind.JAXBException; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.model.api.authentication.*; -import com.evolveum.midpoint.model.test.asserter.*; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; -import com.evolveum.midpoint.prism.path.*; -import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; -import com.evolveum.midpoint.schema.*; -import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.*; -import com.evolveum.midpoint.schema.statistics.StatisticsUtil; -import com.evolveum.midpoint.task.api.TaskDebugUtil; -import com.evolveum.midpoint.test.*; -import com.evolveum.midpoint.test.asserter.*; -import com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter; -import com.evolveum.midpoint.util.*; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.mutable.MutableInt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.opends.server.types.DirectoryException; -import org.opends.server.types.Entry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.security.access.ConfigAttribute; -import org.springframework.security.access.SecurityConfig; -import org.springframework.security.authentication.AnonymousAuthenticationToken; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.context.SecurityContextImpl; -import org.springframework.security.web.FilterInvocation; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; - -import com.evolveum.icf.dummy.resource.ConflictException; -import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyGroup; -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.icf.dummy.resource.SchemaViolationException; -import com.evolveum.midpoint.audit.api.AuditEventRecord; -import com.evolveum.midpoint.audit.api.AuditEventStage; -import com.evolveum.midpoint.audit.api.AuditEventType; -import com.evolveum.midpoint.audit.api.AuditReferenceValue; -import com.evolveum.midpoint.common.Clock; -import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; -import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification; -import com.evolveum.midpoint.model.api.ModelAuditService; -import com.evolveum.midpoint.model.api.ModelAuthorizationAction; -import com.evolveum.midpoint.model.api.ModelDiagnosticService; -import com.evolveum.midpoint.model.api.ModelExecuteOptions; -import com.evolveum.midpoint.model.api.ModelInteractionService; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.api.RoleSelectionSpecification; -import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; -import com.evolveum.midpoint.model.api.context.ModelContext; -import com.evolveum.midpoint.model.api.context.ModelElementContext; -import com.evolveum.midpoint.model.api.context.ModelProjectionContext; -import com.evolveum.midpoint.model.api.expr.MidpointFunctions; -import com.evolveum.midpoint.model.api.hooks.HookRegistry; -import com.evolveum.midpoint.model.api.interaction.DashboardService; -import com.evolveum.midpoint.model.common.SystemObjectCache; -import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver; -import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; -import com.evolveum.midpoint.notifications.api.NotificationManager; -import com.evolveum.midpoint.notifications.api.transports.Message; -import com.evolveum.midpoint.prism.crypto.EncryptionException; -import com.evolveum.midpoint.prism.match.MatchingRule; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.ObjectFilter; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.query.OrgFilter; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.prism.xml.XmlTypeConverter; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.common.ObjectResolver; -import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; -import com.evolveum.midpoint.schema.constants.ObjectTypes; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.security.api.Authorization; -import com.evolveum.midpoint.security.api.AuthorizationConstants; -import com.evolveum.midpoint.security.api.MidPointPrincipal; -import com.evolveum.midpoint.security.api.SecurityContextManager; -import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; -import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; -import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.task.api.TaskExecutionStatus; -import com.evolveum.midpoint.test.util.MidPointAsserts; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.exception.TunnelException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; -import com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType; -import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; - -/** - * Abstract framework for an integration test that is placed on top of a model API. - * This provides complete environment that the test should need, e.g model service instance, repository, provisioning, - * dummy auditing, etc. It also implements lots of useful methods to make writing the tests easier. - * - * @author Radovan Semancik - * - */ -public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTest { - - protected static final int DEFAULT_TASK_WAIT_TIMEOUT = 25000; - protected static final long DEFAULT_TASK_SLEEP_TIME = 200; - - protected static final String CONNECTOR_DUMMY_TYPE = "com.evolveum.icf.dummy.connector.DummyConnector"; - protected static final String CONNECTOR_DUMMY_VERSION = "2.0"; - protected static final String CONNECTOR_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; - - protected static final String CONNECTOR_LDAP_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; - protected static final String CONNECTOR_LDAP_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"; - - protected static final String CONNECTOR_AD_TYPE = "Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; - protected static final String CONNECTOR_AD_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/ActiveDirectory.Connector/Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; - - protected static final ItemPath ACTIVATION_ADMINISTRATIVE_STATUS_PATH = SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; - protected static final ItemPath ACTIVATION_VALID_FROM_PATH = SchemaConstants.PATH_ACTIVATION_VALID_FROM; - protected static final ItemPath ACTIVATION_VALID_TO_PATH = SchemaConstants.PATH_ACTIVATION_VALID_TO; - protected static final ItemPath PASSWORD_VALUE_PATH = SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; - - private static final String DEFAULT_CHANNEL = SchemaConstants.CHANNEL_GUI_USER_URI; - - protected static final String LOG_PREFIX_FAIL = "SSSSS=X "; - protected static final String LOG_PREFIX_ATTEMPT = "SSSSS=> "; - protected static final String LOG_PREFIX_DENY = "SSSSS=- "; - protected static final String LOG_PREFIX_ALLOW = "SSSSS=+ "; - - @Autowired protected ModelService modelService; - @Autowired protected ModelInteractionService modelInteractionService; - @Autowired protected ModelDiagnosticService modelDiagnosticService; - @Autowired protected DashboardService dashboardService; - @Autowired protected ModelAuditService modelAuditService; - @Autowired protected ModelPortType modelWeb; - @Autowired - @Qualifier("cacheRepositoryService") - protected RepositoryService repositoryService; - @Autowired - @Qualifier("sqlRepositoryServiceImpl") - protected RepositoryService plainRepositoryService; - - @Autowired protected SystemObjectCache systemObjectCache; - @Autowired protected RelationRegistry relationRegistry; - @Autowired protected ProvisioningService provisioningService; - @Autowired protected HookRegistry hookRegistry; - @Autowired protected Clock clock; - @Autowired protected SchemaHelper schemaHelper; - @Autowired protected DummyTransport dummyTransport; - @Autowired protected SecurityEnforcer securityEnforcer; - @Autowired protected SecurityContextManager securityContextManager; - @Autowired protected MidpointFunctions libraryMidpointFunctions; - @Autowired protected ValuePolicyProcessor valuePolicyProcessor; - - @Autowired(required = false) - @Qualifier("modelObjectResolver") - protected ObjectResolver modelObjectResolver; - - @Autowired(required = false) - protected NotificationManager notificationManager; - - @Autowired(required = false) - protected GuiProfiledPrincipalManager focusProfileService; - - protected DummyResourceCollection dummyResourceCollection; - - protected DummyAuditService dummyAuditService; - - protected boolean verbose = false; - - private static final Trace LOGGER = TraceManager.getTrace(AbstractModelIntegrationTest.class); - - public AbstractModelIntegrationTest() { - super(); - } - - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - LOGGER.trace("initSystem"); - dummyResourceCollection = new DummyResourceCollection(modelService); - startResources(); - dummyAuditService = DummyAuditService.getInstance(); - InternalsConfig.reset(); - InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); - // Make sure the checks are turned on - InternalsConfig.turnOnAllChecks(); - // By default, notifications are turned off because of performance implications. Individual tests turn them on for themselves. - if (notificationManager != null) { - notificationManager.setDisabled(true); - } - } - - protected boolean isAvoidLoggingChange() { - return true; - } - - @Override - public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { - super.postInitSystem(initTask, initResult); - if (dummyResourceCollection != null) { - dummyResourceCollection.resetResources(); - } - } - - protected void startResources() throws Exception { - // Nothing to do by default - } - - @AfterClass - protected void cleanUpSecurity() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - securityContext.setAuthentication(null); - } - - protected void initDummyResource(String name, DummyResourceContoller controller) { - dummyResourceCollection.initDummyResource(name, controller); - } - - protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, - 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 { - return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, null, task, result); - } - - protected DummyResourceContoller initDummyResourcePirate(String name, File resourceFile, String resourceOid, - 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 { - return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaAd(), task, result); - } - - protected DummyResourceContoller getDummyResourceController(String name) { - return dummyResourceCollection.get(name); - } - - protected DummyResourceContoller getDummyResourceController() { - return getDummyResourceController(null); - } - - protected DummyAccountAsserter assertDummyAccountByUsername(String dummyResourceName, String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertAccountByUsername(username); - } - - protected DummyGroupAsserter assertDummyGroupByName(String dummyResourceName, String name) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertGroupByName(name); - } - - protected DummyResource getDummyResource(String name) { - return dummyResourceCollection.getDummyResource(name); - } - - protected DummyResource getDummyResource() { - return getDummyResource(null); - } - - protected PrismObject getDummyResourceObject(String name) { - return dummyResourceCollection.getResourceObject(name); - } - - protected PrismObject getDummyResourceObject() { - return getDummyResourceObject(null); - } - - protected ResourceType getDummyResourceType(String name) { - return dummyResourceCollection.getResourceType(name); - } - - protected ResourceType getDummyResourceType() { - return getDummyResourceType(null); - } - - protected void importObjectFromFile(String filename) throws FileNotFoundException { - importObjectFromFile(new File(filename)); - } - - protected void importObjectFromFile(File file) throws FileNotFoundException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".importObjectFromFile"); - importObjectFromFile(file, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void importObjectFromFile(String filename, OperationResult result) throws FileNotFoundException { - importObjectFromFile(new File(filename), result); - } - - protected void importObjectFromFile(File file, OperationResult result) throws FileNotFoundException { - OperationResult subResult = result.createSubresult(AbstractModelIntegrationTest.class.getName()+".importObjectFromFile"); - subResult.addParam("filename", file.getPath()); - LOGGER.trace("importObjectFromFile: {}", file); - Task task = taskManager.createTaskInstance(); - importObjectFromFile(file, task, result); - subResult.computeStatus(); - if (subResult.isError()) { - LOGGER.error("Import of file "+file+" failed:\n{}", subResult.debugDump()); - Throwable cause = findCause(subResult); - throw new SystemException("Import of file "+file+" failed: "+subResult.getMessage(), cause); - } - } - - protected void importObjectFromFile(File file, Task task, OperationResult result) throws FileNotFoundException { - importObjectFromFile(file, MiscSchemaUtil.getDefaultImportOptions(), task, result); - } - - protected void importObjectFromFile(File file, ImportOptionsType options, Task task, OperationResult result) throws FileNotFoundException { - FileInputStream stream = new FileInputStream(file); - modelService.importObjectsFromStream(stream, PrismContext.LANG_XML, options, task, result); - } - - protected void importObjectsFromFileNotRaw(File file, Task task, OperationResult result) throws FileNotFoundException { - ImportOptionsType options = MiscSchemaUtil.getDefaultImportOptions(); - ModelExecuteOptionsType modelOptions = new ModelExecuteOptionsType(); - modelOptions.setRaw(false); - options.setModelExecutionOptions(modelOptions); - importObjectFromFile(file, options, task, result); - } - - protected Throwable findCause(OperationResult result) { - if (result.getCause() != null) { - return result.getCause(); - } - for (OperationResult sub: result.getSubresults()) { - Throwable cause = findCause(sub); - if (cause != null) { - return cause; - } - } - return null; - } - - protected PrismObject importAndGetObjectFromFile(Class type, String filename, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return importAndGetObjectFromFile(type, new File(filename), oid, task, result); - } - - protected PrismObject importAndGetObjectFromFile(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - importObjectFromFile(file, result); - OperationResult importResult = result.getLastSubresult(); - TestUtil.assertSuccess("Import of "+file+" has failed", importResult); - return modelService.getObject(type, oid, null, task, result); - } - - protected PrismObject importAndGetObjectFromFileIgnoreWarnings(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - importObjectFromFile(file, result); - OperationResult importResult = result.getLastSubresult(); - OperationResultStatus status = importResult.getStatus(); - if (status == OperationResultStatus.FATAL_ERROR || status == OperationResultStatus.PARTIAL_ERROR) { - fail("Import of "+file+" has failed: "+importResult.getMessage()); - } - return modelService.getObject(type, oid, null, task, result); - } - - /** - * This is not the real thing. It is just for the tests. - */ - protected void applyResourceSchema(ShadowType accountType, ResourceType resourceType) throws SchemaException { - IntegrationTestTools.applyResourceSchema(accountType, resourceType, prismContext); - } - - - protected void assertUsers(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(UserType.class, expectedNumberOfUsers); - } - - protected void assertRoles(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(RoleType.class, expectedNumberOfUsers); - } - - protected void assertServices(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(ServiceType.class, expectedNumberOfUsers); - } - - protected void assertObjects(Class type, int expectedNumberOfUsers) throws SchemaException, - ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertObjects(type, null, expectedNumberOfUsers); - } - - protected void assertObjects(Class type, ObjectQuery query, int expectedNumberOfUsers) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfUsers, getObjectCount(type, query)); - } - - protected int getObjectCount(Class type) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getObjectCount(type, null); - } - - protected int getObjectCount(Class type, ObjectQuery query) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); - OperationResult result = task.getResult(); - List> users = modelService.searchObjects(type, query, null, task, result); - if (verbose) display(type.getSimpleName()+"s", users); - return users.size(); - } - - protected void searchObjectsIterative(Class type, ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertObjects"); - OperationResult result = task.getResult(); - final MutableInt count = new MutableInt(0); - // Cannot convert to lambda here. Java does not want to understand the generic types properly. - SearchResultMetadata searchMetadata = modelService.searchObjectsIterative(type, query, (object, oresult) -> { - count.increment(); - if (handler != null) { - handler.accept(object); - } - return true; - }, null, task, result); - if (verbose) display(type.getSimpleName()+"s", count.getValue()); - assertEquals("Unexpected number of "+type.getSimpleName()+"s", expectedNumberOfObjects, count.getValue()); - } - - protected void assertUserProperty(String userOid, QName propertyName, Object... expectedPropValues) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("getObject"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertUserProperty(user, propertyName, expectedPropValues); - } - - protected void assertUserNoProperty(String userOid, QName propertyName) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("getObject"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertUserNoProperty(user, propertyName); - } - - protected void assertUserProperty(PrismObject user, QName propertyName, Object... expectedPropValues) { - PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property != null : "No property "+propertyName+" in "+user; - PrismAsserts.assertPropertyValue(property, expectedPropValues); - } - - protected void assertUserNoProperty(PrismObject user, QName propertyName) { - PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); - assert property == null : "Property "+propertyName+" present in "+user+": "+property; - } - - protected void assertAdministrativeStatusEnabled(PrismObject user) { - assertAdministrativeStatus(user, ActivationStatusType.ENABLED); - } - - protected void assertAdministrativeStatusDisabled(PrismObject user) { - assertAdministrativeStatus(user, ActivationStatusType.DISABLED); - } - - protected void assertAdministrativeStatus(PrismObject object, ActivationStatusType expected) { - PrismProperty statusProperty = object.findProperty(ACTIVATION_ADMINISTRATIVE_STATUS_PATH); - if (expected == null && statusProperty == null) { - return; - } - assert statusProperty != null : "No status property in "+object; - ActivationStatusType status = statusProperty.getRealValue(); - if (expected == null && status == null) { - return; - } - assert status != null : "No status property is null in "+object; - assert status == expected : "status property is "+status+", expected "+expected+" in "+object; - } - - protected void assertEffectiveStatus(PrismObject focus, ActivationStatusType expected) { - ActivationType activation = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activation); - assertEquals("Unexpected effective activation status in "+focus, expected, activation.getEffectiveStatus()); - } - - protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserReplace(userOid, propertyPath, null, task, result, newRealValue); - } - - protected void modifyUserReplace(String userOid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserReplaceDelta(userOid, propertyPath, newRealValue); - executeChanges(objectDelta, options, task, result); - } - - protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyObjectReplaceProperty(type, oid, propertyPath, null, task, result, newRealValue); - } - - protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, options, task, result); - } - - protected void modifyObjectDeleteProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationDeleteProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectAddProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationAddProperty(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectReplaceContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectAddContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectDeleteContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(type, oid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyObjectReplaceReference(Class type, String oid, ItemPath refPath, Task task, OperationResult result, PrismReferenceValue... refVals) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = prismContext.deltaFactory().object() - .createModificationReplaceReference(type, oid, refPath, refVals); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyUserAdd(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserAddDelta(userOid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyUserDelete(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta objectDelta = createModifyUserDeleteDelta(userOid, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void modifyAccountShadowReplace(String accountOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, - ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - PrismObject shadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); - String resourceOid = shadow.asObjectable().getResourceRef().getOid(); - PrismObject resource = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result); - ObjectDelta objectDelta = createModifyAccountShadowReplaceDelta(accountOid, resource, propertyPath, newRealValue); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected ObjectDelta createOldNewPasswordDelta(String oid, String oldPassword, String newPassword) throws SchemaException { - ProtectedStringType oldPasswordPs = new ProtectedStringType(); - oldPasswordPs.setClearValue(oldPassword); - - ProtectedStringType newPasswordPs = new ProtectedStringType(); - newPasswordPs.setClearValue(newPassword); - - return deltaFor(UserType.class) - .item(PASSWORD_VALUE_PATH) - .oldRealValue(oldPasswordPs) - .replace(newPasswordPs) - .asObjectDelta(oid); - } - - protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { - Task task = createTask("modifyUserChangePassword"); - OperationResult result = task.getResult(); - modifyUserChangePassword(userOid, newPassword, task, result); - assertSuccess(result); - } - - protected void modifyUserChangePassword(String userOid, String newPassword, Task task, OperationResult result) throws CommonException { - modifyFocusChangePassword(UserType.class, userOid, newPassword, task, result); - } - - protected void modifyFocusChangePassword(Class type, String oid, String newPassword, Task task, OperationResult result) throws CommonException { - ProtectedStringType passwordPs = new ProtectedStringType(); - passwordPs.setClearValue(newPassword); - modifyObjectReplaceProperty(type, oid, PASSWORD_VALUE_PATH, task, result, passwordPs); - } - - protected void modifyUserSetPassword(String userOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ProtectedStringType userPasswordPs = new ProtectedStringType(); - userPasswordPs.setClearValue(newPassword); - PasswordType passwordType = new PasswordType(); - passwordType.setValue(userPasswordPs); - ObjectDelta delta = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).add(passwordType) - .asObjectDelta(userOid); - executeChanges(delta, null, task, result); - } - - protected void modifyAccountChangePassword(String accountOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ProtectedStringType userPasswordPs = new ProtectedStringType(); - userPasswordPs.setClearValue(newPassword); - modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); - } - - protected void clearUserPassword(String userOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask("clearUserPassword"); - OperationResult result = task.getResult(); - List> itemDeltas = prismContext.deltaFor(UserType.class) - .item(SchemaConstants.PATH_PASSWORD).replace() - .asItemDeltas(); - repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); - assertSuccess(result); - } - - protected void renameObject(Class type, String oid, String newName, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyObjectReplaceProperty(type, oid, ObjectType.F_NAME, task, result, createPolyString(newName)); - } - - protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("recomputeUser"); - OperationResult result = task.getResult(); - modelService.recompute(UserType.class, userOid, null, task, result); - assertSuccess(result); - } - - protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(UserType.class, userOid, null, task, result); - } - - protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(clazz, userOid, null, task, result); - } - - protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - modelService.recompute(UserType.class, userOid, options, task, result); - } - - protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); - OperationResult result = task.getResult(); - assignRole(userOid, roleOid, task, result); - assertSuccess(result); - } - - protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - 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 { - 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 { - 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 { - assignRole(focusClass, focusOid, roleOid, (ActivationType) null, task, result); - } - - protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void unassignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); - } - - protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - 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 { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); - } - - protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void assignService(Class focusClass, String focusOid, String targetOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, ServiceType.COMPLEX_TYPE, null, task, null, activationType, true, result); - } - - protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); - } - - protected void assignFocus(Class focusClass, String focusOid, QName targetType, String targetOid, QName relation, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, targetType, relation, task, null, activationType, true, result); - } - - protected void assignRole(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, true, result); - } - - protected void assignRole(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, true, options, result); - } - - protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignRole"); - OperationResult result = task.getResult(); - assignRole(userOid, roleOid, relation, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, true, result); - } - - protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = createTask("unassignRole"); - OperationResult result = task.getResult(); - unassignRole(userOid, roleOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void unassignRoleByAssignmentValue(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - AssignmentType assignment = findAssignmentByTargetRequired(focus, roleOid); - ObjectDelta delta = prismContext.deltaFor(focus.getCompileTimeClass()) - .item(FocusType.F_ASSIGNMENT) - .delete(assignment.clone()) - .asObjectDeltaCast(focus.getOid()); - modelService.executeChanges(singleton(delta), null, task, result); - } - - protected void unassignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void unassignService(String userOid, String serviceOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void unassignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, options, result); - } - - protected void assignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, true, result); - } - - protected void assignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, true, options, result); - } - - protected void unassignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, false, result); - } - - protected void unassignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, false, options, result); - } - - 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); - } - - 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); - } - - protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, false, result); - } - - protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignAllRoles(userOid, false); - } - - protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = getOrCreateSimpleTask("unassignAllRoles"); - OperationResult result = task.getResult(); - PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignment: user.asObjectable().getAssignment()) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null) { - if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container() - .createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - cval.setId(assignment.getId()); - assignmentDelta.addValueToDelete(cval); - modifications.add(assignmentDelta); - } - } - } - if (modifications.isEmpty()) { - return; - } - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(userOid, modifications, UserType.class); - Collection> deltas = MiscSchemaUtil.createCollection(userDelta); - modelService.executeChanges(deltas, useRawPlusRecompute ? ModelExecuteOptions.createRaw() : null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - - if (useRawPlusRecompute) { - recomputeUser(userOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - } - - protected void assignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, true, result); - } - - protected void unassignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer)null, false, result); - } - - protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - induceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); - } - - protected void induceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, true, null, result); - } - - protected void induceOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, orgOid, OrgType.COMPLEX_TYPE, null, task, null, true, null, result); - } - - protected void uninduceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, null, result); - } - - protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - uninduceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); - } - - protected void assignOrg(String userOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignOrg(userOid, orgOid, null, task, result); - } - - protected void assignOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - assignOrg(focusType, focusOid, orgOid, null, task, result); - } - - protected void assignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignOrg(userOid, orgOid, prismContext.getDefaultRelation()); - } - - protected void assignOrg(String userOid, String orgOid, QName relation) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractIntegrationTest.class.getName()+".assignOrg"); - OperationResult result = task.getResult(); - assignOrg(userOid, orgOid, relation, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); - } - - protected void assignOrg(Class focusType, String focusOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, true, result); - } - - protected void unassignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignOrg(userOid, orgOid, prismContext.getDefaultRelation()); - } - - protected void unassignOrg(String userOid, String orgOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - unassignOrg(userOid, orgOid, null, task, result); - } - - protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".unassignOrg"); - OperationResult result = task.getResult(); - unassignOrg(userOid, orgOid, relation, task, result); - assertSuccess(result); - } - - protected void unassignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); - } - - protected void unassignOrg(Class type, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignOrg(type, focusOid, orgOid, null, task, result); - } - - protected void unassignOrg(Class type, String focusOid, String orgOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer)null, false, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - 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) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, activationType, add, null, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, - OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentUserDelta(userOid, roleOid, refType, relation, extension, activationType, add); - executeChanges(userDelta, options, task, result); - } - - protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, - PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, refType, relation, task, extension, activationType, add, null, result); - } - - 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) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta delta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleOid, refType, relation, extension, activationType, add); - executeChanges(delta, options, task, result); - } - - protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, - 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) - 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) - 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) - 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) - 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); - executeChanges(focusDelta, options, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, null, null, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, relation, null, task, result); - } - - protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, - 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); - } - - protected void unassign(Class focusClass, String focusOid, String roleId, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - ObjectDelta focusDelta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleId, null, null, null, null, false); - executeChanges(focusDelta, null, task, result); - } - - protected void unassign(Class focusClass, String focusOid, long assignmentId, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassign(focusClass, focusOid, assignmentId, null, task, result); - } - - protected void unassign(Class focusClass, String focusOid, long assignmentId, ModelExecuteOptions options, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassign(focusClass, focusOid, createAssignmentIdOnly(assignmentId), options, task, result); - } - - protected void unassign(Class focusClass, String focusOid, AssignmentType currentAssignment, ModelExecuteOptions options, Task task, OperationResult result) - throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - assignmentDelta.addValuesToDelete(currentAssignment.asPrismContainerValue().clone()); - modifications.add(assignmentDelta); - ObjectDelta focusDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass - ); - executeChanges(focusDelta, options, task, result); - } - - protected void unlink(Class focusClass, String focusOid, String targetOid, Task task, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object() - .createModificationDeleteReference(focusClass, focusOid, FocusType.F_LINK_REF, - targetOid); - executeChanges(delta, null, task, result); - } - - protected void unlinkUser(String userOid, String targetOid) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - Task task = createTask("unlinkUser"); - OperationResult result = task.getResult(); - unlink(UserType.class, userOid, targetOid, task, result); - assertSuccess(result); - } - - /** - * Executes unassign delta by removing each assignment individually by id. - */ - protected void unassignAll(PrismObject focusBefore, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - executeChanges(createUnassignAllDelta(focusBefore), null, task, result); - } - - /** - * Creates unassign delta by removing each assignment individually by id. - */ - protected ObjectDelta createUnassignAllDelta(PrismObject focusBefore) throws SchemaException { - Collection> modifications = new ArrayList<>(); - for (AssignmentType assignmentType: focusBefore.asObjectable().getAssignment()) { - modifications.add((createAssignmentModification(assignmentType.getId(), false))); - } - return prismContext.deltaFactory().object() - .createModifyDelta(focusBefore.getOid(), modifications, focusBefore.getCompileTimeClass() - ); - } - - /** - * Executes assignment replace delta with empty values. - */ - protected void unassignAllReplace(String userOid, Task task, OperationResult result) - throws ObjectNotFoundException, - SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, - PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(UserType.class, userOid, - 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 { - 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 { - try { - return createAssignmentModification(type, elementName, roleOid, refType, relation, - assignment -> { - if (extension != null) { - try { - assignment.asPrismContainerValue().add(extension.clone()); - } catch (SchemaException e) { - throw new TunnelException(e); - } - } - assignment.setActivation(activationType); - }, add); - } catch (TunnelException te) { - throw (SchemaException)te.getCause(); - } - } - - - protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, - Consumer modificationBlock, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - if (add) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); - targetRef.getValue().setOid(roleOid); - targetRef.getValue().setTargetType(refType); - targetRef.getValue().setRelation(relation); - if (modificationBlock != null) { - modificationBlock.accept(cval.asContainerable()); - } - return assignmentDelta; - } - - protected ContainerDelta createAssignmentModification(long id, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - cval.setId(id); - if (add) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - return assignmentDelta; - } - - protected ContainerDelta createAssignmentEmptyDeleteModification(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { - AssignmentType existingAssignment = findAssignment(existingFocus, roleOid, relation); - return createAssignmentModification(existingAssignment.getId(), false); - } - - protected AssignmentType findAssignment(PrismObject existingFocus, String targetOid, QName relation) { - for (AssignmentType assignmentType : existingFocus.asObjectable().getAssignment()) { - if (assignmentMatches(assignmentType, targetOid, relation)) { - return assignmentType; - } - } - return null; - } - - protected boolean assignmentMatches(AssignmentType assignmentType, String targetOid, QName relation) { - ObjectReferenceType targetRef = assignmentType.getTargetRef(); - if (targetRef == null) { - return false; - } - return referenceMatches(targetRef, targetOid, relation); - } - - private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QName relation) { - if (targetOid != null && !targetOid.equals(ref.getOid())) { - return false; - } - if (relation != null && !QNameUtil.match(relation, ref.getRelation())) { - return false; - } - return true; - } - - protected ObjectDelta createAssignmentUserDelta(String userOid, String roleOid, QName refType, QName relation, - 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() - .createModifyDelta(userOid, modifications, UserType.class); - return userDelta; - } - - protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, - 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 { - 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 { - 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 { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); - return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); - } - - protected ObjectDelta createAssignmentFocusEmptyDeleteDelta(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { - Collection> modifications = new ArrayList<>(); - modifications.add((createAssignmentEmptyDeleteModification(existingFocus, roleOid, relation))); - return prismContext.deltaFactory().object() - .createModifyDelta(existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass() - ); - } - - protected ContainerDelta createAccountAssignmentModification(String resourceOid, String intent, boolean add) throws SchemaException { - return createAssignmentModification(resourceOid, ShadowKindType.ACCOUNT, intent, add); - } - - protected PropertyDelta createUserPropertyReplaceModification(QName propertyName, V... values) { - return prismContext.deltaFactory().property().createReplaceDelta(getUserDefinition(), propertyName, values); - } - - protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, - String intent, boolean add) throws SchemaException { - AssignmentType assignmentType = createConstructionAssignment(resourceOid, kind, intent); - return createAssignmentModification(assignmentType, add); - } - - protected ContainerDelta createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - - if (add) { - assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); - } else { - assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); - } - - PrismContainerDefinition assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); - assignmentDelta.applyDefinition(assignmentDef); - - return assignmentDelta; - } - - protected AssignmentType createAccountAssignment(String resourceOid, String intent) { - return createConstructionAssignment(resourceOid, ShadowKindType.ACCOUNT, intent); - } - - protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { - AssignmentType assignmentType = new AssignmentType(); - ConstructionType constructionType = new ConstructionType(); - constructionType.setKind(kind); - assignmentType.setConstruction(constructionType); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - resourceRef.setType(ResourceType.COMPLEX_TYPE); - constructionType.setResourceRef(resourceRef); - constructionType.setIntent(intent); - return assignmentType; - } - - protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { - AssignmentType assignmentType = new AssignmentType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(targetOid); - targetRef.setType(targetType); - assignmentType.setTargetRef(targetRef); - return assignmentType; - } - - protected ObjectDelta createParametricAssignmentDelta(String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) throws SchemaException { - Collection> modifications = new ArrayList<>(); - - ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); - PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); - if (adding) { - assignmentDelta.addValueToAdd(cval); - } else { - assignmentDelta.addValueToDelete(cval); - } - PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); - targetRef.getValue().setOid(roleOid); - targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); - - if (orgOid != null) { - PrismReference orgRef = cval.findOrCreateReference(AssignmentType.F_ORG_REF); - orgRef.getValue().setOid(orgOid); - } - - if (tenantOid != null) { - PrismReference tenantRef = cval.findOrCreateReference(AssignmentType.F_TENANT_REF); - tenantRef.getValue().setOid(tenantOid); - } - - - modifications.add(assignmentDelta); - return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class - ); - } - - protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); - } - - protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> deltas = MiscSchemaUtil.createCollection( - createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, true)); - modelService.executeChanges(deltas, options, task, result); - } - - protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); - } - - protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> deltas = MiscSchemaUtil.createCollection( - createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, false)); - modelService.executeChanges(deltas, options, task, result); - } - - protected void assertAssignees(String targetOid, int expectedAssignees) throws SchemaException { - assertAssignees(targetOid, prismContext.getDefaultRelation(), expectedAssignees); - } - - protected void assertAssignees(String targetOid, QName relation, int expectedAssignees) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".assertAssignees"); - int count = countAssignees(targetOid, relation, result); - if (count != expectedAssignees) { - SearchResultList> assignees = listAssignees(targetOid, result); - AssertJUnit.fail("Unexpected number of assignees of "+targetOid+" as '"+relation+"', expected "+expectedAssignees+", but was " + count+ ": "+assignees); - } - - } - - protected int countAssignees(String targetOid, OperationResult result) throws SchemaException { - return countAssignees(targetOid, prismContext.getDefaultRelation(), result); - } - - protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { - PrismReferenceValue refVal = itemFactory().createReferenceValue(); - refVal.setOid(targetOid); - refVal.setRelation(relation); - ObjectQuery query = prismContext.queryFor(FocusType.class) - .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(refVal) - .build(); - return repositoryService.countObjects(FocusType.class, query, null, result); - } - - protected SearchResultList> listAssignees(String targetOid, OperationResult result) throws SchemaException { - ObjectQuery query = prismContext.queryFor(FocusType.class) - .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(targetOid) - .build(); - return repositoryService.searchObjects(FocusType.class, query, null, result); - } - - protected ConstructionType createAccountConstruction(String resourceOid, String intent) throws SchemaException { - ConstructionType accountConstructionType = new ConstructionType(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - accountConstructionType.setResourceRef(resourceRef); - accountConstructionType.setIntent(intent); - return accountConstructionType; - } - - protected ObjectDelta createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException { - PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION); - ContainerDelta acDelta = prismContext.deltaFactory().container().create( - ItemPath.create(UserType.F_ASSIGNMENT, id, AssignmentType.F_CONSTRUCTION), pcd); - acDelta.setValueToReplace(newValue.asPrismContainerValue()); - - Collection> modifications = new ArrayList<>(); - modifications.add(acDelta); - ObjectDelta userDelta = prismContext.deltaFactory().object() - .createModifyDelta(userOid, modifications, UserType.class); - return userDelta; - } - - protected ObjectDelta createAccountAssignmentUserDelta(String focusOid, String resourceOid, String intent, boolean add) throws SchemaException { - return createAssignmentDelta(UserType.class, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, add); - } - - protected ObjectDelta createAssignmentDelta(Class type, String focusOid, - 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 - ); - return userDelta; - } - - protected Collection> executeChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Executing delta", objectDelta); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - return modelService.executeChanges(deltas, options, task, result); - } - - protected Collection> executeChanges(Collection> deltas, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Executing deltas", deltas); - return modelService.executeChanges(deltas, options, task, result); - } - - protected Collection> executeChangesAssertSuccess(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> rv = executeChanges(objectDelta, options, task, result); - assertSuccess(result); - return rv; - } - - protected ModelContext previewChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - display("Preview changes for delta", objectDelta); - Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - return modelInteractionService.previewChanges(deltas, options, task, result); - } - - protected void assignAccountToUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignAccount(UserType.class, focusOid, resourceOid, intent); - } - - protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); - OperationResult result = task.getResult(); - assignAccount(type, focusOid, resourceOid, intent, task, result); - assertSuccess(result); - } - - protected void assignAccountToUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assignAccount(UserType.class, focusOid, resourceOid, intent, task, result); - } - - protected void assignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, true); - executeChanges(userDelta, null, task, result); - } - - protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignAccount(UserType.class, focusOid, resourceOid, intent); - } - - protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assignAccount"); - OperationResult result = task.getResult(); - unassignAccount(type, focusOid, resourceOid, intent, task, result); - assertSuccess(result); - } - - protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - unassignAccount(UserType.class, focusOid, resourceOid, intent, task, result); - } - - protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, false); - Collection> deltas = MiscSchemaUtil.createCollection(userDelta); - modelService.executeChanges(deltas, null, task, result); - } - - protected void assignPolicyRule(Class type, String focusOid, PolicyRuleType policyRule, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AssignmentType assignmentType = new AssignmentType(); - assignmentType.setPolicyRule(policyRule); - assign(type, focusOid, assignmentType, task, result); - } - - protected void assign(Class type, String focusOid, AssignmentType assignmentType, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Collection> modifications = new ArrayList<>(); - modifications.add(createAssignmentModification(assignmentType, true)); - ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type - ); - executeChanges(userDelta, null, task, result); - } - - protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getUser"); - OperationResult result = task.getResult(); - PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(User) result not success", result); - return user; - } - - protected PrismObject getUserFromRepo(String userOid) throws ObjectNotFoundException, SchemaException { - return repositoryService.getObject(UserType.class, userOid, null, new OperationResult("dummy")); - } - - protected PrismObject findObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = getOrCreateSimpleTask("findObjectByName"); - OperationResult result = task.getResult(); - List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); - if (objects.isEmpty()) { - return null; - } - assert objects.size() == 1 : "Too many objects found for name "+name+": "+objects; - return objects.iterator().next(); - } - - protected ObjectQuery createNameQuery(String name) throws SchemaException { - return ObjectQueryUtil.createNameQuery(PrismTestUtil.createPolyString(name), prismContext); - } - - protected PrismObject findUserByUsername(String username) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return findObjectByName(UserType.class, username); - } - - protected PrismObject findServiceByName(String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return findObjectByName(ServiceType.class, name); - } - - protected RoleType getRoleSimple(String oid) { - try { - return getRole(oid).asObjectable(); - } catch (CommonException e) { - throw new SystemException("Unexpected exception while getting role " + oid + ": " + e.getMessage(), e); - } - } - - protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getRole"); - OperationResult result = task.getResult(); - PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Role) result not success", result); - return role; - } - - protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".findAccountByUsername"); - OperationResult result = task.getResult(); - return findAccountByUsername(username, resource, task, result); - } - - protected PrismObject findAccountByUsername(String username, PrismObject resource, - 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()) { - return null; - } - assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; - return accounts.iterator().next(); - } - - protected Collection> listAccounts(PrismObject resource, - Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; - ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); - ObjectQuery query = prismContext.queryFor(ShadowType.class) - .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) - .build(); - List> accounts = modelService.searchObjects(ShadowType.class, query, null, task, result); - return accounts; - } - - protected PrismObject getShadowModel(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, null, true); - } - - protected PrismObject getShadowModelNoFetch(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, GetOperationOptions.createNoFetch(), true); - } - - protected PrismObject getShadowModelFuture(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getShadowModel(accountOid, GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE), true); - } - - protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getShadowModel"); - OperationResult result = task.getResult(); - Collection> opts = null; - if (rootOptions != null) { - opts = SelectorOptions.createCollection(rootOptions); - } - LOGGER.info("Getting model shadow {} with options {}", shadowOid, opts); - PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts , task, result); - LOGGER.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); - result.computeStatus(); - if (assertSuccess) { - TestUtil.assertSuccess("getObject(shadow) result not success", result); - } - return shadow; - } - - protected void assertNoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertNoObject"); - assertNoObject(type, oid, task, task.getResult()); - } - - 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 - return; - } - } - - protected void assertObjectByName(Class type, String name, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, - ExpressionEvaluationException, ObjectNotFoundException { - SearchResultList> objects = modelService - .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, - result); - if (objects.isEmpty()) { - fail("Expected that " + type + " " + name + " did exist but it did not"); - } - } - - protected void assertNoObjectByName(Class type, String name, Task task, OperationResult result) - throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, - ExpressionEvaluationException, ObjectNotFoundException { - SearchResultList> objects = modelService - .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, - result); - if (!objects.isEmpty()) { - fail("Expected that " + type + " " + name + " did not exists but it did: " + objects); - } - } - - protected void assertNoShadow(String username, PrismObject resource, - 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()) { - return; - } - LOGGER.error("Found shadow for "+username+" on "+resource+" while not expecting it:\n"+accounts.get(0).debugDump()); - assert false : "Found shadow for "+username+" on "+resource+" while not expecting it: "+accounts; - } - - protected void assertHasShadow(String username, PrismObject resource, - 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()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); - } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); - } - } - - protected ShadowAsserter assertShadow(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { - ObjectQuery query = createAccountShadowQuery(username, resource); - OperationResult result = new OperationResult("assertShadow"); - List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); - if (accounts.isEmpty()) { - AssertJUnit.fail("No shadow for "+username+" on "+resource); - } else if (accounts.size() > 1) { - AssertJUnit.fail("Too many shadows for "+username+" on "+resource+" ("+accounts.size()+"): "+accounts); - } - ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username "+username+" on "+resource); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ShadowAsserter assertShadowByName(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException { - PrismObject shadow = findShadowByName(kind, intent, name, resource, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - - protected ShadowAsserter assertShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, String message, Task task, OperationResult result) - throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, - SecurityViolationException, ExpressionEvaluationException { - PrismObject shadow = findShadowByNameViaModel(kind, intent, name, resource, task, result); - assertNotNull("No shadow with name '"+name+"'", shadow); - return assertShadow(shadow, message); - } - - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Task task, OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - return findShadowByNameViaModel(kind, intent, name, resource, schemaHelper.getOperationOptionsBuilder().noFetch().build(), - task, result); - } - - protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, - PrismObject resource, Collection> options, Task task, - OperationResult result) - throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, - ConfigurationException, ExpressionEvaluationException { - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); - ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); - List> shadows = modelService.searchObjects(ShadowType.class, query, options, task, result); - if (shadows.isEmpty()) { - return null; - } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; - return shadows.iterator().next(); - } - - - protected ObjectQuery createAccountShadowQuery(String username, PrismObject resource) throws SchemaException { - RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - Collection identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; - ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); - //TODO: set matching rule instead of null - return prismContext.queryFor(ShadowType.class) - .itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getItemName()).eq(username) - .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) - .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) - .build(); - } - - protected String getSingleLinkOid(PrismObject focus) { - PrismReferenceValue accountRefValue = getSingleLinkRef(focus); - assertNull("Unexpected object in linkRefValue", accountRefValue.getObject()); - return accountRefValue.getOid(); - } - - protected PrismReferenceValue getSingleLinkRef(PrismObject focus) { - F focusType = focus.asObjectable(); - assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size()); - ObjectReferenceType linkRefType = focusType.getLinkRef().get(0); - String accountOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(accountOid)); - PrismReferenceValue accountRefValue = linkRefType.asReferenceValue(); - assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid()); - return accountRefValue; - } - - protected String getLinkRefOid(String userOid, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getLinkRefOid(getUser(userOid), resourceOid); - } - - protected String getLinkRefOid(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismReferenceValue linkRef = getLinkRef(focus, resourceOid); - if (linkRef == null) { - return null; - } - return linkRef.getOid(); - } - - protected PrismReferenceValue getLinkRef(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { - String linkTargetOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); - PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); - if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) { - // This is noFetch. Therefore there is no fetchResult - return linkRefType.asReferenceValue(); - } - } - AssertJUnit.fail("Account for resource "+resourceOid+" not found in "+focus); - return null; // Never reached. But compiler complains about missing return - } - - protected String getLinkRefOid(PrismObject focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - F focusType = focus.asObjectable(); - for (ObjectReferenceType linkRefType: focusType.getLinkRef()) { - String linkTargetOid = linkRefType.getOid(); - assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); - PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); - ShadowType shadowType = account.asObjectable(); - if (kind != null && !kind.equals(shadowType.getKind())) { - continue; - } - if (!MiscUtil.equals(intent, shadowType.getIntent())) { - continue; - } - if (resourceOid.equals(shadowType.getResourceRef().getOid())) { - // This is noFetch. Therefore there is no fetchResult - return linkTargetOid; - } - } - AssertJUnit.fail("Linked shadow for resource "+resourceOid+", kind "+kind+" and intent "+intent+" not found in "+focus); - return null; // Never reached. But compiler complains about missing return - } - - protected void assertUserNoAccountRefs(PrismObject user) { - UserType userJackType = user.asObjectable(); - assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size()); - } - - protected String assertAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(user, resourceOid); - assertNotNull("User " + user + " has no account on resource " + resourceOid, accountOid); - return accountOid; - } - - protected void assertAccounts(String userOid, int numAccounts) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("assertAccounts"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertLinks(user, numAccounts); - } - - protected void assertNoShadows(Collection shadowOids) throws SchemaException { - for (String shadowOid: shadowOids) { - assertNoShadow(shadowOid); - } - } - - protected void assertNoShadow(String shadowOid) throws SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); - // Check is shadow is gone - try { - PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); - display("Unexpected shadow", shadow); - AssertJUnit.fail("Shadow "+shadowOid+" still exists"); - } catch (ObjectNotFoundException e) { - // This is OK - } - } - - protected AssignmentType getUserAssignment(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getAssignment(getUser(userOid), roleOid); - } - - protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) - throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(userOid); - List assignments = user.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, - targetRef.getRelation())) { - return assignment; - } - } - return null; - } - - protected AssignmentType getAssignment(PrismObject focus, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List assignments = focus.asObjectable().getAssignment(); - for (AssignmentType assignment: assignments) { - ObjectReferenceType targetRef = assignment.getTargetRef(); - if (targetRef != null && roleOid.equals(targetRef.getOid())) { - return assignment; - } - } - return null; - } - - protected ItemPath getAssignmentPath(long id) { - return ItemPath.create(FocusType.F_ASSIGNMENT, id); - } - - protected void assertNoAssignments(PrismObject user) { - MidPointAsserts.assertNoAssignments(user); - } - - protected void assertNoAssignments(String userOid, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertNoAssignments(user); - } - - protected void assertNoAssignments(String userOid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoShadow"); - assertNoAssignments(userOid, result); - } - - protected AssignmentType assertAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - return assertAssignedRole(user, roleOid); - } - - protected AssignmentType assertAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - return assertAssignedRole(focus, roleOid); - } - - protected AssignmentType assertAssignedRole(PrismObject user, String roleOid) { - return MidPointAsserts.assertAssignedRole(user, roleOid); - } - - protected static void assertAssignedRoles(PrismObject user, String... roleOids) { - MidPointAsserts.assertAssignedRoles(user, roleOids); - } - - protected static void assertAssignedRoles(PrismObject user, Collection roleOids) { - MidPointAsserts.assertAssignedRoles(user, roleOids); - } - - protected AssignmentType assertInducedRole(PrismObject role, String roleOid) { - return MidPointAsserts.assertInducedRole(role, roleOid); - } - - protected void assignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignDeputy(userDeputyOid, userTargetOid, null, task, result); - } - - protected void assignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, true, result); - } - - protected void unassignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignDeputy(userDeputyOid, userTargetOid, null, task, result); - } - - protected void unassignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, false, result); - } - - protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, null, task, result, limitTargets); - } - - protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, assignmentMutator, task, result, limitTargets); - } - - protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, null, task, result, limitTargets); - } - - protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, assignmentMutator, task, result, limitTargets); - } - - protected void modifyDeputyAssignmentLimits(String userDeputyOid, String userTargetOid, boolean add, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, - assignment -> { - AssignmentSelectorType limitTargetContent = new AssignmentSelectorType(); - assignment.setLimitTargetContent(limitTargetContent); - for (ObjectReferenceType limitTarget: limitTargets) { - limitTargetContent.getTargetRef().add(limitTarget); - } - if (assignmentMutator != null) { - assignmentMutator.accept(assignment); - } - }, add, result); - } - - protected void assertAssignedDeputy(PrismObject focus, String targetUserOid) { - MidPointAsserts.assertAssigned(focus, targetUserOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY); - } - - protected static void assertAssignedOrgs(PrismObject user, String... orgOids) { - MidPointAsserts.assertAssignedOrgs(user, orgOids); - } - - protected void assertObjectRefs(String contextDesc, Collection real, ObjectType... expected) { - assertObjectRefs(contextDesc, real, objectsToOids(expected)); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, ObjectType... expected) { - assertPrismRefValues(contextDesc, real, objectsToOids(expected)); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, Collection expected) { - assertPrismRefValues(contextDesc, real, objectsToOids(expected)); - } - - protected void assertObjectRefs(String contextDesc, Collection real, String... expected) { - assertObjectRefs(contextDesc, true, real, expected); - } - - protected void assertObjectRefs(String contextDesc, boolean checkNames, Collection real, String... expected) { - List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: real) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getType()); - if (checkNames) { - assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); - } - } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); - } - - protected void assertPrismRefValues(String contextDesc, Collection real, String... expected) { - List refOids = new ArrayList<>(); - for (PrismReferenceValue ref: real) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in "+ref.getOid()+" in "+contextDesc, ref.getTargetType()); - assertNotNull("Missing name in "+ref.getOid()+" in "+contextDesc, ref.getTargetName()); - } - PrismAsserts.assertSets("Wrong values in "+contextDesc, refOids, expected); - } - - private String[] objectsToOids(ObjectType[] objects) { - return Arrays.stream(objects) - .map(o -> o.getOid()) - .toArray(String[]::new); - } - - private String[] objectsToOids(Collection objects) { - return objects.stream() - .map(o -> o.getOid()) - .toArray(String[]::new); - } - - protected void assertDelegatedRef(PrismObject focus, String... oids) { - List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getDelegatedRef()) { - refOids.add(ref.getOid()); - assertNotNull("Missing type in delegatedRef "+ref.getOid()+" in "+focus, ref.getType()); - } - PrismAsserts.assertSets("Wrong values in delegatedRef in "+focus, refOids, oids); - } - - protected void assertNotAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - MidPointAsserts.assertNotAssignedRole(focus, roleOid); - } - - protected void assertNotAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - MidPointAsserts.assertNotAssignedRole(user, roleOid); - } - - protected void assertNotAssignedResource(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - MidPointAsserts.assertNotAssignedResource(user, resourceOid); - } - - protected void assertAssignedResource(Class type, String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject focus = repositoryService.getObject(type, userOid, null, result); - MidPointAsserts.assertAssignedResource(focus, resourceOid); - } - - protected void assertNotAssignedRole(PrismObject user, String roleOid) { - MidPointAsserts.assertNotAssignedRole(user, roleOid); - } - - protected void assertNotAssignedOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertNotAssignedOrg(user, orgOid, relation); - } - - protected void assertAssignedOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedOrg(user, orgOid); - } - - protected void assertAssignedOrg(PrismObject focus, String orgOid, QName relation) { - MidPointAsserts.assertAssignedOrg(focus, orgOid, relation); - } - - protected AssignmentType assertAssignedOrg(PrismObject focus, String orgOid) { - return MidPointAsserts.assertAssignedOrg(focus, orgOid); - } - - protected void assertNotAssignedOrg(PrismObject focus, String orgOid) { - MidPointAsserts.assertNotAssignedOrg(focus, orgOid); - } - - protected AssignmentType assertAssignedOrg(PrismObject user, PrismObject org) { - return MidPointAsserts.assertAssignedOrg(user, org.getOid()); - } - - protected void assertHasOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedOrg(user, orgOid); - } - - protected void assertHasOrgs(PrismObject user, String... orgOids) throws Exception { - for (String orgOid: orgOids) { - assertHasOrg(user, orgOid); - } - assertHasOrgs(user, orgOids.length); - } - - protected void assertHasOrg(PrismObject focus, String orgOid) { - MidPointAsserts.assertHasOrg(focus, orgOid); - } - - protected void assertHasOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertHasOrg(user, orgOid, relation); - } - - protected void assertHasNoOrg(PrismObject user, String orgOid) { - MidPointAsserts.assertHasNoOrg(user, orgOid, null); - } - - protected void assertHasNoOrg(PrismObject user, String orgOid, QName relation) { - MidPointAsserts.assertHasNoOrg(user, orgOid, relation); - } - - protected void assertHasNoOrg(PrismObject user) { - MidPointAsserts.assertHasNoOrg(user); - } - - protected void assertHasOrgs(PrismObject user, int expectedNumber) { - MidPointAsserts.assertHasOrgs(user, expectedNumber); - } - - protected void assertHasArchetypes(PrismObject object, String... oids) { - for (String oid : oids) { - assertHasArchetype(object, oid); - } - assertHasArchetypes(object, oids.length); - } - - protected void assertHasArchetypes(PrismObject object, int expectedNumber) { - MidPointAsserts.assertHasArchetypes(object, expectedNumber); - } - - protected void assertHasArchetype(PrismObject object, String oid) { - MidPointAsserts.assertHasArchetype(object, oid); - } - - protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - List> subOrgs = getSubOrgs(baseOrgOid, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of org "+baseOrgOid+", has suborgs "+subOrgs, expected, subOrgs.size()); - } - - protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEquals("Unexpected number of suborgs of"+baseOrg+", has suborgs "+subOrgs, expected, subOrgs.size()); - } - - protected List> getSubOrgs(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(OrgType.class) - .isDirectChildOf(baseOrgOid) - .build(); - return modelService.searchObjects(OrgType.class, query, null, task, result); - } - - protected List> getSubOrgUsers(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(UserType.class) - .isDirectChildOf(baseOrgOid) - .build(); - return modelService.searchObjects(UserType.class, query, null, task, result); - } - - protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return dumpOrgTree(topOrgOid, false); - } - - protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".assertSubOrgs"); - OperationResult result = task.getResult(); - PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); - String dump = dumpOrgTree(topOrg, dumpUsers, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return dump; - } - - protected String dumpOrgTree(PrismObject topOrg, boolean dumpUsers, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - StringBuilder sb = new StringBuilder(); - dumpOrg(sb, topOrg, 0); - sb.append("\n"); - dumpSubOrgs(sb, topOrg.getOid(), dumpUsers, 1, task, result); - return sb.toString(); - } - - private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List> subOrgs = getSubOrgs(baseOrgOid, task, result); - for (PrismObject suborg: subOrgs) { - dumpOrg(sb, suborg, indent); - if (dumpUsers) { - dumpOrgUsers(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); - } - sb.append("\n"); - dumpSubOrgs(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); - } - } - - private void dumpOrgUsers(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - List> subUsers = getSubOrgUsers(baseOrgOid, task, result); - for (PrismObject subuser: subUsers) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, indent); - sb.append(subuser); - } - } - - private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { - DebugUtil.indentDebugDump(sb, indent); - sb.append(org); - List linkRefs = org.asObjectable().getLinkRef(); - sb.append(": ").append(linkRefs.size()).append(" links"); - } - - protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".displayUsers"); - OperationResult result = task.getResult(); - ResultHandler handler = (user, parentResult) -> { - display("User", user); - return true; - }; - modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void dumpFocus(String message, PrismObject focus) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".dumpFocus"); - StringBuilder sb = new StringBuilder(); - sb.append(focus.debugDump(0)); - sb.append("\nOrgs:"); - for (ObjectReferenceType parentOrgRef: focus.asObjectable().getParentOrgRef()) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - PrismObject org = repositoryService.getObject(OrgType.class, parentOrgRef.getOid(), null, result); - sb.append(org); - PolyStringType displayName = org.asObjectable().getDisplayName(); - if (displayName != null) { - sb.append(": ").append(displayName); - } - } - sb.append("\nProjections:"); - for (ObjectReferenceType linkRef: focus.asObjectable().getLinkRef()) { - PrismObject shadow = repositoryService.getObject(ShadowType.class, linkRef.getOid(), null, result); - ObjectReferenceType resourceRef = shadow.asObjectable().getResourceRef(); - PrismObject resource = repositoryService.getObject(ResourceType.class, resourceRef.getOid(), null, result); - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - sb.append(resource); - sb.append("/"); - sb.append(shadow.asObjectable().getKind()); - sb.append("/"); - sb.append(shadow.asObjectable().getIntent()); - sb.append(": "); - sb.append(shadow.asObjectable().getName()); - } - sb.append("\nAssignments:"); - for (AssignmentType assignmentType: focus.asObjectable().getAssignment()) { - sb.append("\n"); - DebugUtil.indentDebugDump(sb, 1); - if (assignmentType.getConstruction() != null) { - sb.append("Constr(").append(assignmentType.getConstruction().getDescription()).append(") "); - } - if (assignmentType.getTargetRef() != null) { - sb.append("-["); - if (assignmentType.getTargetRef().getRelation() != null) { - sb.append(assignmentType.getTargetRef().getRelation().getLocalPart()); - } - sb.append("]-> "); - Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(assignmentType.getTargetRef().getType()).getClassDefinition(); - PrismObject target = repositoryService.getObject(targetClass, assignmentType.getTargetRef().getOid(), null, result); - sb.append(target); - } - } - display(message, sb.toString()); - } - - protected void assertAssignments(PrismObject user, int expectedNumber) { - MidPointAsserts.assertAssignments(user, expectedNumber); - } - - protected void assertInducements(PrismObject role, int expectedNumber) { - MidPointAsserts.assertInducements(role, expectedNumber); - } - - protected void assertInducedRoles(PrismObject role, String... roleOids) { - assertInducements(role, roleOids.length); - for (String roleOid : roleOids) { - assertInducedRole(role, roleOid); - } - } - - protected void assertAssignments(PrismObject user, Class expectedType, int expectedNumber) { - MidPointAsserts.assertAssignments(user, expectedType, expectedNumber); - } - - protected void assertAssigned(PrismObject user, String targetOid, QName refType) { - MidPointAsserts.assertAssigned(user, targetOid, refType); - } - - protected void assertAssignedNoOrg(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedNoOrg(user); - } - - protected void assertAssignedNoOrg(PrismObject user) { - assertAssignedNo(user, OrgType.COMPLEX_TYPE); - } - - protected void assertAssignedNoRole(PrismObject focus, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - assertAssignedNoRole(focus); - } - - protected void assertAssignedNoRole(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedNoRole(user); - } - - protected void assertAssignedNoRole(PrismObject user) { - assertAssignedNo(user, RoleType.COMPLEX_TYPE); - } - - protected void assertAssignedNo(PrismObject user, QName refType) { - F userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ObjectReferenceType targetRef = assignmentType.getTargetRef(); - if (targetRef != null) { - if (refType.equals(targetRef.getType())) { - AssertJUnit.fail(user+" has role "+targetRef.getOid()+" while expected no roles"); - } - } - } - } - - protected void assertAssignedAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - assertAssignedAccount(user, resourceOid); - } - - protected AssignmentType assertAssignedAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { - UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ConstructionType construction = assignmentType.getConstruction(); - if (construction != null) { - if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { - continue; - } - if (resourceOid.equals(construction.getResourceRef().getOid())) { - return assignmentType; - } - } - } - AssertJUnit.fail(user.toString() + " does not have account assignment for resource " + resourceOid); - return null; // not reached - } - - protected void assertAssignedNoAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { - UserType userType = user.asObjectable(); - for (AssignmentType assignmentType: userType.getAssignment()) { - ConstructionType construction = assignmentType.getConstruction(); - if (construction != null) { - if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { - continue; - } - if (resourceOid.equals(construction.getResourceRef().getOid())) { - AssertJUnit.fail(user.toString()+" has account assignment for resource "+resourceOid+" while expecting no such assignment"); - } - } - } - } - - protected PrismObjectDefinition getRoleDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); - } - - protected PrismObjectDefinition getShadowDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); - } - - protected PrismContainerDefinition getAssignmentDefinition() { - return prismContext.getSchemaRegistry().findContainerDefinitionByType(AssignmentType.COMPLEX_TYPE); - } - - protected PrismContainerDefinition getAssignmentExtensionDefinition() { - PrismContainerDefinition assignmentDefinition = getAssignmentDefinition(); - return assignmentDefinition.findContainerDefinition(AssignmentType.F_EXTENSION); - } - - protected PrismContainer getAssignmentExtensionInstance() throws SchemaException { - return getAssignmentExtensionDefinition().instantiate(); - } - - protected PrismObjectDefinition getResourceDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); - } - - protected PrismObjectDefinition getAccountShadowDefinition() { - return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); - } - - - protected PrismObject createObject(Class type, String name) throws SchemaException { - PrismObject object = getObjectDefinition(type).instantiate(); - object.asObjectable().setName(createPolyStringType(name)); - return object; - } - - protected PrismObject createUser(String name, String fullName) throws SchemaException { - return createUser(name, fullName, null); - } - - protected PrismObject createUser(String name, String fullName, Boolean enabled) throws SchemaException { - PrismObject user = createObject(UserType.class, name); - UserType userType = user.asObjectable(); - userType.setFullName(createPolyStringType(fullName)); - if (enabled != null) { - ActivationType activation = new ActivationType(); - userType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - } - return user; - } - - protected PrismObject createUser(String name, String givenName, String familyName, Boolean enabled) throws SchemaException { - PrismObject user = getUserDefinition().instantiate(); - UserType userType = user.asObjectable(); - userType.setName(createPolyStringType(name)); - userType.setGivenName(createPolyStringType(givenName)); - userType.setFamilyName(createPolyStringType(familyName)); - userType.setFullName(createPolyStringType(givenName + " " + familyName)); - if (enabled != null) { - ActivationType activation = new ActivationType(); - userType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - } - return user; - } - - protected void fillinUser(PrismObject user, String name, String fullName) { - user.asObjectable().setName(createPolyStringType(name)); - user.asObjectable().setFullName(createPolyStringType(fullName)); - } - - protected void fillinUserAssignmentAccountConstruction(PrismObject user, String resourceOid) { - AssignmentType assignmentType = new AssignmentType(); - ConstructionType accountConstruntion = new ConstructionType(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resourceOid); - resourceRef.setType(ResourceType.COMPLEX_TYPE); - accountConstruntion.setResourceRef(resourceRef); - accountConstruntion.setKind(ShadowKindType.ACCOUNT); - assignmentType.setConstruction(accountConstruntion); - user.asObjectable().getAssignment().add(assignmentType); - } - - protected PrismObject createAccount(PrismObject resource, String name, boolean enabled) throws SchemaException { - PrismObject shadow = getShadowDefinition().instantiate(); - ShadowType shadowType = shadow.asObjectable(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resource.getOid()); - shadowType.setResourceRef(resourceRef); - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - shadowType.setObjectClass(objectClassDefinition.getTypeName()); - shadowType.setKind(ShadowKindType.ACCOUNT); - ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); - RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next(); - ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate(); - icfsNameAttr.setRealValue(name); - attrCont.add(icfsNameAttr); - ActivationType activation = new ActivationType(); - shadowType.setActivation(activation); - if (enabled) { - activation.setAdministrativeStatus(ActivationStatusType.ENABLED); - } else { - activation.setAdministrativeStatus(ActivationStatusType.DISABLED); - } - return shadow; - } - - 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)); - ResourceAttribute attr = attrSnDef.instantiate(); - attr.setRealValue(attrValue); - attrs.add(attr); - } - - protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); - } - - protected void setDefaultObjectTemplate(QName objectType, String userTemplateOid) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName()+".setDefaultObjectTemplate"); - setDefaultObjectTemplate(objectType, userTemplateOid, result); - result.computeStatus(); - TestUtil.assertSuccess("Applying default object template failed (result)", result); - } - - - protected void setDefaultObjectTemplate(QName objectType, String objectTemplateOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - setDefaultObjectTemplate(objectType, null, objectTemplateOid, parentResult); - } - - protected void setDefaultObjectTemplate(QName objectType, String subType, String objectTemplateOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); - - PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { - if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { - oldValue = focusPolicyType.asPrismContainerValue(); - } - } - Collection modifications = new ArrayList<>(); - - if (oldValue != null) { - ObjectPolicyConfigurationType oldPolicy = oldValue.asContainerable(); - ObjectReferenceType oldObjectTemplateRef = oldPolicy.getObjectTemplateRef(); - if (oldObjectTemplateRef != null) { - if (oldObjectTemplateRef.getOid().equals(objectTemplateOid)) { - // Already set - return; - } - } - ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); - } - - if (objectTemplateOid != null) { - ObjectPolicyConfigurationType newFocusPolicyType; - ContainerDelta addDelta; - if (oldValue == null) { - newFocusPolicyType = new ObjectPolicyConfigurationType(); - newFocusPolicyType.setType(objectType); - newFocusPolicyType.setSubtype(subType); - addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); - } else { - PrismContainerValue newValue = oldValue.cloneComplex(CloneStrategy.REUSE); - addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newValue); - newFocusPolicyType = newValue.asContainerable(); - } - ObjectReferenceType templateRef = new ObjectReferenceType(); - templateRef.setOid(objectTemplateOid); - newFocusPolicyType.setObjectTemplateRef(templateRef); - ((Collection)modifications).add(addDelta); - } - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); - - PrismContainerValue oldValue = null; - for (ObjectPolicyConfigurationType focusPolicyType: systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { - if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { - oldValue = focusPolicyType.asPrismContainerValue(); - } - } - Collection modifications = new ArrayList<>(); - - if (oldValue != null) { - ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, oldValue.clone()); - ((Collection)modifications).add(deleteDelta); - } - - ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType(); - newFocusPolicyType.setType(objectType); - newFocusPolicyType.setSubtype(subType); - if (oldValue != null) { - ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef(); - if (oldObjectTemplateRef != null) { - newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone()); - } - } - - newFocusPolicyType.setConflictResolution(conflictResolution); - - ContainerDelta addDelta = prismContext.deltaFactory().container() - .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, - SystemConfigurationType.class, newFocusPolicyType); - - ((Collection)modifications).add(addDelta); - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void setConflictResolutionAction(QName objectType, String subType, ConflictResolutionActionType conflictResolutionAction, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - ConflictResolutionType conflictResolutionType = new ConflictResolutionType(); - conflictResolutionType.action(conflictResolutionAction); - setConflictResolution(objectType, subType, conflictResolutionType, parentResult); - } - - protected void setGlobalSecurityPolicy(String securityPolicyOid, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - - Collection modifications = new ArrayList<>(); - - ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(SystemConfigurationType.F_GLOBAL_SECURITY_POLICY_REF, - SystemConfigurationType.class, securityPolicyOid); - modifications.add(refDelta); - - modifySystemObjectInRepo(SystemConfigurationType.class, - SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); - - } - - protected void modifySystemObjectInRepo(Class type, String oid, Collection modifications, OperationResult parentResult) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - display("Modifications of system object "+oid, modifications); - repositoryService.modifyObject(type, oid, modifications, parentResult); - invalidateSystemObjectsCache(); - } - - @Override - protected void invalidateSystemObjectsCache() { - systemObjectCache.invalidateCaches(); - } - - protected ItemPath getIcfsNameAttributePath() { - return ItemPath.create( - ShadowType.F_ATTRIBUTES, - SchemaTestConstants.ICFS_NAME); - - } - - protected void assertResolvedResourceRefs(ModelContext context) { - for (ModelProjectionContext projectionContext: context.getProjectionContexts()) { - assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in "+projectionContext); - assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in "+projectionContext); - } - } - - private void assertResolvedResourceRefs(ObjectDelta delta, String desc) { - if (delta == null) { - return; - } - if (delta.isAdd()) { - assertResolvedResourceRefs(delta.getObjectToAdd(), desc); - } else if (delta.isModify()) { - ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); - if (referenceDelta != null) { - assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in "+desc); - assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in "+desc); - } - } - } - - private void assertResolvedResourceRefs(PrismObject shadow, String desc) { - if (shadow == null) { - return; - } - PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); - if (resourceRef == null) { - AssertJUnit.fail("No resourceRef in "+desc); - } - assertResolvedResourceRefs(resourceRef.getValues(), desc); - } - - private void assertResolvedResourceRefs(Collection values, String desc) { - if (values == null) { - return; - } - for (PrismReferenceValue pval: values) { - assertNotNull("resourceRef in "+desc+" does not contain object", pval.getObject()); - } - } - - /** - * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to - * existing user values. - */ - protected void breakAssignmentDelta(Collection> deltas) throws SchemaException { - breakAssignmentDelta((ObjectDelta)deltas.iterator().next()); - } - - /** - * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to - * existing user values. - */ - protected void breakAssignmentDelta(ObjectDelta userDelta) throws SchemaException { - ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); - PrismContainerValue assignmentDeltaValue = null; - if (assignmentDelta.getValuesToAdd() != null) { - assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); - } - if (assignmentDelta.getValuesToDelete() != null) { - assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); - } - PrismContainer activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); - PrismContainerValue emptyValue = prismContext.itemFactory().createContainerValue(); - activationContainer.add(emptyValue); - } - - - protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".purgeResourceSchema"); - OperationResult result = task.getResult(); - - ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, - resourceOid, ResourceType.F_SCHEMA, new PrismContainerValue[0]); - Collection> deltas = MiscSchemaUtil.createCollection(resourceDelta); - - modelService.executeChanges(deltas, null, task, result); - - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected List> searchOrg(String baseOrgOid, OrgFilter.Scope scope, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(OrgType.class) - .isInScopeOf(baseOrgOid, scope) - .build(); - return modelService.searchObjects(OrgType.class, query, null, task, result); - } - - protected PrismObject searchObjectByName(Class type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".searchObjectByName"); - OperationResult result = task.getResult(); - PrismObject out = searchObjectByName(type, name, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return out; - } - - protected PrismObject searchObjectByName(Class type, String name, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = ObjectQueryUtil.createNameQuery(name, prismContext); - List> foundObjects = modelService.searchObjects(type, query, null, task, result); - if (foundObjects.isEmpty()) { - return null; - } - if (foundObjects.size() > 1) { - throw new IllegalStateException("More than one object found for type "+type+" and name '"+name+"'"); - } - return foundObjects.iterator().next(); - } - - protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), null); - } - - protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, MatchingRule matchingRule) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), matchingRule); - } - - protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass) throws SchemaException { - assertShadowModel(accountShadow, oid, username, resourceType, objectClass, null); - } - - protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { - assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); - IntegrationTestTools.assertProvisioningShadow(accountShadow, resourceType, RefinedAttributeDefinition.class, objectClass); - } - - protected ObjectDelta createModifyUserAddDummyAccount(String userOid, String dummyResourceName) throws SchemaException { - return createModifyUserAddAccount(userOid, getDummyResourceObject(dummyResourceName)); - } - - protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource) throws SchemaException { - return createModifyUserAddAccount(userOid, resource, null); - } - - protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource, String intent) throws SchemaException { - PrismObject account = getAccountShadowDefinition().instantiate(); - ObjectReferenceType resourceRef = new ObjectReferenceType(); - resourceRef.setOid(resource.getOid()); - account.asObjectable().setResourceRef(resourceRef); - RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rocd = null; - if (StringUtils.isNotBlank(intent)) { - rocd = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, intent); - account.asObjectable().setIntent(intent); - } else { - rocd = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); - } - account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName()); - account.asObjectable().setKind(ShadowKindType.ACCOUNT); - - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected ObjectDelta createModifyUserDeleteDummyAccount(String userOid, String dummyResourceName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return createModifyUserDeleteAccount(userOid, getDummyResourceObject(dummyResourceName)); - } - - protected ObjectDelta createModifyUserDeleteAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return createModifyUserDeleteAccount(userOid, resource.getOid()); - } - - protected ObjectDelta createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(userOid, resourceOid); - PrismObject account = getShadowModel(accountOid); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected ObjectDelta createModifyUserUnlinkAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - String accountOid = getLinkRefOid(userOid, resource.getOid()); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setOid(accountOid); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - - return userDelta; - } - - protected void deleteUserAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta userDelta = createModifyUserDeleteAccount(userOid, resourceOid); - executeChanges(userDelta, null, task, result); - } - - - // TASKS - - protected void waitForTaskFinish(Task task, boolean checkSubresult) throws Exception { - waitForTaskFinish(task, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskFinish(Task task, boolean checkSubresult, final int timeout) throws Exception { - waitForTaskFinish(task, checkSubresult, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskFinish(final Task task, final boolean checkSubresult, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - task.refresh(waitResult); - waitResult.summarize(); -// Task freshTask = taskManager.getTaskWithResult(task.getOid(), waitResult); - OperationResult result = task.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+task+": "+TestUtil.getErrorMessage(result); - assert !isUnknown(result, checkSubresult) : "Unknown result in "+task+": "+TestUtil.getErrorMessage(result); - return !isInProgress(result, checkSubresult); - } - @Override - public void timeout() { - try { - task.refresh(waitResult); - } catch (ObjectNotFoundException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } catch (SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } - OperationResult result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+task+" to finish. Last result "+result; - } - }; - IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime); - } - - protected void waitForTaskCloseOrSuspend(String taskOid) throws Exception { - waitForTaskCloseOrSuspend(taskOid, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) throws Exception { - waitForTaskCloseOrSuspend(taskOid, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskCloseOrSuspend"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task task = taskManager.getTaskWithResult(taskOid, waitResult); - waitResult.summarize(); - display("Task execution status = " + task.getExecutionStatus()); - return task.getExecutionStatus() == TaskExecutionStatus.CLOSED - || task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED; - } - @Override - public void timeout() { - Task task = null; - try { - task = taskManager.getTaskWithResult(taskOid, waitResult); - } catch (ObjectNotFoundException|SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e,e); - } - OperationResult result = null; - if (task != null) { - result = task.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - } - assert false : "Timeout ("+timeout+") while waiting for "+taskOid+" to close or suspend. Last result "+result; - } - }; - IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, Function customizer) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, 0, DEFAULT_TASK_WAIT_TIMEOUT, false, 0, customizer); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, timeout, false); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout, final boolean errorOk) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, 0, timeout, errorOk); - } - - protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, long startTime, final int timeout, final boolean errorOk) throws CommonException { - return waitForTaskFinish(taskOid, checkSubresult, startTime, timeout, errorOk, 0, null); - } - - protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, long startTime, int timeout, boolean errorOk, - int showProgressEach, Function customizer) throws CommonException { - long realStartTime = startTime != 0 ? startTime : System.currentTimeMillis(); - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskFinish"); - TaskFinishChecker.Builder builder = new TaskFinishChecker.Builder() - .taskManager(taskManager) - .taskOid(taskOid) - .waitResult(waitResult) - .checkSubresult(checkSubresult) - .errorOk(errorOk) - .timeout(timeout) - .showProgressEach(showProgressEach) - .verbose(verbose); - if (customizer != null) { - builder = customizer.apply(builder); - } - TaskFinishChecker checker = builder.build(); - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " finish", checker, realStartTime, timeout, DEFAULT_TASK_SLEEP_TIME); - return checker.getLastTask(); - } - - protected void dumpTaskTree(String oid, OperationResult result) - throws ObjectNotFoundException, - SchemaException { - Collection> options = schemaHelper.getOperationOptionsBuilder() - .item(TaskType.F_SUBTASK).retrieve() - .build(); - PrismObject task = taskManager.getObject(TaskType.class, oid, options, result); - dumpTaskAndSubtasks(task.asObjectable(), 0); - } - - protected void dumpTaskAndSubtasks(TaskType task, int level) throws SchemaException { - String xml = prismContext.xmlSerializer().serialize(task.asPrismObject()); - display("Task (level " + level + ")", xml); - for (TaskType subtask : TaskTypeUtil.getResolvedSubtasks(task)) { - dumpTaskAndSubtasks(subtask, level + 1); - } - } - - protected long getRunDurationMillis(String taskReconOpendjOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return getTaskRunDurationMillis(getTask(taskReconOpendjOid).asObjectable()); - } - - protected long getTaskRunDurationMillis(TaskType taskType) { - long duration = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp()) - - XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp()); - System.out.println("Duration for " + taskType.getName() + " is " + duration); - return duration; - } - - protected long getTreeRunDurationMillis(String rootTaskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject rootTask = getTaskTree(rootTaskOid); - return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) - .mapToLong(this::getTaskRunDurationMillis) - .max().orElse(0); - } - - protected void displayOperationStatistics(String label, OperationStatsType statistics) { - display(label, StatisticsUtil.format(statistics)); - } - - @Nullable - protected OperationStatsType getTaskTreeOperationStatistics(String rootTaskOid) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - PrismObject rootTask = getTaskTree(rootTaskOid); - return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) - .map(t -> t.getOperationStats()) - .reduce(StatisticsUtil::sum) - .orElse(null); - } - - protected List getSubcases(String parentCaseOid, Collection> options, - OperationResult result) throws SchemaException { - return asObjectableList( - repositoryService.searchObjects(CaseType.class, - prismContext.queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(parentCaseOid).build(), - options, result)); - } - - protected void deleteCaseTree(String rootCaseOid, OperationResult result) throws SchemaException, ObjectNotFoundException { - List subcases = getSubcases(rootCaseOid, null, result); - for (CaseType subcase : subcases) { - deleteCaseTree(subcase.getOid(), result); - } - repositoryService.deleteObject(CaseType.class, rootCaseOid, result); - } - - protected void displayTaskWithOperationStats(String message, PrismObject task) throws SchemaException { - display(message, task); - String stats = prismContext.xmlSerializer() - .serializeRealValue(task.asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); - display(message + ": Operational stats", stats); - } - - protected void displayTaskWithOperationStats(String message, Task task) throws SchemaException { - display(message, task); - String stats = prismContext.xmlSerializer() - .serializeRealValue(task.getUpdatedOrClonedTaskObject().asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); - display(message + ": Operational stats", stats); - } - - protected void assertJpegPhoto(Class clazz, String oid, byte[] expectedValue, OperationResult result) - throws SchemaException, ObjectNotFoundException { - PrismObject object = repositoryService - .getObject(clazz, oid, schemaHelper.getOperationOptionsBuilder().retrieve().build(), result); - byte[] actualValue = object.asObjectable().getJpegPhoto(); - if (expectedValue == null) { - if (actualValue != null) { - fail("Photo present even if it should not be: " + Arrays.toString(actualValue)); - } - } else { - assertNotNull("No photo", actualValue); - if (!Arrays.equals(actualValue, expectedValue)) { - fail("Photo is different than expected.\nExpected = " + Arrays.toString(expectedValue) - + "\nActual value = " + Arrays.toString(actualValue)); - } - } - } - - protected void waitForTaskStart(String taskOid, boolean checkSubresult) throws Exception { - waitForTaskStart(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected void waitForTaskStart(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskStart"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); - if (isUnknown(result, checkSubresult)) { - return false; - } - return freshTask.getLastRunStartTimestamp() != null; - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { - OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextStart"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - if (kickTheTask) { - taskManager.scheduleTaskNow(origTask, waitResult); - } - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - if (verbose) display("Check result", result); - assert !isError(result, checkSubresult) : "Error in "+freshTask+": "+TestUtil.getErrorMessage(result); - return !isUnknown(result, checkSubresult) && - !java.util.Objects.equals(freshTask.getLastRunStartTimestamp(), origLastRunStartTimestamp); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); - OperationResult result = freshTask.getResult(); - LOGGER.debug("Result of timed-out task:\n{}", result.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+freshTask+" to start. Last result "+result; - } catch (ObjectNotFoundException | SchemaException e) { - LOGGER.error("Exception during task refresh: {}", e, e); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + taskOid + " next start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(String taskOid, boolean checkSubresult) throws Exception { - return waitForTaskNextRunAssertSuccess(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, boolean checkSubresult) throws Exception { - return waitForTaskNextRunAssertSuccess(origTask, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); - } - - protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - OperationResult taskResult = waitForTaskNextRun(taskOid, checkSubresult, timeout); - if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+taskOid+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); - } - return taskResult; - } - - protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, final boolean checkSubresult, final int timeout) throws Exception { - OperationResult taskResult = waitForTaskNextRun(origTask, checkSubresult, timeout); - if (isError(taskResult, checkSubresult)) { - assert false : "Error in task "+origTask+": "+TestUtil.getErrorMessage(taskResult)+"\n\n"+taskResult.debugDump(); - } - return taskResult; - } - - protected OperationResult waitForTaskNextRun(final String taskOid) throws Exception { - return waitForTaskNextRun(taskOid, false, DEFAULT_TASK_WAIT_TIMEOUT, false); - } - - protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - return waitForTaskNextRun(taskOid, checkSubresult, timeout, false); - } - - protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout) throws Exception { - return waitForTaskNextRun(origTask, checkSubresult, timeout, false); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskNextRun"); - return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); - } - - protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, final OperationResult waitResult, boolean kickTheTask) throws Exception { - final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); - if (kickTheTask) { - taskManager.scheduleTaskNow(origTask, waitResult); - } - final Holder taskResultHolder = new Holder<>(); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); - taskResultHolder.setValue(taskResult); - if (isError(taskResult, checkSubresult)) { - return true; - } - if (isUnknown(taskResult, checkSubresult)) { - return false; - } - if (freshTask.getLastRunFinishTimestamp() == null) { - return false; - } - if (freshTask.getLastRunStartTimestamp() == null) { - return false; - } - return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - 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())); - 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); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + origTask + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - 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())); - - return taskResultHolder.getValue(); - } - - protected OperationResult waitForTaskTreeNextFinishedRun(String rootTaskOid, int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskTreeNextFinishedRun"); - Task origRootTask = taskManager.getTaskWithResult(rootTaskOid, waitResult); - return waitForTaskTreeNextFinishedRun(origRootTask, timeout, waitResult); - } - - // a bit experimental - protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int timeout, OperationResult waitResult) throws Exception { - Long origLastRunStartTimestamp = origRootTask.getLastRunStartTimestamp(); - Long origLastRunFinishTimestamp = origRootTask.getLastRunFinishTimestamp(); - long start = System.currentTimeMillis(); - Holder triggered = new Holder<>(false); // to avoid repeated checking for start-finish timestamps - OperationResult aggregateResult = new OperationResult("aggregate"); - Checker checker = () -> { - Task freshRootTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); - - String s = TaskDebugUtil.dumpTaskTree(freshRootTask, waitResult); - display("task tree", s); - - long waiting = (System.currentTimeMillis() - start) / 1000; - String description = - freshRootTask.getName().getOrig() + " [es:" + freshRootTask.getExecutionStatus() + ", rs:" + - freshRootTask.getResultStatus() + ", p:" + freshRootTask.getProgress() + ", n:" + - freshRootTask.getNode() + "] (waiting for: " + waiting + ")"; - // was the whole task tree refreshed at least once after we were called? - if (!triggered.getValue() && (freshRootTask.getLastRunStartTimestamp() == null - || freshRootTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - || freshRootTask.getLastRunFinishTimestamp() == null - || freshRootTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - || freshRootTask.getLastRunStartTimestamp() >= freshRootTask.getLastRunFinishTimestamp())) { - display("Root (triggering) task next run has not been completed yet: " + description); - return false; - } - triggered.setValue(true); - - aggregateResult.getSubresults().clear(); - List subtasks = freshRootTask.listSubtasksDeeply(waitResult); - for (Task subtask : subtasks) { - try { - subtask.refresh(waitResult); // quick hack to get operation results - } catch (ObjectNotFoundException e) { - LOGGER.warn("Task {} does not exist any more", subtask); - } - } - Task failedTask = null; - for (Task subtask : subtasks) { - if (subtask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { - display("Found runnable/running subtasks during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtask.getExecutionStatus() == TaskExecutionStatus.WAITING) { - display("Found waiting subtasks during waiting => continuing waiting: " + description, subtask); - return false; - } - OperationResult subtaskResult = subtask.getResult(); - if (subtaskResult == null) { - display("No subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtaskResult.getStatus() == OperationResultStatus.IN_PROGRESS) { - display("Found 'in_progress' subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - if (subtaskResult.getStatus() == OperationResultStatus.UNKNOWN) { - display("Found 'unknown' subtask operation result during waiting => continuing waiting: " + description, subtask); - return false; - } - aggregateResult.addSubresult(subtaskResult); - if (subtaskResult.isError()) { - failedTask = subtask; - } - } - if (failedTask != null) { - display("Found 'error' subtask operation result during waiting => done waiting: " + description, failedTask); - return true; - } - if (freshRootTask.getExecutionStatus() == TaskExecutionStatus.WAITING) { - display("Found WAITING root task during wait for next finished run => continuing waiting: " + description); - return false; - } - return true; // all executive subtasks are closed - }; - IntegrationTestTools.waitFor("Waiting for task tree " + origRootTask + " next finished run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - Task freshTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); - LOGGER.debug("Final root task:\n{}", freshTask.debugDump()); - aggregateResult.computeStatusIfUnknown(); - return aggregateResult; - } - - public void waitForCaseClose(CaseType aCase) throws Exception { - waitForCaseClose(aCase, 60000); - } - - public void waitForCaseClose(CaseType aCase, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForCaseClose"); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - CaseType currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult).asObjectable(); - if (verbose) AbstractIntegrationTest.display("Case", currentCase); - return SchemaConstants.CASE_STATE_CLOSED.equals(currentCase.getState()); - } - @Override - public void timeout() { - PrismObject currentCase; - try { - currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult); - } catch (ObjectNotFoundException | SchemaException e) { - throw new AssertionError("Couldn't retrieve case " + aCase, e); - } - LOGGER.debug("Timed-out case:\n{}", currentCase.debugDump()); - assert false : "Timeout ("+timeout+") while waiting for "+currentCase+" to finish"; - } - }; - IntegrationTestTools.waitFor("Waiting for "+aCase+" finish", checker, timeout, 1000); - } - - - private String longTimeToString(Long longTime) { - if (longTime == null) { - return "null"; - } - return longTime.toString(); - } - - public static boolean isError(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult != null && subresult.isError(); - } - - public static boolean isUnknown(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult != null && subresult.isUnknown(); // TODO or return true if null? - } - - public static boolean isInProgress(OperationResult result, boolean checkSubresult) { - OperationResult subresult = getSubresult(result, checkSubresult); - return subresult == null || subresult.isInProgress(); // "true" if there are no subresults - } - - private static OperationResult getSubresult(OperationResult result, boolean checkSubresult) { - if (checkSubresult) { - return result != null ? result.getLastSubresult() : null; - } - return result; - } - - protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { - final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class+".waitForTaskResume"); - Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); - - final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); - final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); - - taskManager.resumeTask(origTask, waitResult); - - final Holder taskResultHolder = new Holder<>(); - Checker checker = new Checker() { - @Override - public boolean check() throws CommonException { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - OperationResult taskResult = freshTask.getResult(); -// display("Times", longTimeToString(origLastRunStartTimestamp) + "-" + longTimeToString(origLastRunStartTimestamp) -// + " : " + longTimeToString(freshTask.getLastRunStartTimestamp()) + "-" + longTimeToString(freshTask.getLastRunFinishTimestamp())); - if (verbose) display("Check result", taskResult); - taskResultHolder.setValue(taskResult); - if (isError(taskResult, checkSubresult)) { - return true; - } - if (isUnknown(taskResult, checkSubresult)) { - return false; - } - if (freshTask.getLastRunFinishTimestamp() == null) { - return false; - } - if (freshTask.getLastRunStartTimestamp() == null) { - return false; - } - return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) - && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) - && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); - } - @Override - public void timeout() { - try { - Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); - 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())); - 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); - } - } - }; - IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); - - 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())); - - return taskResultHolder.getValue(); - } - - protected void restartTask(String taskOid) throws CommonException { - - // Wait at least 1ms here. We have the timestamp in the tasks with a millisecond granularity. If the tasks is started, - // executed and then resstarted and excecuted within the same millisecond then the second execution will not be - // detected and the wait for task finish will time-out. So waiting one millisecond here will make sure that the - // timestamps are different. And 1ms is not that long to significantly affect test run times. - try { - Thread.sleep(1); - } catch (InterruptedException e) { - LOGGER.warn("Sleep interrupted: {}", e.getMessage(), e); - } - - OperationResult result = createSubresult("restartTask"); - try { - Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Restarting task {}", taskOid); - if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) { - LOGGER.debug("Task {} is suspended, resuming it", task); - taskManager.resumeTask(task, result); - } else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) { - LOGGER.debug("Task {} is closed, scheduling it to run now", task); - taskManager.scheduleTasksNow(singleton(taskOid), result); - } else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { - if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) { - // Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO) - LOGGER.debug("Task {} is running, waiting while it finishes before restarting", task); - waitForTaskFinish(taskOid, false); - } - LOGGER.debug("Task {} is finished, scheduling it to run now", task); - taskManager.scheduleTasksNow(singleton(taskOid), result); - } else { - throw new IllegalStateException( - "Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus()); - } - } catch (Throwable t) { - result.recordFatalError(t); - throw t; - } finally { - result.computeStatusIfUnknown(); - } - } - - protected boolean suspendTask(String taskOid) throws CommonException { - return suspendTask(taskOid, 3000); - } - - protected boolean suspendTask(String taskOid, int waitTime) throws CommonException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".suspendTask"); - Task task = taskManager.getTaskWithResult(taskOid, result); - LOGGER.info("Suspending task {}", taskOid); - return taskManager.suspendTaskQuietly(task, waitTime, result); - } - - /** - * Restarts task and waits for finish. - */ - protected void rerunTask(String taskOid) throws CommonException { - long startTime = System.currentTimeMillis(); - restartTask(taskOid); - waitForTaskFinish(taskOid, true, startTime, DEFAULT_TASK_WAIT_TIMEOUT, false); - } - - protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException { - final OperationResult result = new OperationResult(AbstractIntegrationTest.class+".assertTaskExecutionStatus"); - Task task = taskManager.getTask(taskOid, result); - assertEquals("Wrong executionStatus in "+task, expectedExecutionStatus, task.getExecutionStatus()); - } - - protected void setSecurityContextUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance("get administrator"); - PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); - - assertNotNull("User " + userOid + " is null", object.asObjectable()); - SecurityContextHolder.getContext().setAuthentication( - new UsernamePasswordAuthenticationToken( - new MidPointPrincipal(object.asObjectable()), null)); - } - - protected String getSecurityContextUserOid() { - return ((MidPointPrincipal) (SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getOid(); - } - - protected void assertSideEffectiveDeltasOnly(String desc, ObjectDelta focusDelta) { - if (focusDelta == null) { - return; - } - int expectedModifications = 0; - // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { - if (isSideEffectDelta(modification)) { - expectedModifications++; - } - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { - expectedModifications++; - } - PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); - if (effectiveStatusDelta != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { - expectedModifications++; - } - assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); - } - - protected void assertSideEffectiveDeltasOnly(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation) { - assertEffectualDeltas(focusDelta, desc, expectedEfficientActivation, 0); - } - - protected void assertEffectualDeltas(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation, int expectedEffectualModifications) { - if (focusDelta == null) { - return; - } - int expectedModifications = expectedEffectualModifications; - // There may be metadata modification, we tolerate that - for (ItemDelta modification: focusDelta.getModifications()) { - if (isSideEffectDelta(modification)) { - expectedModifications++; - } - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { - expectedModifications++; - } - PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); - if (effectiveStatusDelta != null) { - expectedModifications++; - PrismAsserts.assertReplace(effectiveStatusDelta, expectedEfficientActivation); - } - if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { - expectedModifications++; - } - if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { - expectedModifications++; - } - assertEquals("Unexpected modifications in "+desc+": "+focusDelta, expectedModifications, focusDelta.getModifications().size()); - } - - private boolean isSideEffectDelta(ItemDelta modification) { - if (modification.getPath().containsNameExactly(ObjectType.F_METADATA) || - (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { - return true; - } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta)) { - Collection> valuesToReplace = ((ContainerDelta)modification).getValuesToReplace(); - if (valuesToReplace != null && valuesToReplace.size() == 1) { - PrismContainerValue cval = valuesToReplace.iterator().next(); - if (cval.size() == 1) { - Item item = cval.getItems().iterator().next(); - return ActivationType.F_EFFECTIVE_STATUS.equals(item.getElementName()); - } - } - } - return false; - } - - protected void assertValidFrom(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validFrom in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), - getActivation(obj).getValidFrom()); - } - - protected void assertValidTo(PrismObject obj, Date expectedDate) { - assertEquals("Wrong validTo in "+obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), - getActivation(obj).getValidTo()); - } - - protected ActivationType getActivation(PrismObject obj) { - ObjectType objectType = obj.asObjectable(); - ActivationType activation; - if (objectType instanceof ShadowType) { - activation = ((ShadowType)objectType).getActivation(); - } else if (objectType instanceof UserType) { - activation = ((UserType)objectType).getActivation(); - } else { - throw new IllegalArgumentException("Cannot get activation from "+obj); - } - assertNotNull("No activation in " + obj, activation); - return activation; - } - - protected PrismObject getTask(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); - OperationResult result = task.getResult(); - PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Task) result not success", result); - return retTask; - } - - protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getTask"); - OperationResult result = task.getResult(); - PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); - result.computeStatus(); - TestUtil.assertSuccess("getObject(Task) result not success", result); - return retTask; - } - - protected CaseType getCase(String oid) throws ObjectNotFoundException, SchemaException { - return repositoryService.getObject(CaseType.class, oid, null, new OperationResult("dummy")).asObjectable(); - } - - protected void assertObjectExists(Class clazz, String oid) { - OperationResult result = new OperationResult("assertObjectExists"); - try { - repositoryService.getObject(clazz, oid, null, result); - } catch (ObjectNotFoundException e) { - fail("Object of type " + clazz.getName() + " with OID " + oid + " doesn't exist: " + e.getMessage()); - } catch (SchemaException e) { - throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists but couldn't be read: " + e.getMessage(), e); - } - } - - protected void assertObjectDoesntExist(Class clazz, String oid) { - OperationResult result = new OperationResult("assertObjectDoesntExist"); - try { - PrismObject object = repositoryService.getObject(clazz, oid, null, result); - fail("Object of type " + clazz.getName() + " with OID " + oid + " exists even if it shouldn't: " + object.debugDump()); - } catch (ObjectNotFoundException e) { - // ok - } catch (SchemaException e) { - throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists, and moreover it couldn't be read: " + e.getMessage(), e); - } - } - - protected PrismObject getObject(Class type, String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); - OperationResult result = task.getResult(); - PrismObject object = modelService.getObject(type, oid, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return object; - } - - protected PrismObject getObjectViaRepo(Class type, String oid) throws ObjectNotFoundException, SchemaException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject"); - OperationResult result = task.getResult(); - PrismObject object = repositoryService.getObject(type, oid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return object; - } - - protected void addObjects(File... files) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - for (File file : files) { - addObject(file); - } - } - - protected void addObject(TestResource resource, Task task, OperationResult result) - throws IOException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, - PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, - SchemaException { - addObject(resource.file, task, result); - } - - protected PrismObject repoAddObject(TestResource resource, OperationResult result) - throws IOException, ObjectAlreadyExistsException, SchemaException, EncryptionException { - return repoAddObjectFromFile(resource.file, result); - } - - // not going through model to avoid conflicts (because the task starts execution during the clockwork operation) - protected void addTask(File file) throws SchemaException, IOException, ObjectAlreadyExistsException { - taskManager.addTask(prismContext.parseObject(file), new OperationResult("addTask")); - } - - protected void addObject(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = prismContext.parseObject(file); - addObject(object); - } - - protected PrismObject addObject(File file, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - return addObject(file, task, result, null); - } - - protected PrismObject addObject(File file, Task task, OperationResult result, Consumer> customizer) - throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, - CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = prismContext.parseObject(file); - if (customizer != null) { - customizer.accept(object); - } - addObject(object, task, result); - return object; - } - - protected String addObject(PrismObject object) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addObject"); - OperationResult result = task.getResult(); - String oid = addObject(object, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return oid; - } - - protected String addObject(PrismObject object, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - return addObject(object, null, task, result); - } - - protected String addObject(PrismObject object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta addDelta = object.createAddDelta(); - assertFalse("Immutable object provided?",addDelta.getObjectToAdd().isImmutable()); - Collection> executedDeltas = executeChanges(addDelta, options, task, result); - object.setOid(ObjectDeltaOperation.findAddDeltaOid(executedDeltas, object)); - return object.getOid(); - } - - protected void deleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, null, task, result); - } - - protected void deleteObjectRaw(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, ModelExecuteOptions.createRaw(), task, result); - } - - protected void deleteObject(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".deleteObject"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void deleteObjectRepo(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".deleteObjectRepo"); - repositoryService.deleteObject(type, oid, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void forceDeleteShadow(String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".forceDeleteShadow"); - OperationResult result = task.getResult(); - forceDeleteObject(ShadowType.class, oid, task, result); - assertSuccess(result); - } - - protected void forceDeleteShadow(String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - forceDeleteObject(ShadowType.class, oid, task, result); - } - - protected void forceDeleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - ModelExecuteOptions options = ModelExecuteOptions.createForce(); - executeChanges(delta, options, task, result); - } - - protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTrigger"); - OperationResult result = task.getResult(); - TriggerType triggerType = new TriggerType(); - triggerType.setTimestamp(timestamp); - triggerType.setHandlerUri(uri); - ObjectDelta delta = prismContext.deltaFactory().object() - .createModificationAddContainer(ObjectType.class, oid, ObjectType.F_TRIGGER, - triggerType); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTriggers"); - OperationResult result = task.getResult(); - Collection triggers = timestamps.stream() - .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) - .map(ts -> makeDistinct ? addRandomValue(ts) : ts) - .collect(Collectors.toList()); - ObjectDelta delta = prismContext.deltaFor(ObjectType.class) - .item(ObjectType.F_TRIGGER).addRealValues(triggers) - .asObjectDeltaCast(oid); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - private TriggerType addRandomValue(TriggerType trigger) { - //noinspection unchecked - @NotNull PrismPropertyDefinition workItemIdDef = - prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ID); - PrismProperty workItemIdProp = workItemIdDef.instantiate(); - workItemIdProp.addRealValue((long) (Math.random() * 100000000000L)); - try { - //noinspection unchecked - trigger.asPrismContainerValue().findOrCreateContainer(TriggerType.F_EXTENSION).add(workItemIdProp); - } catch (SchemaException e) { - throw new AssertionError(e); - } - return trigger; - } - - protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".replaceTriggers"); - OperationResult result = task.getResult(); - Collection triggers = timestamps.stream() - .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); - executeChanges(delta, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) throws ObjectNotFoundException, SchemaException { - for (TriggerType trigger: object.asObjectable().getTrigger()) { - if (handlerUri.equals(trigger.getHandlerUri()) - && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { - return; - } - } - AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); - } - - protected void assertTrigger(PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) throws ObjectNotFoundException, SchemaException { - XMLGregorianCalendar start = XmlTypeConverter.addMillis(mid, -tolerance); - XMLGregorianCalendar end = XmlTypeConverter.addMillis(mid, tolerance); - for (TriggerType trigger: object.asObjectable().getTrigger()) { - if (handlerUri.equals(trigger.getHandlerUri()) - && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { - return; - } - } - AssertJUnit.fail("Expected that "+object+" will have a trigger but it has not"); - } - - protected void assertNoTrigger(Class type, String oid) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractModelIntegrationTest.class.getName() + ".assertNoTrigger"); - PrismObject object = repositoryService.getObject(type, oid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertNoTrigger(object); - } - - protected void assertNoTrigger(PrismObject object) throws ObjectNotFoundException, SchemaException { - List triggers = object.asObjectable().getTrigger(); - if (triggers != null && !triggers.isEmpty()) { - AssertJUnit.fail("Expected that "+object+" will have no triggers but it has "+triggers.size()+ " trigger: "+ triggers); - } - } - - protected void prepareNotifications() { - notificationManager.setDisabled(false); - dummyTransport.clearMessages(); - } - - protected void checkDummyTransportMessages(String name, int expectedCount) { - List messages = dummyTransport.getMessages("dummy:" + name); - if (expectedCount == 0) { - if (messages != null && !messages.isEmpty()) { - LOGGER.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); - logNotifyMessages(messages); - printNotifyMessages(messages); - fail(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); - } - } else { - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (expectedCount != messages.size()) { - LOGGER.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: "+expectedCount+", actual: "+messages.size()); - logNotifyMessages(messages); - printNotifyMessages(messages); - assertEquals("Invalid number of messages recorded in dummy transport '" + name + "'", expectedCount, messages.size()); - } - } - } - - protected void assertSingleDummyTransportMessage(String name, String expectedBody) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); - } - Message message = messages.get(0); - assertEquals("Unexpected notifier "+name+" message body", expectedBody, message.getBody()); - } - - protected void assertSingleDummyTransportMessageContaining(String name, String expectedSubstring) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - if (messages.size() != 1) { - fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: "+messages.size()); - } - Message message = messages.get(0); - assertTrue("Notifier "+name+" message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), - message.getBody().contains(expectedSubstring)); - } - - protected String getDummyTransportMessageBody(String name, int index) { - List messages = dummyTransport.getMessages("dummy:" + name); - Message message = messages.get(index); - return message.getBody(); - } - - protected void assertHasDummyTransportMessage(String name, String expectedBody) { - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - for (Message message: messages) { - if (expectedBody.equals(message.getBody())) { - return; - } - } - fail("Notifier "+name+" message body " + expectedBody + " not found"); - } - - protected void displayAllNotifications() { - for (java.util.Map.Entry> entry: dummyTransport.getMessages().entrySet()) { - List messages = entry.getValue(); - if (messages != null && !messages.isEmpty()) { - display("Notification messages: "+entry.getKey(), messages); - } - } - } - - protected void displayNotifications(String name) { - List messages = dummyTransport.getMessages("dummy:" + name); - display("Notification messages: "+name, messages); - } - - private void logNotifyMessages(List messages) { - for (Message message: messages) { - LOGGER.debug("Notification message:\n{}", message.getBody()); - } - } - - private void printNotifyMessages(List messages) { - for (Message message: messages) { - System.out.println(message); - } - } - - protected void checkDummyTransportMessagesAtLeast(String name, int expectedCount) { - if (expectedCount == 0) { - return; - } - List messages = dummyTransport.getMessages("dummy:" + name); - assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); - assertTrue("Number of messages recorded in dummy transport '" + name + "' (" + messages.size() + ") is not at least " + expectedCount, messages.size() >= expectedCount); - } - - protected DummyAccount getDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getAccountByUsername(username); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getAccountById(id); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected DummyAccount assertDefaultDummyAccount(String username, String fullname, boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - return assertDummyAccount(null, username, fullname, active); - } - - protected DummyAccount assertDummyAccount(String dummyInstanceName, String username, String fullname, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - // display("account", account); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); - assertEquals("Wrong fullname for dummy("+dummyInstanceName+") account "+username, fullname, account.getAttributeValue("fullname")); - assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); - return account; - } - - protected DummyAccount assertDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); - return account; - } - - protected DummyAccountAsserter assertDummyAccountById(String dummyResourceName, String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - return getDummyResourceController(dummyResourceName).assertAccountById(id); - } - - protected void assertNoDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccountById(dummyInstanceName, id); - assertNull("Dummy(" + dummyInstanceName + ") account for id " + id + " exists while not expecting it", account); - } - - protected void assertDummyAccountActivation(String dummyInstanceName, String username, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy("+dummyInstanceName+") account for username "+username, account); - assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); - } - - protected void assertNoDummyAccount(String username) throws SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyAccount(null, username); - } - - protected void assertNoDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNull("Dummy account for username " + username + " exists while not expecting it (" + dummyInstanceName + ")", account); - } - - protected void assertDefaultDummyAccountAttribute(String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyAccountAttribute(null, username, attributeName, expectedAttributeValues); - } - - protected void assertDummyAccountAttribute(String dummyInstanceName, String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { - return; - } - 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, - expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { - if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of "+dummyInstanceName+" dummy account "+username+ - " but not found. Values found: "+values); - } - } - } - - protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy "+dummyInstanceName+" account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - if (values == null || values.isEmpty()) { - return; - } - AssertJUnit.fail("Expected no value in attribute " + attributeName + " of "+dummyInstanceName+" dummy account " + username + - ". Values found: " + values); - } - - protected void assertDummyAccountAttributeGenerated(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Integer generated = account.getAttributeValue(DummyAccount.ATTR_INTERNAL_ID, Integer.class); - if (generated == null) { - AssertJUnit.fail("No value in generated attribute dir of " + dummyInstanceName + " dummy account " + username); - } - } - - protected DummyGroup getDummyGroup(String dummyInstanceName, String name) throws SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - try { - return dummyResource.getGroupByName(name); - } catch (ConnectException e) { - throw new IllegalStateException(e.getMessage(),e); - } catch (FileNotFoundException e) { - throw new IllegalStateException(e.getMessage(),e); - } - } - - protected void assertDummyGroup(String username, String description) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroup(null, username, description, null); - } - - protected void assertDummyGroup(String username, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroup(null, username, description, active); - } - - protected void assertDummyGroup(String dummyInstanceName, String groupname, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy("+dummyInstanceName+") group for name "+groupname, group); - assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") group " + groupname, description, - group.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION)); - if (active != null) { - assertEquals("Wrong activation for dummy("+dummyInstanceName+") group "+groupname, active, group.isEnabled()); - } - } - - protected void assertNoDummyGroup(String groupname) throws SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyGroup(null, groupname); - } - - protected void assertNoDummyGroup(String dummyInstanceName, String groupname) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNull("Dummy group '" + groupname + "' exists while not expecting it (" + dummyInstanceName + ")", group); - } - - protected void assertDummyGroupAttribute(String dummyInstanceName, String groupname, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { - DummyGroup group = getDummyGroup(dummyInstanceName, groupname); - assertNotNull("No dummy group for groupname "+groupname, group); - Set values = group.getAttributeValues(attributeName, Object.class); - if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { - return; - } - assertNotNull("No values for attribute "+attributeName+" of "+dummyInstanceName+" dummy group "+groupname, values); - assertEquals("Unexpected number of values for attribute " + attributeName + " of dummy group " + groupname + ": " + values, expectedAttributeValues.length, values.size()); - for (Object expectedValue: expectedAttributeValues) { - if (!values.contains(expectedValue)) { - AssertJUnit.fail("Value '"+expectedValue+"' expected in attribute "+attributeName+" of dummy group "+groupname+ - " but not found. Values found: "+values); - } - } - } - - protected void assertDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - DummyGroup group = dummyResource.getGroupByName(dummyGroupName); - assertNotNull("No dummy group "+dummyGroupName, group); - IntegrationTestTools.assertGroupMember(group, accountId); - } - - protected void assertDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - assertDummyGroupMember(null, dummyGroupName, accountId); - } - - protected void assertNoDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); - DummyGroup group = dummyResource.getGroupByName(dummyGroupName); - IntegrationTestTools.assertNoGroupMember(group, accountId); - } - - protected void assertNoDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { - assertNoDummyGroupMember(null, dummyGroupName, accountId); - } - - protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(dummyInstanceName, username); - assertNotNull("No dummy account for username "+username, account); - Set values = account.getAttributeValues(attributeName, Object.class); - assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty()); - } - - protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException { - Entry entry = openDJController.searchByUid(uid); - assertNotNull("OpenDJ accoun with uid "+uid+" not found", entry); - openDJController.assertAttribute(entry, "cn", cn); - if (active != null) { - openDJController.assertActive(entry, active); - } - return entry; - } - - protected void assertNoOpenDjAccount(String uid) throws DirectoryException { - Entry entry = openDJController.searchByUid(uid); - assertNull("Expected that OpenDJ account with uid " + uid + " will be gone, but it is still there", entry); - } - - protected void assertIteration(PrismObject shadow, Integer expectedIteration, String expectedIterationToken) { - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION, expectedIteration); - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); - } - - protected void assertIterationDelta(ObjectDelta shadowDelta, Integer expectedIteration, String expectedIterationToken) { - PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION, expectedIteration); - PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); - } - - protected void assertSituation(PrismObject shadow, SynchronizationSituationType expectedSituation) { - if (expectedSituation == null) { - PrismAsserts.assertNoItem(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION); - } else { - PrismAsserts.assertPropertyValue(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION, expectedSituation); - } - } - - protected void assertEnableTimestampFocus(PrismObject focus, - 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 userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong user disableTimestamp in "+focus, - startTime, endTime, userDisableTimestamp); - } - - protected void assertEnableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - ActivationType activationType = shadow.asObjectable().getActivation(); - assertNotNull("No activation in "+shadow, activationType); - XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); - TestUtil.assertBetween("Wrong shadow enableTimestamp in "+shadow, - startTime, endTime, userDisableTimestamp); - } - - protected void assertDisableTimestampShadow(PrismObject shadow, - XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { - XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); - TestUtil.assertBetween("Wrong shadow disableTimestamp in "+shadow, - startTime, endTime, userDisableTimestamp); - } - - protected void assertDisableReasonShadow(PrismObject shadow, String expectedReason) { - String disableReason = shadow.asObjectable().getActivation().getDisableReason(); - assertEquals("Wrong shadow disableReason in " + shadow, expectedReason, disableReason); - } - - protected String getPassword(PrismObject user) throws EncryptionException { - CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertNotNull("No password value in "+user, protectedStringType); - return protector.decryptString(protectedStringType); - } - - protected void assertPassword(PrismObject user, String expectedPassword) throws EncryptionException { - String decryptedUserPassword = getPassword(user); - assertEquals("Wrong password in "+user, expectedPassword, decryptedUserPassword); - } - - protected void assertUserLdapPassword(PrismObject user, String expectedPassword) throws EncryptionException { - CredentialsType credentialsType = user.asObjectable().getCredentials(); - assertNotNull("No credentials in "+user, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+user, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertLdapPassword(protectedStringType, expectedPassword, user); - } - - protected void assertShadowLdapPassword(PrismObject shadow, String expectedPassword) throws EncryptionException { - CredentialsType credentialsType = shadow.asObjectable().getCredentials(); - assertNotNull("No credentials in "+shadow, credentialsType); - PasswordType passwordType = credentialsType.getPassword(); - assertNotNull("No password in "+shadow, passwordType); - ProtectedStringType protectedStringType = passwordType.getValue(); - assertLdapPassword(protectedStringType, expectedPassword, shadow); - } - - protected void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject source) throws EncryptionException { - assertNotNull("No password value in "+source, protectedStringType); - String decryptedUserPassword = protector.decryptString(protectedStringType); - assertNotNull("Null password in " + source, decryptedUserPassword); - if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) { - assertTrue("Wrong password hash in "+source+": "+decryptedUserPassword+", expected "+expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); - } else { - assertEquals("Wrong password in "+source, expectedPassword, decryptedUserPassword); - } - } - - protected void assertGroupMember(DummyGroup group, String accountId) { - IntegrationTestTools.assertGroupMember(group, accountId); - } - - protected void assertNoGroupMember(DummyGroup group, String accountId) { - IntegrationTestTools.assertNoGroupMember(group, accountId); - } - - protected void assertNoGroupMembers(DummyGroup group) { - IntegrationTestTools.assertNoGroupMembers(group); - } - - protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); - login(principal); - } - - protected void login(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - login(principal); - } - - protected void login(MidPointPrincipal principal) { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null, principal.getAuthorities()); - securityContext.setAuthentication(createMpAuthentication(authentication)); - } - - protected Authentication createMpAuthentication(Authentication authentication) { - MidpointAuthentication mpAuthentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence()); - ModuleAuthentication moduleAuthentication = new ModuleAuthentication(NameOfModuleType.LOGIN_FORM); - moduleAuthentication.setAuthentication(authentication); - moduleAuthentication.setNameOfModule(SecurityPolicyUtil.DEFAULT_MODULE_NAME); - moduleAuthentication.setState(StateOfModule.SUCCESSFULLY); - moduleAuthentication.setPrefix(ModuleWebSecurityConfiguration.DEFAULT_PREFIX_OF_MODULE_WITH_SLASH - + ModuleWebSecurityConfiguration.DEFAULT_PREFIX_FOR_DEFAULT_MODULE + SecurityPolicyUtil.DEFAULT_MODULE_NAME + "/"); - mpAuthentication.addAuthentications(moduleAuthentication); - mpAuthentication.setPrincipal(authentication.getPrincipal()); - return mpAuthentication; - } - - protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); - loginSuperUser(principal); - } - - protected void loginSuperUser(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - loginSuperUser(principal); - } - - protected void loginSuperUser(MidPointPrincipal principal) throws SchemaException { - AuthorizationType superAutzType = new AuthorizationType(); - prismContext.adopt(superAutzType, RoleType.class, RoleType.F_AUTHORIZATION); - superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL); - Authorization superAutz = new Authorization(superAutzType); - Collection authorities = principal.getAuthorities(); - authorities.add(superAutz); - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); - securityContext.setAuthentication(createMpAuthentication(authentication)); - } - - protected void loginAnonymous() { - Authentication authentication = new AnonymousAuthenticationToken("foo", - AuthorizationConstants.ANONYMOUS_USER_PRINCIPAL, AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); - SecurityContextHolder.getContext().setAuthentication(createMpAuthentication(authentication)); - } - - protected void assertLoggedInUsername(String username) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - FocusType user = midPointPrincipal.getFocus(); - if (user == null) { - if (username == null) { - return; - } else { - AssertJUnit.fail("Expected logged in user '"+username+"' but there was no user in the spring security context"); - } - } - assertEquals("Wrong logged-in user", username, user.getName().getOrig()); - } - - protected void assertLoggedInUserOid(String userOid) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - assertPrincipalUserOid(midPointPrincipal, userOid); - } - - protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOid) { - FocusType user = principal.getFocus(); - if (user == null) { - if (userOid == null) { - return; - } else { - AssertJUnit.fail("Expected user "+userOid+" in principal "+principal+" but there was none"); - } - } - assertEquals("Wrong user OID in principal", userOid, user.getOid()); - } - - protected MidPointPrincipal getSecurityContextPrincipal() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - if (authentication == null) { - return null; - } - Object principal = authentication.getPrincipal(); - if (principal == null) { - return null; - } - if (principal instanceof MidPointPrincipal) { - return (MidPointPrincipal)principal; - } else { - AssertJUnit.fail("Unknown principal in the spring security context: "+principal); - return null; // not reached - } - } - - protected PrismObject getSecurityContextPrincipalFocus() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - if (authentication == null) { - return null; - } - Object principal = authentication.getPrincipal(); - if (principal == null) { - return null; - } - if (principal instanceof MidPointPrincipal) { - FocusType focusType = ((MidPointPrincipal)principal).getFocus(); - if (focusType == null) { - return null; - } - return focusType.asPrismObject(); - } else { - return null; - } - } - - protected void assertAuthenticated() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - Authentication authentication = securityContext.getAuthentication(); - assertTrue("Security context is not authenticated", authentication.isAuthenticated()); - } - - protected void resetAuthentication() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - securityContext.setAuthentication(null); - } - - protected void assertNoAuthentication() { - SecurityContext securityContext = SecurityContextHolder.getContext(); - assertNull("Unexpected authentication", securityContext.getAuthentication()); - } - - protected void assertSecurityContextPrincipalAttorneyOid(String attotrneyOid) { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - assertPrincipalAttorneyOid(midPointPrincipal, attotrneyOid); - } - - protected void assertPrincipalAttorneyOid(MidPointPrincipal principal, String attotrneyOid) { - FocusType attorney = principal.getAttorney(); - if (attorney == null) { - if (attotrneyOid == null) { - return; - } else { - AssertJUnit.fail("Expected attorney "+attotrneyOid+" in principal "+principal+" but there was none"); - } - } - assertEquals("Wrong attroney OID in principal", attotrneyOid, attorney.getOid()); - } - - protected Collection getSecurityContextAuthorizations() { - MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); - if (midPointPrincipal == null) { - return null; - } - return midPointPrincipal.getAuthorities(); - } - - protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { - Collection actualActions = autzs.stream() - .map(a -> a.getAction()) - .flatMap(List::stream) - .collect(Collectors.toList()); - PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); - } - - protected void assertSecurityContextAuthorizationActions(String... expectedActions) { - Collection securityContextAuthorizations = getSecurityContextAuthorizations(); - assertAuthorizationActions("Wrong authorizations in security context", securityContextAuthorizations, expectedActions); - } - - protected void assertSecurityContextAuthorizationActions(ModelAuthorizationAction... expectedModelActions) { - Collection securityContextAuthorizations = getSecurityContextAuthorizations(); - String[] expectedActions = new String[expectedModelActions.length]; - for (int i=0;i securityContextAuthorizations = getSecurityContextAuthorizations(); - if (securityContextAuthorizations != null && !securityContextAuthorizations.isEmpty()) { - fail("Unexpected authorizations in security context: "+securityContextAuthorizations); - } - } - - protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".displayAllUsers"); - OperationResult result = task.getResult(); - ResultHandler handler = (object, parentResult) -> { - display("User", object); - return true; - }; - modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - /** - * Returns appropriate object synchronization settings for the class. - * Assumes single sync setting for now. - */ - protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class type, String name) { - SynchronizationType synchronization = resource.getSynchronization(); - if (synchronization == null) { - return null; - } - List objectSynchronizations = synchronization.getObjectSynchronization(); - if (objectSynchronizations.isEmpty()) { - return null; - } - for (ObjectSynchronizationType objSyncType: objectSynchronizations) { - QName focusTypeQName = objSyncType.getFocusType(); - if (focusTypeQName == null) { - if (type != UserType.class) { - continue; - } - } else { - ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName); - if (type != focusType.getClassDefinition()) { - continue; - } - } - if (name == null) { - // we got it - return objSyncType; - } else { - if (name.equals(objSyncType.getName())) { - return objSyncType; - } - } - } - throw new IllegalArgumentException("Synchronization setting for "+type+" and name "+name+" not found in "+resource); - } - - protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, - String expectedIntent) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowKindIntent"); - PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertShadowKindIntent(shadow, expectedKind, expectedIntent); - } - - protected void assertShadowKindIntent(PrismObject shadow, ShadowKindType expectedKind, - String expectedIntent) { - assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); - assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); - } - - protected PrismObject getDefaultActor() { - return null; - } - - protected Task createTask(String operationName) { - Task task = super.createTask(operationName); - PrismObject defaultActor = getDefaultActor(); - if (defaultActor != null) { - task.setOwner(defaultActor); - } - task.setChannel(DEFAULT_CHANNEL); - return task; - } - - protected Task createTask(String operationName, MidPointPrincipal principal) { - Task task = super.createTask(operationName); - task.setOwner(principal.getFocus().asPrismObject()); - task.setChannel(DEFAULT_CHANNEL); - return task; - } - - protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction"); - OperationResult result = task.getResult(); - ConstructionType construction = new ConstructionType(); - ObjectReferenceType resourceRedRef = new ObjectReferenceType(); - resourceRedRef.setOid(resourceOid); - construction.setResourceRef(resourceRedRef); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, - ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), - construction); - modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget"); - } - OperationResult result = task.getResult(); - AssignmentType inducement = new AssignmentType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(targetOid); - inducement.setTargetRef(targetRef); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); - ModelExecuteOptions options = nullToEmpty(defaultOptions); - options.setReconcileAffected(reconcileAffected); - executeChanges(roleDelta, options, task, result); - result.computeStatus(); - if (reconcileAffected) { - TestUtil.assertInProgressOrSuccess(result); - } else { - TestUtil.assertSuccess(result); - } - } - - protected void modifyRoleAddExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRoleExclusion(roleOid, excludedRoleOid, true, task, result); - } - - protected void modifyRoleDeleteExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRoleExclusion(roleOid, excludedRoleOid, false, task, result); - } - - protected void modifyRoleExclusion(String roleOid, String excludedRoleOid, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - modifyRolePolicyRule(roleOid, createExclusionPolicyRule(excludedRoleOid), add, task, result); - } - - protected void modifyRolePolicyRule(String roleOid, PolicyRuleType exclusionPolicyRule, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - AssignmentType assignment = new AssignmentType(); - assignment.setPolicyRule(exclusionPolicyRule); - ObjectDelta roleDelta; - if (add) { - roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - } else { - roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - } - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleAddAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleDeleteAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, - assignment); - executeChanges(roleDelta, null, task, result); - } - - protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType(); - ObjectReferenceType targetRef = new ObjectReferenceType(); - targetRef.setOid(excludedRoleOid); - targetRef.setType(RoleType.COMPLEX_TYPE); - exclusionConstraint.setTargetRef(targetRef); - policyContraints.getExclusion().add(exclusionConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected PolicyRuleType createMinAssigneePolicyRule(int minAssignees) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - MultiplicityPolicyConstraintType minAssigneeConstraint = new MultiplicityPolicyConstraintType(); - minAssigneeConstraint.setMultiplicity(Integer.toString(minAssignees)); - policyContraints.getMinAssignees().add(minAssigneeConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected PolicyRuleType createMaxAssigneePolicyRule(int maxAssignees) { - PolicyRuleType policyRule = new PolicyRuleType(); - PolicyConstraintsType policyContraints = new PolicyConstraintsType(); - MultiplicityPolicyConstraintType maxAssigneeConstraint = new MultiplicityPolicyConstraintType(); - maxAssigneeConstraint.setMultiplicity(Integer.toString(maxAssignees)); - policyContraints.getMaxAssignees().add(maxAssigneeConstraint); - policyRule.setPolicyConstraints(policyContraints); - return policyRule; - } - - protected AssignmentType createAssignmentIdOnly(long id) { - AssignmentType assignment = new AssignmentType(); - assignment.asPrismContainerValue().setId(id); - return assignment; - } - - protected void modifyRoleAddPolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleDeletePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected void modifyRoleReplacePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationReplaceContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, - policyException); - executeChanges(roleDelta, null, task, result); - } - - protected PolicyExceptionType createPolicyException(String ruleName, String policySituation) { - PolicyExceptionType policyException = new PolicyExceptionType(); - policyException.setPolicySituation(policySituation); - policyException.setRuleName(ruleName); - return policyException; - } - - protected Optional findAssignmentByTarget(PrismObject focus, String targetOid) { - return focus.asObjectable().getAssignment().stream() - .filter(a -> a.getTargetRef() != null && targetOid.equals(a.getTargetRef().getOid())) - .findFirst(); - } - - protected AssignmentType findAssignmentByTargetRequired(PrismObject focus, String targetOid) { - return findAssignmentByTarget(focus, targetOid) - .orElseThrow(() -> new IllegalStateException("No assignment to " + targetOid + " in " + focus)); - } - - - protected AssignmentType findInducementByTarget(String roleOid, String targetOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".findInducementByTarget"); - OperationResult result = task.getResult(); - PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); - for (AssignmentType inducement: role.asObjectable().getInducement()) { - ObjectReferenceType targetRef = inducement.getTargetRef(); - if (targetRef != null && targetOid.equals(targetRef.getOid())) { - return inducement; - } - } - return null; - } - - protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, - 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); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_INDUCEMENT, - inducement.asPrismContainerValue().clone()); - modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, - ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - if (task == null) { - task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleDeleteInducement"); - } - OperationResult result = task.getResult(); - - AssignmentType inducement = new AssignmentType(); - inducement.setId(inducementId); - ObjectDelta roleDelta = prismContext.deltaFactory().object() - .createModificationDeleteContainer(RoleType.class, roleOid, - RoleType.F_INDUCEMENT, inducement); - ModelExecuteOptions options = nullToEmpty(defaultOptions); - options.setReconcileAffected(reconcileAffected); - executeChanges(roleDelta, options, task, result); - result.computeStatus(); - if (reconcileAffected) { - TestUtil.assertInProgressOrSuccess(result); - } else { - TestUtil.assertSuccess(result); - } - } - - @NotNull - protected ModelExecuteOptions nullToEmpty(ModelExecuteOptions options) { - return options != null ? options : new ModelExecuteOptions(); - } - - protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - PrismObject account = prismContext.parseObject(accountFile); - - ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid - ); - PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); - accountRefVal.setObject(account); - ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); - userDelta.addModification(accountDelta); - Collection> deltas = (Collection)MiscUtil.createCollection(userDelta); - - modelService.executeChanges(deltas, null, task, result); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertAuthorized", principal); - assertAuthorized(principal, action, null, task, task.getResult()); - assertAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); - assertAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertAuthorized", principal); - assertAuthorized(principal, action, phase, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - SecurityContext origContext = SecurityContextHolder.getContext(); - createSecurityContext(principal); - try { - assertTrue("AuthorizationEvaluator.isAuthorized: Principal "+principal+" NOT authorized for action "+action, - securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result)); - if (phase == null) { - List requiredActions = new ArrayList<>(1); - requiredActions.add(action); - securityEnforcer.decideAccess(getSecurityContextPrincipal(), requiredActions, task, result); - } - } finally { - SecurityContextHolder.setContext(origContext); - } - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertNotAuthorized", principal); - assertNotAuthorized(principal, action, null, task, task.getResult()); - assertNotAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); - assertNotAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertNotAuthorized", principal); - assertNotAuthorized(principal, action, phase, task, task.getResult()); - assertSuccess(task.getResult()); - } - - protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - SecurityContext origContext = SecurityContextHolder.getContext(); - createSecurityContext(principal); - boolean isAuthorized = securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result); - SecurityContextHolder.setContext(origContext); - assertFalse("AuthorizationEvaluator.isAuthorized: Principal " + principal + " IS authorized for action " + action + " (" + phase + ") but he should not be", isAuthorized); - } - - protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); - assertAuthorizations(principal, expectedAuthorizations); - } - - protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { - List actualAuthorizations = new ArrayList<>(); - for (Authorization authorization: principal.getAuthorities()) { - actualAuthorizations.addAll(authorization.getAction()); - } - PrismAsserts.assertSets("Wrong authorizations in "+principal, actualAuthorizations, expectedAuthorizations); - } - - - protected void assertNoAuthorizations(PrismObject user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - MidPointPrincipal principal = focusProfileService.getPrincipal(user); - assertNotNull("No principal for "+user, principal); - assertNoAuthorizations(principal); - } - - protected void assertNoAuthorizations(MidPointPrincipal principal) { - if (principal.getAuthorities() != null && !principal.getAuthorities().isEmpty()) { - AssertJUnit.fail("Unexpected authorizations in "+principal+": "+principal.getAuthorities()); - } - } - - protected CompiledGuiProfileAsserter assertCompiledGuiProfile(MidPointPrincipal principal) { - if (!(principal instanceof GuiProfiledPrincipal)) { - fail("Expected GuiProfiledPrincipal, but got "+principal.getClass()); - } - CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal)principal).getCompiledGuiProfile(); - CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal "+principal); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected CompiledGuiProfileAsserter assertCompiledGuiProfile(CompiledGuiProfile compiledGuiProfile) { - CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, null); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules) { - EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, null); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules, PrismObject sourceObject) { - EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, sourceObject.toString()); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected void createSecurityContext(MidPointPrincipal principal) { - SecurityContext context = new SecurityContextImpl(); - Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); - context.setAuthentication(authentication); - SecurityContextHolder.setContext(context); - } - - protected Object createSecureObject() { - return new FilterInvocation("/midpoint", "whateverServlet", "doSomething"); - } - - protected Collection createConfigAttributes(String action) { - Collection attrs = new ArrayList<>(); - attrs.add(new SecurityConfig(action)); - return attrs; - } - - protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getEditObjectDefinition"); - OperationResult result = task.getResult(); - PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - return editSchema; - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject targetHolder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - return getAssignableRoleSpecification(targetHolder, 0); - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - return getAssignableRoleSpecification(focus, AbstractRoleType.class, 0); - } - - protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".getAssignableRoleSpecification"); - OperationResult result = task.getResult(); - RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); - assertSuccess(result); - return spec; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", order "+order); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder, Class roleType, int order) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, roleType, order); - RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter(spec, null, "for holder "+targetHolder+", role type "+roleType.getSimpleName()+", order "+order); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".assertAllowRequestItems"); - OperationResult result = task.getResult(); - assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); - assertSuccess(result); - } - - protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) - throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(userOid); - PrismObject target = getRole(targetRoleOid); - - ItemSecurityConstraints constraints = modelInteractionService.getAllowedRequestAssignmentItems(user, target, task, result); - display("Request decisions for "+target, constraints); - - for (ItemPath expectedAllowedItemPath: expectedAllowedItemPaths) { - AuthorizationDecisionType decision = constraints.findItemDecision(expectedAllowedItemPath); - assertEquals("Wrong decision for item "+expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); - } - } - - - protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); - PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - assertEncryptedUserPassword(user, expectedClearPassword); - } - - protected void assertEncryptedUserPassword(PrismObject user, String expectedClearPassword) throws EncryptionException { - UserType userType = user.asObjectable(); - ProtectedStringType protectedActualPassword = userType.getCredentials().getPassword().getValue(); - String actualClearPassword = protector.decryptString(protectedActualPassword); - assertEquals("Wrong password for "+user, expectedClearPassword, actualClearPassword); - } - - @Deprecated - protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { - PrismContainer metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); - assertNotNull("No password metadata in "+user, metadataContainer); - MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); - } - - protected void assertPasswordMetadata(PrismObject user, QName credentialType, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { - PrismContainer metadataContainer = user.findContainer(ItemPath.create(UserType.F_CREDENTIALS, credentialType, PasswordType.F_METADATA)); - assertNotNull("No password metadata in "+user, metadataContainer); - MetadataType metadataType = metadataContainer.getValue().asContainerable(); - assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); - } - - protected void assertCreateMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = object.asObjectable().getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(object.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertModifyMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = object.asObjectable().getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(object.toString(), metadataType, false, false, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertCreateMetadata(AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { - MetadataType metadataType = assignmentType.getMetadata(); - PrismObject defaultActor = getDefaultActor(); - assertMetadata(assignmentType.toString(), metadataType, true, true, start, end, - defaultActor==null?null:defaultActor.getOid(), DEFAULT_CHANNEL); - } - - protected void assertDummyPassword(String instance, String userId, String expectedClearPassword) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); - assertEquals("Wrong password in dummy '"+instance+"' account "+userId, expectedClearPassword, account.getPassword()); - } - - protected void assertDummyPasswordNotEmpty(String instance, String userId) throws SchemaViolationException, ConflictException, InterruptedException { - DummyAccount account = getDummyAccount(instance, userId); - assertNotNull("No dummy account "+userId, account); - String actualPassword = account.getPassword(); - if (actualPassword == null || actualPassword.isEmpty()) { - fail("Empty password in dummy '"+instance+"' account "+userId); - } - } - - protected void reconcileUser(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - reconcileUser(oid, null, task, result); - } - - protected void reconcileUser(String oid, ModelExecuteOptions options, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, oid); - modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(options), task, result); - } - - protected void reconcileOrg(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(OrgType.class, oid); - modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result); - } - - protected void assertRefEquals(String message, ObjectReferenceType expected, ObjectReferenceType actual) { - if (expected == null && actual == null) { - return; - } - if (expected == null || actual == null) { - fail(message + ": expected=" + expected + ", actual=" + actual); - } - PrismAsserts.assertRefEquivalent(message, expected.asReferenceValue(), actual.asReferenceValue()); - } - - protected void assertTaskClosed(PrismObject task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); - } - - protected void assertTaskClosed(Task task) { - assertEquals("Wrong executionStatus in "+task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); - } - - protected List getAllAuditRecords(Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); - } - - protected List getAuditRecords(int maxRecords, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("setMaxResults", maxRecords); - return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); - } - - protected List getObjectAuditRecords(String oid) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getObjectAuditRecords"); - OperationResult result = task.getResult(); - return getObjectAuditRecords(oid, task, result); - } - - protected List getObjectAuditRecords(String oid, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("targetOid", oid); - return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.targetOid = :targetOid) order by aer.timestampValue asc", - params, task, result); - } - - protected List getParamAuditRecords(String paramName, String paramValue, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("paramName", paramName); - params.put("paramValue", paramValue); - return modelAuditService.listRecords("select * from m_audit_event as aer left join aer.propertyValues as pv where (pv.name = :paramName and pv.value = :paramValue) order by aer.timestampValue asc", - params, task, result); - } - - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Task task = createTask("getAuditRecordsFromTo"); - OperationResult result = task.getResult(); - return getAuditRecordsFromTo(from, to, task, result); - } - - protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { - Map params = new HashMap<>(); - params.put("from", from); - params.put("to", to); - return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.timestampValue >= :from) and (aer.timestampValue <= :to) order by aer.timestampValue asc", - params, task, result); - } - - protected void checkUserApprovers(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); - checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getModifyApproverRef(), result); - } - - protected void checkUserApproversForCreate(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); - checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getCreateApproverRef(), result); - } - - protected void checkApproversForCreate(Class clazz, String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - PrismObject object = repositoryService.getObject(clazz, oid, null, result); - checkApprovers(object, expectedApprovers, object.asObjectable().getMetadata().getCreateApproverRef(), result); - } - - protected void checkApprovers(PrismObject object, List expectedApprovers, List realApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { - HashSet realApproversSet = new HashSet<>(); - for (ObjectReferenceType approver : realApprovers) { - realApproversSet.add(approver.getOid()); - assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType()); - } - assertEquals("Mismatch in approvers in metadata", new HashSet(expectedApprovers), realApproversSet); - } - - protected PrismObject findUserInRepo(String name, OperationResult result) throws SchemaException { - List> users = findUserInRepoUnchecked(name, result); - assertEquals("Didn't find exactly 1 user object with name " + name, 1, users.size()); - return users.get(0); - } - - protected List> findUserInRepoUnchecked(String name, OperationResult result) throws SchemaException { - ObjectQuery q = prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly(name).matchingOrig().build(); - return repositoryService.searchObjects(UserType.class, q, null, result); - } - - protected List> findRoleInRepoUnchecked(String name, OperationResult result) throws SchemaException { - ObjectQuery q = prismContext.queryFor(RoleType.class).item(RoleType.F_NAME).eqPoly(name).matchingOrig().build(); - return repositoryService.searchObjects(RoleType.class, q, null, result); - } - - protected void assertFocusModificationSanity(ModelContext context) throws JAXBException { - ModelElementContext focusContext = context.getFocusContext(); - PrismObject focusOld = focusContext.getObjectOld(); - if (focusOld == null) { - return; - } - ObjectDelta focusPrimaryDelta = focusContext.getPrimaryDelta(); - if (focusPrimaryDelta != null) { - assertEquals("No OID in old focus object", focusOld.getOid(), focusPrimaryDelta.getOid()); - assertEquals(ChangeType.MODIFY, focusPrimaryDelta.getChangeType()); - assertNull(focusPrimaryDelta.getObjectToAdd()); - for (ItemDelta itemMod : focusPrimaryDelta.getModifications()) { - if (itemMod.getValuesToDelete() != null) { - Item property = focusOld.findItem(itemMod.getPath()); - assertNotNull("Deleted item " + itemMod.getParentPath() + "/" + itemMod.getElementName() + " not found in focus", property); - for (Object valueToDelete : itemMod.getValuesToDelete()) { - if (!property.contains((PrismValue) valueToDelete, EquivalenceStrategy.REAL_VALUE)) { - display("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); - display("Deleted value", valueToDelete); - display("HASHCODE: " + valueToDelete.hashCode()); - for (Object value : property.getValues()) { - display("Existing value", value); - display("EQUALS: " + valueToDelete.equals(value)); - display("HASHCODE: " + value.hashCode()); - } - fail("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); - } - } - } - - } - } - } - - protected PrismObject getUserFromRepo(String oid, OperationResult result) throws SchemaException, ObjectNotFoundException { - return repositoryService.getObject(UserType.class, oid, null, result); - } - - protected boolean assignmentExists(List assignmentList, String targetOid) { - for (AssignmentType assignmentType : assignmentList) { - if (assignmentType.getTargetRef() != null && targetOid.equals(assignmentType.getTargetRef().getOid())) { - return true; - } - } - return false; - } - - // just guessing (good enough for testing) - protected boolean isH2() { - Task task = createTask("isH2"); - RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); - return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); - } - - protected void assertNoPostponedOperation(PrismObject shadow) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - if (!pendingOperations.isEmpty()) { - AssertJUnit.fail("Expected no pending operations in "+shadow+", but found one: "+pendingOperations); - } - } - - protected String addAndRecomputeUser(File file, Task initTask, OperationResult initResult) throws Exception { - String oid = repoAddObjectFromFile(file, initResult).getOid(); - recomputeUser(oid, initTask, initResult); - display("User " + file, getUser(oid)); - return oid; - } - - protected String addAndRecompute(File file, Task task, OperationResult result) throws Exception { - PrismObject object = repoAddObjectFromFile(file, result); - modelService.recompute(object.asObjectable().getClass(), object.getOid(), null, task, result); - display("Object: " + file, getObject(object.asObjectable().getClass(), object.getOid())); - return object.getOid(); - } - - protected void assertAuditReferenceValue(List events, String refName, String oid, QName type, String name) { - if (events.size() != 1) { - display("Events", events); - assertEquals("Wrong # of events", 1, events.size()); - } - assertAuditReferenceValue(events.get(0), refName, oid, type, name); - } - - protected void assertAuditReferenceValue(AuditEventRecord event, String refName, String oid, QName type, String name) { - Set values = event.getReferenceValues(refName); - assertEquals("Wrong # of reference values of '" + refName + "'", 1, values.size()); - AuditReferenceValue value = values.iterator().next(); - assertEquals("Wrong OID", oid, value.getOid()); - assertEquals("Wrong type", type, value.getType()); - assertEquals("Wrong name", name, PolyString.getOrig(value.getTargetName())); - } - - protected void assertAuditTarget(AuditEventRecord event, String oid, QName type, String name) { - PrismReferenceValue target = event.getTarget(); - assertNotNull("No target", target); - assertEquals("Wrong OID", oid, target.getOid()); - assertEquals("Wrong type", type, target.getTargetType()); - assertEquals("Wrong name", name, PolyString.getOrig(target.getTargetName())); - } - - protected List filter(List records, AuditEventStage stage) { - return records.stream() - .filter(r -> r.getEventStage() == stage) - .collect(Collectors.toList()); - } - - protected List filter(List records, AuditEventType type, AuditEventStage stage) { - return records.stream() - .filter(r -> r.getEventType() == type && r.getEventStage() == stage) - .collect(Collectors.toList()); - } - - protected void resetTriggerTask(String taskOid, File taskFile, OperationResult result) - throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, FileNotFoundException { - taskManager.suspendAndDeleteTasks(Collections.singletonList(taskOid), 60000L, true, result); - importObjectFromFile(taskFile, result); - taskManager.suspendTasks(Collections.singletonList(taskOid), 60000L, result); - modifySystemObjectInRepo(TaskType.class, taskOid, - prismContext.deltaFor(TaskType.class) - .item(TaskType.F_SCHEDULE).replace() - .asItemDeltas(), - result); - taskManager.resumeTasks(singleton(taskOid), result); - } - - protected void repoAddObjects(List objects, OperationResult result) - throws EncryptionException, ObjectAlreadyExistsException, SchemaException { - for (ObjectType object : objects) { - repoAddObject(object.asPrismObject(), result); - } - } - - protected void recomputeAndRefreshObjects(List objects, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, - SchemaException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException { - for (int i = 0; i < objects.size(); i++) { - ObjectType object = objects.get(i); - modelService.recompute(object.getClass(), object.getOid(), null, task, result); - objects.set(i, repositoryService.getObject(object.getClass(), object.getOid(), null, result).asObjectable()); - } - } - - protected void dumpAllUsers(OperationResult initResult) throws SchemaException { - SearchResultList> users = repositoryService - .searchObjects(UserType.class, null, null, initResult); - display("Users", users); - } - - protected PrismObject

assertLinkedPersona(PrismObject focus, Class

personaClass, String subtype) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult("assertLinkedPersona"); - for (ObjectReferenceType personaRef: focus.asObjectable().getPersonaRef()) { - PrismObject

persona = repositoryService.getObject((Class

)ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), - personaRef.getOid(), null, result); - if (isTypeAndSubtype(persona, personaClass, subtype)) { - return persona; - } - } - fail("No persona "+personaClass.getSimpleName()+"/"+subtype+" in "+focus); - return null; // not reached - } - - protected boolean isTypeAndSubtype(PrismObject focus, Class expectedType, String subtype) { - if (!expectedType.isAssignableFrom(focus.getCompileTimeClass())) { - return false; - } - if (!FocusTypeUtil.hasSubtype(focus, subtype)) { - return false; - } - return true; - } - - protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = findObjectByName(OrgType.class, orgName); - assertNotNull("The org "+orgName+" is missing!", org); - display("Org "+orgName, org); - PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, createPolyString(orgName)); - return org; - } - - protected void dumpOrgTree() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - display("Org tree", dumpOrgTree(getTopOrgOid())); - } - - protected void dumpOrgTreeAndUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - display("Org tree", dumpOrgTree(getTopOrgOid(), true)); - } - - protected String getTopOrgOid() { - return null; - } - - protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Task task, OperationResult parentResult) throws SchemaException, IOException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - // copy rules from the file into live system config object - 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())) - .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); - } - - protected void displayProvisioningScripts() { - displayProvisioningScripts(null); - } - - protected void displayProvisioningScripts(String dummyName) { - display("Provisioning scripts "+dummyName, getDummyResource(dummyName).getScriptHistory()); - } - - protected void purgeProvisioningScriptHistory() { - purgeProvisioningScriptHistory(null); - } - - protected void purgeProvisioningScriptHistory(String dummyName) { - getDummyResource(dummyName).purgeScriptHistory(); - } - - protected void assertNoProvisioningScripts() { - if (!getDummyResource().getScriptHistory().isEmpty()) { - IntegrationTestTools.displayScripts(getDummyResource().getScriptHistory()); - AssertJUnit.fail(getDummyResource().getScriptHistory().size()+" provisioning scripts were executed while not expected any"); - } - } - - protected void assertDummyProvisioningScriptsNone() { - IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory()); - } - - protected void applyPasswordPolicy(String passwordPolicyOid, String securityPolicyOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - if (passwordPolicyOid == null) { - modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, - task, result /* no value */); - } else { - PrismReferenceValue passPolicyRef = itemFactory().createReferenceValue(passwordPolicyOid, ValuePolicyType.COMPLEX_TYPE); - modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, - task, result, passPolicyRef); - } - } - - protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("assertPasswordCompliesWithPolicy"); - OperationResult result = task.getResult(); - assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); - assertSuccess(result); - } - - protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid, Task task, OperationResult result) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { - String password = getPassword(user); - display("Password of "+user, password); - PrismObject passwordPolicy = repositoryService.getObject(ValuePolicyType.class, passwordPolicyOid, null, result); - List messages = new ArrayList<>(); - boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of "+user, task, result); - if (!valid) { - fail("Password for "+user+" does not comply with password policy: "+messages); - } - } - - protected FocusValuePolicyOriginResolver createUserOriginResolver(PrismObject user) { - if (user != null) { - return new FocusValuePolicyOriginResolver<>(user, modelObjectResolver); - } else { - return null; - } - } - - protected List> getTasksForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(TaskType.class) - .item(TaskType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) - .build(); - return modelService.searchObjects(TaskType.class, query, options, task, result); - } - - protected List> getCasesForObject(String oid, QName type, - Collection> options, Task task, OperationResult result) - throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, - ConfigurationException, ExpressionEvaluationException { - ObjectQuery query = prismContext.queryFor(CaseType.class) - .item(CaseType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) - .build(); - return modelService.searchObjects(CaseType.class, query, options, task, result); - } - - protected CaseType getApprovalCase(List> cases) { - List rv = cases.stream() - .filter(o -> ObjectTypeUtil.hasArchetype(o, SystemObjectsType.ARCHETYPE_APPROVAL_CASE.value())) - .map(o -> o.asObjectable()) - .collect(Collectors.toList()); - if (rv.isEmpty()) { - throw new AssertionError("No approval case found"); - } else if (rv.size() > 1) { - throw new AssertionError("More than one approval case found: " + rv); - } else { - return rv.get(0); - } - } - - protected CaseType getRootCase(List> cases) { - List rv = cases.stream() - .map(o -> o.asObjectable()) - .filter(c -> c.getParentRef() == null) - .collect(Collectors.toList()); - if (rv.isEmpty()) { - throw new AssertionError("No root case found"); - } else if (rv.size() > 1) { - throw new AssertionError("More than one root case found: " + rv); - } else { - return rv.get(0); - } - } - - @SuppressWarnings("unused") // maybe in the future :) - protected Consumer createShowTaskTreeConsumer(long period) { - AtomicLong lastTimeShown = new AtomicLong(0); - return task -> { - try { - if (lastTimeShown.get() + period < System.currentTimeMillis()) { - dumpTaskTree(task.getOid(), getResult()); - lastTimeShown.set(System.currentTimeMillis()); - } - } catch (CommonException e) { - throw new AssertionError(e); - } - }; - } - - // highly experimental - public class TestCtx { - public final String name; - - public final Task task; - public final OperationResult result; - - TestCtx(Object testCase, String name) { - this.name = name; - TestUtil.displayTestTitle(testCase, name); - task = taskManager.createTaskInstance(testCase.getClass().getName() + "." + name); - result = task.getResult(); - dummyAuditService.clear(); - } - - public void displayWhen() { - TestUtil.displayWhen(name); - } - - public void displayThen() { - TestUtil.displayThen(name); - } - } - - protected TestCtx createContext(Object testCase, String testName) { - return new TestCtx(testCase, testName); - } - - protected T runPrivileged(Producer producer) { - return securityContextManager.runPrivileged(producer); - } - - protected void assertPendingOperationDeltas(PrismObject shadow, int expectedNumber) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - assertEquals("Wrong number of pending operations in "+shadow, expectedNumber, pendingOperations.size()); - } - - protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { - return assertSinglePendingOperation(shadow, requestStart, requestEnd, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, - 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) { - assertPendingOperationDeltas(shadow, 1); - return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), - requestStart, requestEnd, expectedStatus, completionStart, completionEnd); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { - return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { - return assertPendingOperation(shadow, pendingOperation, null, null, - expectedExecutionStatus, expectedResultStatus, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation) { - return assertPendingOperation(shadow, pendingOperation, null, null, - OperationResultStatusType.IN_PROGRESS, null, null); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - OperationResultStatusType expectedResultStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { - PendingOperationExecutionStatusType expectedExecutionStatus; - if (expectedResultStatus == OperationResultStatusType.IN_PROGRESS) { - expectedExecutionStatus = PendingOperationExecutionStatusType.EXECUTING; - } else { - expectedExecutionStatus = PendingOperationExecutionStatusType.COMPLETED; - } - return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, expectedExecutionStatus, expectedResultStatus, completionStart, completionEnd); - } - - protected PendingOperationType assertPendingOperation( - PrismObject shadow, PendingOperationType pendingOperation, - XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, - PendingOperationExecutionStatusType expectedExecutionStatus, - OperationResultStatusType expectedResultStatus, - XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { - assertNotNull("No operation ", pendingOperation); - - ObjectDeltaType deltaType = pendingOperation.getDelta(); - assertNotNull("No delta in pending operation in "+shadow, deltaType); - // TODO: check content of pending operations in the shadow - - TestUtil.assertBetween("No request timestamp in pending operation in "+shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); - - PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); - assertEquals("Wrong execution status in pending operation in "+shadow, expectedExecutionStatus, executiontStatus); - - OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); - assertEquals("Wrong result status in pending operation in "+shadow, expectedResultStatus, resultStatus); - - // TODO: assert other timestamps - - if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { - TestUtil.assertBetween("No completion timestamp in pending operation in "+shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); - } - - return pendingOperation; - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus) { - return findPendingOperation(shadow, expectedExecutionStaus, null, null, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult) { - return findPendingOperation(shadow, null, expectedResult, null, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ItemPath itemPath) { - return findPendingOperation(shadow, null, expectedResult, null, itemPath); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { - return findPendingOperation(shadow, expectedExecutionStaus, null, null, itemPath); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { - return findPendingOperation(shadow, null, expectedResult, expectedChangeType, null); - } - - protected PendingOperationType findPendingOperation(PrismObject shadow, - PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, - ChangeTypeType expectedChangeType, ItemPath itemPath) { - List pendingOperations = shadow.asObjectable().getPendingOperation(); - for (PendingOperationType pendingOperation: pendingOperations) { - if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { - continue; - } - if (expectedResult != null && !expectedResult.equals(pendingOperation.getResultStatus())) { - continue; - } - ObjectDeltaType delta = pendingOperation.getDelta(); - if (expectedChangeType != null) { - if (!expectedChangeType.equals(delta.getChangeType())) { - continue; - } - } - if (itemPath == null) { - return pendingOperation; - } - assertNotNull("No delta in pending operation in "+shadow, delta); - for (ItemDeltaType itemDelta: delta.getItemDelta()) { - ItemPath deltaPath = itemDelta.getPath().getItemPath(); - if (itemPath.equivalent(deltaPath)) { - return pendingOperation; - } - } - } - return null; - } - - protected UserAsserter assertUserAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUser(oid, "after"); - asserter.assertOid(oid); - return asserter; - } - - protected UserAsserter assertUserAfterByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUserByUsername(username, "after"); - asserter.display(); - asserter.assertName(username); - return asserter; - } - - protected UserAsserter assertUserBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUser(oid, "before"); - asserter.assertOid(oid); - return asserter; - } - - protected UserAsserter assertUserBeforeByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = assertUserByUsername(username, "before"); - asserter.display(); - asserter.assertName(username); - return asserter; - } - - protected UserAsserter assertUser(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = getUser(oid); - return assertUser(user, message); - } - protected RepoOpAsserter createRepoOpAsserter(PerformanceInformation performanceInformation, String details) { - return new RepoOpAsserter(performanceInformation, details); - } - - protected RepoOpAsserter createRepoOpAsserter(String details) { - PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); - return new RepoOpAsserter(repoPerformanceInformation, details); - } - - protected UserAsserter assertUser(PrismObject user, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - UserAsserter asserter = UserAsserter.forUser(user, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected UserAsserter assertUserByUsername(String username, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject user = findUserByUsername(username); - assertNotNull("User with username '"+username+"' was not found", user); - UserAsserter asserter = UserAsserter.forUser(user, message); - initializeAsserter(asserter); - return asserter; - } - - protected OrgAsserter assertOrg(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = getObject(OrgType.class, oid); - OrgAsserter asserter = assertOrg(org, message); - asserter.assertOid(oid); - return asserter; - } - - protected OrgAsserter assertOrg(PrismObject org, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OrgAsserter asserter = OrgAsserter.forOrg(org, message); - initializeAsserter(asserter); - return asserter; - } - - protected OrgAsserter assertOrgAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - OrgAsserter asserter = assertOrg(oid, "after"); - asserter.display(); - asserter.assertOid(oid); - return asserter; - } - - protected OrgAsserter assertOrgByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject org = findObjectByName(OrgType.class, name); - assertNotNull("No org with name '"+name+"'", org); - OrgAsserter asserter = OrgAsserter.forOrg(org, message); - initializeAsserter(asserter); - asserter.assertName(name); - return asserter; - } - - protected RoleAsserter assertRole(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject role = getObject(RoleType.class, oid); - RoleAsserter asserter = assertRole(role, message); - asserter.assertOid(oid); - return asserter; - } - - protected RoleAsserter assertRoleByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject role = findObjectByName(RoleType.class, name); - assertNotNull("No role with name '"+name+"'", role); - RoleAsserter asserter = assertRole(role, message); - asserter.assertName(name); - return asserter; - } - - protected RoleAsserter assertRole(PrismObject role, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = RoleAsserter.forRole(role, message); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected RoleAsserter assertRoleBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRole(oid, "before"); - return asserter; - } - - protected RoleAsserter assertRoleAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRole(oid, "after"); - return asserter; - } - - protected RoleAsserter assertRoleAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - RoleAsserter asserter = assertRoleByName(name, "after"); - return asserter; - } - - protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = getObject(ServiceType.class, oid); - // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); - initializeAsserter(asserter); - asserter.assertOid(oid); - return asserter; - } - - protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = findServiceByName(name); - // TODO: change to ServiceAsserter later - FocusAsserter asserter = FocusAsserter.forFocus(service, message); - initializeAsserter(asserter); - asserter.assertName(name); - return asserter; - } - - protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertServiceByName(name, "after"); - } - - protected FocusAsserter assertServiceBeforeByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertServiceByName(name, "before"); - } - - protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertService(oid, "after"); - } - - protected FocusAsserter assertServiceBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - return assertService(oid, "before"); - } - - protected void assertNoServiceByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject service = findServiceByName(name); - if (service != null) { - display("Unexpected service", service); - fail("Unexpected "+service); - } - } - - protected CaseAsserter assertCase(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject acase = getObject(CaseType.class, oid); - CaseAsserter asserter = CaseAsserter.forCase(acase, message); - initializeAsserter(asserter); - asserter.assertOid(oid); - return asserter; - } - - protected CaseAsserter assertCaseAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - CaseAsserter asserter = assertCase(oid, "after"); - asserter.display(); - asserter.assertOid(oid); - return asserter; - } - - protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModel(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModelNoFetch(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowFuture(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject repoShadow = getShadowModelFuture(oid); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); - asserter - .display(); - return asserter; - } - - protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); - options.setNoFetch(true); - PrismObject repoShadow = getShadowModel(oid, options, true); - ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); - asserter - .display(); - return asserter; - } - - protected void assertNoModelShadow(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadow"); - OperationResult result = task.getResult(); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, null, task, result); - fail("Expected that shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - - protected void assertNoModelShadowFuture(String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertNoModelShadowFuture"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - try { - PrismObject shadow = modelService.getObject(ShadowType.class, oid, options, task, result); - fail("Expected that future shadow "+oid+" will not be in the model. But it was: "+shadow); - } catch (ObjectNotFoundException e) { - // Expected - assertFailure(result); - } - } - - protected ResourceAsserter assertResource(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - PrismObject resource = getObject(ResourceType.class, oid); - return assertResource(resource, message); - } - - protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - ResourceAsserter asserter = assertResource(oid, "after"); - asserter.assertOid(oid); - return asserter; - } - - // Change to PrismObjectDefinitionAsserter later - protected PrismContainerDefinitionAsserter assertObjectDefinition(PrismObjectDefinition objectDef) { - return assertContainerDefinition(objectDef); - } - - protected PrismContainerDefinitionAsserter assertContainerDefinition(PrismContainerDefinition containerDef) { - PrismContainerDefinitionAsserter asserter = PrismContainerDefinitionAsserter.forContainerDefinition(containerDef); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { - ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected OperationResultAsserter assertOperationResult(OperationResult result) { - OperationResultAsserter asserter = OperationResultAsserter.forResult(result); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - // SECURITY - - protected void assertGetDeny(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - assertGetDeny(type, oid, null); - } - - protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetDeny"); - OperationResult result = task.getResult(); - try { - logAttempt("get", type, oid, null); - PrismObject object = modelService.getObject(type, oid, options, task, result); - failDeny("get", type, oid, null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("get", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected PrismObject assertGetAllow(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - return assertGetAllow(type, oid, null); - } - - protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetAllow"); - OperationResult result = task.getResult(); - logAttempt("get", type, oid, null); - PrismObject object = modelService.getObject(type, oid, options, task, result); - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("get", type, oid, null); - return object; - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, int expectedResults) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), null, expectedResults); - } - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, int expectedResults) throws Exception { - return assertSearch(type, query, null, expectedResults); - } - - protected void assertSearchRaw(Class type, ObjectQuery query, int expectedResults) throws Exception { - assertSearch(type, query, SelectorOptions.createCollection(GetOperationOptions.createRaw()), expectedResults); - } - - protected void assertSearchDeny(Class type, ObjectQuery query, - Collection> options) throws Exception { - try { - assertSearch(type, query, options, 0); - } catch (SecurityViolationException e) { - // This is expected. The search should either return zero results or throw an exception. - logDeny("search"); - } - } - - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, int expectedResults) throws Exception { - ObjectQuery originalQuery = query != null ? query.clone() : null; - return assertSearch(type, query, options, - new SearchAssertion() { - - @Override - public void assertObjects(String message, List> objects) throws Exception { - if (objects.size() > expectedResults) { - failDeny(message, type, originalQuery, expectedResults, objects.size()); - } else if (objects.size() < expectedResults) { - failAllow(message, type, originalQuery, expectedResults, objects.size()); - } - } - - @Override - public void assertCount(int count) throws Exception { - if (count > expectedResults) { - failDeny("count", type, originalQuery, expectedResults, count); - } else if (count < expectedResults) { - failAllow("count", type, originalQuery, expectedResults, count); - } - } - - }); - } - - protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { - assertSearch(type, query, null, expectedOids); - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, - Collection> options, String... expectedOids) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), options, expectedOids); - } - - protected void assertSearchFilter(Class type, ObjectFilter filter, String... expectedOids) throws Exception { - assertSearch(type, prismContext.queryFactory().createQuery(filter), expectedOids); - } - - protected void assertSearch(Class type, ObjectQuery query, - Collection> options, String... expectedOids) throws Exception { - assertSearch(type, query, options, - new SearchAssertion() { - - @Override - public void assertObjects(String message, List> objects) throws Exception { - if (!MiscUtil.unorderedCollectionEquals(objects, Arrays.asList(expectedOids), - (object,expectedOid) -> expectedOid.equals(object.getOid()))) { - failAllow(message, type, (query==null?"null":query.toString())+", expected "+Arrays.toString(expectedOids)+", actual "+objects, null); - } - } - - @Override - public void assertCount(int count) throws Exception { - if (count != expectedOids.length) { - failAllow("count", type, query, expectedOids.length, count); - } - } - - }); - } - - protected SearchResultList> assertSearch(Class type, ObjectQuery query, - Collection> options, SearchAssertion assertion) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects"); - OperationResult result = task.getResult(); - SearchResultList> objects; - try { - logAttempt("search", type, query); - objects = modelService.searchObjects(type, query, options, task, result); - display("Search returned", objects.toString()); - assertion.assertObjects("search", objects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("search", type, query, e); - return null; // not reached - } - - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjectsIterative"); - result = task.getResult(); - try { - logAttempt("searchIterative", type, query); - final List> iterativeObjects = new ArrayList<>(); - ResultHandler handler = new ResultHandler() { - @Override - public boolean handle(PrismObject object, OperationResult parentResult) { - iterativeObjects.add(object); - return true; - } - }; - modelService.searchObjectsIterative(type, query, handler, options, task, result); - display("Search iterative returned", iterativeObjects.toString()); - assertion.assertObjects("searchIterative", iterativeObjects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("searchIterative", type, query, e); - return null; // not reached - } - - task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertSearchObjects.count"); - result = task.getResult(); - try { - logAttempt("count", type, query); - int numObjects = modelService.countObjects(type, query, options, task, result); - display("Count returned", numObjects); - assertion.assertCount(numObjects); - assertSuccess(result); - } catch (SecurityViolationException e) { - // this should not happen - result.computeStatus(); - TestUtil.assertFailure(result); - failAllow("search", type, query, e); - return null; // not reached - } - - return objects; - } - - - protected void assertAddDeny(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - assertAddDeny(file, null); - } - - protected void assertAddDenyRaw(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - assertAddDeny(file, ModelExecuteOptions.createRaw()); - } - - protected void assertAddDeny(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - assertAddDeny(object, options); - } - - protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAddDeny"); - OperationResult result = task.getResult(); - ObjectDelta addDelta = object.createAddDelta(); - try { - logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); - modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); - failDeny("add", object.getCompileTimeClass(), object.getOid(), null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("add", object.getCompileTimeClass(), object.getOid(), null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected void assertAddAllow(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - assertAddAllow(file, null); - } - - protected OperationResult assertAddAllowTracing(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - return assertAddAllowTracing(file, null); - } - - protected void assertAddAllow(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - assertAddAllow(object, options); - } - - protected OperationResult assertAddAllowTracing(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - PrismObject object = PrismTestUtil.parseObject(file); - return assertAddAllowTracing(object, options); - } - - protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); - return assertAddAllow(object, options, task); - } - - protected OperationResult assertAddAllowTracing(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - Task task = createAllowDenyTask(AbstractModelIntegrationTest.class.getName() + ".assertAddAllow"); - setTracing(task, createDefaultTracingProfile()); - return assertAddAllow(object, options, task); - } - - protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { - OperationResult result = task.getResult(); - ObjectDelta addDelta = object.createAddDelta(); - logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); - } catch (SecurityViolationException e) { - failAllow("add", object.getCompileTimeClass(), object.getOid(), null, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("add", object.getCompileTimeClass(), object.getOid(), null); - return result; - } - - protected void assertDeleteDeny(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assertDeleteDeny(type, oid, null); - } - - protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteDeny"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - try { - logAttempt("delete", type, oid, null); - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - failDeny("delete", type, oid, null); - } catch (SecurityViolationException e) { - // this is expected - logDeny("delete", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } catch (ObjectNotFoundException e) { - // MID-3221 - // still consider OK ... for now - logError("delete", type, oid, null); - result.computeStatus(); - TestUtil.assertFailure(result); - } - } - - protected void assertDeleteAllow(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - assertDeleteAllow(type, oid, null); - } - - protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertDeleteAllow"); - OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); - logAttempt("delete", type, oid, null); - try { - modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); - } catch (SecurityViolationException e) { - failAllow("delete", type, oid, null, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow("delete", type, oid, null); - } - - private Task createAllowDenyTask(String opname) { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertAllow."+opname); - task.setOwner(getSecurityContextPrincipalFocus()); - task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); - return task; - } - - protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - return assertAllow(opname, attempt, task); - } - - protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - setTracing(task, createDefaultTracingProfile()); - return assertAllow(opname, attempt, task); - } - - protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { - OperationResult result = task.getResult(); - try { - logAttempt(opname); - attempt.run(task, result); - } catch (SecurityViolationException e) { - failAllow(opname, e); - } - result.computeStatus(); - TestUtil.assertSuccess(result); - logAllow(opname); - return result; - } - - protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { - Task task = createAllowDenyTask(opname); - OperationResult result = task.getResult(); - try { - logAttempt(opname); - attempt.run(task, result); - failDeny(opname); - } catch (SecurityViolationException e) { - // this is expected - logDeny(opname); - result.computeStatus(); - TestUtil.assertFailure(result); - } - return result; - } - - protected void asAdministrator(Attempt attempt) throws Exception { - Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".asAdministrator"); - OperationResult result = task.getResult(); - MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); - login(USER_ADMINISTRATOR_USERNAME); - task.setOwner(getSecurityContextPrincipalFocus()); - task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); - try { - attempt.run(task, result); - } catch (Throwable e) { - login(origPrincipal); - throw e; - } - login(origPrincipal); - result.computeStatus(); - TestUtil.assertSuccess(result); - } - - protected void logAttempt(String action) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logDeny(String action, Class type, ObjectQuery query) { - logDeny(action, type, query==null?"null":query.toString()); - } - - protected void logDeny(String action, Class type, String oid, ItemPath itemPath) { - logDeny(action, type, oid+" prop "+itemPath); - } - - protected void logDeny(String action, Class type, String desc) { - String msg = LOG_PREFIX_DENY+"Denied "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logDeny(String action) { - String msg = LOG_PREFIX_DENY+"Denied "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAllow(String action, Class type, ObjectQuery query) { - logAllow(action, type, query==null?"null":query.toString()); - } - - protected void logAllow(String action, Class type, String oid, ItemPath itemPath) { - logAllow(action, type, oid+" prop "+itemPath); - } - - protected void logAllow(String action, Class type, String desc) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAllow(String action) { - String msg = LOG_PREFIX_ALLOW+"Allowed "+action; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logError(String action, Class type, String oid, ItemPath itemPath, Throwable e) { - logError(action, type, oid+" prop "+itemPath, e); - } - - protected void logError(String action, Class type, String desc, Throwable e) { - String msg = LOG_PREFIX_DENY+"Error "+action+" of "+type.getSimpleName()+":"+desc + "("+e+")"; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void logAttempt(String action, Class type, ObjectQuery query) { - logAttempt(action, type, query==null?"null":query.toString()); - } - - protected void logAttempt(String action, Class type, String oid, ItemPath itemPath) { - logAttempt(action, type, oid+" prop "+itemPath); - } - - protected void logAttempt(String action, Class type, String desc) { - String msg = LOG_PREFIX_ATTEMPT+"Trying "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(msg); - LOGGER.info(msg); - } - - protected void failDeny(String action, Class type, ObjectQuery query, int expected, int actual) { - failDeny(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual); - } - - protected void failDeny(String action, Class type, String oid, ItemPath itemPath) { - failDeny(action, type, oid+" prop "+itemPath); - } - - protected void failDeny(String action, Class type, String desc) { - String msg = "Failed to deny "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - AssertJUnit.fail(msg); - } - - protected void failDeny(String action) { - String msg = "Failed to deny "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - AssertJUnit.fail(msg); - } - - protected void failAllow(String action, Class type, ObjectQuery query, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, query==null?"null":query.toString(), e); - } - - protected void failAllow(String action, Class type, ObjectQuery query, int expected, int actual) throws SecurityViolationException { - failAllow(action, type, (query==null?"null":query.toString())+", expected "+expected+", actual "+actual, null); - } - - protected void failAllow(String action, Class type, String oid, ItemPath itemPath, SecurityViolationException e) throws SecurityViolationException { - failAllow(action, type, oid+" prop "+itemPath, e); - } - - protected void failAllow(String action, Class type, String desc, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action+" of "+type.getSimpleName()+":"+desc; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); - } else { - AssertJUnit.fail(msg); - } - } - - protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { - String msg = "Failed to allow "+action; - System.out.println(LOG_PREFIX_FAIL+msg); - LOGGER.error(LOG_PREFIX_FAIL+msg); - if (e != null) { - throw new SecurityViolationException(msg+": "+e.getMessage(), e); - } else { - AssertJUnit.fail(msg); - } - } - - protected ArchetypePolicyAsserter assertArchetypePolicy(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertArchetypePolicy"); - ArchetypePolicyType archetypePolicy = modelInteractionService.determineArchetypePolicy(object, result); - ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected AssignmentCandidatesSpecificationAsserter assertAssignmentTargetSpecification(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertAssignmentTargetSpecification"); - AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentTargetSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected AssignmentCandidatesSpecificationAsserter assertAssignmentHolderSpecification(PrismObject object) throws SchemaException, ConfigurationException { - OperationResult result = new OperationResult("assertAssignmentHolderSpecification"); - AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentHolderSpecification(object, result); - AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for "+object); - initializeAsserter(asserter); - asserter.display(); - return asserter; - } - - protected ExpressionVariables createVariables(Object... params) { - return ExpressionVariables.create(prismContext, params); - } - -} +/* + * Copyright (c) 2010-2019 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.test; + +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.PrismObject.asObjectableList; +import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.ConnectException; +import java.util.*; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.mutable.MutableInt; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.opends.server.types.DirectoryException; +import org.opends.server.types.Entry; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.access.ConfigAttribute; +import org.springframework.security.access.SecurityConfig; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.context.SecurityContextImpl; +import org.springframework.security.web.FilterInvocation; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeMethod; + +import com.evolveum.icf.dummy.resource.*; +import com.evolveum.midpoint.audit.api.AuditEventRecord; +import com.evolveum.midpoint.audit.api.AuditEventStage; +import com.evolveum.midpoint.audit.api.AuditEventType; +import com.evolveum.midpoint.audit.api.AuditReferenceValue; +import com.evolveum.midpoint.common.Clock; +import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; +import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.model.api.*; +import com.evolveum.midpoint.model.api.authentication.*; +import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule; +import com.evolveum.midpoint.model.api.context.ModelContext; +import com.evolveum.midpoint.model.api.context.ModelElementContext; +import com.evolveum.midpoint.model.api.context.ModelProjectionContext; +import com.evolveum.midpoint.model.api.expr.MidpointFunctions; +import com.evolveum.midpoint.model.api.hooks.HookRegistry; +import com.evolveum.midpoint.model.api.interaction.DashboardService; +import com.evolveum.midpoint.model.common.SystemObjectCache; +import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver; +import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor; +import com.evolveum.midpoint.model.test.asserter.*; +import com.evolveum.midpoint.notifications.api.NotificationManager; +import com.evolveum.midpoint.notifications.api.transports.Message; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.crypto.EncryptionException; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy; +import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.OrgFilter; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xml.XmlTypeConverter; +import com.evolveum.midpoint.provisioning.api.ProvisioningService; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.api.perf.PerformanceInformation; +import com.evolveum.midpoint.repo.common.ObjectResolver; +import com.evolveum.midpoint.repo.common.expression.ExpressionVariables; +import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.internals.InternalsConfig; +import com.evolveum.midpoint.schema.processor.ResourceAttribute; +import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; +import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.result.OperationResultStatus; +import com.evolveum.midpoint.schema.statistics.StatisticsUtil; +import com.evolveum.midpoint.schema.util.*; +import com.evolveum.midpoint.security.api.Authorization; +import com.evolveum.midpoint.security.api.AuthorizationConstants; +import com.evolveum.midpoint.security.api.MidPointPrincipal; +import com.evolveum.midpoint.security.api.SecurityContextManager; +import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters; +import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints; +import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.task.api.TaskDebugUtil; +import com.evolveum.midpoint.task.api.TaskExecutionStatus; +import com.evolveum.midpoint.test.*; +import com.evolveum.midpoint.test.asserter.*; +import com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter; +import com.evolveum.midpoint.test.util.MidPointAsserts; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.*; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ImportOptionsType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType; +import com.evolveum.prism.xml.ns._public.types_3.*; + +/** + * Abstract framework for an integration test that is placed on top of a model API. + * This provides complete environment that the test should need, e.g model service instance, repository, provisioning, + * dummy auditing, etc. It also implements lots of useful methods to make writing the tests easier. + * + * @author Radovan Semancik + */ +public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTest { + + protected static final int DEFAULT_TASK_WAIT_TIMEOUT = 25000; + protected static final long DEFAULT_TASK_SLEEP_TIME = 200; + + protected static final String CONNECTOR_DUMMY_TYPE = "com.evolveum.icf.dummy.connector.DummyConnector"; + protected static final String CONNECTOR_DUMMY_VERSION = "2.0"; + protected static final String CONNECTOR_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; + + protected static final String CONNECTOR_LDAP_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; + protected static final String CONNECTOR_LDAP_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector"; + + protected static final String CONNECTOR_AD_TYPE = "Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; + protected static final String CONNECTOR_AD_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/ActiveDirectory.Connector/Org.IdentityConnectors.ActiveDirectory.ActiveDirectoryConnector"; + + protected static final ItemPath ACTIVATION_ADMINISTRATIVE_STATUS_PATH = SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; + protected static final ItemPath ACTIVATION_VALID_FROM_PATH = SchemaConstants.PATH_ACTIVATION_VALID_FROM; + protected static final ItemPath ACTIVATION_VALID_TO_PATH = SchemaConstants.PATH_ACTIVATION_VALID_TO; + protected static final ItemPath PASSWORD_VALUE_PATH = SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; + + private static final String DEFAULT_CHANNEL = SchemaConstants.CHANNEL_GUI_USER_URI; + + protected static final String LOG_PREFIX_FAIL = "SSSSS=X "; + protected static final String LOG_PREFIX_ATTEMPT = "SSSSS=> "; + protected static final String LOG_PREFIX_DENY = "SSSSS=- "; + protected static final String LOG_PREFIX_ALLOW = "SSSSS=+ "; + + @Autowired protected ModelService modelService; + @Autowired protected ModelInteractionService modelInteractionService; + @Autowired protected ModelDiagnosticService modelDiagnosticService; + @Autowired protected DashboardService dashboardService; + @Autowired protected ModelAuditService modelAuditService; + @Autowired protected ModelPortType modelWeb; + @Autowired + @Qualifier("cacheRepositoryService") + protected RepositoryService repositoryService; + @Autowired + @Qualifier("sqlRepositoryServiceImpl") + protected RepositoryService plainRepositoryService; + + @Autowired protected SystemObjectCache systemObjectCache; + @Autowired protected RelationRegistry relationRegistry; + @Autowired protected ProvisioningService provisioningService; + @Autowired protected HookRegistry hookRegistry; + @Autowired protected Clock clock; + @Autowired protected SchemaHelper schemaHelper; + @Autowired protected DummyTransport dummyTransport; + @Autowired protected SecurityEnforcer securityEnforcer; + @Autowired protected SecurityContextManager securityContextManager; + @Autowired protected MidpointFunctions libraryMidpointFunctions; + @Autowired protected ValuePolicyProcessor valuePolicyProcessor; + + @Autowired(required = false) + @Qualifier("modelObjectResolver") + protected ObjectResolver modelObjectResolver; + + @Autowired(required = false) + protected NotificationManager notificationManager; + + @Autowired(required = false) + protected GuiProfiledPrincipalManager focusProfileService; + + protected DummyResourceCollection dummyResourceCollection; + + protected DummyAuditService dummyAuditService; + + protected boolean verbose = false; + + public AbstractModelIntegrationTest() { + dummyAuditService = DummyAuditService.getInstance(); + } + + @Override + public void initSystem(Task initTask, OperationResult initResult) throws Exception { + logger.trace("initSystem"); + dummyResourceCollection = new DummyResourceCollection(modelService); + startResources(); + InternalsConfig.reset(); + InternalsConfig.setAvoidLoggingChange(isAvoidLoggingChange()); + // Make sure the checks are turned on + InternalsConfig.turnOnAllChecks(); + // By default, notifications are turned off because of performance implications. Individual tests turn them on for themselves. + if (notificationManager != null) { + notificationManager.setDisabled(true); + } + } + + @Override + public void postInitSystem(Task initTask, OperationResult initResult) throws Exception { + if (dummyResourceCollection != null) { + dummyResourceCollection.resetResources(); + } + } + + protected boolean isAvoidLoggingChange() { + return true; + } + + protected void startResources() throws Exception { + // Nothing to do by default + } + + @AfterClass + protected void cleanUpSecurity() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + securityContext.setAuthentication(null); + } + + @BeforeMethod + protected void prepareBeforeTestMethod() { + dummyAuditService.clear(); + } + + protected void initDummyResource(String name, DummyResourceContoller controller) { + dummyResourceCollection.initDummyResource(name, controller); + } + + protected DummyResourceContoller initDummyResource(String name, File resourceFile, String resourceOid, + 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 { + return dummyResourceCollection.initDummyResource(name, resourceFile, resourceOid, null, task, result); + } + + protected DummyResourceContoller initDummyResourcePirate(String name, File resourceFile, String resourceOid, + 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 { + return initDummyResource(name, resourceFile, resourceOid, controller -> controller.extendSchemaAd(), task, result); + } + + protected DummyResourceContoller getDummyResourceController(String name) { + return dummyResourceCollection.get(name); + } + + protected DummyResourceContoller getDummyResourceController() { + return getDummyResourceController(null); + } + + protected DummyAccountAsserter assertDummyAccountByUsername(String dummyResourceName, String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertAccountByUsername(username); + } + + protected DummyGroupAsserter assertDummyGroupByName(String dummyResourceName, String name) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertGroupByName(name); + } + + protected DummyResource getDummyResource(String name) { + return dummyResourceCollection.getDummyResource(name); + } + + protected DummyResource getDummyResource() { + return getDummyResource(null); + } + + protected PrismObject getDummyResourceObject(String name) { + return dummyResourceCollection.getResourceObject(name); + } + + protected PrismObject getDummyResourceObject() { + return getDummyResourceObject(null); + } + + protected ResourceType getDummyResourceType(String name) { + return dummyResourceCollection.getResourceType(name); + } + + protected ResourceType getDummyResourceType() { + return getDummyResourceType(null); + } + + protected void importObjectFromFile(String filename) throws FileNotFoundException { + importObjectFromFile(new File(filename)); + } + + protected void importObjectFromFile(File file) throws FileNotFoundException { + OperationResult result = new OperationResult(contextName() + ".importObjectFromFile"); + importObjectFromFile(file, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void importObjectFromFile(String filename, OperationResult result) throws FileNotFoundException { + importObjectFromFile(new File(filename), result); + } + + protected void importObjectFromFile(File file, OperationResult result) throws FileNotFoundException { + OperationResult subResult = result.createSubresult(contextName() + ".importObjectFromFile"); + subResult.addParam("filename", file.getPath()); + logger.trace("importObjectFromFile: {}", file); + Task task = createPlainTask("importObjectFromFile"); + importObjectFromFile(file, task, result); + subResult.computeStatus(); + if (subResult.isError()) { + logger.error("Import of file " + file + " failed:\n{}", subResult.debugDump()); + Throwable cause = findCause(subResult); + throw new SystemException("Import of file " + file + " failed: " + subResult.getMessage(), cause); + } + } + + protected void importObjectFromFile(File file, Task task, OperationResult result) throws FileNotFoundException { + importObjectFromFile(file, MiscSchemaUtil.getDefaultImportOptions(), task, result); + } + + protected void importObjectFromFile(File file, ImportOptionsType options, Task task, OperationResult result) throws FileNotFoundException { + FileInputStream stream = new FileInputStream(file); + modelService.importObjectsFromStream(stream, PrismContext.LANG_XML, options, task, result); + } + + protected void importObjectsFromFileNotRaw(File file, Task task, OperationResult result) throws FileNotFoundException { + ImportOptionsType options = MiscSchemaUtil.getDefaultImportOptions(); + ModelExecuteOptionsType modelOptions = new ModelExecuteOptionsType(); + modelOptions.setRaw(false); + options.setModelExecutionOptions(modelOptions); + importObjectFromFile(file, options, task, result); + } + + protected Throwable findCause(OperationResult result) { + if (result.getCause() != null) { + return result.getCause(); + } + for (OperationResult sub : result.getSubresults()) { + Throwable cause = findCause(sub); + if (cause != null) { + return cause; + } + } + return null; + } + + protected PrismObject importAndGetObjectFromFile(Class type, String filename, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return importAndGetObjectFromFile(type, new File(filename), oid, task, result); + } + + protected PrismObject importAndGetObjectFromFile(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + importObjectFromFile(file, result); + OperationResult importResult = result.getLastSubresult(); + TestUtil.assertSuccess("Import of " + file + " has failed", importResult); + return modelService.getObject(type, oid, null, task, result); + } + + protected PrismObject importAndGetObjectFromFileIgnoreWarnings(Class type, File file, String oid, Task task, OperationResult result) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + importObjectFromFile(file, result); + OperationResult importResult = result.getLastSubresult(); + OperationResultStatus status = importResult.getStatus(); + if (status == OperationResultStatus.FATAL_ERROR || status == OperationResultStatus.PARTIAL_ERROR) { + fail("Import of " + file + " has failed: " + importResult.getMessage()); + } + return modelService.getObject(type, oid, null, task, result); + } + + /** + * This is not the real thing. It is just for the tests. + */ + protected void applyResourceSchema(ShadowType accountType, ResourceType resourceType) throws SchemaException { + IntegrationTestTools.applyResourceSchema(accountType, resourceType, prismContext); + } + + protected void assertUsers(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(UserType.class, expectedNumberOfUsers); + } + + protected void assertRoles(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(RoleType.class, expectedNumberOfUsers); + } + + protected void assertServices(int expectedNumberOfUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(ServiceType.class, expectedNumberOfUsers); + } + + protected void assertObjects(Class type, int expectedNumberOfUsers) throws SchemaException, + ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertObjects(type, null, expectedNumberOfUsers); + } + + protected void assertObjects(Class type, ObjectQuery query, int expectedNumberOfUsers) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + assertEquals("Unexpected number of " + type.getSimpleName() + "s", expectedNumberOfUsers, getObjectCount(type, query)); + } + + protected int getObjectCount(Class type) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getObjectCount(type, null); + } + + protected int getObjectCount(Class type, ObjectQuery query) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getObjectCount"); + OperationResult result = task.getResult(); + List> users = modelService.searchObjects(type, query, null, task, result); + if (verbose) { display(type.getSimpleName() + "s", users); } + return users.size(); + } + + protected void searchObjectsIterative(Class type, + ObjectQuery query, Consumer> handler, Integer expectedNumberOfObjects) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("searchObjectsIterative"); + OperationResult result = task.getResult(); + final MutableInt count = new MutableInt(0); + // Cannot convert to lambda here. Java does not want to understand the generic types properly. + SearchResultMetadata searchMetadata = modelService.searchObjectsIterative(type, query, (object, oresult) -> { + count.increment(); + if (handler != null) { + handler.accept(object); + } + return true; + }, null, task, result); + if (verbose) { display(type.getSimpleName() + "s", count.getValue()); } + assertEquals("Unexpected number of " + type.getSimpleName() + "s", expectedNumberOfObjects, count.getValue()); + } + + protected void assertUserProperty(String userOid, QName propertyName, Object... expectedPropValues) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("getObject"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertUserProperty(user, propertyName, expectedPropValues); + } + + protected void assertUserNoProperty(String userOid, QName propertyName) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("getObject"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertUserNoProperty(user, propertyName); + } + + protected void assertUserProperty(PrismObject user, QName propertyName, Object... expectedPropValues) { + PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); + assert property != null : "No property " + propertyName + " in " + user; + PrismAsserts.assertPropertyValue(property, expectedPropValues); + } + + protected void assertUserNoProperty(PrismObject user, QName propertyName) { + PrismProperty property = user.findProperty(ItemName.fromQName(propertyName)); + assert property == null : "Property " + propertyName + " present in " + user + ": " + property; + } + + protected void assertAdministrativeStatusEnabled(PrismObject user) { + assertAdministrativeStatus(user, ActivationStatusType.ENABLED); + } + + protected void assertAdministrativeStatusDisabled(PrismObject user) { + assertAdministrativeStatus(user, ActivationStatusType.DISABLED); + } + + protected void assertAdministrativeStatus(PrismObject object, ActivationStatusType expected) { + PrismProperty statusProperty = object.findProperty(ACTIVATION_ADMINISTRATIVE_STATUS_PATH); + if (expected == null && statusProperty == null) { + return; + } + assert statusProperty != null : "No status property in " + object; + ActivationStatusType status = statusProperty.getRealValue(); + if (expected == null && status == null) { + return; + } + assert status != null : "No status property is null in " + object; + assert status == expected : "status property is " + status + ", expected " + expected + " in " + object; + } + + protected void assertEffectiveStatus(PrismObject focus, ActivationStatusType expected) { + ActivationType activation = focus.asObjectable().getActivation(); + assertNotNull("No activation in " + focus, activation); + assertEquals("Unexpected effective activation status in " + focus, expected, activation.getEffectiveStatus()); + } + + protected void modifyUserReplace(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserReplace(userOid, propertyPath, null, task, result, newRealValue); + } + + protected void modifyUserReplace(String userOid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserReplaceDelta(userOid, propertyPath, newRealValue); + executeChanges(objectDelta, options, task, result); + } + + protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyObjectReplaceProperty(type, oid, propertyPath, null, task, result, newRealValue); + } + + protected void modifyObjectReplaceProperty(Class type, String oid, ItemPath propertyPath, ModelExecuteOptions options, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, options, task, result); + } + + protected void modifyObjectDeleteProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationDeleteProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectAddProperty(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationAddProperty(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectReplaceContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectAddContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectDeleteContainer(Class type, String oid, ItemPath propertyPath, Task task, OperationResult result, C... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(type, oid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyObjectReplaceReference(Class type, String oid, ItemPath refPath, Task task, OperationResult result, PrismReferenceValue... refVals) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = prismContext.deltaFactory().object() + .createModificationReplaceReference(type, oid, refPath, refVals); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyUserAdd(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserAddDelta(userOid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyUserDelete(String userOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta objectDelta = createModifyUserDeleteDelta(userOid, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void modifyAccountShadowReplace(String accountOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, + ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + PrismObject shadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); + String resourceOid = shadow.asObjectable().getResourceRef().getOid(); + PrismObject resource = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result); + ObjectDelta objectDelta = createModifyAccountShadowReplaceDelta(accountOid, resource, propertyPath, newRealValue); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected ObjectDelta createOldNewPasswordDelta(String oid, String oldPassword, String newPassword) throws SchemaException { + ProtectedStringType oldPasswordPs = new ProtectedStringType(); + oldPasswordPs.setClearValue(oldPassword); + + ProtectedStringType newPasswordPs = new ProtectedStringType(); + newPasswordPs.setClearValue(newPassword); + + return deltaFor(UserType.class) + .item(PASSWORD_VALUE_PATH) + .oldRealValue(oldPasswordPs) + .replace(newPasswordPs) + .asObjectDelta(oid); + } + + protected void modifyUserChangePassword(String userOid, String newPassword) throws CommonException { + Task task = createPlainTask("modifyUserChangePassword"); + OperationResult result = task.getResult(); + modifyUserChangePassword(userOid, newPassword, task, result); + assertSuccess(result); + } + + protected void modifyUserChangePassword(String userOid, String newPassword, Task task, OperationResult result) throws CommonException { + modifyFocusChangePassword(UserType.class, userOid, newPassword, task, result); + } + + protected void modifyFocusChangePassword(Class type, String oid, String newPassword, Task task, OperationResult result) throws CommonException { + ProtectedStringType passwordPs = new ProtectedStringType(); + passwordPs.setClearValue(newPassword); + modifyObjectReplaceProperty(type, oid, PASSWORD_VALUE_PATH, task, result, passwordPs); + } + + protected void modifyUserSetPassword(String userOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ProtectedStringType userPasswordPs = new ProtectedStringType(); + userPasswordPs.setClearValue(newPassword); + PasswordType passwordType = new PasswordType(); + passwordType.setValue(userPasswordPs); + ObjectDelta delta = prismContext.deltaFor(UserType.class) + .item(SchemaConstants.PATH_PASSWORD).add(passwordType) + .asObjectDelta(userOid); + executeChanges(delta, null, task, result); + } + + protected void modifyAccountChangePassword(String accountOid, String newPassword, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ProtectedStringType userPasswordPs = new ProtectedStringType(); + userPasswordPs.setClearValue(newPassword); + modifyAccountShadowReplace(accountOid, PASSWORD_VALUE_PATH, task, result, userPasswordPs); + } + + protected void clearUserPassword(String userOid) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException { + Task task = createPlainTask("clearUserPassword"); + OperationResult result = task.getResult(); + List> itemDeltas = prismContext.deltaFor(UserType.class) + .item(SchemaConstants.PATH_PASSWORD).replace() + .asItemDeltas(); + repositoryService.modifyObject(UserType.class, userOid, itemDeltas, result); + assertSuccess(result); + } + + protected void renameObject(Class type, String oid, String newName, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyObjectReplaceProperty(type, oid, ObjectType.F_NAME, task, result, createPolyString(newName)); + } + + protected void recomputeUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createPlainTask("recomputeUser"); + OperationResult result = task.getResult(); + modelService.recompute(UserType.class, userOid, null, task, result); + assertSuccess(result); + } + + protected void recomputeUser(String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(UserType.class, userOid, null, task, result); + } + + protected void recomputeFocus(Class clazz, String userOid, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(clazz, userOid, null, task, result); + } + + protected void recomputeUser(String userOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { + modelService.recompute(UserType.class, userOid, options, task, result); + } + + protected void assignRole(String userOid, String roleOid) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("assignRole"); + OperationResult result = task.getResult(); + assignRole(userOid, roleOid, task, result); + assertSuccess(result); + } + + protected void assignRole(String userOid, String roleOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignRole(UserType.class, userOid, roleOid, null, task, result); + } + + protected void assignService(String userOid, String targetOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignService(UserType.class, userOid, targetOid, 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 { + assignRole(UserType.class, userOid, roleOid, 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 { + assignRole(focusClass, focusOid, roleOid, null, task, result); + } + + protected void assignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void unassignRole(String userOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); + } + + protected void unassignRole(Class focusClass, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignRole(focusClass, focusOid, roleOid, 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 { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); + } + + protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void assignService(Class focusClass, String focusOid, String targetOid, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, ServiceType.COMPLEX_TYPE, null, task, null, activationType, true, result); + } + + protected void assignRole(Class focusClass, String focusOid, String roleOid, ActivationType activationType, Task task, ModelExecuteOptions options, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result); + } + + protected void assignFocus(Class focusClass, String focusOid, QName targetType, String targetOid, QName relation, ActivationType activationType, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, targetOid, targetType, relation, task, null, activationType, true, result); + } + + protected void assignRole(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, true, result); + } + + protected void assignRole(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, true, options, result); + } + + protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("assignRole"); + OperationResult result = task.getResult(); + assignRole(userOid, roleOid, relation, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, true, result); + } + + protected void unassignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("unassignRole"); + OperationResult result = task.getResult(); + unassignRole(userOid, roleOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void unassignRoleByAssignmentValue(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + AssignmentType assignment = findAssignmentByTargetRequired(focus, roleOid); + ObjectDelta delta = prismContext.deltaFor(focus.getCompileTimeClass()) + .item(FocusType.F_ASSIGNMENT) + .delete(assignment.clone()) + .asObjectDeltaCast(focus.getOid()); + modelService.executeChanges(singleton(delta), null, task, result); + } + + protected void unassignRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); + } + + protected void unassignService(String userOid, String serviceOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, serviceOid, ServiceType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); + } + + protected void unassignRole(String userOid, String roleOid, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, options, result); + } + + protected void assignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, true, result); + } + + protected void assignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, true, options, result); + } + + protected void unassignRole(String userOid, String roleOid, PrismContainer extension, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, false, result); + } + + protected void unassignRole(String userOid, String roleOid, PrismContainer extension, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(UserType.class, userOid, roleOid, RoleType.COMPLEX_TYPE, null, task, extension, null, false, options, result); + } + + 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); + } + + 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); + } + + protected void unassignRole(String userOid, String roleOid, QName relation, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, RoleType.COMPLEX_TYPE, relation, task, modificationBlock, false, result); + } + + protected void unassignAllRoles(String userOid) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignAllRoles(userOid, false); + } + + protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("unassignAllRoles"); + OperationResult result = task.getResult(); + PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignment : user.asObjectable().getAssignment()) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null) { + if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container() + .createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + cval.setId(assignment.getId()); + assignmentDelta.addValueToDelete(cval); + modifications.add(assignmentDelta); + } + } + } + if (modifications.isEmpty()) { + return; + } + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(userOid, modifications, UserType.class); + Collection> deltas = MiscSchemaUtil.createCollection(userDelta); + modelService.executeChanges(deltas, useRawPlusRecompute ? ModelExecuteOptions.createRaw() : null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + + if (useRawPlusRecompute) { + recomputeUser(userOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + } + + protected void assignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer) null, true, result); + } + + protected void unassignArchetype(String userOid, String archetypeOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, archetypeOid, ArchetypeType.COMPLEX_TYPE, null, task, (Consumer) null, false, result); + } + + protected void induceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + induceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); + } + + protected void induceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, true, null, result); + } + + protected void induceOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, orgOid, OrgType.COMPLEX_TYPE, null, task, null, true, null, result); + } + + protected void uninduceRole(Class focusType, String focusOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, AbstractRoleType.F_INDUCEMENT, roleOid, RoleType.COMPLEX_TYPE, null, task, null, false, null, result); + } + + protected void uninduceRole(String focusRoleOid, String targetRoleOid, Task task, OperationResult result) throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + uninduceRole(RoleType.class, focusRoleOid, targetRoleOid, task, result); + } + + protected void assignOrg(String userOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignOrg(userOid, orgOid, null, task, result); + } + + protected void assignOrg(Class focusType, String focusOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + assignOrg(focusType, focusOid, orgOid, null, task, result); + } + + protected void assignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + assignOrg(userOid, orgOid, prismContext.getDefaultRelation()); + } + + protected void assignOrg(String userOid, String orgOid, QName relation) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("assignOrg"); + OperationResult result = task.getResult(); + assignOrg(userOid, orgOid, relation, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, true, result); + } + + protected void assignOrg(Class focusType, String focusOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(focusType, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, true, result); + } + + protected void unassignOrg(String userOid, String orgOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignOrg(userOid, orgOid, prismContext.getDefaultRelation()); + } + + protected void unassignOrg(String userOid, String orgOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + unassignOrg(userOid, orgOid, null, task, result); + } + + protected void unassignOrg(String userOid, String orgOid, QName relation) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("unassignOrg"); + OperationResult result = task.getResult(); + unassignOrg(userOid, orgOid, relation, task, result); + assertSuccess(result); + } + + protected void unassignOrg(String userOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, false, result); + } + + protected void unassignOrg(Class type, String focusOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignOrg(type, focusOid, orgOid, null, task, result); + } + + protected void unassignOrg(Class type, String focusOid, String orgOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyFocusAssignment(type, focusOid, orgOid, OrgType.COMPLEX_TYPE, relation, task, (Consumer) null, false, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + 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) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userOid, roleOid, refType, relation, task, extension, activationType, add, null, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, ModelExecuteOptions options, + OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentUserDelta(userOid, roleOid, refType, relation, extension, activationType, add); + executeChanges(userDelta, options, task, result); + } + + protected void modifyAssignmentHolderAssignment(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, Task task, + PrismContainer extension, ActivationType activationType, boolean add, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + modifyAssignmentHolderAssignment(focusClass, focusOid, roleOid, refType, relation, task, extension, activationType, add, null, result); + } + + 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) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta delta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleOid, refType, relation, extension, activationType, add); + executeChanges(delta, options, task, result); + } + + protected void modifyUserAssignment(String userOid, String roleOid, QName refType, QName relation, Task task, + 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) + 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) + 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) + 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) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta focusDelta = createAssignmentFocusDelta(focusClass, focusOid, elementName, roleOid, refType, relation, modificationBlock, add); + executeChanges(focusDelta, options, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, null, null, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + deleteFocusAssignmentEmptyDelta(existingFocus, targetOid, relation, null, task, result); + } + + protected void deleteFocusAssignmentEmptyDelta(PrismObject existingFocus, String targetOid, QName relation, + 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); + } + + protected void unassign(Class focusClass, String focusOid, String roleId, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + ObjectDelta focusDelta = createAssignmentAssignmentHolderDelta(focusClass, focusOid, roleId, null, null, null, null, false); + executeChanges(focusDelta, null, task, result); + } + + protected void unassign(Class focusClass, String focusOid, long assignmentId, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassign(focusClass, focusOid, assignmentId, null, task, result); + } + + protected void unassign(Class focusClass, String focusOid, long assignmentId, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassign(focusClass, focusOid, createAssignmentIdOnly(assignmentId), options, task, result); + } + + protected void unassign(Class focusClass, String focusOid, AssignmentType currentAssignment, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + Collection> modifications = new ArrayList<>(); + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + assignmentDelta.addValuesToDelete(currentAssignment.asPrismContainerValue().clone()); + modifications.add(assignmentDelta); + ObjectDelta focusDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass + ); + executeChanges(focusDelta, options, task, result); + } + + protected void unlink(Class focusClass, String focusOid, String targetOid, Task task, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object() + .createModificationDeleteReference(focusClass, focusOid, FocusType.F_LINK_REF, + targetOid); + executeChanges(delta, null, task, result); + } + + protected void unlinkUser(String userOid, String targetOid) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("unlinkUser"); + OperationResult result = task.getResult(); + unlink(UserType.class, userOid, targetOid, task, result); + assertSuccess(result); + } + + /** + * Executes unassign delta by removing each assignment individually by id. + */ + protected void unassignAll(PrismObject focusBefore, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + executeChanges(createUnassignAllDelta(focusBefore), null, task, result); + } + + /** + * Creates unassign delta by removing each assignment individually by id. + */ + protected ObjectDelta createUnassignAllDelta(PrismObject focusBefore) throws SchemaException { + Collection> modifications = new ArrayList<>(); + for (AssignmentType assignmentType : focusBefore.asObjectable().getAssignment()) { + modifications.add((createAssignmentModification(assignmentType.getId(), false))); + } + return prismContext.deltaFactory().object() + .createModifyDelta(focusBefore.getOid(), modifications, focusBefore.getCompileTimeClass() + ); + } + + /** + * Executes assignment replace delta with empty values. + */ + protected void unassignAllReplace(String userOid, Task task, OperationResult result) + throws ObjectNotFoundException, + SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, + PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = + prismContext.deltaFactory().object().createModificationReplaceContainer( + UserType.class, userOid, 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 { + 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 { + try { + return createAssignmentModification(type, elementName, roleOid, refType, relation, + assignment -> { + if (extension != null) { + try { + assignment.asPrismContainerValue().add(extension.clone()); + } catch (SchemaException e) { + throw new TunnelException(e); + } + } + assignment.setActivation(activationType); + }, add); + } catch (TunnelException te) { + throw (SchemaException) te.getCause(); + } + } + + protected ContainerDelta createAssignmentModification(Class type, QName elementName, String roleOid, QName refType, QName relation, + Consumer modificationBlock, boolean add) throws SchemaException { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(ItemName.fromQName(elementName), getObjectDefinition(type)); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + if (add) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); + targetRef.getValue().setOid(roleOid); + targetRef.getValue().setTargetType(refType); + targetRef.getValue().setRelation(relation); + if (modificationBlock != null) { + modificationBlock.accept(cval.asContainerable()); + } + return assignmentDelta; + } + + protected ContainerDelta createAssignmentModification(long id, boolean add) { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + cval.setId(id); + if (add) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + return assignmentDelta; + } + + protected ContainerDelta createAssignmentEmptyDeleteModification( + PrismObject existingFocus, String roleOid, QName relation) { + AssignmentType existingAssignment = findAssignment(existingFocus, roleOid, relation); + return createAssignmentModification(existingAssignment.getId(), false); + } + + protected AssignmentType findAssignment( + PrismObject existingFocus, String targetOid, QName relation) { + for (AssignmentType assignmentType : existingFocus.asObjectable().getAssignment()) { + if (assignmentMatches(assignmentType, targetOid, relation)) { + return assignmentType; + } + } + return null; + } + + protected boolean assignmentMatches(AssignmentType assignmentType, String targetOid, QName relation) { + ObjectReferenceType targetRef = assignmentType.getTargetRef(); + if (targetRef == null) { + return false; + } + return referenceMatches(targetRef, targetOid, relation); + } + + private boolean referenceMatches(ObjectReferenceType ref, String targetOid, QName relation) { + if (targetOid != null && !targetOid.equals(ref.getOid())) { + return false; + } + if (relation != null && !QNameUtil.match(relation, ref.getRelation())) { + return false; + } + return true; + } + + protected ObjectDelta createAssignmentUserDelta( + String userOid, String roleOid, QName refType, QName relation, + 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() + .createModifyDelta(userOid, modifications, UserType.class); + return userDelta; + } + + protected ObjectDelta createAssignmentAssignmentHolderDelta(Class focusClass, String focusOid, String roleOid, QName refType, QName relation, + 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 { + 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 { + 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 { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentModification(focusClass, elementName, roleOid, refType, relation, modificationBlock, add))); + return prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, focusClass); + } + + protected ObjectDelta createAssignmentFocusEmptyDeleteDelta(PrismObject existingFocus, String roleOid, QName relation) throws SchemaException { + Collection> modifications = new ArrayList<>(); + modifications.add((createAssignmentEmptyDeleteModification(existingFocus, roleOid, relation))); + return prismContext.deltaFactory().object().createModifyDelta( + existingFocus.getOid(), modifications, existingFocus.getCompileTimeClass()); + } + + protected ContainerDelta createAccountAssignmentModification( + String resourceOid, String intent, boolean add) throws SchemaException { + return createAssignmentModification(resourceOid, ShadowKindType.ACCOUNT, intent, add); + } + + protected PropertyDelta createUserPropertyReplaceModification(QName propertyName, V... values) { + return prismContext.deltaFactory().property().createReplaceDelta(getUserDefinition(), propertyName, values); + } + + protected ContainerDelta createAssignmentModification(String resourceOid, ShadowKindType kind, + String intent, boolean add) throws SchemaException { + AssignmentType assignmentType = createConstructionAssignment(resourceOid, kind, intent); + return createAssignmentModification(assignmentType, add); + } + + protected ContainerDelta createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + + if (add) { + assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); + } else { + assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); + } + + PrismContainerDefinition assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); + assignmentDelta.applyDefinition(assignmentDef); + + return assignmentDelta; + } + + protected AssignmentType createAccountAssignment(String resourceOid, String intent) { + return createConstructionAssignment(resourceOid, ShadowKindType.ACCOUNT, intent); + } + + protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { + AssignmentType assignmentType = new AssignmentType(); + ConstructionType constructionType = new ConstructionType(); + constructionType.setKind(kind); + assignmentType.setConstruction(constructionType); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + resourceRef.setType(ResourceType.COMPLEX_TYPE); + constructionType.setResourceRef(resourceRef); + constructionType.setIntent(intent); + return assignmentType; + } + + protected AssignmentType createTargetAssignment(String targetOid, QName targetType) { + return FocusTypeUtil.createTargetAssignment(targetOid, targetType); + } + + protected ObjectDelta createParametricAssignmentDelta( + String userOid, String roleOid, String orgOid, String tenantOid, boolean adding) + throws SchemaException { + Collection> modifications = new ArrayList<>(); + + ContainerDelta assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); + PrismContainerValue cval = prismContext.itemFactory().createContainerValue(); + if (adding) { + assignmentDelta.addValueToAdd(cval); + } else { + assignmentDelta.addValueToDelete(cval); + } + PrismReference targetRef = cval.findOrCreateReference(AssignmentType.F_TARGET_REF); + targetRef.getValue().setOid(roleOid); + targetRef.getValue().setTargetType(RoleType.COMPLEX_TYPE); + + 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); + } + + modifications.add(assignmentDelta); + return prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class + ); + } + + protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); + } + + protected void assignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> deltas = MiscSchemaUtil.createCollection( + createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, true)); + modelService.executeChanges(deltas, options, task, result); + } + + protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignParametricRole(userOid, roleOid, orgOid, tenantOid, null, task, result); + } + + protected void unassignParametricRole(String userOid, String roleOid, String orgOid, String tenantOid, ModelExecuteOptions options, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> deltas = MiscSchemaUtil.createCollection( + createParametricAssignmentDelta(userOid, roleOid, orgOid, tenantOid, false)); + modelService.executeChanges(deltas, options, task, result); + } + + protected void assertAssignees(String targetOid, int expectedAssignees) throws SchemaException { + assertAssignees(targetOid, prismContext.getDefaultRelation(), expectedAssignees); + } + + protected void assertAssignees(String targetOid, QName relation, int expectedAssignees) throws SchemaException { + OperationResult result = new OperationResult(contextName() + ".assertAssignees"); + int count = countAssignees(targetOid, relation, result); + if (count != expectedAssignees) { + SearchResultList> assignees = listAssignees(targetOid, result); + AssertJUnit.fail("Unexpected number of assignees of " + targetOid + " as '" + relation + "', expected " + expectedAssignees + ", but was " + count + ": " + assignees); + } + + } + + protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { + PrismReferenceValue refVal = itemFactory().createReferenceValue(); + refVal.setOid(targetOid); + refVal.setRelation(relation); + ObjectQuery query = prismContext.queryFor(FocusType.class) + .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(refVal) + .build(); + return repositoryService.countObjects(FocusType.class, query, null, result); + } + + protected SearchResultList> listAssignees(String targetOid, OperationResult result) throws SchemaException { + ObjectQuery query = prismContext.queryFor(FocusType.class) + .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(targetOid) + .build(); + return repositoryService.searchObjects(FocusType.class, query, null, result); + } + + protected ConstructionType createAccountConstruction(String resourceOid, String intent) { + ConstructionType accountConstructionType = new ConstructionType(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + accountConstructionType.setResourceRef(resourceRef); + accountConstructionType.setIntent(intent); + return accountConstructionType; + } + + protected ObjectDelta createReplaceAccountConstructionUserDelta( + String userOid, Long id, ConstructionType newValue) { + PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION); + ContainerDelta acDelta = prismContext.deltaFactory().container().create( + ItemPath.create(UserType.F_ASSIGNMENT, id, AssignmentType.F_CONSTRUCTION), pcd); + acDelta.setValueToReplace(newValue.asPrismContainerValue()); + + Collection> modifications = new ArrayList<>(); + modifications.add(acDelta); + ObjectDelta userDelta = prismContext.deltaFactory().object() + .createModifyDelta(userOid, modifications, UserType.class); + return userDelta; + } + + protected ObjectDelta createAccountAssignmentUserDelta(String focusOid, String resourceOid, String intent, boolean add) throws SchemaException { + return createAssignmentDelta(UserType.class, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, add); + } + + protected ObjectDelta createAssignmentDelta(Class type, String focusOid, + 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 + ); + return userDelta; + } + + protected Collection> executeChanges( + ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + display("Executing delta", objectDelta); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + return modelService.executeChanges(deltas, options, task, result); + } + + protected Collection> executeChanges( + Collection> deltas, + ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + display("Executing deltas", deltas); + return modelService.executeChanges(deltas, options, task, result); + } + + protected Collection> executeChangesAssertSuccess( + ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Collection> rv = executeChanges(objectDelta, options, task, result); + assertSuccess(result); + return rv; + } + + protected ModelContext previewChanges(ObjectDelta objectDelta, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + display("Preview changes for delta", objectDelta); + Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); + return modelInteractionService.previewChanges(deltas, options, task, result); + } + + protected void assignAccountToUser( + String focusOid, String resourceOid, String intent) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + assignAccount(UserType.class, focusOid, resourceOid, intent); + } + + protected void assignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("assignAccount"); + OperationResult result = task.getResult(); + assignAccount(type, focusOid, resourceOid, intent, task, result); + assertSuccess(result); + } + + protected void assignAccountToUser( + String focusOid, String resourceOid, String intent, Task task, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + assignAccount(UserType.class, focusOid, resourceOid, intent, task, result); + } + + protected void assignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, true); + executeChanges(userDelta, null, task, result); + } + + protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignAccount(UserType.class, focusOid, resourceOid, intent); + } + + protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("unassignAccount"); + OperationResult result = task.getResult(); + unassignAccount(type, focusOid, resourceOid, intent, task, result); + assertSuccess(result); + } + + protected void unassignAccountFromUser(String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + unassignAccount(UserType.class, focusOid, resourceOid, intent, task, result); + } + + protected void unassignAccount(Class type, String focusOid, String resourceOid, String intent, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createAssignmentDelta(type, focusOid, resourceOid, ShadowKindType.ACCOUNT, intent, false); + Collection> deltas = MiscSchemaUtil.createCollection(userDelta); + modelService.executeChanges(deltas, null, task, result); + } + + protected void assignPolicyRule(Class type, String focusOid, PolicyRuleType policyRule, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + AssignmentType assignmentType = new AssignmentType(); + assignmentType.setPolicyRule(policyRule); + assign(type, focusOid, assignmentType, task, result); + } + + protected void assign(Class type, String focusOid, AssignmentType assignmentType, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Collection> modifications = new ArrayList<>(); + modifications.add(createAssignmentModification(assignmentType, true)); + ObjectDelta userDelta = prismContext.deltaFactory().object().createModifyDelta(focusOid, modifications, type + ); + executeChanges(userDelta, null, task, result); + } + + protected PrismObject getUser(String userOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getUser"); + OperationResult result = task.getResult(); + PrismObject user = modelService.getObject(UserType.class, userOid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(User) result not success", result); + return user; + } + + protected PrismObject getUserFromRepo(String userOid) throws ObjectNotFoundException, SchemaException { + return repositoryService.getObject(UserType.class, userOid, null, new OperationResult("dummy")); + } + + protected PrismObject findObjectByName(Class type, String name) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("findObjectByName"); + OperationResult result = task.getResult(); + List> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result); + if (objects.isEmpty()) { + return null; + } + assert objects.size() == 1 : "Too many objects found for name " + name + ": " + objects; + return objects.iterator().next(); + } + + protected ObjectQuery createNameQuery(String name) throws SchemaException { + return ObjectQueryUtil.createNameQuery(PrismTestUtil.createPolyString(name), prismContext); + } + + protected PrismObject findUserByUsername(String username) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return findObjectByName(UserType.class, username); + } + + protected PrismObject findServiceByName(String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return findObjectByName(ServiceType.class, name); + } + + protected RoleType getRoleSimple(String oid) { + try { + return getRole(oid).asObjectable(); + } catch (CommonException e) { + throw new SystemException("Unexpected exception while getting role " + oid + ": " + e.getMessage(), e); + } + } + + protected PrismObject getRole(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getRole"); + OperationResult result = task.getResult(); + PrismObject role = modelService.getObject(RoleType.class, oid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Role) result not success", result); + return role; + } + + protected PrismObject findAccountByUsername(String username, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("findAccountByUsername"); + OperationResult result = task.getResult(); + return findAccountByUsername(username, resource, task, result); + } + + protected PrismObject findAccountByUsername(String username, PrismObject resource, + 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()) { + return null; + } + assert accounts.size() == 1 : "Too many accounts found for username " + username + " on " + resource + ": " + accounts; + return accounts.iterator().next(); + } + + protected Collection> listAccounts( + PrismObject resource, Task task, OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + Collection identifierDefs = rAccount.getPrimaryIdentifiers(); + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; + ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); + ObjectQuery query = prismContext.queryFor(ShadowType.class) + .item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) + .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) + .build(); + return modelService.searchObjects(ShadowType.class, query, null, task, result); + } + + protected PrismObject getShadowModel(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, null, true); + } + + protected PrismObject getShadowModelNoFetch(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, GetOperationOptions.createNoFetch(), true); + } + + protected PrismObject getShadowModelFuture(String accountOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getShadowModel(accountOid, GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE), true); + } + + protected PrismObject getShadowModel(String shadowOid, GetOperationOptions rootOptions, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getShadowModel"); + OperationResult result = task.getResult(); + Collection> opts = null; + if (rootOptions != null) { + opts = SelectorOptions.createCollection(rootOptions); + } + logger.info("Getting model shadow {} with options {}", shadowOid, opts); + PrismObject shadow = modelService.getObject(ShadowType.class, shadowOid, opts, task, result); + logger.info("Got model shadow (options {})\n{}", shadowOid, shadow.debugDumpLazily(1)); + result.computeStatus(); + if (assertSuccess) { + TestUtil.assertSuccess("getObject(shadow) result not success", result); + } + return shadow; + } + + protected void assertNoObject(Class type, String oid) + throws SchemaException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("assertNoObject"); + assertNoObject(type, oid, task, task.getResult()); + } + + 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 + } + } + + protected void assertObjectByName(Class type, String name, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, + ExpressionEvaluationException, ObjectNotFoundException { + SearchResultList> objects = modelService + .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, + result); + if (objects.isEmpty()) { + fail("Expected that " + type + " " + name + " did exist but it did not"); + } + } + + protected void assertNoObjectByName(Class type, String name, Task task, OperationResult result) + throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, + ExpressionEvaluationException, ObjectNotFoundException { + SearchResultList> objects = modelService + .searchObjects(type, prismContext.queryFor(type).item(ObjectType.F_NAME).eqPoly(name).build(), null, task, + result); + if (!objects.isEmpty()) { + fail("Expected that " + type + " " + name + " did not exists but it did: " + objects); + } + } + + protected void assertNoShadow( + String username, PrismObject resource, OperationResult result) + throws SchemaException { + ObjectQuery query = createAccountShadowQuery(username, resource); + List> accounts = + repositoryService.searchObjects(ShadowType.class, query, null, result); + if (accounts.isEmpty()) { + return; + } + logger.error("Found shadow for " + username + " on " + resource + " while not expecting it:\n" + accounts.get(0).debugDump()); + assert false : "Found shadow for " + username + " on " + resource + " while not expecting it: " + accounts; + } + + protected ShadowAsserter assertShadow(String username, PrismObject resource) + throws SchemaException { + ObjectQuery query = createAccountShadowQuery(username, resource); + OperationResult result = new OperationResult("assertShadow"); + List> accounts = repositoryService.searchObjects(ShadowType.class, query, null, result); + if (accounts.isEmpty()) { + AssertJUnit.fail("No shadow for " + username + " on " + resource); + } else if (accounts.size() > 1) { + AssertJUnit.fail("Too many shadows for " + username + " on " + resource + " (" + accounts.size() + "): " + accounts); + } + ShadowAsserter asserter = ShadowAsserter.forShadow(accounts.get(0), "shadow for username " + username + " on " + resource); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected PrismObject findShadowByNameViaModel(ShadowKindType kind, String intent, String name, + PrismObject resource, Collection> options, Task task, + OperationResult result) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, + ConfigurationException, ExpressionEvaluationException { + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind, intent); + ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); + List> shadows = modelService.searchObjects(ShadowType.class, query, options, task, result); + if (shadows.isEmpty()) { + return null; + } + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; + return shadows.iterator().next(); + } + + protected ObjectQuery createAccountShadowQuery(String username, PrismObject resource) throws SchemaException { + RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + Collection identifierDefs = rAccount.getPrimaryIdentifiers(); + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; + ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); + //TODO: set matching rule instead of null + return prismContext.queryFor(ShadowType.class) + .itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getItemName()).eq(username) + .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()) + .and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) + .build(); + } + + protected String getSingleLinkOid(PrismObject focus) { + PrismReferenceValue accountRefValue = getSingleLinkRef(focus); + assertNull("Unexpected object in linkRefValue", accountRefValue.getObject()); + return accountRefValue.getOid(); + } + + protected PrismReferenceValue getSingleLinkRef(PrismObject focus) { + F focusType = focus.asObjectable(); + assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size()); + ObjectReferenceType linkRefType = focusType.getLinkRef().get(0); + String accountOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(accountOid)); + PrismReferenceValue accountRefValue = linkRefType.asReferenceValue(); + assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid()); + return accountRefValue; + } + + protected String getLinkRefOid(String userOid, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getLinkRefOid(getUser(userOid), resourceOid); + } + + protected String getLinkRefOid(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismReferenceValue linkRef = getLinkRef(focus, resourceOid); + if (linkRef == null) { + return null; + } + return linkRef.getOid(); + } + + protected PrismReferenceValue getLinkRef(PrismObject focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + F focusType = focus.asObjectable(); + for (ObjectReferenceType linkRefType : focusType.getLinkRef()) { + String linkTargetOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); + PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); + if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) { + // This is noFetch. Therefore there is no fetchResult + return linkRefType.asReferenceValue(); + } + } + AssertJUnit.fail("Account for resource " + resourceOid + " not found in " + focus); + return null; // Never reached. But compiler complains about missing return + } + + protected String getLinkRefOid(PrismObject focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + F focusType = focus.asObjectable(); + for (ObjectReferenceType linkRefType : focusType.getLinkRef()) { + String linkTargetOid = linkRefType.getOid(); + assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid)); + PrismObject account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false); + ShadowType shadowType = account.asObjectable(); + if (kind != null && !kind.equals(shadowType.getKind())) { + continue; + } + if (!MiscUtil.equals(intent, shadowType.getIntent())) { + continue; + } + if (resourceOid.equals(shadowType.getResourceRef().getOid())) { + // This is noFetch. Therefore there is no fetchResult + return linkTargetOid; + } + } + AssertJUnit.fail("Linked shadow for resource " + resourceOid + ", kind " + kind + " and intent " + intent + " not found in " + focus); + return null; // Never reached. But compiler complains about missing return + } + + protected void assertUserNoAccountRefs(PrismObject user) { + UserType userJackType = user.asObjectable(); + assertEquals("Unexpected number of accountRefs", 0, userJackType.getLinkRef().size()); + } + + protected String assertAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(user, resourceOid); + assertNotNull("User " + user + " has no account on resource " + resourceOid, accountOid); + return accountOid; + } + + protected void assertAccounts(String userOid, int numAccounts) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("assertAccounts"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertLinks(user, numAccounts); + } + + protected void assertNoShadows(Collection shadowOids) throws SchemaException { + for (String shadowOid : shadowOids) { + assertNoShadow(shadowOid); + } + } + + protected void assertNoShadow(String shadowOid) throws SchemaException { + OperationResult result = new OperationResult(contextName() + ".assertNoShadow"); + // Check is shadow is gone + try { + PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); + display("Unexpected shadow", shadow); + AssertJUnit.fail("Shadow " + shadowOid + " still exists"); + } catch (ObjectNotFoundException e) { + // This is OK + } + } + + protected AssignmentType getUserAssignment(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getAssignment(getUser(userOid), roleOid); + } + + protected AssignmentType getUserAssignment(String userOid, String roleOid, QName relation) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(userOid); + List assignments = user.asObjectable().getAssignment(); + for (AssignmentType assignment : assignments) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null && roleOid.equals(targetRef.getOid()) && prismContext.relationMatches(relation, + targetRef.getRelation())) { + return assignment; + } + } + return null; + } + + protected AssignmentType getAssignment(PrismObject focus, String roleOid) { + List assignments = focus.asObjectable().getAssignment(); + for (AssignmentType assignment : assignments) { + ObjectReferenceType targetRef = assignment.getTargetRef(); + if (targetRef != null && roleOid.equals(targetRef.getOid())) { + return assignment; + } + } + return null; + } + + protected ItemPath getAssignmentPath(long id) { + return ItemPath.create(FocusType.F_ASSIGNMENT, id); + } + + protected void assertNoAssignments(PrismObject user) { + MidPointAsserts.assertNoAssignments(user); + } + + protected void assertNoAssignments(String userOid, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertNoAssignments(user); + } + + protected void assertNoAssignments(String userOid) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(contextName() + ".assertNoShadow"); + assertNoAssignments(userOid, result); + } + + protected AssignmentType assertAssignedRole( + String userOid, String roleOid, OperationResult result) + throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + return assertAssignedRole(user, roleOid); + } + + protected AssignmentType assertAssignedRole( + PrismObject user, String roleOid) { + return MidPointAsserts.assertAssignedRole(user, roleOid); + } + + protected static void assertAssignedRoles( + PrismObject user, String... roleOids) { + MidPointAsserts.assertAssignedRoles(user, roleOids); + } + + protected static void assertAssignedRoles(PrismObject user, Collection roleOids) { + MidPointAsserts.assertAssignedRoles(user, roleOids); + } + + protected AssignmentType assertInducedRole(PrismObject role, String roleOid) { + return MidPointAsserts.assertInducedRole(role, roleOid); + } + + protected void assignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + assignDeputy(userDeputyOid, userTargetOid, null, task, result); + } + + protected void assignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, true, result); + } + + protected void unassignDeputy(String userDeputyOid, String userTargetOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + unassignDeputy(userDeputyOid, userTargetOid, null, task, result); + } + + protected void unassignDeputy(String userDeputyOid, String userTargetOid, Consumer modificationBlock, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, modificationBlock, false, result); + } + + protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, null, task, result, limitTargets); + } + + protected void assignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, true, assignmentMutator, task, result, limitTargets); + } + + protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, null, task, result, limitTargets); + } + + protected void unassignDeputyLimits(String userDeputyOid, String userTargetOid, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyDeputyAssignmentLimits(userDeputyOid, userTargetOid, false, assignmentMutator, task, result, limitTargets); + } + + protected void modifyDeputyAssignmentLimits(String userDeputyOid, String userTargetOid, boolean add, Consumer assignmentMutator, Task task, OperationResult result, ObjectReferenceType... limitTargets) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + modifyUserAssignment(userDeputyOid, userTargetOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY, task, + assignment -> { + AssignmentSelectorType limitTargetContent = new AssignmentSelectorType(); + assignment.setLimitTargetContent(limitTargetContent); + for (ObjectReferenceType limitTarget : limitTargets) { + limitTargetContent.getTargetRef().add(limitTarget); + } + if (assignmentMutator != null) { + assignmentMutator.accept(assignment); + } + }, add, result); + } + + protected void assertAssignedDeputy(PrismObject focus, String targetUserOid) { + MidPointAsserts.assertAssigned(focus, targetUserOid, UserType.COMPLEX_TYPE, SchemaConstants.ORG_DEPUTY); + } + + protected static void assertAssignedOrgs(PrismObject user, String... orgOids) { + MidPointAsserts.assertAssignedOrgs(user, orgOids); + } + + protected void assertObjectRefs(String contextDesc, Collection real, ObjectType... expected) { + assertObjectRefs(contextDesc, real, objectsToOids(expected)); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, ObjectType... expected) { + assertPrismRefValues(contextDesc, real, objectsToOids(expected)); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, Collection expected) { + assertPrismRefValues(contextDesc, real, objectsToOids(expected)); + } + + protected void assertObjectRefs(String contextDesc, Collection real, String... expected) { + assertObjectRefs(contextDesc, true, real, expected); + } + + protected void assertObjectRefs(String contextDesc, boolean checkNames, Collection real, String... expected) { + List refOids = new ArrayList<>(); + for (ObjectReferenceType ref : real) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in " + ref.getOid() + " in " + contextDesc, ref.getType()); + if (checkNames) { + assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); + } + } + PrismAsserts.assertSets("Wrong values in " + contextDesc, refOids, expected); + } + + protected void assertPrismRefValues(String contextDesc, Collection real, String... expected) { + List refOids = new ArrayList<>(); + for (PrismReferenceValue ref : real) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in " + ref.getOid() + " in " + contextDesc, ref.getTargetType()); + assertNotNull("Missing name in " + ref.getOid() + " in " + contextDesc, ref.getTargetName()); + } + PrismAsserts.assertSets("Wrong values in " + contextDesc, refOids, expected); + } + + private String[] objectsToOids(ObjectType[] objects) { + return Arrays.stream(objects) + .map(o -> o.getOid()) + .toArray(String[]::new); + } + + private String[] objectsToOids(Collection objects) { + return objects.stream() + .map(o -> o.getOid()) + .toArray(String[]::new); + } + + protected void assertDelegatedRef(PrismObject focus, String... oids) { + List refOids = new ArrayList<>(); + for (ObjectReferenceType ref : focus.asObjectable().getDelegatedRef()) { + refOids.add(ref.getOid()); + assertNotNull("Missing type in delegatedRef " + ref.getOid() + " in " + focus, ref.getType()); + } + PrismAsserts.assertSets("Wrong values in delegatedRef in " + focus, refOids, oids); + } + + protected void assertNotAssignedRole(PrismObject focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + MidPointAsserts.assertNotAssignedRole(focus, roleOid); + } + + protected void assertNotAssignedRole(String userOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + MidPointAsserts.assertNotAssignedRole(user, roleOid); + } + + protected void assertNotAssignedResource(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + MidPointAsserts.assertNotAssignedResource(user, resourceOid); + } + + protected void assertAssignedResource(Class type, String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject focus = repositoryService.getObject(type, userOid, null, result); + MidPointAsserts.assertAssignedResource(focus, resourceOid); + } + + protected void assertNotAssignedRole(PrismObject user, String roleOid) { + MidPointAsserts.assertNotAssignedRole(user, roleOid); + } + + protected void assertNotAssignedOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertNotAssignedOrg(user, orgOid, relation); + } + + protected void assertAssignedOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedOrg(user, orgOid); + } + + protected void assertAssignedOrg(PrismObject focus, String orgOid, QName relation) { + MidPointAsserts.assertAssignedOrg(focus, orgOid, relation); + } + + protected AssignmentType assertAssignedOrg(PrismObject focus, String orgOid) { + return MidPointAsserts.assertAssignedOrg(focus, orgOid); + } + + protected void assertNotAssignedOrg(PrismObject focus, String orgOid) { + MidPointAsserts.assertNotAssignedOrg(focus, orgOid); + } + + protected AssignmentType assertAssignedOrg(PrismObject user, PrismObject org) { + return MidPointAsserts.assertAssignedOrg(user, org.getOid()); + } + + protected void assertHasOrg(String userOid, String orgOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedOrg(user, orgOid); + } + + protected void assertHasOrgs(PrismObject user, String... orgOids) throws Exception { + for (String orgOid : orgOids) { + assertHasOrg(user, orgOid); + } + assertHasOrgs(user, orgOids.length); + } + + protected void assertHasOrg(PrismObject focus, String orgOid) { + MidPointAsserts.assertHasOrg(focus, orgOid); + } + + protected void assertHasOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertHasOrg(user, orgOid, relation); + } + + protected void assertHasNoOrg(PrismObject user, String orgOid) { + MidPointAsserts.assertHasNoOrg(user, orgOid, null); + } + + protected void assertHasNoOrg(PrismObject user, String orgOid, QName relation) { + MidPointAsserts.assertHasNoOrg(user, orgOid, relation); + } + + protected void assertHasNoOrg(PrismObject user) { + MidPointAsserts.assertHasNoOrg(user); + } + + protected void assertHasOrgs(PrismObject user, int expectedNumber) { + MidPointAsserts.assertHasOrgs(user, expectedNumber); + } + + protected void assertHasArchetypes(PrismObject object, String... oids) { + for (String oid : oids) { + assertHasArchetype(object, oid); + } + assertHasArchetypes(object, oids.length); + } + + protected void assertHasArchetypes(PrismObject object, int expectedNumber) { + MidPointAsserts.assertHasArchetypes(object, expectedNumber); + } + + protected void assertHasArchetype(PrismObject object, String oid) { + MidPointAsserts.assertHasArchetype(object, oid); + } + + protected void assertSubOrgs(String baseOrgOid, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("assertSubOrgs"); + OperationResult result = task.getResult(); + List> subOrgs = getSubOrgs(baseOrgOid, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEquals("Unexpected number of suborgs of org " + baseOrgOid + ", has suborgs " + subOrgs, expected, subOrgs.size()); + } + + protected void assertSubOrgs(PrismObject baseOrg, int expected) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("assertSubOrgs"); + OperationResult result = task.getResult(); + List> subOrgs = getSubOrgs(baseOrg.getOid(), task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEquals("Unexpected number of suborgs of" + baseOrg + ", has suborgs " + subOrgs, expected, subOrgs.size()); + } + + protected List> getSubOrgs(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(OrgType.class) + .isDirectChildOf(baseOrgOid) + .build(); + return modelService.searchObjects(OrgType.class, query, null, task, result); + } + + protected List> getSubOrgUsers(String baseOrgOid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(UserType.class) + .isDirectChildOf(baseOrgOid) + .build(); + return modelService.searchObjects(UserType.class, query, null, task, result); + } + + protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return dumpOrgTree(topOrgOid, false); + } + + protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("dumpOrgTree"); + OperationResult result = task.getResult(); + PrismObject topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result); + String dump = dumpOrgTree(topOrg, dumpUsers, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return dump; + } + + protected String dumpOrgTree(PrismObject topOrg, boolean dumpUsers, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + StringBuilder sb = new StringBuilder(); + dumpOrg(sb, topOrg, 0); + sb.append("\n"); + dumpSubOrgs(sb, topOrg.getOid(), dumpUsers, 1, task, result); + return sb.toString(); + } + + private void dumpSubOrgs(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + List> subOrgs = getSubOrgs(baseOrgOid, task, result); + for (PrismObject suborg : subOrgs) { + dumpOrg(sb, suborg, indent); + if (dumpUsers) { + dumpOrgUsers(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); + } + sb.append("\n"); + dumpSubOrgs(sb, suborg.getOid(), dumpUsers, indent + 1, task, result); + } + } + + private void dumpOrgUsers(StringBuilder sb, String baseOrgOid, boolean dumpUsers, int indent, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + List> subUsers = getSubOrgUsers(baseOrgOid, task, result); + for (PrismObject subuser : subUsers) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, indent); + sb.append(subuser); + } + } + + private void dumpOrg(StringBuilder sb, PrismObject org, int indent) { + DebugUtil.indentDebugDump(sb, indent); + sb.append(org); + List linkRefs = org.asObjectable().getLinkRef(); + sb.append(": ").append(linkRefs.size()).append(" links"); + } + + protected void displayUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("displayUsers"); + OperationResult result = task.getResult(); + ResultHandler handler = (user, parentResult) -> { + display("User", user); + return true; + }; + modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void dumpFocus(String message, PrismObject focus) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".dumpFocus"); + StringBuilder sb = new StringBuilder(); + sb.append(focus.debugDump(0)); + sb.append("\nOrgs:"); + for (ObjectReferenceType parentOrgRef : focus.asObjectable().getParentOrgRef()) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + PrismObject org = repositoryService.getObject(OrgType.class, parentOrgRef.getOid(), null, result); + sb.append(org); + PolyStringType displayName = org.asObjectable().getDisplayName(); + if (displayName != null) { + sb.append(": ").append(displayName); + } + } + sb.append("\nProjections:"); + for (ObjectReferenceType linkRef : focus.asObjectable().getLinkRef()) { + PrismObject shadow = repositoryService.getObject(ShadowType.class, linkRef.getOid(), null, result); + ObjectReferenceType resourceRef = shadow.asObjectable().getResourceRef(); + PrismObject resource = repositoryService.getObject(ResourceType.class, resourceRef.getOid(), null, result); + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + sb.append(resource); + sb.append("/"); + sb.append(shadow.asObjectable().getKind()); + sb.append("/"); + sb.append(shadow.asObjectable().getIntent()); + sb.append(": "); + sb.append(shadow.asObjectable().getName()); + } + sb.append("\nAssignments:"); + for (AssignmentType assignmentType : focus.asObjectable().getAssignment()) { + sb.append("\n"); + DebugUtil.indentDebugDump(sb, 1); + if (assignmentType.getConstruction() != null) { + sb.append("Constr(").append(assignmentType.getConstruction().getDescription()).append(") "); + } + if (assignmentType.getTargetRef() != null) { + sb.append("-["); + if (assignmentType.getTargetRef().getRelation() != null) { + sb.append(assignmentType.getTargetRef().getRelation().getLocalPart()); + } + sb.append("]-> "); + Class targetClass = ObjectTypes.getObjectTypeFromTypeQName(assignmentType.getTargetRef().getType()).getClassDefinition(); + PrismObject target = repositoryService.getObject(targetClass, assignmentType.getTargetRef().getOid(), null, result); + sb.append(target); + } + } + display(message, sb.toString()); + } + + protected void assertAssignments(PrismObject user, int expectedNumber) { + MidPointAsserts.assertAssignments(user, expectedNumber); + } + + protected void assertInducements(PrismObject role, int expectedNumber) { + MidPointAsserts.assertInducements(role, expectedNumber); + } + + protected void assertInducedRoles(PrismObject role, String... roleOids) { + assertInducements(role, roleOids.length); + for (String roleOid : roleOids) { + assertInducedRole(role, roleOid); + } + } + + protected void assertAssignments(PrismObject user, Class expectedType, int expectedNumber) { + MidPointAsserts.assertAssignments(user, expectedType, expectedNumber); + } + + protected void assertAssigned(PrismObject user, String targetOid, QName refType) { + MidPointAsserts.assertAssigned(user, targetOid, refType); + } + + protected void assertAssignedNoOrg(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedNoOrg(user); + } + + protected void assertAssignedNoOrg(PrismObject user) { + assertAssignedNo(user, OrgType.COMPLEX_TYPE); + } + + protected void assertAssignedNoRole(PrismObject focus, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + assertAssignedNoRole(focus); + } + + protected void assertAssignedNoRole(String userOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedNoRole(user); + } + + protected void assertAssignedNoRole(PrismObject user) { + assertAssignedNo(user, RoleType.COMPLEX_TYPE); + } + + protected void assertAssignedNo(PrismObject user, QName refType) { + F userType = user.asObjectable(); + for (AssignmentType assignmentType : userType.getAssignment()) { + ObjectReferenceType targetRef = assignmentType.getTargetRef(); + if (targetRef != null) { + if (refType.equals(targetRef.getType())) { + AssertJUnit.fail(user + " has role " + targetRef.getOid() + " while expected no roles"); + } + } + } + } + + protected void assertAssignedAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException { + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + assertAssignedAccount(user, resourceOid); + } + + protected AssignmentType assertAssignedAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { + UserType userType = user.asObjectable(); + for (AssignmentType assignmentType : userType.getAssignment()) { + ConstructionType construction = assignmentType.getConstruction(); + if (construction != null) { + if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { + continue; + } + if (resourceOid.equals(construction.getResourceRef().getOid())) { + return assignmentType; + } + } + } + AssertJUnit.fail(user.toString() + " does not have account assignment for resource " + resourceOid); + return null; // not reached + } + + protected void assertAssignedNoAccount(PrismObject user, String resourceOid) throws ObjectNotFoundException, SchemaException { + UserType userType = user.asObjectable(); + for (AssignmentType assignmentType : userType.getAssignment()) { + ConstructionType construction = assignmentType.getConstruction(); + if (construction != null) { + if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { + continue; + } + if (resourceOid.equals(construction.getResourceRef().getOid())) { + AssertJUnit.fail(user.toString() + " has account assignment for resource " + resourceOid + " while expecting no such assignment"); + } + } + } + } + + protected PrismObjectDefinition getRoleDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); + } + + protected PrismObjectDefinition getShadowDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); + } + + protected PrismContainerDefinition getAssignmentDefinition() { + return prismContext.getSchemaRegistry().findContainerDefinitionByType(AssignmentType.COMPLEX_TYPE); + } + + protected PrismContainerDefinition getAssignmentExtensionDefinition() { + PrismContainerDefinition assignmentDefinition = getAssignmentDefinition(); + return assignmentDefinition.findContainerDefinition(AssignmentType.F_EXTENSION); + } + + protected PrismContainer getAssignmentExtensionInstance() throws SchemaException { + return getAssignmentExtensionDefinition().instantiate(); + } + + protected PrismObjectDefinition getResourceDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class); + } + + protected PrismObjectDefinition getAccountShadowDefinition() { + return prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); + } + + protected PrismObject createObject(Class type, String name) throws SchemaException { + PrismObject object = getObjectDefinition(type).instantiate(); + object.asObjectable().setName(createPolyStringType(name)); + return object; + } + + protected PrismObject createUser(String name, String fullName) throws SchemaException { + return createUser(name, fullName, null); + } + + protected PrismObject createUser(String name, String fullName, Boolean enabled) throws SchemaException { + PrismObject user = createObject(UserType.class, name); + UserType userType = user.asObjectable(); + userType.setFullName(createPolyStringType(fullName)); + if (enabled != null) { + ActivationType activation = new ActivationType(); + userType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + } + return user; + } + + protected PrismObject createUser(String name, String givenName, String familyName, Boolean enabled) throws SchemaException { + PrismObject user = getUserDefinition().instantiate(); + UserType userType = user.asObjectable(); + userType.setName(createPolyStringType(name)); + userType.setGivenName(createPolyStringType(givenName)); + userType.setFamilyName(createPolyStringType(familyName)); + userType.setFullName(createPolyStringType(givenName + " " + familyName)); + if (enabled != null) { + ActivationType activation = new ActivationType(); + userType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + } + return user; + } + + protected void fillinUser(PrismObject user, String name, String fullName) { + user.asObjectable().setName(createPolyStringType(name)); + user.asObjectable().setFullName(createPolyStringType(fullName)); + } + + protected void fillinUserAssignmentAccountConstruction(PrismObject user, String resourceOid) { + AssignmentType assignmentType = new AssignmentType(); + ConstructionType accountConstruntion = new ConstructionType(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resourceOid); + resourceRef.setType(ResourceType.COMPLEX_TYPE); + accountConstruntion.setResourceRef(resourceRef); + accountConstruntion.setKind(ShadowKindType.ACCOUNT); + assignmentType.setConstruction(accountConstruntion); + user.asObjectable().getAssignment().add(assignmentType); + } + + protected PrismObject createAccount(PrismObject resource, String name, boolean enabled) throws SchemaException { + PrismObject shadow = getShadowDefinition().instantiate(); + ShadowType shadowType = shadow.asObjectable(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resource.getOid()); + shadowType.setResourceRef(resourceRef); + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + shadowType.setObjectClass(objectClassDefinition.getTypeName()); + shadowType.setKind(ShadowKindType.ACCOUNT); + ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); + RefinedAttributeDefinition idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next(); + ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate(); + icfsNameAttr.setRealValue(name); + attrCont.add(icfsNameAttr); + ActivationType activation = new ActivationType(); + shadowType.setActivation(activation); + if (enabled) { + activation.setAdministrativeStatus(ActivationStatusType.ENABLED); + } else { + activation.setAdministrativeStatus(ActivationStatusType.DISABLED); + } + return shadow; + } + + 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)); + ResourceAttribute attr = attrSnDef.instantiate(); + attr.setRealValue(attrValue); + attrs.add(attr); + } + + protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + setDefaultObjectTemplate(UserType.COMPLEX_TYPE, userTemplateOid); + } + + protected void setDefaultObjectTemplate(QName objectType, String userTemplateOid) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + OperationResult result = new OperationResult(contextName() + ".setDefaultObjectTemplate"); + setDefaultObjectTemplate(objectType, userTemplateOid, result); + result.computeStatus(); + TestUtil.assertSuccess("Applying default object template failed (result)", result); + } + + protected void setDefaultObjectTemplate(QName objectType, String objectTemplateOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + setDefaultObjectTemplate(objectType, null, objectTemplateOid, parentResult); + } + + protected void setDefaultObjectTemplate(QName objectType, String subType, String objectTemplateOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); + + PrismContainerValue oldValue = null; + for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { + oldValue = focusPolicyType.asPrismContainerValue(); + } + } + Collection modifications = new ArrayList<>(); + + if (oldValue != null) { + ObjectPolicyConfigurationType oldPolicy = oldValue.asContainerable(); + ObjectReferenceType oldObjectTemplateRef = oldPolicy.getObjectTemplateRef(); + if (oldObjectTemplateRef != null) { + if (oldObjectTemplateRef.getOid().equals(objectTemplateOid)) { + // Already set + return; + } + } + ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, oldValue.clone()); + ((Collection) modifications).add(deleteDelta); + } + + if (objectTemplateOid != null) { + ObjectPolicyConfigurationType newFocusPolicyType; + ContainerDelta addDelta; + if (oldValue == null) { + newFocusPolicyType = new ObjectPolicyConfigurationType(); + newFocusPolicyType.setType(objectType); + newFocusPolicyType.setSubtype(subType); + addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newFocusPolicyType); + } else { + PrismContainerValue newValue = oldValue.cloneComplex(CloneStrategy.REUSE); + addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newValue); + newFocusPolicyType = newValue.asContainerable(); + } + ObjectReferenceType templateRef = new ObjectReferenceType(); + templateRef.setOid(objectTemplateOid); + newFocusPolicyType.setObjectTemplateRef(templateRef); + ((Collection) modifications).add(addDelta); + } + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + PrismObject systemConfig = repositoryService.getObject(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult); + + PrismContainerValue oldValue = null; + for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) { + if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) { + oldValue = focusPolicyType.asPrismContainerValue(); + } + } + Collection modifications = new ArrayList<>(); + + if (oldValue != null) { + ContainerDelta deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, oldValue.clone()); + ((Collection) modifications).add(deleteDelta); + } + + ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType(); + newFocusPolicyType.setType(objectType); + newFocusPolicyType.setSubtype(subType); + if (oldValue != null) { + ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef(); + if (oldObjectTemplateRef != null) { + newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone()); + } + } + + newFocusPolicyType.setConflictResolution(conflictResolution); + + ContainerDelta addDelta = prismContext.deltaFactory().container() + .createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, + SystemConfigurationType.class, newFocusPolicyType); + + ((Collection) modifications).add(addDelta); + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void setConflictResolutionAction(QName objectType, String subType, ConflictResolutionActionType conflictResolutionAction, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + ConflictResolutionType conflictResolutionType = new ConflictResolutionType(); + conflictResolutionType.action(conflictResolutionAction); + setConflictResolution(objectType, subType, conflictResolutionType, parentResult); + } + + protected void setGlobalSecurityPolicy(String securityPolicyOid, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + + Collection modifications = new ArrayList<>(); + + ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(SystemConfigurationType.F_GLOBAL_SECURITY_POLICY_REF, + SystemConfigurationType.class, securityPolicyOid); + modifications.add(refDelta); + + modifySystemObjectInRepo(SystemConfigurationType.class, + SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult); + + } + + protected void modifySystemObjectInRepo(Class type, String oid, Collection modifications, OperationResult parentResult) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { + display("Modifications of system object " + oid, modifications); + repositoryService.modifyObject(type, oid, modifications, parentResult); + invalidateSystemObjectsCache(); + } + + @Override + protected void invalidateSystemObjectsCache() { + systemObjectCache.invalidateCaches(); + } + + protected ItemPath getIcfsNameAttributePath() { + return ItemPath.create( + ShadowType.F_ATTRIBUTES, + SchemaTestConstants.ICFS_NAME); + + } + + protected void assertResolvedResourceRefs(ModelContext context) { + for (ModelProjectionContext projectionContext : context.getProjectionContexts()) { + assertResolvedResourceRefs(projectionContext.getObjectOld(), "objectOld in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getObjectNew(), "objectNew in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getPrimaryDelta(), "primaryDelta in " + projectionContext); + assertResolvedResourceRefs(projectionContext.getSecondaryDelta(), "secondaryDelta in " + projectionContext); + } + } + + private void assertResolvedResourceRefs(ObjectDelta delta, String desc) { + if (delta == null) { + return; + } + if (delta.isAdd()) { + assertResolvedResourceRefs(delta.getObjectToAdd(), desc); + } else if (delta.isModify()) { + ReferenceDelta referenceDelta = delta.findReferenceModification(ShadowType.F_RESOURCE_REF); + if (referenceDelta != null) { + assertResolvedResourceRefs(referenceDelta.getValuesToAdd(), "valuesToAdd in " + desc); + assertResolvedResourceRefs(referenceDelta.getValuesToDelete(), "valuesToDelete in " + desc); + assertResolvedResourceRefs(referenceDelta.getValuesToReplace(), "valuesToReplace in " + desc); + } + } + } + + private void assertResolvedResourceRefs(PrismObject shadow, String desc) { + if (shadow == null) { + return; + } + PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); + if (resourceRef == null) { + AssertJUnit.fail("No resourceRef in " + desc); + } + assertResolvedResourceRefs(resourceRef.getValues(), desc); + } + + private void assertResolvedResourceRefs(Collection values, String desc) { + if (values == null) { + return; + } + for (PrismReferenceValue pval : values) { + assertNotNull("resourceRef in " + desc + " does not contain object", pval.getObject()); + } + } + + /** + * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to + * existing user values. + */ + protected void breakAssignmentDelta(Collection> deltas) throws SchemaException { + breakAssignmentDelta((ObjectDelta) deltas.iterator().next()); + } + + /** + * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to + * existing user values. + */ + protected void breakAssignmentDelta(ObjectDelta userDelta) throws SchemaException { + ContainerDelta assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); + PrismContainerValue assignmentDeltaValue = null; + if (assignmentDelta.getValuesToAdd() != null) { + assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); + } + if (assignmentDelta.getValuesToDelete() != null) { + assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); + } + PrismContainer activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); + PrismContainerValue emptyValue = prismContext.itemFactory().createContainerValue(); + activationContainer.add(emptyValue); + } + + protected void purgeResourceSchema(String resourceOid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("purgeResourceSchema"); + OperationResult result = task.getResult(); + + ObjectDelta resourceDelta = prismContext.deltaFactory().object().createModificationReplaceContainer(ResourceType.class, + resourceOid, ResourceType.F_SCHEMA, new PrismContainerValue[0]); + Collection> deltas = MiscSchemaUtil.createCollection(resourceDelta); + + modelService.executeChanges(deltas, null, task, result); + + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected List> searchOrg(String baseOrgOid, OrgFilter.Scope scope, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(OrgType.class) + .isInScopeOf(baseOrgOid, scope) + .build(); + return modelService.searchObjects(OrgType.class, query, null, task, result); + } + + protected PrismObject searchObjectByName(Class type, String name) + throws SchemaException, ObjectNotFoundException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("searchObjectByName"); + OperationResult result = task.getResult(); + PrismObject out = searchObjectByName(type, name, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return out; + } + + protected PrismObject searchObjectByName(Class type, String name, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = ObjectQueryUtil.createNameQuery(name, prismContext); + List> foundObjects = modelService.searchObjects(type, query, null, task, result); + if (foundObjects.isEmpty()) { + return null; + } + if (foundObjects.size() > 1) { + throw new IllegalStateException("More than one object found for type " + type + " and name '" + name + "'"); + } + return foundObjects.iterator().next(); + } + + protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), null); + } + + protected void assertAccountShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, MatchingRule matchingRule) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), matchingRule); + } + + protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, + QName objectClass) throws SchemaException { + assertShadowModel(accountShadow, oid, username, resourceType, objectClass, null); + } + + protected void assertShadowModel(PrismObject accountShadow, String oid, String username, ResourceType resourceType, + QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { + assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, false); + IntegrationTestTools.assertProvisioningShadow(accountShadow, RefinedAttributeDefinition.class, objectClass); + } + + protected ObjectDelta createModifyUserAddDummyAccount(String userOid, String dummyResourceName) throws SchemaException { + return createModifyUserAddAccount(userOid, getDummyResourceObject(dummyResourceName)); + } + + protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource) throws SchemaException { + return createModifyUserAddAccount(userOid, resource, null); + } + + protected ObjectDelta createModifyUserAddAccount(String userOid, PrismObject resource, String intent) throws SchemaException { + PrismObject account = getAccountShadowDefinition().instantiate(); + ObjectReferenceType resourceRef = new ObjectReferenceType(); + resourceRef.setOid(resource.getOid()); + account.asObjectable().setResourceRef(resourceRef); + RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); + RefinedObjectClassDefinition rocd = null; + if (StringUtils.isNotBlank(intent)) { + rocd = refinedSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, intent); + account.asObjectable().setIntent(intent); + } else { + rocd = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); + } + account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName()); + account.asObjectable().setKind(ShadowKindType.ACCOUNT); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected ObjectDelta createModifyUserDeleteDummyAccount(String userOid, String dummyResourceName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return createModifyUserDeleteAccount(userOid, getDummyResourceObject(dummyResourceName)); + } + + protected ObjectDelta createModifyUserDeleteAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return createModifyUserDeleteAccount(userOid, resource.getOid()); + } + + protected ObjectDelta createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(userOid, resourceOid); + PrismObject account = getShadowModel(accountOid); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected ObjectDelta createModifyUserUnlinkAccount(String userOid, PrismObject resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + String accountOid = getLinkRefOid(userOid, resource.getOid()); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setOid(accountOid); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + + return userDelta; + } + + protected void deleteUserAccount(String userOid, String resourceOid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta userDelta = createModifyUserDeleteAccount(userOid, resourceOid); + executeChanges(userDelta, null, task, result); + } + + // TASKS + + protected void waitForTaskFinish(Task task, boolean checkSubresult) throws Exception { + waitForTaskFinish(task, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskFinish(Task task, boolean checkSubresult, final int timeout) throws Exception { + waitForTaskFinish(task, checkSubresult, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskFinish(final Task task, final boolean checkSubresult, final int timeout, long sleepTime) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskFinish"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + task.refresh(waitResult); + waitResult.summarize(); + OperationResult result = task.getResult(); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + task + ": " + TestUtil.getErrorMessage(result); + assert !isUnknown(result, checkSubresult) : "Unknown result in " + task + ": " + TestUtil.getErrorMessage(result); + return !isInProgress(result, checkSubresult); + } + + @Override + public void timeout() { + try { + task.refresh(waitResult); + } catch (ObjectNotFoundException e) { + logger.error("Exception during task refresh: {}", e, e); + } catch (SchemaException e) { + logger.error("Exception during task refresh: {}", e, e); + } + OperationResult result = task.getResult(); + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + task + " to finish. Last result " + result; + } + }; + IntegrationTestTools.waitFor("Waiting for " + task + " finish", checker, timeout, sleepTime); + } + + protected void waitForTaskCloseOrSuspend(String taskOid) throws Exception { + waitForTaskCloseOrSuspend(taskOid, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskCloseOrSuspend(String taskOid, final int timeout) throws Exception { + waitForTaskCloseOrSuspend(taskOid, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskCloseOrSuspend(final String taskOid, final int timeout, long sleepTime) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskCloseOrSuspend"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task task = taskManager.getTaskWithResult(taskOid, waitResult); + waitResult.summarize(); + display("Task execution status = " + task.getExecutionStatus()); + return task.getExecutionStatus() == TaskExecutionStatus.CLOSED + || task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED; + } + + @Override + public void timeout() { + Task task = null; + try { + task = taskManager.getTaskWithResult(taskOid, waitResult); + } catch (ObjectNotFoundException | SchemaException e) { + logger.error("Exception during task refresh: {}", e, e); + } + OperationResult result = null; + if (task != null) { + result = task.getResult(); + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + } + assert false : "Timeout (" + timeout + ") while waiting for " + taskOid + " to close or suspend. Last result " + result; + } + }; + IntegrationTestTools.waitFor("Waiting for " + taskOid + " close/suspend", checker, timeout, sleepTime); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, Function customizer) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, 0, DEFAULT_TASK_WAIT_TIMEOUT, false, 0, customizer); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, timeout, false); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, final int timeout, final boolean errorOk) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, 0, timeout, errorOk); + } + + protected Task waitForTaskFinish(final String taskOid, final boolean checkSubresult, long startTime, final int timeout, final boolean errorOk) throws CommonException { + return waitForTaskFinish(taskOid, checkSubresult, startTime, timeout, errorOk, 0, null); + } + + protected Task waitForTaskFinish(String taskOid, boolean checkSubresult, long startTime, int timeout, boolean errorOk, + int showProgressEach, Function customizer) throws CommonException { + long realStartTime = startTime != 0 ? startTime : System.currentTimeMillis(); + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskFinish"); + TaskFinishChecker.Builder builder = new TaskFinishChecker.Builder() + .taskManager(taskManager) + .taskOid(taskOid) + .waitResult(waitResult) + .checkSubresult(checkSubresult) + .errorOk(errorOk) + .timeout(timeout) + .showProgressEach(showProgressEach) + .verbose(verbose); + if (customizer != null) { + builder = customizer.apply(builder); + } + TaskFinishChecker checker = builder.build(); + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " finish", checker, realStartTime, timeout, DEFAULT_TASK_SLEEP_TIME); + return checker.getLastTask(); + } + + protected void dumpTaskTree(String oid, OperationResult result) + throws ObjectNotFoundException, + SchemaException { + Collection> options = schemaHelper.getOperationOptionsBuilder() + .item(TaskType.F_SUBTASK).retrieve() + .build(); + PrismObject task = taskManager.getObject(TaskType.class, oid, options, result); + dumpTaskAndSubtasks(task.asObjectable(), 0); + } + + protected void dumpTaskAndSubtasks(TaskType task, int level) throws SchemaException { + String xml = prismContext.xmlSerializer().serialize(task.asPrismObject()); + display("Task (level " + level + ")", xml); + for (TaskType subtask : TaskTypeUtil.getResolvedSubtasks(task)) { + dumpTaskAndSubtasks(subtask, level + 1); + } + } + + protected long getRunDurationMillis(String taskReconOpendjOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return getTaskRunDurationMillis(getTask(taskReconOpendjOid).asObjectable()); + } + + protected long getTaskRunDurationMillis(TaskType taskType) { + long duration = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp()) + - XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp()); + System.out.println("Duration for " + taskType.getName() + " is " + duration); + return duration; + } + + protected long getTreeRunDurationMillis(String rootTaskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject rootTask = getTaskTree(rootTaskOid); + return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) + .mapToLong(this::getTaskRunDurationMillis) + .max().orElse(0); + } + + protected void displayOperationStatistics(String label, OperationStatsType statistics) { + display(label, StatisticsUtil.format(statistics)); + } + + @Nullable + protected OperationStatsType getTaskTreeOperationStatistics(String rootTaskOid) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException { + PrismObject rootTask = getTaskTree(rootTaskOid); + return TaskTypeUtil.getAllTasksStream(rootTask.asObjectable()) + .map(t -> t.getOperationStats()) + .reduce(StatisticsUtil::sum) + .orElse(null); + } + + protected List getSubcases(String parentCaseOid, Collection> options, + OperationResult result) throws SchemaException { + return asObjectableList( + repositoryService.searchObjects(CaseType.class, + prismContext.queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(parentCaseOid).build(), + options, result)); + } + + protected void deleteCaseTree(String rootCaseOid, OperationResult result) throws SchemaException, ObjectNotFoundException { + List subcases = getSubcases(rootCaseOid, null, result); + for (CaseType subcase : subcases) { + deleteCaseTree(subcase.getOid(), result); + } + repositoryService.deleteObject(CaseType.class, rootCaseOid, result); + } + + protected void displayTaskWithOperationStats(String message, PrismObject task) throws SchemaException { + display(message, task); + String stats = prismContext.xmlSerializer() + .serializeRealValue(task.asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); + display(message + ": Operational stats", stats); + } + + protected void displayTaskWithOperationStats(String message, Task task) throws SchemaException { + display(message, task); + String stats = prismContext.xmlSerializer() + .serializeRealValue(task.getUpdatedOrClonedTaskObject().asObjectable().getOperationStats(), TaskType.F_OPERATION_STATS); + display(message + ": Operational stats", stats); + } + + protected void assertJpegPhoto(Class clazz, String oid, byte[] expectedValue, OperationResult result) + throws SchemaException, ObjectNotFoundException { + PrismObject object = repositoryService + .getObject(clazz, oid, schemaHelper.getOperationOptionsBuilder().retrieve().build(), result); + byte[] actualValue = object.asObjectable().getJpegPhoto(); + if (expectedValue == null) { + if (actualValue != null) { + fail("Photo present even if it should not be: " + Arrays.toString(actualValue)); + } + } else { + assertNotNull("No photo", actualValue); + if (!Arrays.equals(actualValue, expectedValue)) { + fail("Photo is different than expected.\nExpected = " + Arrays.toString(expectedValue) + + "\nActual value = " + Arrays.toString(actualValue)); + } + } + } + + protected void waitForTaskStart(String taskOid, boolean checkSubresult) throws Exception { + waitForTaskStart(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected void waitForTaskStart(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskStart"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + freshTask + ": " + TestUtil.getErrorMessage(result); + if (isUnknown(result, checkSubresult)) { + return false; + } + return freshTask.getLastRunStartTimestamp() != null; + } + + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " to start. Last result " + result; + } catch (ObjectNotFoundException | SchemaException e) { + logger.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected void waitForTaskNextStart(String taskOid, boolean checkSubresult, int timeout, boolean kickTheTask) throws Exception { + OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextStart"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + if (kickTheTask) { + taskManager.scheduleTaskNow(origTask, waitResult); + } + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + if (verbose) { display("Check result", result); } + assert !isError(result, checkSubresult) : "Error in " + freshTask + ": " + TestUtil.getErrorMessage(result); + return !isUnknown(result, checkSubresult) && + !java.util.Objects.equals(freshTask.getLastRunStartTimestamp(), origLastRunStartTimestamp); + } + + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(taskOid, waitResult); + OperationResult result = freshTask.getResult(); + logger.debug("Result of timed-out task:\n{}", result.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + freshTask + " to start. Last result " + result; + } catch (ObjectNotFoundException | SchemaException e) { + logger.error("Exception during task refresh: {}", e, e); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + taskOid + " next start", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(String taskOid, boolean checkSubresult) throws Exception { + return waitForTaskNextRunAssertSuccess(taskOid, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, boolean checkSubresult) throws Exception { + return waitForTaskNextRunAssertSuccess(origTask, checkSubresult, DEFAULT_TASK_WAIT_TIMEOUT); + } + + protected OperationResult waitForTaskNextRunAssertSuccess(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + OperationResult taskResult = waitForTaskNextRun(taskOid, checkSubresult, timeout); + if (isError(taskResult, checkSubresult)) { + assert false : "Error in task " + taskOid + ": " + TestUtil.getErrorMessage(taskResult) + "\n\n" + taskResult.debugDump(); + } + return taskResult; + } + + protected OperationResult waitForTaskNextRunAssertSuccess(Task origTask, final boolean checkSubresult, final int timeout) throws Exception { + OperationResult taskResult = waitForTaskNextRun(origTask, checkSubresult, timeout); + if (isError(taskResult, checkSubresult)) { + assert false : "Error in task " + origTask + ": " + TestUtil.getErrorMessage(taskResult) + "\n\n" + taskResult.debugDump(); + } + return taskResult; + } + + protected OperationResult waitForTaskNextRun(final String taskOid) throws Exception { + return waitForTaskNextRun(taskOid, false, DEFAULT_TASK_WAIT_TIMEOUT, false); + } + + protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + return waitForTaskNextRun(taskOid, checkSubresult, timeout, false); + } + + protected OperationResult waitForTaskNextRun(final String taskOid, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextRun"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout) throws Exception { + return waitForTaskNextRun(origTask, checkSubresult, timeout, false); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, boolean kickTheTask) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskNextRun"); + return waitForTaskNextRun(origTask, checkSubresult, timeout, waitResult, kickTheTask); + } + + protected OperationResult waitForTaskNextRun(final Task origTask, final boolean checkSubresult, final int timeout, final OperationResult waitResult, boolean kickTheTask) throws Exception { + final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); + if (kickTheTask) { + taskManager.scheduleTaskNow(origTask, waitResult); + } + final Holder taskResultHolder = new Holder<>(); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult taskResult = freshTask.getResult(); + if (verbose) { display("Check result", taskResult); } + taskResultHolder.setValue(taskResult); + if (isError(taskResult, checkSubresult)) { + return true; + } + if (isUnknown(taskResult, checkSubresult)) { + return false; + } + if (freshTask.getLastRunFinishTimestamp() == null) { + return false; + } + if (freshTask.getLastRunStartTimestamp() == null) { + return false; + } + return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); + } + + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + 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())); + 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); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + origTask + " next run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + 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())); + + return taskResultHolder.getValue(); + } + + protected OperationResult waitForTaskTreeNextFinishedRun(String rootTaskOid, int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskTreeNextFinishedRun"); + Task origRootTask = taskManager.getTaskWithResult(rootTaskOid, waitResult); + return waitForTaskTreeNextFinishedRun(origRootTask, timeout, waitResult); + } + + // a bit experimental + protected OperationResult waitForTaskTreeNextFinishedRun(Task origRootTask, int timeout, OperationResult waitResult) throws Exception { + Long origLastRunStartTimestamp = origRootTask.getLastRunStartTimestamp(); + Long origLastRunFinishTimestamp = origRootTask.getLastRunFinishTimestamp(); + long start = System.currentTimeMillis(); + Holder triggered = new Holder<>(false); // to avoid repeated checking for start-finish timestamps + OperationResult aggregateResult = new OperationResult("aggregate"); + Checker checker = () -> { + Task freshRootTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); + + String s = TaskDebugUtil.dumpTaskTree(freshRootTask, waitResult); + display("task tree", s); + + long waiting = (System.currentTimeMillis() - start) / 1000; + String description = + freshRootTask.getName().getOrig() + " [es:" + freshRootTask.getExecutionStatus() + ", rs:" + + freshRootTask.getResultStatus() + ", p:" + freshRootTask.getProgress() + ", n:" + + freshRootTask.getNode() + "] (waiting for: " + waiting + ")"; + // was the whole task tree refreshed at least once after we were called? + if (!triggered.getValue() && (freshRootTask.getLastRunStartTimestamp() == null + || freshRootTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + || freshRootTask.getLastRunFinishTimestamp() == null + || freshRootTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + || freshRootTask.getLastRunStartTimestamp() >= freshRootTask.getLastRunFinishTimestamp())) { + display("Root (triggering) task next run has not been completed yet: " + description); + return false; + } + triggered.setValue(true); + + aggregateResult.getSubresults().clear(); + List subtasks = freshRootTask.listSubtasksDeeply(waitResult); + for (Task subtask : subtasks) { + try { + subtask.refresh(waitResult); // quick hack to get operation results + } catch (ObjectNotFoundException e) { + logger.warn("Task {} does not exist any more", subtask); + } + } + Task failedTask = null; + for (Task subtask : subtasks) { + if (subtask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { + display("Found runnable/running subtasks during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtask.getExecutionStatus() == TaskExecutionStatus.WAITING) { + display("Found waiting subtasks during waiting => continuing waiting: " + description, subtask); + return false; + } + OperationResult subtaskResult = subtask.getResult(); + if (subtaskResult == null) { + display("No subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtaskResult.getStatus() == OperationResultStatus.IN_PROGRESS) { + display("Found 'in_progress' subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + if (subtaskResult.getStatus() == OperationResultStatus.UNKNOWN) { + display("Found 'unknown' subtask operation result during waiting => continuing waiting: " + description, subtask); + return false; + } + aggregateResult.addSubresult(subtaskResult); + if (subtaskResult.isError()) { + failedTask = subtask; + } + } + if (failedTask != null) { + display("Found 'error' subtask operation result during waiting => done waiting: " + description, failedTask); + return true; + } + if (freshRootTask.getExecutionStatus() == TaskExecutionStatus.WAITING) { + display("Found WAITING root task during wait for next finished run => continuing waiting: " + description); + return false; + } + return true; // all executive subtasks are closed + }; + IntegrationTestTools.waitFor("Waiting for task tree " + origRootTask + " next finished run", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + Task freshTask = taskManager.getTaskWithResult(origRootTask.getOid(), waitResult); + logger.debug("Final root task:\n{}", freshTask.debugDump()); + aggregateResult.computeStatusIfUnknown(); + return aggregateResult; + } + + public void waitForCaseClose(CaseType aCase) throws Exception { + waitForCaseClose(aCase, 60000); + } + + public void waitForCaseClose(CaseType aCase, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForCaseClose"); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + CaseType currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult).asObjectable(); + if (verbose) { AbstractIntegrationTest.display("Case", currentCase); } + return SchemaConstants.CASE_STATE_CLOSED.equals(currentCase.getState()); + } + + @Override + public void timeout() { + PrismObject currentCase; + try { + currentCase = repositoryService.getObject(CaseType.class, aCase.getOid(), null, waitResult); + } catch (ObjectNotFoundException | SchemaException e) { + throw new AssertionError("Couldn't retrieve case " + aCase, e); + } + logger.debug("Timed-out case:\n{}", currentCase.debugDump()); + assert false : "Timeout (" + timeout + ") while waiting for " + currentCase + " to finish"; + } + }; + IntegrationTestTools.waitFor("Waiting for " + aCase + " finish", checker, timeout, 1000); + } + + private String longTimeToString(Long longTime) { + if (longTime == null) { + return "null"; + } + return longTime.toString(); + } + + public static boolean isError(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult != null && subresult.isError(); + } + + public static boolean isUnknown(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult != null && subresult.isUnknown(); // TODO or return true if null? + } + + public static boolean isInProgress(OperationResult result, boolean checkSubresult) { + OperationResult subresult = getSubresult(result, checkSubresult); + return subresult == null || subresult.isInProgress(); // "true" if there are no subresults + } + + private static OperationResult getSubresult(OperationResult result, boolean checkSubresult) { + if (checkSubresult) { + return result != null ? result.getLastSubresult() : null; + } + return result; + } + + protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskResume"); + Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); + + final Long origLastRunStartTimestamp = origTask.getLastRunStartTimestamp(); + final Long origLastRunFinishTimestamp = origTask.getLastRunFinishTimestamp(); + + taskManager.resumeTask(origTask, waitResult); + + final Holder taskResultHolder = new Holder<>(); + Checker checker = new Checker() { + @Override + public boolean check() throws CommonException { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + OperationResult taskResult = freshTask.getResult(); + if (verbose) { display("Check result", taskResult); } + taskResultHolder.setValue(taskResult); + if (isError(taskResult, checkSubresult)) { + return true; + } + if (isUnknown(taskResult, checkSubresult)) { + return false; + } + if (freshTask.getLastRunFinishTimestamp() == null) { + return false; + } + if (freshTask.getLastRunStartTimestamp() == null) { + return false; + } + return !freshTask.getLastRunStartTimestamp().equals(origLastRunStartTimestamp) + && !freshTask.getLastRunFinishTimestamp().equals(origLastRunFinishTimestamp) + && freshTask.getLastRunStartTimestamp() < freshTask.getLastRunFinishTimestamp(); + } + + @Override + public void timeout() { + try { + Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); + 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())); + 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); + } + } + }; + IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + + 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())); + + return taskResultHolder.getValue(); + } + + protected void restartTask(String taskOid) throws CommonException { + + // Wait at least 1ms here. We have the timestamp in the tasks with a millisecond granularity. If the tasks is started, + // executed and then resstarted and excecuted within the same millisecond then the second execution will not be + // detected and the wait for task finish will time-out. So waiting one millisecond here will make sure that the + // timestamps are different. And 1ms is not that long to significantly affect test run times. + try { + Thread.sleep(1); + } catch (InterruptedException e) { + logger.warn("Sleep interrupted: {}", e.getMessage(), e); + } + + OperationResult result = createSubresult("restartTask"); + try { + Task task = taskManager.getTaskWithResult(taskOid, result); + logger.info("Restarting task {}", taskOid); + if (task.getExecutionStatus() == TaskExecutionStatus.SUSPENDED) { + logger.debug("Task {} is suspended, resuming it", task); + taskManager.resumeTask(task, result); + } else if (task.getExecutionStatus() == TaskExecutionStatus.CLOSED) { + logger.debug("Task {} is closed, scheduling it to run now", task); + taskManager.scheduleTasksNow(singleton(taskOid), result); + } else if (task.getExecutionStatus() == TaskExecutionStatus.RUNNABLE) { + if (taskManager.getLocallyRunningTaskByIdentifier(task.getTaskIdentifier()) != null) { + // Task is really executing. Let's wait until it finishes; hopefully it won't start again (TODO) + logger.debug("Task {} is running, waiting while it finishes before restarting", task); + waitForTaskFinish(taskOid, false); + } + logger.debug("Task {} is finished, scheduling it to run now", task); + taskManager.scheduleTasksNow(singleton(taskOid), result); + } else { + throw new IllegalStateException( + "Task " + task + " cannot be restarted, because its state is: " + task.getExecutionStatus()); + } + } catch (Throwable t) { + result.recordFatalError(t); + throw t; + } finally { + result.computeStatusIfUnknown(); + } + } + + protected boolean suspendTask(String taskOid) throws CommonException { + return suspendTask(taskOid, 3000); + } + + protected boolean suspendTask(String taskOid, int waitTime) throws CommonException { + final OperationResult result = new OperationResult(AbstractIntegrationTest.class + ".suspendTask"); + Task task = taskManager.getTaskWithResult(taskOid, result); + logger.info("Suspending task {}", taskOid); + return taskManager.suspendTaskQuietly(task, waitTime, result); + } + + /** + * Restarts task and waits for finish. + */ + protected void rerunTask(String taskOid) throws CommonException { + long startTime = System.currentTimeMillis(); + restartTask(taskOid); + waitForTaskFinish(taskOid, true, startTime, DEFAULT_TASK_WAIT_TIMEOUT, false); + } + + protected void assertTaskExecutionStatus(String taskOid, TaskExecutionStatus expectedExecutionStatus) throws ObjectNotFoundException, SchemaException { + final OperationResult result = new OperationResult(AbstractIntegrationTest.class + ".assertTaskExecutionStatus"); + Task task = taskManager.getTask(taskOid, result); + assertEquals("Wrong executionStatus in " + task, expectedExecutionStatus, task.getExecutionStatus()); + } + + protected void setSecurityContextUser(String userOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("setSecurityContextUser"); + PrismObject object = modelService.getObject(UserType.class, userOid, null, task, task.getResult()); + + assertNotNull("User " + userOid + " is null", object.asObjectable()); + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken( + new MidPointPrincipal(object.asObjectable()), null)); + } + + protected String getSecurityContextUserOid() { + return ((MidPointPrincipal) (SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getOid(); + } + + protected void assertSideEffectiveDeltasOnly(String desc, ObjectDelta focusDelta) { + if (focusDelta == null) { + return; + } + int expectedModifications = 0; + // There may be metadata modification, we tolerate that + for (ItemDelta modification : focusDelta.getModifications()) { + if (isSideEffectDelta(modification)) { + expectedModifications++; + } + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { + expectedModifications++; + } + PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); + if (effectiveStatusDelta != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { + expectedModifications++; + } + assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); + } + + protected void assertSideEffectiveDeltasOnly(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation) { + assertEffectualDeltas(focusDelta, desc, expectedEfficientActivation, 0); + } + + protected void assertEffectualDeltas(ObjectDelta focusDelta, String desc, ActivationStatusType expectedEfficientActivation, int expectedEffectualModifications) { + if (focusDelta == null) { + return; + } + int expectedModifications = expectedEffectualModifications; + // There may be metadata modification, we tolerate that + for (ItemDelta modification : focusDelta.getModifications()) { + if (isSideEffectDelta(modification)) { + expectedModifications++; + } + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ENABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_DISABLE_TIMESTAMP) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(PATH_ACTIVATION_ARCHIVE_TIMESTAMP) != null) { + expectedModifications++; + } + PropertyDelta effectiveStatusDelta = focusDelta.findPropertyDelta(PATH_ACTIVATION_EFFECTIVE_STATUS); + if (effectiveStatusDelta != null) { + expectedModifications++; + PrismAsserts.assertReplace(effectiveStatusDelta, expectedEfficientActivation); + } + if (focusDelta.findItemDelta(FocusType.F_ROLE_MEMBERSHIP_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_DELEGATED_REF) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION) != null) { + expectedModifications++; + } + if (focusDelta.findItemDelta(FocusType.F_ITERATION_TOKEN) != null) { + expectedModifications++; + } + assertEquals("Unexpected modifications in " + desc + ": " + focusDelta, expectedModifications, focusDelta.getModifications().size()); + } + + private boolean isSideEffectDelta(ItemDelta modification) { + if (modification.getPath().containsNameExactly(ObjectType.F_METADATA) || + (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { + return true; + } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta)) { + Collection> valuesToReplace = ((ContainerDelta) modification).getValuesToReplace(); + if (valuesToReplace != null && valuesToReplace.size() == 1) { + PrismContainerValue cval = valuesToReplace.iterator().next(); + if (cval.size() == 1) { + Item item = cval.getItems().iterator().next(); + return ActivationType.F_EFFECTIVE_STATUS.equals(item.getElementName()); + } + } + } + return false; + } + + protected void assertValidFrom(PrismObject obj, Date expectedDate) { + assertEquals("Wrong validFrom in " + obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + getActivation(obj).getValidFrom()); + } + + protected void assertValidTo(PrismObject obj, Date expectedDate) { + assertEquals("Wrong validTo in " + obj, XmlTypeConverter.createXMLGregorianCalendar(expectedDate), + getActivation(obj).getValidTo()); + } + + protected ActivationType getActivation(PrismObject obj) { + ObjectType objectType = obj.asObjectable(); + ActivationType activation; + if (objectType instanceof ShadowType) { + activation = ((ShadowType) objectType).getActivation(); + } else if (objectType instanceof UserType) { + activation = ((UserType) objectType).getActivation(); + } else { + throw new IllegalArgumentException("Cannot get activation from " + obj); + } + assertNotNull("No activation in " + obj, activation); + return activation; + } + + protected PrismObject getTask(String taskOid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getTask"); + OperationResult result = task.getResult(); + PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT), task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Task) result not success", result); + return retTask; + } + + protected PrismObject getTaskTree(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getTaskTree"); + OperationResult result = task.getResult(); + PrismObject retTask = modelService.getObject(TaskType.class, taskOid, retrieveItemsNamed(TaskType.F_RESULT, TaskType.F_SUBTASK), task, result); + result.computeStatus(); + TestUtil.assertSuccess("getObject(Task) result not success", result); + return retTask; + } + + protected CaseType getCase(String oid) throws ObjectNotFoundException, SchemaException { + return repositoryService.getObject(CaseType.class, oid, null, new OperationResult("dummy")).asObjectable(); + } + + protected void assertObjectExists(Class clazz, String oid) { + OperationResult result = new OperationResult("assertObjectExists"); + try { + repositoryService.getObject(clazz, oid, null, result); + } catch (ObjectNotFoundException e) { + fail("Object of type " + clazz.getName() + " with OID " + oid + " doesn't exist: " + e.getMessage()); + } catch (SchemaException e) { + throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists but couldn't be read: " + e.getMessage(), e); + } + } + + protected void assertObjectDoesntExist(Class clazz, String oid) { + OperationResult result = new OperationResult("assertObjectDoesntExist"); + try { + PrismObject object = repositoryService.getObject(clazz, oid, null, result); + fail("Object of type " + clazz.getName() + " with OID " + oid + " exists even if it shouldn't: " + object.debugDump()); + } catch (ObjectNotFoundException e) { + // ok + } catch (SchemaException e) { + throw new SystemException("Object of type " + clazz.getName() + " with OID " + oid + " probably exists, and moreover it couldn't be read: " + e.getMessage(), e); + } + } + + protected PrismObject getObject(Class type, String oid) + throws ObjectNotFoundException, SchemaException, SecurityViolationException, + CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("getObject"); + OperationResult result = task.getResult(); + PrismObject object = modelService.getObject(type, oid, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return object; + } + + protected PrismObject getObjectViaRepo(Class type, String oid) + throws ObjectNotFoundException, SchemaException { + Task task = createPlainTask("getObjectViaRepo"); + OperationResult result = task.getResult(); + PrismObject object = repositoryService.getObject(type, oid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return object; + } + + protected void addObjects(File... files) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + for (File file : files) { + addObject(file); + } + } + + protected void addObject(TestResource resource, Task task, OperationResult result) + throws IOException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, + PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, + SchemaException { + addObject(resource.file, task, result); + } + + protected PrismObject repoAddObject(TestResource resource, OperationResult result) + throws IOException, ObjectAlreadyExistsException, SchemaException, EncryptionException { + return repoAddObjectFromFile(resource.file, result); + } + + // not going through model to avoid conflicts (because the task starts execution during the clockwork operation) + protected void addTask(File file) throws SchemaException, IOException, ObjectAlreadyExistsException { + taskManager.addTask(prismContext.parseObject(file), new OperationResult("addTask")); + } + + protected void addObject(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = prismContext.parseObject(file); + addObject(object); + } + + protected PrismObject addObject(File file, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + return addObject(file, task, result, null); + } + + protected PrismObject addObject(File file, Task task, OperationResult result, Consumer> customizer) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = prismContext.parseObject(file); + if (customizer != null) { + customizer.accept(object); + } + addObject(object, task, result); + return object; + } + + protected String addObject(PrismObject object) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("addObject"); + OperationResult result = task.getResult(); + String oid = addObject(object, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return oid; + } + + protected String addObject(PrismObject object, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + return addObject(object, null, task, result); + } + + protected String addObject(PrismObject object, ModelExecuteOptions options, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta addDelta = object.createAddDelta(); + assertFalse("Immutable object provided?", addDelta.getObjectToAdd().isImmutable()); + Collection> executedDeltas = executeChanges(addDelta, options, task, result); + object.setOid(ObjectDeltaOperation.findAddDeltaOid(executedDeltas, object)); + return object.getOid(); + } + + protected void deleteObject(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, null, task, result); + } + + protected void deleteObjectRaw(Class type, String oid, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, ModelExecuteOptions.createRaw(), task, result); + } + + protected void deleteObject(Class type, String oid) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("deleteObject"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void deleteObjectRepo(Class type, String oid) throws ObjectNotFoundException { + OperationResult result = new OperationResult(contextName() + "deleteObjectRepo"); + repositoryService.deleteObject(type, oid, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void forceDeleteShadow(String oid) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("forceDeleteShadow"); + OperationResult result = task.getResult(); + forceDeleteObject(ShadowType.class, oid, task, result); + assertSuccess(result); + } + + protected void forceDeleteObject( + Class type, String oid, Task task, OperationResult result) + throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + ModelExecuteOptions options = ModelExecuteOptions.createForce(); + executeChanges(delta, options, task, result); + } + + protected void addTrigger(String oid, XMLGregorianCalendar timestamp, String uri) + throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException, + PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("addTrigger"); + OperationResult result = task.getResult(); + TriggerType triggerType = new TriggerType(); + triggerType.setTimestamp(timestamp); + triggerType.setHandlerUri(uri); + ObjectDelta delta = prismContext.deltaFactory().object() + .createModificationAddContainer(ObjectType.class, oid, ObjectType.F_TRIGGER, + triggerType); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void addTriggers(String oid, Collection timestamps, String uri, boolean makeDistinct) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("addTriggers"); + OperationResult result = task.getResult(); + Collection triggers = timestamps.stream() + .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) + .map(ts -> makeDistinct ? addRandomValue(ts) : ts) + .collect(Collectors.toList()); + ObjectDelta delta = prismContext.deltaFor(ObjectType.class) + .item(ObjectType.F_TRIGGER).addRealValues(triggers) + .asObjectDeltaCast(oid); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + private TriggerType addRandomValue(TriggerType trigger) { + //noinspection unchecked + @NotNull PrismPropertyDefinition workItemIdDef = + prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORK_ITEM_ID); + PrismProperty workItemIdProp = workItemIdDef.instantiate(); + workItemIdProp.addRealValue((long) (Math.random() * 100000000000L)); + try { + //noinspection unchecked + trigger.asPrismContainerValue().findOrCreateContainer(TriggerType.F_EXTENSION).add(workItemIdProp); + } catch (SchemaException e) { + throw new AssertionError(e); + } + return trigger; + } + + protected void replaceTriggers(String oid, Collection timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("replaceTriggers"); + OperationResult result = task.getResult(); + Collection triggers = timestamps.stream() + .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); + executeChanges(delta, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void assertTrigger(PrismObject object, + String handlerUri, XMLGregorianCalendar start, XMLGregorianCalendar end) { + for (TriggerType trigger : object.asObjectable().getTrigger()) { + if (handlerUri.equals(trigger.getHandlerUri()) + && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { + return; + } + } + AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); + } + + protected void assertTrigger( + PrismObject object, String handlerUri, XMLGregorianCalendar mid, long tolerance) { + XMLGregorianCalendar start = XmlTypeConverter.addMillis(mid, -tolerance); + XMLGregorianCalendar end = XmlTypeConverter.addMillis(mid, tolerance); + for (TriggerType trigger : object.asObjectable().getTrigger()) { + if (handlerUri.equals(trigger.getHandlerUri()) + && MiscUtil.isBetween(trigger.getTimestamp(), start, end)) { + return; + } + } + AssertJUnit.fail("Expected that " + object + " will have a trigger but it has not"); + } + + protected void assertNoTrigger(Class type, String oid) + throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(contextName() + "assertNoTrigger"); + PrismObject object = repositoryService.getObject(type, oid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertNoTrigger(object); + } + + protected void assertNoTrigger(PrismObject object) { + List triggers = object.asObjectable().getTrigger(); + if (triggers != null && !triggers.isEmpty()) { + AssertJUnit.fail("Expected that " + object + " will have no triggers but it has " + triggers.size() + " trigger: " + triggers); + } + } + + protected void prepareNotifications() { + notificationManager.setDisabled(false); + dummyTransport.clearMessages(); + } + + protected void checkDummyTransportMessages(String name, int expectedCount) { + List messages = dummyTransport.getMessages("dummy:" + name); + if (expectedCount == 0) { + if (messages != null && !messages.isEmpty()) { + logger.error(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); + logNotifyMessages(messages); + printNotifyMessages(messages); + fail(messages.size() + " unexpected message(s) recorded in dummy transport '" + name + "'"); + } + } else { + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (expectedCount != messages.size()) { + logger.error("Invalid number of messages recorded in dummy transport '" + name + "', expected: " + expectedCount + ", actual: " + messages.size()); + logNotifyMessages(messages); + printNotifyMessages(messages); + assertEquals("Invalid number of messages recorded in dummy transport '" + name + "'", expectedCount, messages.size()); + } + } + } + + protected void assertSingleDummyTransportMessage(String name, String expectedBody) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (messages.size() != 1) { + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: " + messages.size()); + } + Message message = messages.get(0); + assertEquals("Unexpected notifier " + name + " message body", expectedBody, message.getBody()); + } + + protected void assertSingleDummyTransportMessageContaining(String name, String expectedSubstring) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + if (messages.size() != 1) { + fail("Invalid number of messages recorded in dummy transport '" + name + "', expected: 1, actual: " + messages.size()); + } + Message message = messages.get(0); + assertTrue("Notifier " + name + " message body does not contain text: " + expectedSubstring + ", it is:\n" + message.getBody(), + message.getBody().contains(expectedSubstring)); + } + + protected String getDummyTransportMessageBody(String name, int index) { + List messages = dummyTransport.getMessages("dummy:" + name); + Message message = messages.get(index); + return message.getBody(); + } + + protected void assertHasDummyTransportMessage(String name, String expectedBody) { + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + for (Message message : messages) { + if (expectedBody.equals(message.getBody())) { + return; + } + } + fail("Notifier " + name + " message body " + expectedBody + " not found"); + } + + protected void displayAllNotifications() { + for (java.util.Map.Entry> entry : dummyTransport.getMessages().entrySet()) { + List messages = entry.getValue(); + if (messages != null && !messages.isEmpty()) { + display("Notification messages: " + entry.getKey(), messages); + } + } + } + + protected void displayNotifications(String name) { + List messages = dummyTransport.getMessages("dummy:" + name); + display("Notification messages: " + name, messages); + } + + private void logNotifyMessages(List messages) { + for (Message message : messages) { + logger.debug("Notification message:\n{}", message.getBody()); + } + } + + private void printNotifyMessages(List messages) { + for (Message message : messages) { + System.out.println(message); + } + } + + protected void checkDummyTransportMessagesAtLeast(String name, int expectedCount) { + if (expectedCount == 0) { + return; + } + List messages = dummyTransport.getMessages("dummy:" + name); + assertNotNull("No messages recorded in dummy transport '" + name + "'", messages); + assertTrue("Number of messages recorded in dummy transport '" + name + "' (" + messages.size() + ") is not at least " + expectedCount, messages.size() >= expectedCount); + } + + protected DummyAccount getDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getAccountByUsername(username); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(), e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(), e); + } + } + + protected DummyAccount getDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getAccountById(id); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(), e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(), e); + } + } + + protected DummyAccount assertDefaultDummyAccount(String username, String fullname, boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + return assertDummyAccount(null, username, fullname, active); + } + + protected DummyAccount assertDummyAccount(String dummyInstanceName, String username, String fullname, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + // display("account", account); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); + assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") account " + username, fullname, account.getAttributeValue("fullname")); + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); + return account; + } + + protected DummyAccount assertDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); + return account; + } + + protected DummyAccountAsserter assertDummyAccountById(String dummyResourceName, String id) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + return getDummyResourceController(dummyResourceName).assertAccountById(id); + } + + protected void assertNoDummyAccountById(String dummyInstanceName, String id) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccountById(dummyInstanceName, id); + assertNull("Dummy(" + dummyInstanceName + ") account for id " + id + " exists while not expecting it", account); + } + + protected void assertDummyAccountActivation(String dummyInstanceName, String username, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account); + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") account " + username, active, account.isEnabled()); + } + + protected void assertNoDummyAccount(String username) throws SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyAccount(null, username); + } + + protected void assertNoDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNull("Dummy account for username " + username + " exists while not expecting it (" + dummyInstanceName + ")", account); + } + + protected void assertDefaultDummyAccountAttribute(String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyAccountAttribute(null, username, attributeName, expectedAttributeValues); + } + + protected void assertDummyAccountAttribute(String dummyInstanceName, String username, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username " + username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { + return; + } + 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, + expectedAttributeValues.length, values.size()); + for (Object expectedValue : expectedAttributeValues) { + if (!values.contains(expectedValue)) { + AssertJUnit.fail("Value '" + expectedValue + "' expected in attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username + + " but not found. Values found: " + values); + } + } + } + + protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy " + dummyInstanceName + " account for username " + username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + if (values == null || values.isEmpty()) { + return; + } + AssertJUnit.fail("Expected no value in attribute " + attributeName + " of " + dummyInstanceName + " dummy account " + username + + ". Values found: " + values); + } + + protected void assertDummyAccountAttributeGenerated(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username " + username, account); + Integer generated = account.getAttributeValue(DummyAccount.ATTR_INTERNAL_ID, Integer.class); + if (generated == null) { + AssertJUnit.fail("No value in generated attribute dir of " + dummyInstanceName + " dummy account " + username); + } + } + + protected DummyGroup getDummyGroup(String dummyInstanceName, String name) throws SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + try { + return dummyResource.getGroupByName(name); + } catch (ConnectException e) { + throw new IllegalStateException(e.getMessage(), e); + } catch (FileNotFoundException e) { + throw new IllegalStateException(e.getMessage(), e); + } + } + + protected void assertDummyGroup(String username, String description) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroup(null, username, description, null); + } + + protected void assertDummyGroup(String username, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroup(null, username, description, active); + } + + protected void assertDummyGroup(String dummyInstanceName, String groupname, String description, Boolean active) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNotNull("No dummy(" + dummyInstanceName + ") group for name " + groupname, group); + assertEquals("Wrong fullname for dummy(" + dummyInstanceName + ") group " + groupname, description, + group.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION)); + if (active != null) { + assertEquals("Wrong activation for dummy(" + dummyInstanceName + ") group " + groupname, active, group.isEnabled()); + } + } + + protected void assertNoDummyGroup(String groupname) throws SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyGroup(null, groupname); + } + + protected void assertNoDummyGroup(String dummyInstanceName, String groupname) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNull("Dummy group '" + groupname + "' exists while not expecting it (" + dummyInstanceName + ")", group); + } + + protected void assertDummyGroupAttribute(String dummyInstanceName, String groupname, String attributeName, Object... expectedAttributeValues) throws SchemaViolationException, ConflictException, InterruptedException { + DummyGroup group = getDummyGroup(dummyInstanceName, groupname); + assertNotNull("No dummy group for groupname " + groupname, group); + Set values = group.getAttributeValues(attributeName, Object.class); + if ((values == null || values.isEmpty()) && (expectedAttributeValues == null || expectedAttributeValues.length == 0)) { + return; + } + assertNotNull("No values for attribute " + attributeName + " of " + dummyInstanceName + " dummy group " + groupname, values); + assertEquals("Unexpected number of values for attribute " + attributeName + " of dummy group " + groupname + ": " + values, expectedAttributeValues.length, values.size()); + for (Object expectedValue : expectedAttributeValues) { + if (!values.contains(expectedValue)) { + AssertJUnit.fail("Value '" + expectedValue + "' expected in attribute " + attributeName + " of dummy group " + groupname + + " but not found. Values found: " + values); + } + } + } + + protected void assertDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + DummyGroup group = dummyResource.getGroupByName(dummyGroupName); + assertNotNull("No dummy group " + dummyGroupName, group); + IntegrationTestTools.assertGroupMember(group, accountId); + } + + protected void assertDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + assertDummyGroupMember(null, dummyGroupName, accountId); + } + + protected void assertNoDummyGroupMember(String dummyInstanceName, String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); + DummyGroup group = dummyResource.getGroupByName(dummyGroupName); + IntegrationTestTools.assertNoGroupMember(group, accountId); + } + + protected void assertNoDefaultDummyGroupMember(String dummyGroupName, String accountId) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { + assertNoDummyGroupMember(null, dummyGroupName, accountId); + } + + protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(dummyInstanceName, username); + assertNotNull("No dummy account for username " + username, account); + Set values = account.getAttributeValues(attributeName, Object.class); + assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty()); + } + + protected Entry assertOpenDjAccount(String uid, String cn, Boolean active) throws DirectoryException { + Entry entry = openDJController.searchByUid(uid); + assertNotNull("OpenDJ accoun with uid " + uid + " not found", entry); + openDJController.assertAttribute(entry, "cn", cn); + if (active != null) { + openDJController.assertActive(entry, active); + } + return entry; + } + + protected void assertNoOpenDjAccount(String uid) throws DirectoryException { + Entry entry = openDJController.searchByUid(uid); + assertNull("Expected that OpenDJ account with uid " + uid + " will be gone, but it is still there", entry); + } + + protected void assertIteration(PrismObject shadow, Integer expectedIteration, String expectedIterationToken) { + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION, expectedIteration); + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); + } + + protected void assertIterationDelta(ObjectDelta shadowDelta, Integer expectedIteration, String expectedIterationToken) { + PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION, expectedIteration); + PrismAsserts.assertPropertyReplace(shadowDelta, ShadowType.F_ITERATION_TOKEN, expectedIterationToken); + } + + protected void assertSituation(PrismObject shadow, SynchronizationSituationType expectedSituation) { + if (expectedSituation == null) { + PrismAsserts.assertNoItem(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION); + } else { + PrismAsserts.assertPropertyValue(shadow, ShadowType.F_SYNCHRONIZATION_SITUATION, expectedSituation); + } + } + + protected void assertEnableTimestampFocus(PrismObject focus, + 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 userDisableTimestamp = focus.asObjectable().getActivation().getDisableTimestamp(); + TestUtil.assertBetween("Wrong user disableTimestamp in " + focus, + startTime, endTime, userDisableTimestamp); + } + + protected void assertEnableTimestampShadow(PrismObject shadow, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + ActivationType activationType = shadow.asObjectable().getActivation(); + assertNotNull("No activation in " + shadow, activationType); + XMLGregorianCalendar userDisableTimestamp = activationType.getEnableTimestamp(); + TestUtil.assertBetween("Wrong shadow enableTimestamp in " + shadow, + startTime, endTime, userDisableTimestamp); + } + + protected void assertDisableTimestampShadow(PrismObject shadow, + XMLGregorianCalendar startTime, XMLGregorianCalendar endTime) { + XMLGregorianCalendar userDisableTimestamp = shadow.asObjectable().getActivation().getDisableTimestamp(); + TestUtil.assertBetween("Wrong shadow disableTimestamp in " + shadow, + startTime, endTime, userDisableTimestamp); + } + + protected void assertDisableReasonShadow(PrismObject shadow, String expectedReason) { + String disableReason = shadow.asObjectable().getActivation().getDisableReason(); + assertEquals("Wrong shadow disableReason in " + shadow, expectedReason, disableReason); + } + + protected String getPassword(PrismObject user) throws EncryptionException { + CredentialsType credentialsType = user.asObjectable().getCredentials(); + assertNotNull("No credentials in " + user, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in " + user, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertNotNull("No password value in " + user, protectedStringType); + return protector.decryptString(protectedStringType); + } + + protected void assertPassword(PrismObject user, String expectedPassword) throws EncryptionException { + String decryptedUserPassword = getPassword(user); + assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword); + } + + protected void assertUserLdapPassword(PrismObject user, String expectedPassword) throws EncryptionException { + CredentialsType credentialsType = user.asObjectable().getCredentials(); + assertNotNull("No credentials in " + user, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in " + user, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertLdapPassword(protectedStringType, expectedPassword, user); + } + + protected void assertShadowLdapPassword(PrismObject shadow, String expectedPassword) throws EncryptionException { + CredentialsType credentialsType = shadow.asObjectable().getCredentials(); + assertNotNull("No credentials in " + shadow, credentialsType); + PasswordType passwordType = credentialsType.getPassword(); + assertNotNull("No password in " + shadow, passwordType); + ProtectedStringType protectedStringType = passwordType.getValue(); + assertLdapPassword(protectedStringType, expectedPassword, shadow); + } + + protected void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject source) throws EncryptionException { + assertNotNull("No password value in " + source, protectedStringType); + String decryptedUserPassword = protector.decryptString(protectedStringType); + assertNotNull("Null password in " + source, decryptedUserPassword); + if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) { + assertTrue("Wrong password hash in " + source + ": " + decryptedUserPassword + ", expected " + expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword)); + } else { + assertEquals("Wrong password in " + source, expectedPassword, decryptedUserPassword); + } + } + + protected void assertGroupMember(DummyGroup group, String accountId) { + IntegrationTestTools.assertGroupMember(group, accountId); + } + + protected void assertNoGroupMember(DummyGroup group, String accountId) { + IntegrationTestTools.assertNoGroupMember(group, accountId); + } + + protected void assertNoGroupMembers(DummyGroup group) { + IntegrationTestTools.assertNoGroupMembers(group); + } + + protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); + login(principal); + } + + protected void login(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + login(principal); + } + + protected void login(MidPointPrincipal principal) { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null, principal.getAuthorities()); + securityContext.setAuthentication(createMpAuthentication(authentication)); + } + + protected Authentication createMpAuthentication(Authentication authentication) { + MidpointAuthentication mpAuthentication = new MidpointAuthentication(SecurityPolicyUtil.createDefaultSequence()); + ModuleAuthentication moduleAuthentication = new ModuleAuthentication(NameOfModuleType.LOGIN_FORM); + moduleAuthentication.setAuthentication(authentication); + moduleAuthentication.setNameOfModule(SecurityPolicyUtil.DEFAULT_MODULE_NAME); + moduleAuthentication.setState(StateOfModule.SUCCESSFULLY); + moduleAuthentication.setPrefix(ModuleWebSecurityConfiguration.DEFAULT_PREFIX_OF_MODULE_WITH_SLASH + + ModuleWebSecurityConfiguration.DEFAULT_PREFIX_FOR_DEFAULT_MODULE + SecurityPolicyUtil.DEFAULT_MODULE_NAME + "/"); + mpAuthentication.addAuthentications(moduleAuthentication); + mpAuthentication.setPrincipal(authentication.getPrincipal()); + return mpAuthentication; + } + + protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(principalName, UserType.class); + loginSuperUser(principal); + } + + protected void loginSuperUser(PrismObject user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + loginSuperUser(principal); + } + + protected void loginSuperUser(MidPointPrincipal principal) throws SchemaException { + AuthorizationType superAutzType = new AuthorizationType(); + prismContext.adopt(superAutzType, RoleType.class, RoleType.F_AUTHORIZATION); + superAutzType.getAction().add(AuthorizationConstants.AUTZ_ALL_URL); + Authorization superAutz = new Authorization(superAutzType); + Collection authorities = principal.getAuthorities(); + authorities.add(superAutz); + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); + securityContext.setAuthentication(createMpAuthentication(authentication)); + } + + protected void loginAnonymous() { + Authentication authentication = new AnonymousAuthenticationToken("foo", + AuthorizationConstants.ANONYMOUS_USER_PRINCIPAL, AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS")); + SecurityContextHolder.getContext().setAuthentication(createMpAuthentication(authentication)); + } + + protected void assertLoggedInUsername(String username) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + FocusType user = midPointPrincipal.getFocus(); + if (user == null) { + if (username == null) { + return; + } else { + AssertJUnit.fail("Expected logged in user '" + username + "' but there was no user in the spring security context"); + } + } + assertEquals("Wrong logged-in user", username, user.getName().getOrig()); + } + + protected void assertLoggedInUserOid(String userOid) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + assertPrincipalUserOid(midPointPrincipal, userOid); + } + + protected void assertPrincipalUserOid(MidPointPrincipal principal, String userOid) { + FocusType user = principal.getFocus(); + if (user == null) { + if (userOid == null) { + return; + } else { + AssertJUnit.fail("Expected user " + userOid + " in principal " + principal + " but there was none"); + } + } + assertEquals("Wrong user OID in principal", userOid, user.getOid()); + } + + protected MidPointPrincipal getSecurityContextPrincipal() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + if (authentication == null) { + return null; + } + Object principal = authentication.getPrincipal(); + if (principal == null) { + return null; + } + if (principal instanceof MidPointPrincipal) { + return (MidPointPrincipal) principal; + } else { + AssertJUnit.fail("Unknown principal in the spring security context: " + principal); + return null; // not reached + } + } + + protected PrismObject getSecurityContextPrincipalFocus() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + if (authentication == null) { + return null; + } + Object principal = authentication.getPrincipal(); + if (principal == null) { + return null; + } + if (principal instanceof MidPointPrincipal) { + FocusType focusType = ((MidPointPrincipal) principal).getFocus(); + return focusType.asPrismObject(); + } else { + return null; + } + } + + protected void assertAuthenticated() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + Authentication authentication = securityContext.getAuthentication(); + assertTrue("Security context is not authenticated", authentication.isAuthenticated()); + } + + protected void resetAuthentication() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + securityContext.setAuthentication(null); + } + + protected void assertNoAuthentication() { + SecurityContext securityContext = SecurityContextHolder.getContext(); + assertNull("Unexpected authentication", securityContext.getAuthentication()); + } + + protected void assertSecurityContextPrincipalAttorneyOid(String attotrneyOid) { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + assertPrincipalAttorneyOid(midPointPrincipal, attotrneyOid); + } + + protected void assertPrincipalAttorneyOid(MidPointPrincipal principal, String attotrneyOid) { + FocusType attorney = principal.getAttorney(); + if (attorney == null) { + if (attotrneyOid == null) { + return; + } else { + AssertJUnit.fail("Expected attorney " + attotrneyOid + " in principal " + principal + " but there was none"); + } + } + assertEquals("Wrong attroney OID in principal", attotrneyOid, attorney.getOid()); + } + + protected Collection getSecurityContextAuthorizations() { + MidPointPrincipal midPointPrincipal = getSecurityContextPrincipal(); + if (midPointPrincipal == null) { + return null; + } + return midPointPrincipal.getAuthorities(); + } + + protected void assertAuthorizationActions(String message, Collection autzs, String... expectedActions) { + Collection actualActions = autzs.stream() + .map(a -> a.getAction()) + .flatMap(List::stream) + .collect(Collectors.toList()); + PrismAsserts.assertEqualsCollectionUnordered(message, actualActions, expectedActions); + } + + protected void assertSecurityContextAuthorizationActions(String... expectedActions) { + Collection securityContextAuthorizations = getSecurityContextAuthorizations(); + assertAuthorizationActions("Wrong authorizations in security context", securityContextAuthorizations, expectedActions); + } + + protected void assertSecurityContextAuthorizationActions(ModelAuthorizationAction... expectedModelActions) { + Collection securityContextAuthorizations = getSecurityContextAuthorizations(); + String[] expectedActions = new String[expectedModelActions.length]; + for (int i = 0; i < expectedModelActions.length; i++) { + expectedActions[i] = expectedModelActions[i].getUrl(); + } + assertAuthorizationActions("Wrong authorizations in security context", securityContextAuthorizations, expectedActions); + } + + protected void assertSecurityContextNoAuthorizationActions() { + Collection securityContextAuthorizations = getSecurityContextAuthorizations(); + if (securityContextAuthorizations != null && !securityContextAuthorizations.isEmpty()) { + fail("Unexpected authorizations in security context: " + securityContextAuthorizations); + } + } + + protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + Task task = createPlainTask("displayAllUsers"); + OperationResult result = task.getResult(); + ResultHandler handler = (object, parentResult) -> { + display("User", object); + return true; + }; + modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + /** + * Returns appropriate object synchronization settings for the class. + * Assumes single sync setting for now. + */ + protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class type, String name) { + SynchronizationType synchronization = resource.getSynchronization(); + if (synchronization == null) { + return null; + } + List objectSynchronizations = synchronization.getObjectSynchronization(); + if (objectSynchronizations.isEmpty()) { + return null; + } + for (ObjectSynchronizationType objSyncType : objectSynchronizations) { + QName focusTypeQName = objSyncType.getFocusType(); + if (focusTypeQName == null) { + if (type != UserType.class) { + continue; + } + } else { + ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName); + if (type != focusType.getClassDefinition()) { + continue; + } + } + if (name == null) { + // we got it + return objSyncType; + } else { + if (name.equals(objSyncType.getName())) { + return objSyncType; + } + } + } + throw new IllegalArgumentException("Synchronization setting for " + type + " and name " + name + " not found in " + resource); + } + + protected void assertShadowKindIntent(String shadowOid, ShadowKindType expectedKind, + String expectedIntent) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertShadowKindIntent"); + PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertShadowKindIntent(shadow, expectedKind, expectedIntent); + } + + protected void assertShadowKindIntent(PrismObject shadow, ShadowKindType expectedKind, + String expectedIntent) { + assertEquals("Wrong kind in " + shadow, expectedKind, shadow.asObjectable().getKind()); + assertEquals("Wrong intent in " + shadow, expectedIntent, shadow.asObjectable().getIntent()); + } + + protected PrismObject getDefaultActor() { + return null; + } + + protected void customizeTask(Task task) { + PrismObject defaultActor = getDefaultActor(); + if (defaultActor != null) { + task.setOwner(defaultActor); + } + task.setChannel(DEFAULT_CHANNEL); + } + + protected Task createTask(String operationName, MidPointPrincipal principal) { + Task task = createPlainTask(operationName); + task.setOwner(principal.getFocus().asPrismObject()); + task.setChannel(DEFAULT_CHANNEL); + return task; + } + + protected Task createTask(MidPointPrincipal principal) { + Task task = createPlainTask(); + task.setOwner(principal.getFocus().asPrismObject()); + task.setChannel(DEFAULT_CHANNEL); + return task; + } + + protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask("modifyRoleAddConstruction"); + OperationResult result = task.getResult(); + ConstructionType construction = new ConstructionType(); + ObjectReferenceType resourceRedRef = new ObjectReferenceType(); + resourceRedRef.setOid(resourceOid); + construction.setResourceRef(resourceRedRef); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, + ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), + construction); + modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void modifyRoleAddInducementTarget( + String roleOid, String targetOid, boolean reconcileAffected, ModelExecuteOptions defaultOptions) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException, + ObjectAlreadyExistsException, PolicyViolationException { + OperationResult result = createSubresult("modifyRoleAddInducementTarget"); + AssignmentType inducement = new AssignmentType(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(targetOid); + inducement.setTargetRef(targetRef); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, + RoleType.F_INDUCEMENT, inducement); + ModelExecuteOptions options = nullToEmpty(defaultOptions); + options.setReconcileAffected(reconcileAffected); + executeChanges(roleDelta, options, getTestTask(), result); + result.computeStatus(); + if (reconcileAffected) { + TestUtil.assertInProgressOrSuccess(result); + } else { + TestUtil.assertSuccess(result); + } + } + + protected void modifyRoleAddExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRoleExclusion(roleOid, excludedRoleOid, true, task, result); + } + + protected void modifyRoleDeleteExclusion(String roleOid, String excludedRoleOid, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRoleExclusion(roleOid, excludedRoleOid, false, task, result); + } + + protected void modifyRoleExclusion(String roleOid, String excludedRoleOid, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + modifyRolePolicyRule(roleOid, createExclusionPolicyRule(excludedRoleOid), add, task, result); + } + + protected void modifyRolePolicyRule(String roleOid, PolicyRuleType exclusionPolicyRule, boolean add, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + AssignmentType assignment = new AssignmentType(); + assignment.setPolicyRule(exclusionPolicyRule); + ObjectDelta roleDelta; + if (add) { + roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + } else { + roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + } + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleDeleteAssignment(String roleOid, AssignmentType assignment, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_ASSIGNMENT, + assignment); + executeChanges(roleDelta, null, task, result); + } + + protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType(); + ObjectReferenceType targetRef = new ObjectReferenceType(); + targetRef.setOid(excludedRoleOid); + targetRef.setType(RoleType.COMPLEX_TYPE); + exclusionConstraint.setTargetRef(targetRef); + policyContraints.getExclusion().add(exclusionConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected PolicyRuleType createMinAssigneePolicyRule(int minAssignees) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + MultiplicityPolicyConstraintType minAssigneeConstraint = new MultiplicityPolicyConstraintType(); + minAssigneeConstraint.setMultiplicity(Integer.toString(minAssignees)); + policyContraints.getMinAssignees().add(minAssigneeConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected PolicyRuleType createMaxAssigneePolicyRule(int maxAssignees) { + PolicyRuleType policyRule = new PolicyRuleType(); + PolicyConstraintsType policyContraints = new PolicyConstraintsType(); + MultiplicityPolicyConstraintType maxAssigneeConstraint = new MultiplicityPolicyConstraintType(); + maxAssigneeConstraint.setMultiplicity(Integer.toString(maxAssignees)); + policyContraints.getMaxAssignees().add(maxAssigneeConstraint); + policyRule.setPolicyConstraints(policyContraints); + return policyRule; + } + + protected AssignmentType createAssignmentIdOnly(long id) { + AssignmentType assignment = new AssignmentType(); + assignment.asPrismContainerValue().setId(id); + return assignment; + } + + protected void modifyRoleAddPolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationAddContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleDeletePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected void modifyRoleReplacePolicyException(String roleOid, PolicyExceptionType policyException, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationReplaceContainer(RoleType.class, roleOid, RoleType.F_POLICY_EXCEPTION, + policyException); + executeChanges(roleDelta, null, task, result); + } + + protected PolicyExceptionType createPolicyException(String ruleName, String policySituation) { + PolicyExceptionType policyException = new PolicyExceptionType(); + policyException.setPolicySituation(policySituation); + policyException.setRuleName(ruleName); + return policyException; + } + + protected Optional findAssignmentByTarget(PrismObject focus, String targetOid) { + return focus.asObjectable().getAssignment().stream() + .filter(a -> a.getTargetRef() != null && targetOid.equals(a.getTargetRef().getOid())) + .findFirst(); + } + + protected AssignmentType findAssignmentByTargetRequired(PrismObject focus, String targetOid) { + return findAssignmentByTarget(focus, targetOid) + .orElseThrow(() -> new IllegalStateException("No assignment to " + targetOid + " in " + focus)); + } + + protected AssignmentType findInducementByTarget(String roleOid, String targetOid) + throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, + CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("findInducementByTarget"); + OperationResult result = task.getResult(); + PrismObject role = modelService.getObject(RoleType.class, roleOid, null, task, result); + for (AssignmentType inducement : role.asObjectable().getInducement()) { + ObjectReferenceType targetRef = inducement.getTargetRef(); + if (targetRef != null && targetOid.equals(targetRef.getOid())) { + return inducement; + } + } + return null; + } + + protected void modifyRoleDeleteInducementTarget(String roleOid, String targetOid, + ModelExecuteOptions options) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createTask("modifyRoleDeleteInducementTarget"); + OperationResult result = task.getResult(); + AssignmentType inducement = findInducementByTarget(roleOid, targetOid); + ObjectDelta roleDelta = + prismContext.deltaFactory().object().createModificationDeleteContainer( + RoleType.class, roleOid, RoleType.F_INDUCEMENT, + inducement.asPrismContainerValue().clone()); + modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void modifyRoleDeleteInducement(String roleOid, long inducementId, boolean reconcileAffected, + ModelExecuteOptions defaultOptions, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + OperationResult result = task.getResult(); + + AssignmentType inducement = new AssignmentType(); + inducement.setId(inducementId); + ObjectDelta roleDelta = prismContext.deltaFactory().object() + .createModificationDeleteContainer(RoleType.class, roleOid, + RoleType.F_INDUCEMENT, inducement); + ModelExecuteOptions options = nullToEmpty(defaultOptions); + options.setReconcileAffected(reconcileAffected); + executeChanges(roleDelta, options, task, result); + result.computeStatus(); + if (reconcileAffected) { + TestUtil.assertInProgressOrSuccess(result); + } else { + TestUtil.assertSuccess(result); + } + } + + @NotNull + protected ModelExecuteOptions nullToEmpty(ModelExecuteOptions options) { + return options != null ? options : new ModelExecuteOptions(); + } + + protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + PrismObject account = prismContext.parseObject(accountFile); + + ObjectDelta userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid + ); + PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); + accountRefVal.setObject(account); + ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); + userDelta.addModification(accountDelta); + Collection> deltas = (Collection) MiscUtil.createCollection(userDelta); + + modelService.executeChanges(deltas, null, task, result); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertAuthorized", principal); + assertAuthorized(principal, action, null, task, task.getResult()); + assertAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); + assertAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertAuthorized", principal); + assertAuthorized(principal, action, phase, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + SecurityContext origContext = SecurityContextHolder.getContext(); + createSecurityContext(principal); + try { + assertTrue("AuthorizationEvaluator.isAuthorized: Principal " + principal + " NOT authorized for action " + action, + securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result)); + if (phase == null) { + List requiredActions = new ArrayList<>(1); + requiredActions.add(action); + securityEnforcer.decideAccess(getSecurityContextPrincipal(), requiredActions, task, result); + } + } finally { + SecurityContextHolder.setContext(origContext); + } + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertNotAuthorized", principal); + assertNotAuthorized(principal, action, null, task, task.getResult()); + assertNotAuthorized(principal, action, AuthorizationPhaseType.REQUEST, task, task.getResult()); + assertNotAuthorized(principal, action, AuthorizationPhaseType.EXECUTION, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertNotAuthorized", principal); + assertNotAuthorized(principal, action, phase, task, task.getResult()); + assertSuccess(task.getResult()); + } + + protected void assertNotAuthorized(MidPointPrincipal principal, String action, AuthorizationPhaseType phase, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + SecurityContext origContext = SecurityContextHolder.getContext(); + createSecurityContext(principal); + boolean isAuthorized = securityEnforcer.isAuthorized(action, phase, AuthorizationParameters.EMPTY, null, task, result); + SecurityContextHolder.setContext(origContext); + assertFalse("AuthorizationEvaluator.isAuthorized: Principal " + principal + " IS authorized for action " + action + " (" + phase + ") but he should not be", isAuthorized); + } + + protected void assertAuthorizations(PrismObject user, String... expectedAuthorizations) + throws SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + assertNotNull("No principal for " + user, principal); + assertAuthorizations(principal, expectedAuthorizations); + } + + protected void assertAuthorizations(MidPointPrincipal principal, String... expectedAuthorizations) { + List actualAuthorizations = new ArrayList<>(); + for (Authorization authorization : principal.getAuthorities()) { + actualAuthorizations.addAll(authorization.getAction()); + } + PrismAsserts.assertSets("Wrong authorizations in " + principal, actualAuthorizations, expectedAuthorizations); + } + + protected void assertNoAuthorizations(PrismObject user) + throws SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException, ExpressionEvaluationException { + MidPointPrincipal principal = focusProfileService.getPrincipal(user); + assertNotNull("No principal for " + user, principal); + assertNoAuthorizations(principal); + } + + protected void assertNoAuthorizations(MidPointPrincipal principal) { + if (principal.getAuthorities() != null && !principal.getAuthorities().isEmpty()) { + AssertJUnit.fail("Unexpected authorizations in " + principal + ": " + principal.getAuthorities()); + } + } + + protected CompiledGuiProfileAsserter assertCompiledGuiProfile(MidPointPrincipal principal) { + if (!(principal instanceof GuiProfiledPrincipal)) { + fail("Expected GuiProfiledPrincipal, but got " + principal.getClass()); + } + CompiledGuiProfile compiledGuiProfile = ((GuiProfiledPrincipal) principal).getCompiledGuiProfile(); + CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, "in principal " + principal); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected CompiledGuiProfileAsserter assertCompiledGuiProfile(CompiledGuiProfile compiledGuiProfile) { + CompiledGuiProfileAsserter asserter = new CompiledGuiProfileAsserter<>(compiledGuiProfile, null, null); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected EvaluatedPolicyRulesAsserter assertEvaluatedPolicyRules(Collection evaluatedPolicyRules, PrismObject sourceObject) { + EvaluatedPolicyRulesAsserter asserter = new EvaluatedPolicyRulesAsserter<>(evaluatedPolicyRules, null, sourceObject.toString()); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected void createSecurityContext(MidPointPrincipal principal) { + SecurityContext context = new SecurityContextImpl(); + Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null); + context.setAuthentication(authentication); + SecurityContextHolder.setContext(context); + } + + protected Object createSecureObject() { + return new FilterInvocation("/midpoint", "whateverServlet", "doSomething"); + } + + protected Collection createConfigAttributes(String action) { + Collection attrs = new ArrayList<>(); + attrs.add(new SecurityConfig(action)); + return attrs; + } + + protected PrismObjectDefinition getEditObjectDefinition(PrismObject object) throws SchemaException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + Task task = createPlainTask("getEditObjectDefinition"); + OperationResult result = task.getResult(); + PrismObjectDefinition editSchema = modelInteractionService.getEditObjectDefinition(object, null, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + return editSchema; + } + + protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject targetHolder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + return getAssignableRoleSpecification(targetHolder, 0); + } + + protected RoleSelectionSpecification getAssignableRoleSpecification( + PrismObject focus, int assignmentOrder) + throws ObjectNotFoundException, SchemaException, ConfigurationException, + ExpressionEvaluationException, CommunicationException, SecurityViolationException { + return getAssignableRoleSpecification(focus, AbstractRoleType.class, 0); + } + + protected RoleSelectionSpecification getAssignableRoleSpecification(PrismObject focus, Class targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { + Task task = createPlainTask("getAssignableRoleSpecification"); + OperationResult result = task.getResult(); + RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result); + assertSuccess(result); + return spec; + } + + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification(PrismObject targetHolder) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter<>(spec, null, "for holder " + targetHolder); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected RoleSelectionSpecificationAsserter assertAssignableRoleSpecification( + PrismObject targetHolder, Class roleType, int order) + throws CommunicationException, ObjectNotFoundException, SchemaException, + SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + RoleSelectionSpecification spec = getAssignableRoleSpecification(targetHolder, roleType, order); + RoleSelectionSpecificationAsserter asserter = new RoleSelectionSpecificationAsserter<>(spec, null, "for holder " + targetHolder + ", role type " + roleType.getSimpleName() + ", order " + order); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected void assertAllowRequestAssignmentItems( + String userOid, String targetRoleOid, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, + ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + Task task = createTask("assertAllowRequestAssignmentItems"); + OperationResult result = task.getResult(); + assertAllowRequestAssignmentItems(userOid, targetRoleOid, task, result, expectedAllowedItemPaths); + assertSuccess(result); + } + + protected void assertAllowRequestAssignmentItems(String userOid, String targetRoleOid, + Task task, OperationResult result, ItemPath... expectedAllowedItemPaths) + throws SchemaException, SecurityViolationException, CommunicationException, + ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(userOid); + PrismObject target = getRole(targetRoleOid); + + ItemSecurityConstraints constraints = modelInteractionService.getAllowedRequestAssignmentItems(user, target, task, result); + display("Request decisions for " + target, constraints); + + for (ItemPath expectedAllowedItemPath : expectedAllowedItemPaths) { + AuthorizationDecisionType decision = constraints.findItemDecision(expectedAllowedItemPath); + assertEquals("Wrong decision for item " + expectedAllowedItemPath, AuthorizationDecisionType.ALLOW, decision); + } + } + + protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertEncryptedUserPassword"); + PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + assertEncryptedUserPassword(user, expectedClearPassword); + } + + protected void assertEncryptedUserPassword(PrismObject user, String expectedClearPassword) throws EncryptionException { + UserType userType = user.asObjectable(); + ProtectedStringType protectedActualPassword = userType.getCredentials().getPassword().getValue(); + String actualClearPassword = protector.decryptString(protectedActualPassword); + assertEquals("Wrong password for " + user, expectedClearPassword, actualClearPassword); + } + + @Deprecated + protected void assertPasswordMetadata(PrismObject user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { + PrismContainer metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); + assertNotNull("No password metadata in " + user, metadataContainer); + MetadataType metadataType = metadataContainer.getValue().asContainerable(); + assertMetadata("password metadata in " + user, metadataType, create, false, start, end, actorOid, channel); + } + + protected void assertPasswordMetadata(PrismObject user, QName credentialType, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { + PrismContainer metadataContainer = user.findContainer(ItemPath.create(UserType.F_CREDENTIALS, credentialType, PasswordType.F_METADATA)); + assertNotNull("No password metadata in " + user, metadataContainer); + MetadataType metadataType = metadataContainer.getValue().asContainerable(); + assertMetadata("password metadata in " + user, metadataType, create, false, start, end, actorOid, channel); + } + + protected void assertCreateMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = object.asObjectable().getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(object.toString(), metadataType, true, true, start, end, + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertModifyMetadata(PrismObject object, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = object.asObjectable().getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(object.toString(), metadataType, false, false, start, end, + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertCreateMetadata( + AssignmentType assignmentType, XMLGregorianCalendar start, XMLGregorianCalendar end) { + MetadataType metadataType = assignmentType.getMetadata(); + PrismObject defaultActor = getDefaultActor(); + assertMetadata(assignmentType.toString(), metadataType, true, true, start, end, + defaultActor == null ? null : defaultActor.getOid(), DEFAULT_CHANNEL); + } + + protected void assertDummyPassword(String instance, String userId, String expectedClearPassword) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(instance, userId); + assertNotNull("No dummy account " + userId, account); + assertEquals("Wrong password in dummy '" + instance + "' account " + userId, expectedClearPassword, account.getPassword()); + } + + protected void assertDummyPasswordNotEmpty(String instance, String userId) throws SchemaViolationException, ConflictException, InterruptedException { + DummyAccount account = getDummyAccount(instance, userId); + assertNotNull("No dummy account " + userId, account); + String actualPassword = account.getPassword(); + if (actualPassword == null || actualPassword.isEmpty()) { + fail("Empty password in dummy '" + instance + "' account " + userId); + } + } + + protected void reconcileUser(String oid, Task task, OperationResult result) + throws SchemaException, CommunicationException, ObjectAlreadyExistsException, + ExpressionEvaluationException, PolicyViolationException, SecurityViolationException, + ConfigurationException, ObjectNotFoundException { + reconcileUser(oid, null, task, result); + } + + protected void reconcileUser(String oid, ModelExecuteOptions options, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, oid); + modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(options), task, result); + } + + protected void reconcileOrg(String oid, Task task, OperationResult result) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { + ObjectDelta emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(OrgType.class, oid); + modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result); + } + + protected void assertRefEquals(String message, ObjectReferenceType expected, ObjectReferenceType actual) { + if (expected == null && actual == null) { + return; + } + if (expected == null || actual == null) { + fail(message + ": expected=" + expected + ", actual=" + actual); + } + PrismAsserts.assertRefEquivalent(message, expected.asReferenceValue(), actual.asReferenceValue()); + } + + protected void assertTaskClosed(PrismObject task) { + assertEquals("Wrong executionStatus in " + task, TaskExecutionStatusType.CLOSED, task.asObjectable().getExecutionStatus()); + } + + protected void assertTaskClosed(Task task) { + assertEquals("Wrong executionStatus in " + task, TaskExecutionStatus.CLOSED, task.getExecutionStatus()); + } + + protected List getAllAuditRecords(Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); + } + + protected List getAuditRecords(int maxRecords, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("setMaxResults", maxRecords); + return modelAuditService.listRecords("select * from m_audit_event as aer order by aer.timestampValue asc", params, task, result); + } + + protected List getObjectAuditRecords(String oid) + throws SecurityViolationException, SchemaException, ObjectNotFoundException, + ExpressionEvaluationException, CommunicationException, ConfigurationException { + Task task = createTask("getObjectAuditRecords"); + OperationResult result = task.getResult(); + Map params = new HashMap<>(); + params.put("targetOid", oid); + return modelAuditService.listRecords("select * from m_audit_event as aer" + + " where (aer.targetOid = :targetOid) order by aer.timestampValue asc", + params, task, result); + } + + protected List getAuditRecordsFromTo(XMLGregorianCalendar from, XMLGregorianCalendar to, Task task, OperationResult result) throws SecurityViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException { + Map params = new HashMap<>(); + params.put("from", from); + params.put("to", to); + return modelAuditService.listRecords("select * from m_audit_event as aer where (aer.timestampValue >= :from) and (aer.timestampValue <= :to) order by aer.timestampValue asc", + params, task, result); + } + + protected void checkUserApprovers(String oid, List expectedApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + PrismObject user = repositoryService.getObject(UserType.class, oid, null, result); + checkApprovers(user, expectedApprovers, user.asObjectable().getMetadata().getModifyApproverRef(), result); + } + + protected void checkApprovers(PrismObject object, List expectedApprovers, List realApprovers, OperationResult result) throws SchemaException, ObjectNotFoundException { + HashSet realApproversSet = new HashSet<>(); + for (ObjectReferenceType approver : realApprovers) { + realApproversSet.add(approver.getOid()); + assertEquals("Unexpected target type in approverRef", UserType.COMPLEX_TYPE, approver.getType()); + } + assertEquals("Mismatch in approvers in metadata", new HashSet<>(expectedApprovers), realApproversSet); + } + + protected List> findUserInRepoUnchecked(String name, OperationResult result) throws SchemaException { + ObjectQuery q = prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly(name).matchingOrig().build(); + return repositoryService.searchObjects(UserType.class, q, null, result); + } + + protected void assertFocusModificationSanity(ModelContext context) { + ModelElementContext focusContext = context.getFocusContext(); + PrismObject focusOld = focusContext.getObjectOld(); + if (focusOld == null) { + return; + } + ObjectDelta focusPrimaryDelta = focusContext.getPrimaryDelta(); + if (focusPrimaryDelta != null) { + assertEquals("No OID in old focus object", focusOld.getOid(), focusPrimaryDelta.getOid()); + assertEquals(ChangeType.MODIFY, focusPrimaryDelta.getChangeType()); + assertNull(focusPrimaryDelta.getObjectToAdd()); + for (ItemDelta itemMod : focusPrimaryDelta.getModifications()) { + if (itemMod.getValuesToDelete() != null) { + Item property = focusOld.findItem(itemMod.getPath()); + assertNotNull("Deleted item " + itemMod.getParentPath() + "/" + itemMod.getElementName() + " not found in focus", property); + for (Object valueToDelete : itemMod.getValuesToDelete()) { + if (!property.contains((PrismValue) valueToDelete, EquivalenceStrategy.REAL_VALUE)) { + display("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); + display("Deleted value", valueToDelete); + display("HASHCODE: " + valueToDelete.hashCode()); + for (Object value : property.getValues()) { + display("Existing value", value); + display("EQUALS: " + valueToDelete.equals(value)); + display("HASHCODE: " + value.hashCode()); + } + fail("Deleted value " + valueToDelete + " is not in focus item " + itemMod.getParentPath() + "/" + itemMod.getElementName()); + } + } + } + } + } + } + + protected PrismObject getUserFromRepo(String oid, OperationResult result) throws SchemaException, ObjectNotFoundException { + return repositoryService.getObject(UserType.class, oid, null, result); + } + + // just guessing (good enough for testing) + protected boolean isH2() { + Task task = createTask("isH2"); + RepositoryDiag diag = modelDiagnosticService.getRepositoryDiag(task, task.getResult()); + return diag.isEmbedded() || "org.h2.Driver".equals(diag.getDriverShortName()); + } + + protected void assertNoPostponedOperation(PrismObject shadow) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + if (!pendingOperations.isEmpty()) { + AssertJUnit.fail("Expected no pending operations in " + shadow + ", but found one: " + pendingOperations); + } + } + + protected String addAndRecomputeUser(File file, Task initTask, OperationResult initResult) throws Exception { + String oid = repoAddObjectFromFile(file, initResult).getOid(); + recomputeUser(oid, initTask, initResult); + display("User " + file, getUser(oid)); + return oid; + } + + protected String addAndRecompute(File file, Task task, OperationResult result) throws Exception { + PrismObject object = repoAddObjectFromFile(file, result); + modelService.recompute(object.asObjectable().getClass(), object.getOid(), null, task, result); + display("Object: " + file, getObject(object.asObjectable().getClass(), object.getOid())); + return object.getOid(); + } + + protected void assertAuditReferenceValue(AuditEventRecord event, String refName, String oid, QName type, String name) { + Set values = event.getReferenceValues(refName); + assertEquals("Wrong # of reference values of '" + refName + "'", 1, values.size()); + AuditReferenceValue value = values.iterator().next(); + assertEquals("Wrong OID", oid, value.getOid()); + assertEquals("Wrong type", type, value.getType()); + assertEquals("Wrong name", name, PolyString.getOrig(value.getTargetName())); + } + + protected List filter(List records, AuditEventStage stage) { + return records.stream() + .filter(r -> r.getEventStage() == stage) + .collect(Collectors.toList()); + } + + protected List filter(List records, AuditEventType type, AuditEventStage stage) { + return records.stream() + .filter(r -> r.getEventType() == type && r.getEventStage() == stage) + .collect(Collectors.toList()); + } + + protected void resetTriggerTask(String taskOid, File taskFile, OperationResult result) + throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, FileNotFoundException { + taskManager.suspendAndDeleteTasks(Collections.singletonList(taskOid), 60000L, true, result); + importObjectFromFile(taskFile, result); + taskManager.suspendTasks(Collections.singletonList(taskOid), 60000L, result); + modifySystemObjectInRepo(TaskType.class, taskOid, + prismContext.deltaFor(TaskType.class) + .item(TaskType.F_SCHEDULE).replace() + .asItemDeltas(), + result); + taskManager.resumeTasks(singleton(taskOid), result); + } + + protected void repoAddObjects(List objects, OperationResult result) + throws EncryptionException, ObjectAlreadyExistsException, SchemaException { + for (ObjectType object : objects) { + repoAddObject(object.asPrismObject(), result); + } + } + + protected void recomputeAndRefreshObjects(List objects, Task task, OperationResult result) + throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, + SchemaException, SecurityViolationException, PolicyViolationException, ExpressionEvaluationException { + for (int i = 0; i < objects.size(); i++) { + ObjectType object = objects.get(i); + modelService.recompute(object.getClass(), object.getOid(), null, task, result); + objects.set(i, repositoryService.getObject(object.getClass(), object.getOid(), null, result).asObjectable()); + } + } + + protected PrismObject

assertLinkedPersona(PrismObject focus, Class

personaClass, String subtype) throws ObjectNotFoundException, SchemaException { + OperationResult result = new OperationResult("assertLinkedPersona"); + for (ObjectReferenceType personaRef : focus.asObjectable().getPersonaRef()) { + PrismObject

persona = repositoryService.getObject((Class

) ObjectTypes.getObjectTypeFromTypeQName(personaRef.getType()).getClassDefinition(), + personaRef.getOid(), null, result); + if (isTypeAndSubtype(persona, personaClass, subtype)) { + return persona; + } + } + fail("No persona " + personaClass.getSimpleName() + "/" + subtype + " in " + focus); + return null; // not reached + } + + protected boolean isTypeAndSubtype(PrismObject focus, Class expectedType, String subtype) { + if (!expectedType.isAssignableFrom(focus.getCompileTimeClass())) { + return false; + } + if (!FocusTypeUtil.hasSubtype(focus, subtype)) { + return false; + } + return true; + } + + protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = findObjectByName(OrgType.class, orgName); + assertNotNull("The org " + orgName + " is missing!", org); + display("Org " + orgName, org); + PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, createPolyString(orgName)); + return org; + } + + protected void dumpOrgTree() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + display("Org tree", dumpOrgTree(getTopOrgOid())); + } + + protected void dumpOrgTreeAndUsers() throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + display("Org tree", dumpOrgTree(getTopOrgOid(), true)); + } + + protected String getTopOrgOid() { + return null; + } + + protected void transplantGlobalPolicyRulesAdd(File configWithGlobalRulesFile, Task task, OperationResult parentResult) throws SchemaException, IOException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + // copy rules from the file into live system config object + 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())) + .asObjectDeltaCast(SystemObjectsType.SYSTEM_CONFIGURATION.value()); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, parentResult); + } + + protected void displayProvisioningScripts() { + displayProvisioningScripts(null); + } + + protected void displayProvisioningScripts(String dummyName) { + display("Provisioning scripts " + dummyName, getDummyResource(dummyName).getScriptHistory()); + } + + protected void purgeProvisioningScriptHistory() { + purgeProvisioningScriptHistory(null); + } + + protected void purgeProvisioningScriptHistory(String dummyName) { + getDummyResource(dummyName).purgeScriptHistory(); + } + + protected void assertNoProvisioningScripts() { + if (!getDummyResource().getScriptHistory().isEmpty()) { + IntegrationTestTools.displayScripts(getDummyResource().getScriptHistory()); + AssertJUnit.fail(getDummyResource().getScriptHistory().size() + " provisioning scripts were executed while not expected any"); + } + } + + protected void assertDummyProvisioningScriptsNone() { + IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory()); + } + + protected void applyPasswordPolicy(String passwordPolicyOid, String securityPolicyOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { + if (passwordPolicyOid == null) { + modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, + task, result /* no value */); + } else { + PrismReferenceValue passPolicyRef = itemFactory().createReferenceValue(passwordPolicyOid, ValuePolicyType.COMPLEX_TYPE); + modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, + task, result, passPolicyRef); + } + } + + protected void assertPasswordCompliesWithPolicy( + PrismObject user, String passwordPolicyOid) + throws EncryptionException, ObjectNotFoundException, ExpressionEvaluationException, + SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { + Task task = createTask("assertPasswordCompliesWithPolicy"); + OperationResult result = task.getResult(); + assertPasswordCompliesWithPolicy(user, passwordPolicyOid, task, result); + assertSuccess(result); + } + + protected void assertPasswordCompliesWithPolicy(PrismObject user, String passwordPolicyOid, Task task, OperationResult result) throws EncryptionException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { + String password = getPassword(user); + display("Password of " + user, password); + PrismObject passwordPolicy = repositoryService.getObject(ValuePolicyType.class, passwordPolicyOid, null, result); + List messages = new ArrayList<>(); + boolean valid = valuePolicyProcessor.validateValue(password, passwordPolicy.asObjectable(), createUserOriginResolver(user), messages, "validating password of " + user, task, result); + if (!valid) { + fail("Password for " + user + " does not comply with password policy: " + messages); + } + } + + protected FocusValuePolicyOriginResolver createUserOriginResolver(PrismObject user) { + if (user != null) { + return new FocusValuePolicyOriginResolver<>(user, modelObjectResolver); + } else { + return null; + } + } + + protected List> getCasesForObject(String oid, QName type, + Collection> options, Task task, OperationResult result) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, + ConfigurationException, ExpressionEvaluationException { + ObjectQuery query = prismContext.queryFor(CaseType.class) + .item(CaseType.F_OBJECT_REF).ref(itemFactory().createReferenceValue(oid, type)) + .build(); + return modelService.searchObjects(CaseType.class, query, options, task, result); + } + + protected CaseType getApprovalCase(List> cases) { + List rv = cases.stream() + .filter(o -> ObjectTypeUtil.hasArchetype(o, SystemObjectsType.ARCHETYPE_APPROVAL_CASE.value())) + .map(o -> o.asObjectable()) + .collect(Collectors.toList()); + if (rv.isEmpty()) { + throw new AssertionError("No approval case found"); + } else if (rv.size() > 1) { + throw new AssertionError("More than one approval case found: " + rv); + } else { + return rv.get(0); + } + } + + protected CaseType getRootCase(List> cases) { + List rv = cases.stream() + .map(o -> o.asObjectable()) + .filter(c -> c.getParentRef() == null) + .collect(Collectors.toList()); + if (rv.isEmpty()) { + throw new AssertionError("No root case found"); + } else if (rv.size() > 1) { + throw new AssertionError("More than one root case found: " + rv); + } else { + return rv.get(0); + } + } + + @SuppressWarnings("unused") // maybe in the future :) + protected Consumer createShowTaskTreeConsumer(long period) { + AtomicLong lastTimeShown = new AtomicLong(0); + return task -> { + try { + if (lastTimeShown.get() + period < System.currentTimeMillis()) { + dumpTaskTree(task.getOid(), createOperationalResult()); + lastTimeShown.set(System.currentTimeMillis()); + } + } catch (CommonException e) { + throw new AssertionError(e); + } + }; + } + + protected T runPrivileged(Producer producer) { + return securityContextManager.runPrivileged(producer); + } + + protected void assertPendingOperationDeltas(PrismObject shadow, int expectedNumber) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + assertEquals("Wrong number of pending operations in " + shadow, expectedNumber, pendingOperations.size()); + } + + protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { + return assertSinglePendingOperation(shadow, requestStart, requestEnd, + OperationResultStatusType.IN_PROGRESS, null, null); + } + + protected PendingOperationType assertSinglePendingOperation(PrismObject shadow, + 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) { + assertPendingOperationDeltas(shadow, 1); + return assertPendingOperation(shadow, shadow.asObjectable().getPendingOperation().get(0), + requestStart, requestEnd, expectedStatus, completionStart, completionEnd); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) { + return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, + OperationResultStatusType.IN_PROGRESS, null, null); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResultStatus) { + return assertPendingOperation(shadow, pendingOperation, null, null, + expectedExecutionStatus, expectedResultStatus, null, null); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + OperationResultStatusType expectedResultStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + PendingOperationExecutionStatusType expectedExecutionStatus; + if (expectedResultStatus == OperationResultStatusType.IN_PROGRESS) { + expectedExecutionStatus = PendingOperationExecutionStatusType.EXECUTING; + } else { + expectedExecutionStatus = PendingOperationExecutionStatusType.COMPLETED; + } + return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd, expectedExecutionStatus, expectedResultStatus, completionStart, completionEnd); + } + + protected PendingOperationType assertPendingOperation( + PrismObject shadow, PendingOperationType pendingOperation, + XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd, + PendingOperationExecutionStatusType expectedExecutionStatus, + OperationResultStatusType expectedResultStatus, + XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) { + assertNotNull("No operation ", pendingOperation); + + ObjectDeltaType deltaType = pendingOperation.getDelta(); + assertNotNull("No delta in pending operation in " + shadow, deltaType); + // TODO: check content of pending operations in the shadow + + TestUtil.assertBetween("No request timestamp in pending operation in " + shadow, requestStart, requestEnd, pendingOperation.getRequestTimestamp()); + + PendingOperationExecutionStatusType executiontStatus = pendingOperation.getExecutionStatus(); + assertEquals("Wrong execution status in pending operation in " + shadow, expectedExecutionStatus, executiontStatus); + + OperationResultStatusType resultStatus = pendingOperation.getResultStatus(); + assertEquals("Wrong result status in pending operation in " + shadow, expectedResultStatus, resultStatus); + + // TODO: assert other timestamps + + if (expectedExecutionStatus == PendingOperationExecutionStatusType.COMPLETED) { + TestUtil.assertBetween("No completion timestamp in pending operation in " + shadow, completionStart, completionEnd, pendingOperation.getCompletionTimestamp()); + } + + return pendingOperation; + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStaus) { + return findPendingOperation(shadow, expectedExecutionStaus, null, null, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult) { + return findPendingOperation(shadow, null, expectedResult, null, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult, ItemPath itemPath) { + return findPendingOperation(shadow, null, expectedResult, null, itemPath); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStaus, ItemPath itemPath) { + return findPendingOperation(shadow, expectedExecutionStaus, null, null, itemPath); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + OperationResultStatusType expectedResult, ChangeTypeType expectedChangeType) { + return findPendingOperation(shadow, null, expectedResult, expectedChangeType, null); + } + + protected PendingOperationType findPendingOperation(PrismObject shadow, + PendingOperationExecutionStatusType expectedExecutionStatus, OperationResultStatusType expectedResult, + ChangeTypeType expectedChangeType, ItemPath itemPath) { + List pendingOperations = shadow.asObjectable().getPendingOperation(); + for (PendingOperationType pendingOperation : pendingOperations) { + if (expectedExecutionStatus != null && !expectedExecutionStatus.equals(pendingOperation.getExecutionStatus())) { + continue; + } + if (expectedResult != null && !expectedResult.equals(pendingOperation.getResultStatus())) { + continue; + } + ObjectDeltaType delta = pendingOperation.getDelta(); + if (expectedChangeType != null) { + if (!expectedChangeType.equals(delta.getChangeType())) { + continue; + } + } + if (itemPath == null) { + return pendingOperation; + } + assertNotNull("No delta in pending operation in " + shadow, delta); + for (ItemDeltaType itemDelta : delta.getItemDelta()) { + ItemPath deltaPath = itemDelta.getPath().getItemPath(); + if (itemPath.equivalent(deltaPath)) { + return pendingOperation; + } + } + } + return null; + } + + protected UserAsserter assertUserAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUser(oid, "after"); + asserter.assertOid(oid); + return asserter; + } + + protected UserAsserter assertUserAfterByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUserByUsername(username, "after"); + asserter.display(); + asserter.assertName(username); + return asserter; + } + + protected UserAsserter assertUserBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUser(oid, "before"); + asserter.assertOid(oid); + return asserter; + } + + protected UserAsserter assertUserBeforeByUsername(String username) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + UserAsserter asserter = assertUserByUsername(username, "before"); + asserter.display(); + asserter.assertName(username); + return asserter; + } + + protected UserAsserter assertUser(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = getUser(oid); + return assertUser(user, message); + } + + protected RepoOpAsserter createRepoOpAsserter(String details) { + PerformanceInformation repoPerformanceInformation = repositoryService.getPerformanceMonitor().getThreadLocalPerformanceInformation(); + return new RepoOpAsserter(repoPerformanceInformation, details); + } + + protected UserAsserter assertUser(PrismObject user, String message) { + UserAsserter asserter = UserAsserter.forUser(user, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected UserAsserter assertUserByUsername(String username, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject user = findUserByUsername(username); + assertNotNull("User with username '" + username + "' was not found", user); + UserAsserter asserter = UserAsserter.forUser(user, message); + initializeAsserter(asserter); + return asserter; + } + + protected OrgAsserter assertOrg(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = getObject(OrgType.class, oid); + OrgAsserter asserter = assertOrg(org, message); + asserter.assertOid(oid); + return asserter; + } + + protected OrgAsserter assertOrg(PrismObject org, String message) { + OrgAsserter asserter = OrgAsserter.forOrg(org, message); + initializeAsserter(asserter); + return asserter; + } + + protected OrgAsserter assertOrgAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + OrgAsserter asserter = assertOrg(oid, "after"); + asserter.display(); + asserter.assertOid(oid); + return asserter; + } + + protected OrgAsserter assertOrgByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject org = findObjectByName(OrgType.class, name); + assertNotNull("No org with name '" + name + "'", org); + OrgAsserter asserter = OrgAsserter.forOrg(org, message); + initializeAsserter(asserter); + asserter.assertName(name); + return asserter; + } + + protected RoleAsserter assertRole(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject role = getObject(RoleType.class, oid); + RoleAsserter asserter = assertRole(role, message); + asserter.assertOid(oid); + return asserter; + } + + protected RoleAsserter assertRoleByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject role = findObjectByName(RoleType.class, name); + assertNotNull("No role with name '" + name + "'", role); + RoleAsserter asserter = assertRole(role, message); + asserter.assertName(name); + return asserter; + } + + protected RoleAsserter assertRole(PrismObject role, String message) { + RoleAsserter asserter = RoleAsserter.forRole(role, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected RoleAsserter assertRoleBefore(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRole(oid, "before"); + return asserter; + } + + protected RoleAsserter assertRoleAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRole(oid, "after"); + return asserter; + } + + protected RoleAsserter assertRoleAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + RoleAsserter asserter = assertRoleByName(name, "after"); + return asserter; + } + + protected FocusAsserter assertService(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = getObject(ServiceType.class, oid); + // TODO: change to ServiceAsserter later + FocusAsserter asserter = FocusAsserter.forFocus(service, message); + initializeAsserter(asserter); + asserter.assertOid(oid); + return asserter; + } + + protected FocusAsserter assertServiceByName(String name, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = findServiceByName(name); + // TODO: change to ServiceAsserter later + FocusAsserter asserter = FocusAsserter.forFocus(service, message); + initializeAsserter(asserter); + asserter.assertName(name); + return asserter; + } + + protected FocusAsserter assertServiceAfterByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertServiceByName(name, "after"); + } + + protected FocusAsserter assertServiceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + return assertService(oid, "after"); + } + + protected void assertNoServiceByName(String name) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject service = findServiceByName(name); + if (service != null) { + display("Unexpected service", service); + fail("Unexpected " + service); + } + } + + protected CaseAsserter assertCase(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject acase = getObject(CaseType.class, oid); + CaseAsserter asserter = CaseAsserter.forCase(acase, message); + initializeAsserter(asserter); + asserter.assertOid(oid); + return asserter; + } + + protected CaseAsserter assertCaseAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + CaseAsserter asserter = assertCase(oid, "after"); + asserter.display(); + asserter.assertOid(oid); + return asserter; + } + + protected ShadowAsserter assertModelShadow(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModel(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModelNoFetch(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(noFetch)"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowFuture(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject repoShadow = getShadowModelFuture(oid); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future)"); + asserter + .display(); + return asserter; + } + + protected ShadowAsserter assertModelShadowFutureNoFetch(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); + options.setNoFetch(true); + PrismObject repoShadow = getShadowModel(oid, options, true); + ShadowAsserter asserter = ShadowAsserter.forShadow(repoShadow, "model(future,noFetch)"); + asserter + .display(); + return asserter; + } + + protected ResourceAsserter assertResource(String oid, String message) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + PrismObject resource = getObject(ResourceType.class, oid); + return assertResource(resource, message); + } + + protected ResourceAsserter assertResource(PrismObject user, String message) { + ResourceAsserter asserter = ResourceAsserter.forResource(user, message); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ResourceAsserter assertResourceAfter(String oid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + ResourceAsserter asserter = assertResource(oid, "after"); + asserter.assertOid(oid); + return asserter; + } + + // Change to PrismObjectDefinitionAsserter later + protected PrismContainerDefinitionAsserter assertObjectDefinition(PrismObjectDefinition objectDef) { + return assertContainerDefinition(objectDef); + } + + protected PrismContainerDefinitionAsserter assertContainerDefinition(PrismContainerDefinition containerDef) { + PrismContainerDefinitionAsserter asserter = PrismContainerDefinitionAsserter.forContainerDefinition(containerDef); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ModelContextAsserter assertPreviewContext(ModelContext previewContext) { + ModelContextAsserter asserter = ModelContextAsserter.forContext(previewContext, "preview context"); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected OperationResultAsserter assertOperationResult(OperationResult result) { + OperationResultAsserter asserter = OperationResultAsserter.forResult(result); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + // SECURITY + + protected void assertGetDeny(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + assertGetDeny(type, oid, null); + } + + protected void assertGetDeny(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + Task task = createPlainTask("assertGetDeny"); + OperationResult result = task.getResult(); + try { + logAttempt("get", type, oid, null); + PrismObject object = modelService.getObject(type, oid, options, task, result); + failDeny("get", type, oid, null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("get", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected PrismObject assertGetAllow(Class type, String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + return assertGetAllow(type, oid, null); + } + + protected PrismObject assertGetAllow(Class type, String oid, Collection> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + Task task = createPlainTask("assertGetAllow"); + OperationResult result = task.getResult(); + logAttempt("get", type, oid, null); + PrismObject object = modelService.getObject(type, oid, options, task, result); + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("get", type, oid, null); + return object; + } + + protected void assertSearchFilter(Class type, ObjectFilter filter, int expectedResults) throws Exception { + assertSearch(type, prismContext.queryFactory().createQuery(filter), null, expectedResults); + } + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, int expectedResults) throws Exception { + return assertSearch(type, query, null, expectedResults); + } + + protected void assertSearchRaw(Class type, ObjectQuery query, int expectedResults) throws Exception { + assertSearch(type, query, SelectorOptions.createCollection(GetOperationOptions.createRaw()), expectedResults); + } + + protected void assertSearchDeny(Class type, ObjectQuery query, + Collection> options) throws Exception { + try { + assertSearch(type, query, options, 0); + } catch (SecurityViolationException e) { + // This is expected. The search should either return zero results or throw an exception. + logDeny("search"); + } + } + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, + Collection> options, int expectedResults) throws Exception { + ObjectQuery originalQuery = query != null ? query.clone() : null; + return assertSearch(type, query, options, + new SearchAssertion() { + + @Override + public void assertObjects(String message, List> objects) throws Exception { + if (objects.size() > expectedResults) { + failDeny(message, type, originalQuery, expectedResults, objects.size()); + } else if (objects.size() < expectedResults) { + failAllow(message, type, originalQuery, expectedResults, objects.size()); + } + } + + @Override + public void assertCount(int count) throws Exception { + if (count > expectedResults) { + failDeny("count", type, originalQuery, expectedResults, count); + } else if (count < expectedResults) { + failAllow("count", type, originalQuery, expectedResults, count); + } + } + + }); + } + + protected void assertSearch(Class type, ObjectQuery query, String... expectedOids) throws Exception { + assertSearch(type, query, null, expectedOids); + } + + protected void assertSearchFilter(Class type, ObjectFilter filter, String... expectedOids) throws Exception { + assertSearch(type, prismContext.queryFactory().createQuery(filter), expectedOids); + } + + protected void assertSearch(Class type, ObjectQuery query, + Collection> options, String... expectedOids) throws Exception { + assertSearch(type, query, options, + new SearchAssertion() { + + @Override + public void assertObjects(String message, List> objects) throws Exception { + if (!MiscUtil.unorderedCollectionEquals(objects, Arrays.asList(expectedOids), + (object, expectedOid) -> expectedOid.equals(object.getOid()))) { + failAllow(message, type, (query == null ? "null" : query.toString()) + ", expected " + Arrays.toString(expectedOids) + ", actual " + objects, null); + } + } + + @Override + public void assertCount(int count) throws Exception { + if (count != expectedOids.length) { + failAllow("count", type, query, expectedOids.length, count); + } + } + + }); + } + + protected SearchResultList> assertSearch(Class type, ObjectQuery query, + Collection> options, SearchAssertion assertion) throws Exception { + Task task = createPlainTask("assertSearchObjects"); + OperationResult result = task.getResult(); + SearchResultList> objects; + try { + logAttempt("search", type, query); + objects = modelService.searchObjects(type, query, options, task, result); + display("Search returned", objects.toString()); + assertion.assertObjects("search", objects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("search", type, query, e); + return null; // not reached + } + + task = createPlainTask("assertSearchObjectsIterative"); + result = task.getResult(); + try { + logAttempt("searchIterative", type, query); + final List> iterativeObjects = new ArrayList<>(); + ResultHandler handler = new ResultHandler() { + @Override + public boolean handle(PrismObject object, OperationResult parentResult) { + iterativeObjects.add(object); + return true; + } + }; + modelService.searchObjectsIterative(type, query, handler, options, task, result); + display("Search iterative returned", iterativeObjects.toString()); + assertion.assertObjects("searchIterative", iterativeObjects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("searchIterative", type, query, e); + return null; // not reached + } + + task = createPlainTask("assertSearchObjects.count"); + result = task.getResult(); + try { + logAttempt("count", type, query); + int numObjects = modelService.countObjects(type, query, options, task, result); + display("Count returned", numObjects); + assertion.assertCount(numObjects); + assertSuccess(result); + } catch (SecurityViolationException e) { + // this should not happen + result.computeStatus(); + TestUtil.assertFailure(result); + failAllow("search", type, query, e); + return null; // not reached + } + + return objects; + } + + protected void assertAddDeny(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + assertAddDeny(file, null); + } + + protected void assertAddDenyRaw(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + assertAddDeny(file, ModelExecuteOptions.createRaw()); + } + + protected void assertAddDeny(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + assertAddDeny(object, options); + } + + protected void assertAddDeny(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { + Task task = createPlainTask("assertAddDeny"); + OperationResult result = task.getResult(); + ObjectDelta addDelta = object.createAddDelta(); + try { + logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); + modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); + failDeny("add", object.getCompileTimeClass(), object.getOid(), null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("add", object.getCompileTimeClass(), object.getOid(), null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected void assertAddAllow(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + assertAddAllow(file, null); + } + + protected OperationResult assertAddAllowTracing(File file) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + return assertAddAllowTracing(file, null); + } + + protected void assertAddAllow(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + assertAddAllow(object, options); + } + + protected OperationResult assertAddAllowTracing(File file, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + PrismObject object = PrismTestUtil.parseObject(file); + return assertAddAllowTracing(object, options); + } + + protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + Task task = createAllowDenyTask("assertAddAllow"); + return assertAddAllow(object, options, task); + } + + protected OperationResult assertAddAllowTracing(PrismObject object, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, IOException { + Task task = createAllowDenyTask(contextName() + ".assertAddAllow"); + setTracing(task, createDefaultTracingProfile()); + return assertAddAllow(object, options, task); + } + + protected OperationResult assertAddAllow(PrismObject object, ModelExecuteOptions options, Task task) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + OperationResult result = task.getResult(); + ObjectDelta addDelta = object.createAddDelta(); + logAttempt("add", object.getCompileTimeClass(), object.getOid(), null); + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(addDelta), options, task, result); + } catch (SecurityViolationException e) { + failAllow("add", object.getCompileTimeClass(), object.getOid(), null, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("add", object.getCompileTimeClass(), object.getOid(), null); + return result; + } + + protected void assertDeleteDeny(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assertDeleteDeny(type, oid, null); + } + + protected void assertDeleteDeny(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException { + Task task = createPlainTask("assertDeleteDeny"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + try { + logAttempt("delete", type, oid, null); + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + failDeny("delete", type, oid, null); + } catch (SecurityViolationException e) { + // this is expected + logDeny("delete", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } catch (ObjectNotFoundException e) { + // MID-3221 + // still consider OK ... for now + logError("delete", type, oid, null); + result.computeStatus(); + TestUtil.assertFailure(result); + } + } + + protected void assertDeleteAllow(Class type, String oid) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + assertDeleteAllow(type, oid, null); + } + + protected void assertDeleteAllow(Class type, String oid, ModelExecuteOptions options) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { + Task task = createPlainTask("assertDeleteAllow"); + OperationResult result = task.getResult(); + ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(type, oid); + logAttempt("delete", type, oid, null); + try { + modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result); + } catch (SecurityViolationException e) { + failAllow("delete", type, oid, null, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow("delete", type, oid, null); + } + + private Task createAllowDenyTask(String opname) { + Task task = createTask("createAllowDenyTask." + opname); + task.setOwner(getSecurityContextPrincipalFocus()); + task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); + return task; + } + + protected OperationResult assertAllow(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + return assertAllow(opname, attempt, task); + } + + protected OperationResult assertAllowTracing(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + setTracing(task, createDefaultTracingProfile()); + return assertAllow(opname, attempt, task); + } + + protected OperationResult assertAllow(String opname, Attempt attempt, Task task) throws Exception { + OperationResult result = task.getResult(); + try { + logAttempt(opname); + attempt.run(task, result); + } catch (SecurityViolationException e) { + failAllow(opname, e); + } + result.computeStatus(); + TestUtil.assertSuccess(result); + logAllow(opname); + return result; + } + + protected OperationResult assertDeny(String opname, Attempt attempt) throws Exception { + Task task = createAllowDenyTask(opname); + OperationResult result = task.getResult(); + try { + logAttempt(opname); + attempt.run(task, result); + failDeny(opname); + } catch (SecurityViolationException e) { + // this is expected + logDeny(opname); + result.computeStatus(); + TestUtil.assertFailure(result); + } + return result; + } + + protected void asAdministrator(Attempt attempt) throws Exception { + Task task = createPlainTask("asAdministrator"); + OperationResult result = task.getResult(); + MidPointPrincipal origPrincipal = getSecurityContextPrincipal(); + login(USER_ADMINISTRATOR_USERNAME); + task.setOwner(getSecurityContextPrincipalFocus()); + task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI); + try { + attempt.run(task, result); + } catch (Throwable e) { + login(origPrincipal); + throw e; + } + login(origPrincipal); + result.computeStatus(); + TestUtil.assertSuccess(result); + } + + protected void logAttempt(String action) { + String msg = LOG_PREFIX_ATTEMPT + "Trying " + action; + System.out.println(msg); + logger.info(msg); + } + + protected void logDeny(String action, Class type, String oid, ItemPath itemPath) { + logDeny(action, type, oid + " prop " + itemPath); + } + + protected void logDeny(String action, Class type, String desc) { + String msg = LOG_PREFIX_DENY + "Denied " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(msg); + logger.info(msg); + } + + protected void logDeny(String action) { + String msg = LOG_PREFIX_DENY + "Denied " + action; + System.out.println(msg); + logger.info(msg); + } + + protected void logAllow(String action, Class type, String oid, ItemPath itemPath) { + logAllow(action, type, oid + " prop " + itemPath); + } + + protected void logAllow(String action, Class type, String desc) { + String msg = LOG_PREFIX_ALLOW + "Allowed " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(msg); + logger.info(msg); + } + + protected void logAllow(String action) { + String msg = LOG_PREFIX_ALLOW + "Allowed " + action; + System.out.println(msg); + logger.info(msg); + } + + protected void logError(String action, Class type, String desc, Throwable e) { + String msg = LOG_PREFIX_DENY + "Error " + action + " of " + type.getSimpleName() + ":" + desc + "(" + e + ")"; + System.out.println(msg); + logger.info(msg); + } + + protected void logAttempt(String action, Class type, ObjectQuery query) { + logAttempt(action, type, query == null ? "null" : query.toString()); + } + + protected void logAttempt(String action, Class type, String oid, ItemPath itemPath) { + logAttempt(action, type, oid + " prop " + itemPath); + } + + protected void logAttempt(String action, Class type, String desc) { + String msg = LOG_PREFIX_ATTEMPT + "Trying " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(msg); + logger.info(msg); + } + + protected void failDeny(String action, Class type, ObjectQuery query, int expected, int actual) { + failDeny(action, type, (query == null ? "null" : query.toString()) + ", expected " + expected + ", actual " + actual); + } + + protected void failDeny(String action, Class type, String oid, ItemPath itemPath) { + failDeny(action, type, oid + " prop " + itemPath); + } + + protected void failDeny(String action, Class type, String desc) { + String msg = "Failed to deny " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); + AssertJUnit.fail(msg); + } + + protected void failDeny(String action) { + String msg = "Failed to deny " + action; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); + AssertJUnit.fail(msg); + } + + protected void failAllow(String action, Class type, ObjectQuery query, SecurityViolationException e) throws SecurityViolationException { + failAllow(action, type, query == null ? "null" : query.toString(), e); + } + + protected void failAllow(String action, Class type, ObjectQuery query, int expected, int actual) throws SecurityViolationException { + failAllow(action, type, (query == null ? "null" : query.toString()) + ", expected " + expected + ", actual " + actual, null); + } + + protected void failAllow(String action, Class type, String oid, ItemPath itemPath, SecurityViolationException e) throws SecurityViolationException { + failAllow(action, type, oid + " prop " + itemPath, e); + } + + protected void failAllow(String action, Class type, String desc, SecurityViolationException e) throws SecurityViolationException { + String msg = "Failed to allow " + action + " of " + type.getSimpleName() + ":" + desc; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); + if (e != null) { + throw new SecurityViolationException(msg + ": " + e.getMessage(), e); + } else { + AssertJUnit.fail(msg); + } + } + + protected void failAllow(String action, SecurityViolationException e) throws SecurityViolationException { + String msg = "Failed to allow " + action; + System.out.println(LOG_PREFIX_FAIL + msg); + logger.error(LOG_PREFIX_FAIL + msg); + if (e != null) { + throw new SecurityViolationException(msg + ": " + e.getMessage(), e); + } else { + AssertJUnit.fail(msg); + } + } + + protected ArchetypePolicyAsserter assertArchetypePolicy(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertArchetypePolicy"); + ArchetypePolicyType archetypePolicy = modelInteractionService.determineArchetypePolicy(object, result); + ArchetypePolicyAsserter asserter = new ArchetypePolicyAsserter<>(archetypePolicy, null, "for " + object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected AssignmentCandidatesSpecificationAsserter assertAssignmentTargetSpecification(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertAssignmentTargetSpecification"); + AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentTargetSpecification(object, result); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "targets for " + object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected AssignmentCandidatesSpecificationAsserter assertAssignmentHolderSpecification(PrismObject object) throws SchemaException, ConfigurationException { + OperationResult result = new OperationResult("assertAssignmentHolderSpecification"); + AssignmentCandidatesSpecification targetSpec = modelInteractionService.determineAssignmentHolderSpecification(object, result); + AssignmentCandidatesSpecificationAsserter asserter = new AssignmentCandidatesSpecificationAsserter<>(targetSpec, null, "holders for " + object); + initializeAsserter(asserter); + asserter.display(); + return asserter; + } + + protected ExpressionVariables createVariables(Object... params) { + return ExpressionVariables.create(prismContext, params); + } + +} diff --git a/model/notifications-impl/pom.xml b/model/notifications-impl/pom.xml index e5f2d506861..30b048df08e 100644 --- a/model/notifications-impl/pom.xml +++ b/model/notifications-impl/pom.xml @@ -262,7 +262,6 @@ com.evolveum.midpoint.infra test-util - ${project.version} test diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java index 0386350d5a7..0f335fac4e8 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.notifications.impl; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import javax.xml.bind.JAXBException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.notifications.impl.formatters.TextFormatter; import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; @@ -15,6 +31,7 @@ import com.evolveum.midpoint.schema.DeltaConvertor; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; @@ -22,24 +39,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.bind.JAXBException; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - /** * @author mederly */ @@ -57,7 +56,7 @@ "classpath:ctx-model-common.xml", "classpath:ctx-notifications-test.xml", "classpath*:ctx-notifications.xml"}) -public class TestTextFormatter extends AbstractTestNGSpringContextTests { +public class TestTextFormatter extends AbstractSpringTest { public static final String OBJECTS_DIR_NAME = "src/test/resources/objects"; public static final String USER_JACK_FILE = OBJECTS_DIR_NAME + "/user-jack.xml"; @@ -258,27 +257,6 @@ public void test030FormatAccount() throws Exception { assertTrue("account password is not shown", jackFormattedHideAux.contains(PASSWORD)); assertTrue("administrative status is not shown", jackFormattedHideAux.contains(ADMINISTRATIVE_STATUS)); assertTrue("effective status is shown although it should be hidden", !jackFormattedHideAux.contains(EFFECTIVE_STATUS)); - -// AssertJUnit.assertTrue("hidden operational attribute when it should be shown ('hide none')", jackFormattedHideNone.contains("createTimestamp:")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (effective status) when it should be shown ('hide none')", jackFormattedHideNone.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be shown ('hide none')", jackFormattedHideNone.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide none')", jackFormattedHideNone.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide oper')", !jackFormattedHideOper.contains("createTimestamp:")); -// AssertJUnit.assertTrue("hidden auxiliary attribute when it should be shown ('hide oper')", jackFormattedHideOper.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden auxiliary attribute (family name) when it should be shown ('hide oper')", jackFormattedHideOper.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide oper')", jackFormattedHideOper.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown auxiliary attribute (metadata) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("createTimestamp:")); -// AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be hidden ('hide aux')", !jackFormattedHideAux.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide aux')", jackFormattedHideAux.contains("ship: Black Pearl")); -// -// AssertJUnit.assertTrue("shown operational attribute when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("createTimestamp:")); -// AssertJUnit.assertTrue("shown auxiliary attribute (effective status) when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Effective Status: ENABLED")); -// AssertJUnit.assertTrue("shown auxiliary attribute (family name) when it should be hidden ('hide aux and oper')", !jackFormattedHideAuxAndOper.contains("Family Name: Sparrow")); -// AssertJUnit.assertTrue("hidden standard attribute when it should be shown ('hide aux and oper')", jackFormattedHideAuxAndOper.contains("ship: Black Pearl")); - } diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java index b4df5d5e126..a88ec58e19d 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTransportUtils.java @@ -14,7 +14,7 @@ import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; @@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.xml.sax.SAXException; @@ -51,7 +50,7 @@ "classpath:ctx-model-common.xml", "classpath:ctx-notifications-test.xml", "classpath*:ctx-notifications.xml"}) -public class TestTransportUtils extends AbstractTestNGSpringContextTests { +public class TestTransportUtils extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(TestTransportUtils.class); @@ -68,8 +67,6 @@ public void setup() throws SchemaException, SAXException, IOException { public void test010CheckVariablesWhiteList() { final String TEST_NAME = "test010CheckVariablesWhiteList"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN NotificationTransportConfigurationType config = new NotificationTransportConfigurationType(); @@ -79,10 +76,10 @@ public void test010CheckVariablesWhiteList() { config.getWhiteList().add("majka@evodevel.*"); Task task = taskManager.createTaskInstance(); - List allowRecipient = new ArrayList(); - List forbiddenRecipient = new ArrayList(); + List allowRecipient = new ArrayList<>(); + List forbiddenRecipient = new ArrayList<>(); - List recipients = new ArrayList(); + List recipients = new ArrayList<>(); recipients.add("janko@evodevel.com"); recipients.add("janko@evolveum.com"); recipients.add("viliam@evodevel.com"); @@ -94,7 +91,7 @@ public void test010CheckVariablesWhiteList() { TransportUtil.validateRecipient(allowRecipient, forbiddenRecipient, recipients, config, task, task.getResult(), expressionFactory, MiscSchemaUtil.getExpressionProfile(), LOGGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertTrue("Expected <4> allowed recipient(s), but was <" +allowRecipient.size()+ ">", allowRecipient.size() == 4); assertTrue("janko@evodevel.com shoud be allowed, but isn't.", allowRecipient.contains("janko@evodevel.com")); @@ -111,8 +108,6 @@ public void test010CheckVariablesWhiteList() { public void test020CheckVariablesBlackList() { final String TEST_NAME = "test020CheckVariablesBlackList"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN NotificationTransportConfigurationType config = new NotificationTransportConfigurationType(); @@ -122,10 +117,10 @@ public void test020CheckVariablesBlackList() { config.getBlackList().add("majka@evodevel.*"); Task task = taskManager.createTaskInstance(); - List allowRecipient = new ArrayList(); - List forbiddenRecipient = new ArrayList(); + List allowRecipient = new ArrayList<>(); + List forbiddenRecipient = new ArrayList<>(); - List recipients = new ArrayList(); + List recipients = new ArrayList<>(); recipients.add("janko@evodevel.com"); recipients.add("janko@evolveum.com"); recipients.add("viliam@evodevel.com"); @@ -137,7 +132,7 @@ public void test020CheckVariablesBlackList() { TransportUtil.validateRecipient(allowRecipient, forbiddenRecipient, recipients, config, task, task.getResult(), expressionFactory, MiscSchemaUtil.getExpressionProfile(), LOGGER); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertTrue("Expected <4> forbidden recipient(s), but was <" +forbiddenRecipient.size()+ ">", forbiddenRecipient.size() == 4); assertTrue("janko@evodevel.com shoud be forbidden, but isn't.", forbiddenRecipient.contains("janko@evodevel.com")); diff --git a/model/report-impl/pom.xml b/model/report-impl/pom.xml index 71b1f44b91a..9d27432ea9d 100644 --- a/model/report-impl/pom.xml +++ b/model/report-impl/pom.xml @@ -251,7 +251,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java index 9481f8e5f68..378e5ba532f 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReport.java @@ -68,15 +68,14 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ReportUserList() throws Exception { final String TEST_NAME = "test100ReportUserList"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_OID); // WHEN - displayWhen(TEST_NAME); + when(); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -86,7 +85,7 @@ public void test100ReportUserList() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - displayThen(TEST_NAME); + then(); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -128,20 +127,19 @@ public void test114ReportUserListExpressionsPoisonousFieldCsv() throws Exception @Test public void test200ReportUserListScript() throws Exception { final String TEST_NAME = "test200ReportUserListScript"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject report = getObject(ReportType.class, REPORT_USER_LIST_SCRIPT_OID); // WHEN - displayWhen(TEST_NAME); + when(); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -151,7 +149,7 @@ public void test200ReportUserListScript() throws Exception { waitForTaskFinish(task.getOid(), true); // THEN - displayThen(TEST_NAME); + then(); PrismObject finishedTask = getTask(task.getOid()); display("Background task", finishedTask); @@ -178,7 +176,6 @@ public void test310ReportAudit() throws Exception { } protected void testReportListUsersCsv(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, false); @@ -189,7 +186,6 @@ protected void testReportListUsersCsv(final String TEST_NAME, String reportOid) } protected void testReportListUsersCsvFailure(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, true); @@ -200,11 +196,11 @@ protected void testReportListUsersCsvFailure(final String TEST_NAME, String repo } protected PrismObject runReport(final String TEST_NAME, PrismObject report, boolean errorOk) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reportManager.runReport(report, null, task, result); assertInProgress(result); @@ -214,7 +210,7 @@ protected PrismObject runReport(final String TEST_NAME, PrismObject finishedTask = getTask(task.getOid()); display("Background task (finished)", finishedTask); @@ -230,7 +226,7 @@ protected void checkCsvUserReport(PrismObject report) throws IOExcep display("Report content ("+lines.size()+" lines)", String.join("\n", lines)); outputFile.renameTo(new File(outputFile.getParentFile(), "processed-"+outputFile.getName())); - Task task = createTask("checkCsvUserReport"); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> currentUsers = modelService.searchObjects(UserType.class, null, null, task, result); display("Current users in midPoint ("+currentUsers.size()+" users)", currentUsers.toString()); @@ -245,7 +241,6 @@ protected void assertNoCsvReport(PrismObject report) throws IOExcept } protected void testReportAuditCsvSuccess(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); @@ -257,7 +252,6 @@ protected void testReportAuditCsvSuccess(final String TEST_NAME, String reportOi } protected void testReportAuditCsvFailure(final String TEST_NAME, String reportOid) throws Exception { - displayTestTitle(TEST_NAME); PrismObject report = getObject(ReportType.class, reportOid); PrismObject finishedTask = runReport(TEST_NAME, report, true); diff --git a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java index e4fe880b0cc..0b22a72d490 100644 --- a/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java +++ b/model/report-impl/src/test/java/com/evolveum/midpoint/report/TestReportWebService.java @@ -62,25 +62,23 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - assertNotNull("No web service", reportWebService); + assertNotNull("No web service", reportWebService); } @Test public void test100ProcessReportUserList() throws Exception { final String TEST_NAME = "test100ProcessReportUserList"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); // WHEN - displayWhen(TEST_NAME); + when(); ObjectListType userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); // THEN - displayThen(TEST_NAME); + then(); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); @@ -89,7 +87,6 @@ public void test100ProcessReportUserList() throws Exception { @Test public void test110ProcessReportUserListNoReportOid() throws Exception { final String TEST_NAME = "test110ProcessReportUserListNoReportOid"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); @@ -97,14 +94,14 @@ public void test110ProcessReportUserListNoReportOid() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); reportWebService.processReport(null, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(); display("Expected fault", f); } } @@ -112,7 +109,6 @@ public void test110ProcessReportUserListNoReportOid() throws Exception { @Test public void test112ProcessReportUserListInvalidReportOid() throws Exception { final String TEST_NAME = "test112ProcessReportUserListInvalidReportOid"; - displayTestTitle(TEST_NAME); String query = createAllQueryString(UserType.class); RemoteReportParametersType parameters = createReportParameters(); @@ -120,14 +116,14 @@ public void test112ProcessReportUserListInvalidReportOid() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); reportWebService.processReport("l00n3y", query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(); display("Expected fault", f); } } @@ -138,7 +134,6 @@ public void test112ProcessReportUserListInvalidReportOid() throws Exception { @Test public void test115ProcessReportUserListUnauthorizedReader() throws Exception { final String TEST_NAME = "test115ProcessReportUserListUnauthorizedReader"; - displayTestTitle(TEST_NAME); login(USER_READER_USERNAME); @@ -148,14 +143,14 @@ public void test115ProcessReportUserListUnauthorizedReader() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -168,7 +163,6 @@ public void test115ProcessReportUserListUnauthorizedReader() throws Exception { @Test public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { final String TEST_NAME = "test116ProcessReportUserListUnauthorizedRunner"; - displayTestTitle(TEST_NAME); login(USER_RUNNER_USERNAME); @@ -178,14 +172,14 @@ public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); assertNotReached(); } catch (Fault f) { // THEN - displayThen(TEST_NAME); + then(); display("Expected fault", f); } finally { login(USER_ADMINISTRATOR_USERNAME); @@ -198,7 +192,6 @@ public void test116ProcessReportUserListUnauthorizedRunner() throws Exception { @Test public void test119ProcessReportUserListReaderRunner() throws Exception { final String TEST_NAME = "test119ProcessReportUserListReaderRunner"; - displayTestTitle(TEST_NAME); login(USER_READER_RUNNER_USERNAME); @@ -209,7 +202,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); userList = reportWebService.processReport(REPORT_USER_LIST_EXPRESSIONS_CSV_OID, query, parameters, null); } finally { @@ -217,7 +210,7 @@ public void test119ProcessReportUserListReaderRunner() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); display("Returned user list ("+userList.getObject().size()+" objects)", userList); assertUserList(userList); @@ -235,7 +228,7 @@ private RemoteReportParametersType createReportParameters() { } private void assertUserList(ObjectListType userList) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask("assertUserList"); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> currentUsers = modelService.searchObjects(UserType.class, null, null, task, result); display("Current users in midPoint ("+currentUsers.size()+" users)", currentUsers.toString()); diff --git a/model/testng-integration.xml b/model/testng-integration.xml deleted file mode 100644 index 86d7187deb6..00000000000 --- a/model/testng-integration.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/model/testng-unit.xml b/model/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/model/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/model/workflow-impl/pom.xml b/model/workflow-impl/pom.xml index d2baa8d0607..63993dbb824 100644 --- a/model/workflow-impl/pom.xml +++ b/model/workflow-impl/pom.xml @@ -161,7 +161,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java index 627d1fe544e..1a92307e866 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/AbstractWfTestPolicy.java @@ -39,7 +39,6 @@ import com.evolveum.midpoint.wf.util.ApprovalUtils; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -87,11 +86,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } @@ -139,9 +133,7 @@ protected OperationResult executeTest(String testNameExpli prepareNotifications(); dummyAuditService.clear(); - String testName = testNameExplicit != null ? testNameExplicit : getTestNameShort(); - - Task opTask = getOrCreateTestTask(testName); + Task opTask = getTestTask(); boolean USE_FULL_TRACING = false; //noinspection ConstantConditions diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java index 9fa34099446..42403a0e2ec 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/AbstractTestAssignmentApproval.java @@ -154,8 +154,8 @@ public void test010AddRole1Assignment() throws Exception { public void test020DeleteRole1Assignment() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); LensContext context = createUserLensContext(); fillContextWithUser(context, userJackOid, result); @@ -180,7 +180,7 @@ public void test020DeleteRole1Assignment() throws Exception { public void test030AddRole1AssignmentAgain() throws Exception { login(userAdministrator); - importLead10(getTask(), getResult()); + importLead10(getTestTask(), getTestOperationResult()); executeAssignRole1ToJack(false, false, null, null, false); } @@ -269,9 +269,9 @@ public void test072AddRoles123AssignmentYYYImmediate() throws Exception { public void test100AddCreateDelegation() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // WHEN assignDeputy(userJackDeputyOid, userJackOid, a -> { @@ -294,8 +294,8 @@ public void test100AddCreateDelegation() throws Exception { public void test130AddRole1aAssignmentWithDeputy() throws Exception { login(userAdministrator); - Task task = getTask(); - importLead1Deputies(task, getResult()); + Task task = getTestTask(); + importLead1Deputies(task, getTestOperationResult()); unassignAllRoles(userJackOid); executeAssignRole1ToJack(false, true, null, null, false); @@ -384,7 +384,7 @@ protected List getExpectedWorkItems() { protected void assertDeltaExecuted(int number, boolean yes, Task opTask, OperationResult result) throws Exception { if (number == 1) { if (yes) { - assertAssignedRole(userJackOid, getRoleOid(1), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(1), result); checkAuditRecords(createResultMap(getRoleOid(1), WorkflowResult.APPROVED)); checkUserApprovers(userJackOid, Collections.singletonList(realApproverOid), result); } else { @@ -431,7 +431,7 @@ private void assertActiveWorkItems(String approverOid, int expectedCount) throws if (approverOid == null && expectedCount == 0) { return; } - Task task = createTask("query"); + Task task = getTestTask(); ObjectQuery query = prismContext.queryFor(CaseWorkItemType.class) .item(CaseWorkItemType.F_ASSIGNEE_REF).ref(getPotentialAssignees(getUser(approverOid))) .and().item(CaseWorkItemType.F_CLOSE_TIMESTAMP).isNull() @@ -527,7 +527,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 0: if (yes) { assertUserProperty(userJackOid, UserType.F_DESCRIPTION, testName); - assertAssignedRole(userJackOid, getRoleOid(4), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(4), result); } else { if (originalDescription != null) { assertUserProperty(userJackOid, UserType.F_DESCRIPTION, originalDescription); @@ -541,7 +541,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 2: case 3: if (yes) { - assertAssignedRole(userJackOid, getRoleOid(number), opTask, result); + assertAssignedRole(userJackOid, getRoleOid(number), result); } else { assertNotAssignedRole(userJackOid, getRoleOid(number), opTask, result); } @@ -574,12 +574,6 @@ public void test300ApprovalAndEnforce() throws Exception { // ignored by default (put here so that zzzMarkAsNotInitialized() will be executed after this one!) } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private void importLead10(Task task, OperationResult result) throws Exception { addAndRecomputeUser(USER_LEAD10_FILE, task, result); } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java index 1d55dc58530..eb8a0f7a3be 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentApprovalGlobal.java @@ -9,7 +9,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType; @@ -63,9 +62,9 @@ protected String getRoleName(int number) { */ public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); - Task task = getTask(); + Task task = getTestTask(); task.setOwner(userAdministrator); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); try { assignRole(userJackOid, roleRole15Oid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java index aae16adb69a..adeded9a887 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/assignments/TestAssignmentsAdvanced.java @@ -278,8 +278,8 @@ public void test230DeleteRoles123AssignmentYById() throws Exception { @Test public void test300ApprovalAndEnforce() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); try { assignRole(userJackOid, roleRole24Oid, task, result); @@ -326,8 +326,8 @@ public void test420AddRoles123AssignmentPreviewImmediate() throws Exception { @Test public void test500NoApprovers() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, roleRole26Oid, task, result); String ref = result.findAsynchronousOperationReference(); // TODO use recompute + getAsync... when fixed @@ -352,15 +352,15 @@ public void test500NoApprovers() throws Exception { @Test public void test600AssignRole29() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); assignRole(userJackOid, roleRole29Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole29Oid); @@ -371,7 +371,7 @@ public void test610ModifyAssignmentOfRole29() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole29Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -465,7 +465,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole29Oid); @@ -487,7 +487,7 @@ public void test620ModifyAssignmentOfRole29Immediate() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole29Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -582,7 +582,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, true); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole29Oid); @@ -592,15 +592,15 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases @Test public void test630UnassignRole29() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignRoleByAssignmentValue(getUser(userJackOid), roleRole29Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, roleRole29Oid); @@ -708,7 +708,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole28Oid); @@ -720,7 +720,7 @@ public void test710ModifyAssignmentOfRole28() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole28Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -816,7 +816,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertAssignedRoles(jackAfter, roleRole28Oid); @@ -828,7 +828,7 @@ public void test720UnassignRole28() throws Exception { login(userAdministrator); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignment = findAssignmentByTargetRequired(jackBefore, roleRole28Oid); ObjectDelta deltaToApprove = prismContext.deltaFor(UserType.class) @@ -925,7 +925,7 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases }, 1, false); // THEN - displayThen(); + then(); PrismObject jackAfter = getUser(userJackOid); display("jack after", jackAfter); assertNotAssignedRole(jackAfter, roleRole28Oid); @@ -934,11 +934,11 @@ protected void afterFirstClockworkRun(CaseType rootCase, List subcases @Test public void test800AssignRole27() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); ObjectDelta delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .add(ObjectTypeUtil.createAssignmentTo(roleRole27Oid, ObjectTypes.ROLE, prismContext) @@ -947,7 +947,7 @@ public void test800AssignRole27() throws Exception { executeChanges(delta, null, task, result); // should proceed without approvals (only 1 of the items is present) // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertAssignedRoles(jack, roleRole27Oid); @@ -956,11 +956,11 @@ public void test800AssignRole27() throws Exception { @Test public void test810ModifyAssignmentOfRole27() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); PrismObject jackBefore = getUser(userJackOid); AssignmentType assignmentBefore = findAssignmentByTargetRequired(jackBefore, roleRole27Oid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -971,7 +971,7 @@ public void test810ModifyAssignmentOfRole27() throws Exception { executeChanges(delta, null, task, result); // should proceed without approvals (only 1 of the items is present) // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); AssignmentType assignment = findAssignmentByTargetRequired(jack, roleRole27Oid); @@ -981,15 +981,15 @@ public void test810ModifyAssignmentOfRole27() throws Exception { @Test public void test820UnassignRole27() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignRoleByAssignmentValue(getUser(userJackOid), roleRole27Oid, task, result); // should proceed without approvals // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, roleRole27Oid); @@ -998,11 +998,11 @@ public void test820UnassignRole27() throws Exception { @Test // MID-5827 public void test900AssignIdempotentRole() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignAllRoles(userJackOid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -1017,7 +1017,7 @@ public void test900AssignIdempotentRole() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, ROLE_IDEMPOTENT.oid); @@ -1038,11 +1038,11 @@ public void test900AssignIdempotentRole() throws Exception { @Test public void test910AssignRoleWithIdempotentMetarole() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); unassignAllRoles(userJackOid); ObjectDelta delta = prismContext.deltaFor(UserType.class) @@ -1057,7 +1057,7 @@ public void test910AssignRoleWithIdempotentMetarole() throws Exception { executeChanges(delta, null, task, result); // THEN - displayThen(); + then(); PrismObject jack = getUser(userJackOid); display("jack", jack); assertNotAssignedRole(jack, ROLE_WITH_IDEMPOTENT_METAROLE.oid); @@ -1077,7 +1077,7 @@ public void test910AssignRoleWithIdempotentMetarole() throws Exception { private void executeAssignRoles123ToJack(boolean immediate, boolean approve1, boolean approve2, boolean approve3a, boolean approve3b, boolean securityDeputy) throws Exception { - Task task = getTask(); + Task task = getTestTask(); String testName = getTestNameShort(); PrismObject jack = getUser(userJackOid); ObjectDelta addRole1Delta = prismContext @@ -1174,7 +1174,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 3: String[] oids = { roleRole21Oid, roleRole22Oid, roleRole23Oid }; if (yes) { - assertAssignedRole(userJackOid, oids[number-1], opTask, result); + assertAssignedRole(userJackOid, oids[number-1], result); } else { assertNotAssignedRole(userJackOid, oids[number-1], opTask, result); } @@ -1218,8 +1218,8 @@ public List getApprovalSequence() { private void previewAssignRolesToJack(boolean immediate, boolean also24) throws Exception { String testName = getTestNameShort(); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); boolean TRACE = false; //noinspection ConstantConditions if (TRACE) { @@ -1445,15 +1445,15 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati assertNotAssignedRole(userJackOid, roleRole21Oid, opTask, result); assertNotAssignedRole(userJackOid, roleRole22Oid, opTask, result); } else { - assertAssignedRole(userJackOid, roleRole21Oid, opTask, result); - assertAssignedRole(userJackOid, roleRole22Oid, opTask, result); + assertAssignedRole(userJackOid, roleRole21Oid, result); + assertAssignedRole(userJackOid, roleRole22Oid, result); } break; case 1: if (yes) { assertNotAssignedRole(userJackOid, roleRole23Oid, opTask, result); } else { - assertAssignedRole(userJackOid, roleRole23Oid, opTask, result); + assertAssignedRole(userJackOid, roleRole23Oid, result); } break; default: @@ -1491,12 +1491,6 @@ private AssignmentType toDelete(AssignmentType assignment, boolean byId) { } } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private static class ExpectedStagePreview { @SuppressWarnings({ "FieldCanBeLocal", "unused" }) private int number; private final Set definitionApproverOids; diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java index 3637f60e4f4..bbb8bf2f4cd 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/association/TestAddAssociation.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.QNameUtil; @@ -144,7 +143,6 @@ protected File getSystemConfigurationFile() { */ @Test public void test010AddJackToTesters() throws Exception { - TestUtil.displayTestTitle(this, "test010AddJackToTesters"); executeTest("test010AddJackToTesters", USER_JACK_OID, new TestDetails() { @Override int subcasesCount() { @@ -225,7 +223,6 @@ boolean decideOnApproval(CaseType subcase, */ @Test public void test020AddElisabethToTestersRejected() throws Exception { - TestUtil.displayTestTitle(this, "test020AddElisabethToTestersRejected"); executeTest("test020AddElisabethToTestersRejected", USER_ELISABETH_OID, new TestDetails() { @Override int subcasesCount() { @@ -307,10 +304,9 @@ boolean decideOnApproval(CaseType subcase, @Test public void test100AddJackToGuests() throws Exception { final String TEST_NAME = "test100AddJackToGuests"; - TestUtil.displayTestTitle(this, TEST_NAME); Task modelTask = taskManager.createTaskInstance(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); modelTask.setOwner(repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, result)); LensContext context = createUserLensContext(); @@ -354,12 +350,6 @@ public void assertHasAssociation(ShadowType shadow, QName associationName, Strin AssertJUnit.fail("No association of type " + associationName + " of " + entitlementOid + " in " + ObjectTypeUtil.toShortString(shadow)); } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - abstract static class TestDetails { abstract int subcasesCount(); abstract boolean immediate(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java index 8850facb20b..8998eb2fb94 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/AbstractTestObjectLifecycleApproval.java @@ -93,8 +93,8 @@ protected boolean approveObjectAdd() { public void test010CreateRolePirate() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); RoleType pirate = new RoleType(prismContext); pirate.setName(PolyStringType.fromOrig("pirate")); @@ -168,12 +168,6 @@ public void test200DeleteRolePirate() throws Exception { Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem)); } - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - private void createObject(ObjectType object, boolean immediate, boolean approve, String assigneeOid) throws Exception { //noinspection unchecked ObjectDelta addObjectDelta = DeltaFactory.Object.createAddDelta((PrismObject) object.asPrismObject()); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java index 205e89fa278..ddb7fd9135c 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleAdvanced.java @@ -19,7 +19,6 @@ import com.evolveum.midpoint.schema.util.ObjectTypeUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.util.logging.Trace; @@ -87,8 +86,8 @@ protected PrismObject getDefaultActor() { public void test010CreateRoleEmployee() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject employee = prismContext.parseObject(ROLE_EMPLOYEE_FILE); executeTest(null, new TestDetails() { @@ -169,8 +168,8 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti public void test020ActivateIncompleteRole() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -203,8 +202,8 @@ public void test020ActivateIncompleteRole() throws Exception { public void test030ActivateIncompleteRoleAgain() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) @@ -235,8 +234,8 @@ public void test030ActivateIncompleteRoleAgain() throws Exception { public void test040AddApprover() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userEmployeeOwnerOid, roleEmployeeOid, SchemaConstants.ORG_APPROVER, task, result); result.computeStatus(); @@ -248,8 +247,8 @@ public void test040AddApprover() throws Exception { public void test045ActivateCompleteRole() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); @SuppressWarnings({ "raw"}) ObjectDelta activateRoleDelta = prismContext.deltaFor(RoleType.class) diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java index ed9aef415e9..fda48aa143a 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/objects/TestObjectLifecycleApprovalGlobal.java @@ -74,8 +74,8 @@ protected void updateSystemConfiguration(SystemConfigurationType systemConfigura public void test500CreateRoleJudge() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); RoleType judge = new RoleType(prismContext) .name("judge") @@ -692,10 +692,4 @@ public List getApprovalSequence() { } // TODO test that contains task0 that adds an object (i.e. rule for 'add' is not applied) - - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java index 688bd4a4d14..c5f514b3183 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/ManualResourceTest.java @@ -112,11 +112,6 @@ protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - private PrismObject createUserWill() throws SchemaException { PrismObject user = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).instantiate(); user.asObjectable() @@ -131,7 +126,7 @@ private PrismObject createUserWill() throws SchemaException { @Test public void test000Sanity() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_MANUAL_OID, null, result).asObjectable(); @@ -156,14 +151,14 @@ public void test000Sanity() throws Exception { @Test public void test012TestConnection() throws Exception { // GIVEN - Task task = getTask(); + Task task = getTestTask(); // WHEN - displayWhen(); + when(); OperationResult testResult = modelService.testResource(RESOURCE_MANUAL_OID, task); // THEN - displayThen(); + then(); display("Test result", testResult); TestUtil.assertSuccess("Test resource failed (result)", testResult); } @@ -171,18 +166,18 @@ public void test012TestConnection() throws Exception { @Test public void test100AssignWillRoleOne() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); // WHEN - displayWhen(); + when(); assignRole(userWillOid, ROLE_ONE_MANUAL_OID, task, result); // THEN - displayThen(); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -202,14 +197,14 @@ public void test100AssignWillRoleOne() throws Exception { @Test public void test110CloseCaseAndRecomputeWill() throws Exception { // GIVEN - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); // WHEN - displayWhen(); + when(); CaseType caseBefore = getCase(willLastCaseOid); display("Case before work item completion", caseBefore); @@ -236,7 +231,7 @@ public void test110CloseCaseAndRecomputeWill() throws Exception { reconcileUser(userWillOid, task, result); // THEN - displayThen(); + then(); assertSuccess(result); CaseType caseAfter = getCase(willLastCaseOid); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java index 2089bde404f..aec8874cfa1 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestDelegation.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.schema.util.CaseWorkItemUtil; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; @@ -76,8 +75,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateTask() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, ROLE_PRINCE_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_PRINCE_OID, task, result); @@ -96,8 +95,8 @@ public void test100CreateTask() throws Exception { public void test110DelegateToGirthUnauthorized() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); try { WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) @@ -117,8 +116,8 @@ public void test110DelegateToGirthUnauthorized() throws Exception { public void test120DelegateToGirth() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_GIRTH_OID)) @@ -149,8 +148,8 @@ public void test120DelegateToGirth() throws Exception { public void test130DelegateToKeenByReplace() throws Exception { login(getUserFromRepo(USER_LONGSHANKS_OID)); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .delegate(ort(USER_KEEN_OID)) @@ -178,8 +177,8 @@ public void test130DelegateToKeenByReplace() throws Exception { public void test140DelegateToNoneByReplace() throws Exception { login(getUserFromRepo(USER_KEEN_OID)); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); WorkItemDelegationRequestType request = new WorkItemDelegationRequestType(prismContext) .method(REPLACE_ASSIGNEES); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java index 23d3ecb718b..1e2a876d6c5 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEscalation.java @@ -89,8 +89,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateE1ApprovalCase() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, ROLE_E1_OID, task, result); // should start approval process assertNotAssignedRole(userJackOid, ROLE_E1_OID, task, result); @@ -117,8 +117,8 @@ public void test100CreateE1ApprovalCase() throws Exception { public void test110NotifyAfter5Days() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); clock.overrideDuration("P5DT1H"); // at P5D there's a notify action waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true); @@ -139,8 +139,8 @@ public void test110NotifyAfter5Days() throws Exception { public void test120EscalateAfter12Days() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); clock.overrideDuration("P12DT1H"); // at -P2D (i.e. P12D) there is a delegate action @@ -161,8 +161,8 @@ public void test120EscalateAfter12Days() throws Exception { public void test130CompleteAfter14Days() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); clock.overrideDuration("P14DT1H"); // at 0 (i.e. P14D) there is a delegate action @@ -176,15 +176,15 @@ public void test130CompleteAfter14Days() throws Exception { display("rootTask", rootCase); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userJackOid, ROLE_E1_OID, task, result); + assertAssignedRole(userJackOid, ROLE_E1_OID, result); } @Test public void test200CreateE2ApprovalCase() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); clock.resetOverride(); resetTriggerTask(TASK_TRIGGER_SCANNER_OID, TASK_TRIGGER_SCANNER_FILE, result); @@ -212,8 +212,8 @@ public void test200CreateE2ApprovalCase() throws Exception { public void test210EscalateAfter3Days() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); @@ -245,8 +245,8 @@ public void test210EscalateAfter3Days() throws Exception { public void test220Reject() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java index 9fcf3036aa0..2e37b68a388 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestEvents.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schema.util.CaseWorkItemUtil; import com.evolveum.midpoint.schema.util.WorkItemId; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -58,8 +57,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100CreateTask() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userJackOid, roleNoApproversOid, task, result); // should start approval process assertNotAssignedRole(userJackOid, roleNoApproversOid, task, result); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java index acc5c9e0950..97abbe1e517 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestMiscellaneous.java @@ -102,8 +102,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test100RequesterComment() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -155,7 +155,7 @@ public void test100RequesterComment() throws Exception { CaseType parentCase = getCase(aCase.getParentRef().getOid()); waitForCaseClose(parentCase); - AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_SAILOR_OID, task, result); + AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_SAILOR_OID, result); display("assignment after creation", assignment); MetadataType metadata = assignment.getMetadata(); assertNotNull("Null request timestamp in metadata", metadata.getRequestTimestamp()); @@ -167,8 +167,8 @@ public void test100RequesterComment() throws Exception { public void test105RequesterCommentImmediate() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -222,7 +222,7 @@ public void test105RequesterCommentImmediate() throws Exception { CaseType parentCase = getCase(aCase.getParentRef().getOid()); waitForCaseClose(parentCase); - AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + AssignmentType assignment = assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); display("assignment after creation", assignment); MetadataType metadata = assignment.getMetadata(); assertNotNull("Null request timestamp in metadata", metadata.getRequestTimestamp()); @@ -234,8 +234,8 @@ public void test105RequesterCommentImmediate() throws Exception { public void test110RequestPrunedRole() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -272,8 +272,8 @@ public void test110RequestPrunedRole() throws Exception { public void test200GetRoleByTemplate() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_OID); @@ -288,15 +288,15 @@ public void test200GetRoleByTemplate() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test public void test210GetRoleByTemplateAfterAssignments() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(TEMPLATE_ASSIGNING_CAPTAIN_AFTER_OID); @@ -312,15 +312,15 @@ public void test210GetRoleByTemplateAfterAssignments() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test public void test220GetRoleByFocusMappings() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(null); @@ -334,15 +334,15 @@ public void test220GetRoleByFocusMappings() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } @Test public void test250SkippingApprovals() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN setDefaultUserTemplate(null); @@ -363,6 +363,6 @@ public void test250SkippingApprovals() throws Exception { result.computeStatus(); TestUtil.assertSuccess(result); - assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, task, result); + assertAssignedRole(userJackOid, ROLE_CAPTAIN_OID, result); } } diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java index f939a8c927e..9ae8b938a53 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestParallelApprovals.java @@ -117,11 +117,11 @@ protected void updateSystemConfiguration(SystemConfigurationType systemConfigura public void test100ParallelApprovals() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN - displayWhen(); + when(); ObjectDelta assignDelta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext), @@ -165,8 +165,8 @@ public void test100ParallelApprovals() throws Exception { public void test110ParallelApprovalsAdd() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); if (listener != null) { taskManager.unregisterTaskListener(listener); @@ -175,7 +175,7 @@ public void test110ParallelApprovalsAdd() throws Exception { taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); UserType alice = prismContext.createObjectable(UserType.class) .name("alice") .assignment(ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext)) @@ -220,11 +220,9 @@ public void approveAllWorkItems(Task task, OperationResult result) throws Except public void test120ParallelApprovalsInTwoOperations() throws Exception { login(userAdministrator); - String testName = getTestNameShort(); - - Task task0 = createTask(testName); - Task task1 = createTask(testName); - Task task2 = createTask(testName); + Task task0 = createPlainTask("task0"); + Task task1 = createPlainTask("task1"); + Task task2 = createPlainTask("task2"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); @@ -236,7 +234,7 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); ObjectDelta assignDelta1 = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add( ObjectTypeUtil.createAssignmentTo(roleRole50aOid, ObjectTypes.ROLE, prismContext), @@ -286,12 +284,10 @@ public void test120ParallelApprovalsInTwoOperations() throws Exception { public void test130ParallelApprovalsInThreeSummarizingOperations() throws Exception { login(userAdministrator); - String testName = getTestNameShort(); - - Task task0 = createTask(testName); - Task task1 = createTask(testName); - Task task2 = createTask(testName); - Task task3 = createTask(testName); + Task task0 = createPlainTask("task0"); + Task task1 = createPlainTask("task1"); + Task task2 = createPlainTask("task2"); + Task task3 = createPlainTask("task3"); OperationResult result0 = task0.getResult(); OperationResult result1 = task1.getResult(); OperationResult result2 = task2.getResult(); @@ -304,7 +300,7 @@ public void test130ParallelApprovalsInThreeSummarizingOperations() throws Except taskManager.registerTaskListener(listener); // WHEN - displayWhen(); + when(); // three separate approval contexts, "summarizing" as the deltas are executed after all approvals assignRole(userChuckOid, roleRole51aOid, task1, result1); assignRole(userChuckOid, roleRole52aOid, task2, result2); diff --git a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java index a864bd75a84..36f5c215b22 100644 --- a/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java +++ b/model/workflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/other/TestSoD.java @@ -12,8 +12,6 @@ import com.evolveum.midpoint.schema.constants.ObjectTypes; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.wf.impl.AbstractWfTestPolicy; @@ -82,15 +80,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti public void test010AssignRoleJudge() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN assignRole(userJackOid, roleJudgeOid, task, result); // THEN display("jack as a Judge", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); } /** @@ -100,8 +98,8 @@ public void test010AssignRoleJudge() throws Exception { public void test020AssignRolePirate() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); PrismObject jack = getUser(userJackOid); String originalDescription = jack.asObjectable().getDescription(); @@ -119,12 +117,12 @@ public void test020AssignRolePirate() throws Exception { // WHEN+THEN executeTest2(null, new TestDetails2() { @Override - protected PrismObject getFocus(OperationResult result) throws Exception { + protected PrismObject getFocus(OperationResult result) { return jack.clone(); } @Override - protected ObjectDelta getFocusDelta() throws SchemaException { + protected ObjectDelta getFocusDelta() { return primaryDelta.clone(); } @@ -185,7 +183,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati case 1: if (yes) { - assertAssignedRole(userJackOid, rolePirateOid, opTask, result); + assertAssignedRole(userJackOid, rolePirateOid, result); } else { assertNotAssignedRole(userJackOid, rolePirateOid, opTask, result); } @@ -203,8 +201,8 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti // THEN display("jack as a Pirate + Judge", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); - assertAssignedRole(userJackOid, rolePirateOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); + assertAssignedRole(userJackOid, rolePirateOid, result); } /** @@ -214,8 +212,8 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti public void test030AssignRoleRespectable() throws Exception { login(userAdministrator); - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN unassignRole(userJackOid, rolePirateOid, task, result); @@ -223,7 +221,6 @@ public void test030AssignRoleRespectable() throws Exception { // WHEN+THEN PrismObject jack = getUser(userJackOid); - @SuppressWarnings("unchecked") ObjectDelta addRespectableDelta = prismContext .deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(createAssignmentTo(roleRespectableOid, ObjectTypes.ROLE, prismContext)) @@ -232,12 +229,12 @@ public void test030AssignRoleRespectable() throws Exception { // WHEN+THEN executeTest2(null, new TestDetails2() { @Override - protected PrismObject getFocus(OperationResult result) throws Exception { + protected PrismObject getFocus(OperationResult result) { return jack.clone(); } @Override - protected ObjectDelta getFocusDelta() throws SchemaException { + protected ObjectDelta getFocusDelta() { return addRespectableDelta.clone(); } @@ -287,7 +284,7 @@ protected void assertDeltaExecuted(int number, boolean yes, Task opTask, Operati switch (number) { case 1: if (yes) { - assertAssignedRole(userJackOid, roleRespectableOid, opTask, result); + assertAssignedRole(userJackOid, roleRespectableOid, result); } else { assertNotAssignedRole(userJackOid, roleRespectableOid, opTask, result); } @@ -305,14 +302,7 @@ protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Excepti // THEN display("jack as a Judge + Respectable", getUser(userJackOid)); - assertAssignedRole(userJackOid, roleJudgeOid, task, result); - assertAssignedRole(userJackOid, roleRespectableOid, task, result); + assertAssignedRole(userJackOid, roleJudgeOid, result); + assertAssignedRole(userJackOid, roleRespectableOid, result); } - - @Test - public void zzzMarkAsNotInitialized() { - display("Setting class as not initialized"); - unsetSystemInitialized(); - } - } diff --git a/pom.xml b/pom.xml index c52c665f450..4b0a8ebcaf4 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,6 @@ - build-tools tools infra repo @@ -112,10 +111,13 @@ true false false - + + ${describe} ${maven.build.timestamp} EEE, d MMM yyyy HH:mm:ss Z + + -Xms1024m -Xmx4096m -Xms1024m -Xmx4096m -Duser.language=en org.slf4j:jcl-over-slf4j + org.slf4j:slf4j-api org.danekja:jdk-serializable-functional @@ -1747,16 +1755,9 @@ org.apache.maven.plugins maven-checkstyle-plugin ${checkstyle.version} - - - com.evolveum.midpoint - build-tools - ${project.version} - - - midpoint-build/checkstyle.xml - midpoint-build/checkstyle-suppressions.xml + ${maven.multiModuleProjectDirectory}/config/checkstyle/checkstyle.xml + ${maven.multiModuleProjectDirectory}/config/checkstyle/checkstyle-suppressions.xml UTF-8 true true @@ -1878,9 +1879,6 @@ 1 true ${redirectTestOutputToFile} - - - false false @@ -1891,8 +1889,6 @@ ${surefire.args} - @@ -2000,9 +1996,11 @@ org.apache.maven.plugins maven-checkstyle-plugin + ${checkstyle.version} - midpoint-build/checkstyle.xml + ${maven.multiModuleProjectDirectory}/build-system/checkstyle-configs/checkstyle.xml + UTF-8 true true @@ -2084,55 +2082,5 @@ 1.8 - - - - extratest - - - - - maven-surefire-plugin - ${surefire.version} - - true - - - - maven-failsafe-plugin - ${failsafe.version} - - true - - - - - - - conntest - - - - - maven-surefire-plugin - ${surefire.version} - - true - - - - maven-failsafe-plugin - ${failsafe.version} - - true - - - - - diff --git a/provisioning/provisioning-impl/pom.xml b/provisioning/provisioning-impl/pom.xml index 473f404a9a2..dc51d917e10 100644 --- a/provisioning/provisioning-impl/pom.xml +++ b/provisioning/provisioning-impl/pom.xml @@ -133,7 +133,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java index 5149f203ffa..f1b5cbb5766 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/AbstractProvisioningIntegrationTest.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collection; @@ -20,10 +18,8 @@ import org.w3c.dom.Element; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.dummy.TestDummyResourceAndSchemaCaching; import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; import com.evolveum.midpoint.schema.GetOperationOptions; @@ -40,19 +36,10 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.asserter.ShadowAsserter; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +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.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; /** @@ -84,16 +71,15 @@ public abstract class AbstractProvisioningIntegrationTest extends AbstractIntegr private ResourceSchema lastResourceSchema = null; private RefinedResourceSchema lastRefinedResourceSchema; - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { InternalsConfig.encryptionChecks = false; - repositoryService.postInit(initResult); // initialize caches here + repositoryService.postInit(initResult); // initialize caches here provisioningService.postInit(initResult); } protected void assertVersion(PrismObject object, String expectedVersion) { - assertEquals("Wrong version of "+object, expectedVersion, object.asObjectable().getVersion()); + assertEquals("Wrong version of " + object, expectedVersion, object.asObjectable().getVersion()); } protected void rememberResourceVersion(String version) { @@ -107,7 +93,7 @@ protected void assertResourceVersionIncrement(PrismObject resource protected void assertResourceVersionIncrement(String currentVersion, int expectedIncrement) { long currentVersionLong = parseVersion(currentVersion); long actualIncrement = currentVersionLong - lastResourceVersion; - assertEquals("Unexpected increment in resource version", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in resource version", expectedIncrement, actualIncrement); lastResourceVersion = currentVersionLong; } @@ -146,7 +132,7 @@ protected void rememberResourceSchema(ResourceSchema resourceSchema) { protected void assertResourceSchemaUnchanged(ResourceSchema currentResourceSchema) { // We really want == there. We want to make sure that this is actually the same instance and that // it was properly cached - assertTrue("Resource schema has changed", lastResourceSchema == currentResourceSchema); + assertSame("Resource schema has changed", lastResourceSchema, currentResourceSchema); } protected void rememberRefinedResourceSchema(RefinedResourceSchema rResourceSchema) { @@ -154,64 +140,49 @@ protected void rememberRefinedResourceSchema(RefinedResourceSchema rResourceSche } protected void assertRefinedResourceSchemaUnchanged(RefinedResourceSchema currentRefinedResourceSchema) { - // We really want == there. We want to make sure that this is actually the same instance and that - // it was properly cached - assertTrue("Refined resource schema has changed", lastRefinedResourceSchema == currentRefinedResourceSchema); + // We really want == (identity test) here. + // We want to make sure that this is actually the same instance and that it was properly cached. + assertSame("Refined resource schema has changed", lastRefinedResourceSchema, currentRefinedResourceSchema); } protected void assertHasSchema(PrismObject resource, String desc) throws SchemaException { ResourceType resourceType = resource.asObjectable(); - display("Resource "+desc, resourceType); + display("Resource " + desc, resourceType); XmlSchemaType xmlSchemaTypeAfter = resourceType.getSchema(); - assertNotNull("No schema in "+desc, xmlSchemaTypeAfter); + assertNotNull("No schema in " + desc, xmlSchemaTypeAfter); Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceType); - assertNotNull("No schema XSD element in "+desc, resourceXsdSchemaElementAfter); - - String resourceXml = prismContext.serializeObjectToString(resource, PrismContext.LANG_XML); -// display("Resource XML", resourceXml); + assertNotNull("No schema XSD element in " + desc, resourceXsdSchemaElementAfter); CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata(); - assertNotNull("No caching metadata in "+desc, cachingMetadata); - assertNotNull("No retrievalTimestamp in "+desc, cachingMetadata.getRetrievalTimestamp()); - assertNotNull("No serialNumber in "+desc, cachingMetadata.getSerialNumber()); + assertNotNull("No caching metadata in " + desc, cachingMetadata); + assertNotNull("No retrievalTimestamp in " + desc, cachingMetadata.getRetrievalTimestamp()); + assertNotNull("No serialNumber in " + desc, cachingMetadata.getSerialNumber()); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter); ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resource.toString(), prismContext); - assertNotNull("No schema after parsing in "+desc, parsedSchema); + assertNotNull("No schema after parsing in " + desc, parsedSchema); } - protected void rememberConnectorInstance(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + ".rememberConnectorInstance"); + protected void rememberConnectorInstance(PrismObject resource) throws SchemaException { rememberConnectorInstance(resourceManager.getConfiguredConnectorInstanceFromCache(resource, ReadCapabilityType.class)); } - protected void rememberConnectorInstance(ConnectorInstance currentConnectorInstance) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void rememberConnectorInstance(ConnectorInstance currentConnectorInstance) { LOGGER.debug("Remembering connector instance {}", currentConnectorInstance); lastConfiguredConnectorInstance = currentConnectorInstance; } - protected void assertConnectorInstanceUnchanged(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void assertConnectorInstanceUnchanged(PrismObject resource) throws SchemaException { if (lastConfiguredConnectorInstance == null) { return; } - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() - + ".assertConnectorInstanceUnchanged"); ConnectorInstance currentConfiguredConnectorInstance = resourceManager.getConfiguredConnectorInstanceFromCache( resource, ReadCapabilityType.class); - assertTrue("Connector instance has changed", lastConfiguredConnectorInstance == currentConfiguredConnectorInstance); + assertSame("Connector instance has changed", lastConfiguredConnectorInstance, currentConfiguredConnectorInstance); } - protected void assertConnectorInstanceChanged(PrismObject resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { - OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() - + ".rememberConnectorInstance"); - ConnectorInstance currentConfiguredConnectorInstance = resourceManager.getConfiguredConnectorInstanceFromCache( - resource, ReadCapabilityType.class); - assertTrue("Connector instance has NOT changed", lastConfiguredConnectorInstance != currentConfiguredConnectorInstance); - lastConfiguredConnectorInstance = currentConfiguredConnectorInstance; - } - - protected void assertSteadyResource() throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException { + protected void assertSteadyResource() throws SchemaException { assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_CAPABILITIES_FETCH_COUNT, 0); assertCounterIncrement(InternalCounters.CONNECTOR_SCHEMA_PARSE_COUNT, 0); @@ -234,77 +205,49 @@ protected PrismObject getResource() { return null; } - protected void assertProvisioningNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertProvisioningNotFound"); - OperationResult result = task.getResult(); - try { - provisioningService.getObject(ShadowType.class, oid, null, task, result); - assertNotReached(); - } catch (ObjectNotFoundException e) { - // expected - } - assertFailure(result); - } - - protected void assertProvisioningFutureNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertProvisioningFutureNotFound"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - try { - provisioningService.getObject(ShadowType.class, oid, options, task, result); - assertNotReached(); - } catch (ObjectNotFoundException e) { - // expected - } - assertFailure(result); - } - protected ShadowAsserter assertShadowProvisioning(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowProvisioning"); - OperationResult result = task.getResult(); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, null, task, result); + OperationResult result = createSubresult("assertShadowProvisioning"); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, null, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "provisioning"); - asserter - .display(); + asserter.display(); return asserter; } - protected ShadowAsserter assertShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowProvisioning"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); + protected ShadowAsserter assertShadowNoFetch(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertShadowNoFetch-" + oid); + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "noFetch"); - asserter - .display(); + asserter.display(); return asserter; } - protected ShadowAsserter assertShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowFuture"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); + protected ShadowAsserter assertShadowFuture(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertShadowFuture-" + oid); + Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "future"); - asserter - .display(); + asserter.display(); return asserter; } protected ShadowAsserter assertShadowFutureNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertShadowFutureNoFetch"); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions rootOptions = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); rootOptions.setNoFetch(true); - Collection> options = SelectorOptions.createCollection(rootOptions); + Collection> options = SelectorOptions.createCollection(rootOptions); PrismObject shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, "future,noFetch"); - asserter - .display(); + asserter.display(); return asserter; } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java index a12cd5041bb..d35c3548e34 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorDiscovery.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.*; import java.util.List; @@ -25,10 +23,7 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; /** @@ -42,40 +37,34 @@ public class TestConnectorDiscovery extends AbstractIntegrationTest { @Autowired private ProvisioningService provisioningService; - private static final Trace LOGGER = TraceManager.getTrace(TestConnectorDiscovery.class); - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { provisioningService.postInit(initResult); } - /** * Check whether the connectors were discovered correctly and were added to the repository. - * @throws SchemaException - * */ @Test public void test001Connectors() throws Exception { final String TEST_NAME = "test001Connectors"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); List> connectors = repositoryService.searchObjects(ConnectorType.class, null, null, result); // THEN - displayThen(TEST_NAME); - assertFalse("No connector found",connectors.isEmpty()); - display("Found "+connectors.size()+" discovered connector"); + then(); + assertFalse("No connector found", connectors.isEmpty()); + display("Found " + connectors.size() + " discovered connector"); assertSuccess(result); for (PrismObject connector : connectors) { ConnectorType conn = connector.asObjectable(); - display("Found connector " +conn, conn); + display("Found connector " + conn, conn); IntegrationTestTools.assertConnectorSchemaSanity(conn, prismContext); } @@ -83,19 +72,17 @@ public void test001Connectors() throws Exception { } @Test - public void testListConnectors() throws Exception{ - TestUtil.displayTestTitle("testListConnectors"); - OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() - + ".listConnectorsTest"); + public void testListConnectors() throws Exception { + OperationResult result = createOperationalResult(); List> connectors = provisioningService.searchObjects(ConnectorType.class, null, null, null, result); assertNotNull(connectors); - for (PrismObject connector : connectors){ + for (PrismObject connector : connectors) { ConnectorType conn = connector.asObjectable(); System.out.println(conn.toString()); - System.out.println("connector name: "+ conn.getName()); - System.out.println("connector type: "+ conn.getConnectorType()); + System.out.println("connector name: " + conn.getName()); + System.out.println("connector type: " + conn.getConnectorType()); System.out.println("-----\n"); } @@ -103,9 +90,8 @@ public void testListConnectors() throws Exception{ } @Test - public void testSearchConnectorSimple() throws SchemaException{ + public void testSearchConnectorSimple() throws SchemaException { final String TEST_NAME = "testSearchConnectorSimple"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); @@ -113,19 +99,16 @@ public void testSearchConnectorSimple() throws SchemaException{ assertEquals("Type does not match", IntegrationTestTools.LDAP_CONNECTOR_TYPE, ldapConnector.asObjectable().getConnectorType()); } - @Test - public void testSearchConnectorAnd() throws SchemaException{ - TestUtil.displayTestTitle("testSearchConnectorAnd"); - OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() - + ".testSearchConnector"); + public void testSearchConnectorAnd() throws SchemaException { + OperationResult result = createOperationalResult(); ObjectQuery query = prismContext.queryFor(ConnectorType.class) .item(SchemaConstants.C_CONNECTOR_FRAMEWORK).eq(SchemaConstants.ICF_FRAMEWORK_URI) .and().item(SchemaConstants.C_CONNECTOR_CONNECTOR_TYPE).eq(IntegrationTestTools.LDAP_CONNECTOR_TYPE) .build(); - System.out.println("Query:\n"+query.debugDump()); + System.out.println("Query:\n" + query.debugDump()); List> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java index 4b848972ef7..c75e77340c4 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestConnectorManager.java @@ -47,16 +47,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ListConnectorFactories() throws Exception { final String TEST_NAME = "test100ListConnectorFactories"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); Collection connectorFactories = connectorManager.getConnectorFactories(); // THEN - displayThen(TEST_NAME); + then(); assertNotNull("Null connector factories", connectorFactories); assertFalse("No connector factories found", connectorFactories.isEmpty()); display("Found "+connectorFactories.size()+" connector factories"); @@ -77,24 +76,22 @@ public void test100ListConnectorFactories() throws Exception { @Test public void test110SelfTest() throws Exception { final String TEST_NAME = "test100ListConnectorFactories"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestConnectorDiscovery.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); connectorManager.connectorFrameworkSelfTest(result, task); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @Test public void test120FrameworkVersion() throws Exception { final String TEST_NAME = "test120FrameworkVersion"; - displayTestTitle(TEST_NAME); // WHEN String frameworkVersion = connectorManager.getFrameworkVersion(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java index bfbe3bb3ac8..bda2790957b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/TestDBTable.java @@ -11,7 +11,6 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; @@ -71,17 +70,6 @@ public class TestDBTable extends AbstractIntegrationTest { @Autowired private ProvisioningService provisioningService; -// @Autowired -// private TaskManager taskManager; - - @Autowired - private SynchronizationServiceMock syncServiceMock; - - - /* (non-Javadoc) - * @see com.evolveum.midpoint.test.AbstractIntegrationTest#initSystem() - */ - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { // We need to switch off the encryption checks. Some values cannot be encrypted as we do @@ -110,9 +98,7 @@ public static void stopDb() throws Exception { @Test public void test000Integrity() throws ObjectNotFoundException, SchemaException { - TestUtil.displayTestTitle("test000Integrity"); - - OperationResult result = new OperationResult(TestDBTable.class.getName()+".test000Integrity"); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result).asObjectable(); String connectorOid = resource.getConnectorRef().getOid(); @@ -123,9 +109,7 @@ public void test000Integrity() throws ObjectNotFoundException, SchemaException { @Test public void test001Connection() throws Exception { - final String TEST_NAME = "test001Connection"; - TestUtil.displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -148,11 +132,8 @@ public void test001Connection() throws Exception { @Test public void test002AddAccount() throws Exception { - final String TEST_NAME = "test002AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDBTable.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -175,7 +156,6 @@ public void test002AddAccount() throws Exception { ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result).asObjectable(); PrismAsserts.assertEqualsPolyString("Name not equal.", ACCOUNT_WILL_USERNAME, provisioningAccountType.getName()); -// assertEquals("will", provisioningAccountType.getName()); // Check database content @@ -198,11 +178,8 @@ public void test002AddAccount() throws Exception { // MID-1234 @Test(enabled=false) public void test005GetAccount() throws Exception { - final String TEST_NAME = "test005GetAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDBTable.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); Task task = taskManager.createTaskInstance(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java index e4ae589050e..4504afa7469 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/async/TestAsyncUpdate.java @@ -95,11 +95,6 @@ protected TracingProfileType getTestMethodTracingProfile() { .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { // We need to switch off the encryption checks. Some values cannot be encrypted as we do @@ -123,7 +118,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); assertNotNull("Resource is null", resource); ResourceType repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, result).asObjectable(); @@ -141,8 +136,8 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // Check that there is a schema, but no capabilities before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, @@ -188,7 +183,7 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, null, result); @@ -228,8 +223,8 @@ public void test005ParsedSchema() throws Exception { @Test public void test100ListeningForShadowAdd() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -260,8 +255,8 @@ public void test100ListeningForShadowAdd() throws Exception { @Test public void test110ListeningForValueAdd() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_110); @@ -298,8 +293,8 @@ public void test110ListeningForValueAdd() throws Exception { @Test public void test112ListeningForValueAddMore() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_112); @@ -336,8 +331,8 @@ public void test112ListeningForValueAddMore() throws Exception { @Test // MID-5832 public void test115ListeningForValueDelete() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_115); @@ -374,8 +369,8 @@ public void test115ListeningForValueDelete() throws Exception { @Test // MID-5832 public void test117ListeningForValueReplace() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_117); @@ -412,8 +407,8 @@ public void test117ListeningForValueReplace() throws Exception { @Test public void test120ListeningForShadowReplace() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_120); @@ -439,8 +434,8 @@ public void test120ListeningForShadowReplace() throws Exception { @Test public void test125ListeningForNotificationOnly() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); if (!hasReadCapability()) { System.out.println("Skipping this test because there's no real read capability"); @@ -473,8 +468,8 @@ public void test125ListeningForNotificationOnly() throws Exception { @Test public void test130ListeningForShadowDelete() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); prepareMessage(CHANGE_130); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java index 764ef24ee12..b9c3d2b2fbb 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/AbstractCsvTest.java @@ -6,16 +6,11 @@ */ package com.evolveum.midpoint.provisioning.impl.csv; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collections; import java.util.List; - import javax.xml.namespace.QName; import org.apache.commons.io.FileUtils; @@ -27,16 +22,11 @@ import org.w3c.dom.Element; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.PropertyDelta; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; @@ -50,16 +40,7 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptHostType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType.Host; @@ -68,7 +49,6 @@ * The test of Provisioning service on the API level. The test is using CSV resource. * * @author Radovan Semancik - * */ @ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml") @DirtiesContext @@ -87,8 +67,6 @@ public abstract class AbstractCsvTest extends AbstractProvisioningIntegrationTes protected static final String ACCOUNT_JACK_FIRSTNAME = "Jack"; protected static final String ACCOUNT_JACK_LASTNAME = "Sparrow"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractCsvTest.class); - protected static final String ATTR_FIRSTNAME = "firstname"; protected static final QName ATTR_FIRSTNAME_QNAME = new QName(RESOURCE_NS, ATTR_FIRSTNAME); @@ -120,14 +98,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(TEST_NAME); - assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractCsvTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -143,17 +117,15 @@ public void test000Integrity() throws Exception { /** * This should be the very first test that works with the resource. - * + *

* The original repository object does not have resource schema. The schema * should be generated from the resource on the first use. This is the test * that executes testResource and checks whether the schema was generated. */ @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, getResourceOid(), @@ -200,10 +172,8 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - final String TEST_NAME = "test004Configuration"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -215,7 +185,7 @@ public void test004Configuration() throws Exception { PrismContainerDefinition confContDef = configurationContainer.getDefinition(); assertNotNull("No configuration container definition", confContDef); PrismContainer confingurationPropertiesContainer = - configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No configuration properties container", confingurationPropertiesContainer); PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition(); assertNotNull("No configuration properties container definition", confPropDef); @@ -224,9 +194,6 @@ public void test004Configuration() throws Exception { @Test public void test005ParsedSchema() throws Exception { - final String TEST_NAME = "test005ParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); @@ -263,11 +230,8 @@ public void test005ParsedSchema() throws Exception { @Test public void test006Capabilities() throws Exception { - final String TEST_NAME = "test006Capabilities"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName()+"."+TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); @@ -278,11 +242,11 @@ public void test006Capabilities() throws Exception { CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative(); List nativeCapabilitiesList = nativeCapabilities.getAny(); - assertFalse("Empty capabilities returned",nativeCapabilitiesList.isEmpty()); + assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty()); // Connector cannot do activation, this should be null ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class); - assertNull("Found activation capability while not expecting it" ,capAct); + assertNull("Found activation capability while not expecting it", capAct); ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class); assertNotNull("No script capability", capScript); @@ -293,53 +257,47 @@ public void test006Capabilities() throws Exception { List effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource); for (Object capability : effectiveCapabilities) { - System.out.println("Capability: "+CapabilityUtil.getCapabilityDisplayName(capability)+" : "+capability); + System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability); } } private void assertScriptHost(ScriptCapabilityType capScript, ProvisioningScriptHostType expectedHostType) { - for (Host host: capScript.getHost()) { + for (Host host : capScript.getHost()) { if (host.getType() == expectedHostType) { return; } } - AssertJUnit.fail("No script capability with host type "+expectedHostType); + AssertJUnit.fail("No script capability with host type " + expectedHostType); } @Test public void test100AddAccountJack() throws Exception { - final String TEST_NAME = "test100AddAccountJack"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowBefore = parseObject(getAccountJackFile()); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.addObject(shadowBefore, null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); } @Test public void test110GetAccountJack() throws Exception { - final String TEST_NAME = "test110GetAccountJack"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, getAccountJackOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(shadow); @@ -366,10 +324,7 @@ public void test110GetAccountJack() throws Exception { @Test public void test120ModifyShadowPrimaryIdentifier() throws Exception { - final String TEST_NAME = "test120ModifyShadowPrimaryIdentifier"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadowBefore = parseObject(getAccountJackFile()); @@ -381,12 +336,12 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { display("PropertyDelta", delta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, getAccountJackOid(), Collections.singletonList(delta), null, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject repoShadow = repositoryService.getObject(ShadowType.class, shadowBefore.getOid(), null, result); ShadowType repoShadowType = repoShadow.asObjectable(); @@ -396,7 +351,4 @@ public void test120ModifyShadowPrimaryIdentifier() throws Exception { protected abstract void assertAccountJackAttributes(ShadowType shadowType); protected abstract void assertAccountJackAttributesRepo(ShadowType shadowType); - - protected abstract QName getQNameOfUID(); - } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java index 13d3911a558..d0028ce10d6 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvBroken.java @@ -75,11 +75,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti */ @Test public void test100Connection() throws Exception { - final String TEST_NAME = "test100Connection"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -121,11 +118,8 @@ public void test100Connection() throws Exception { */ @Test public void test110FixResourceAndTestConnection() throws Exception { - final String TEST_NAME = "test110FixResourceAndTestConnection"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); @@ -175,11 +169,8 @@ public void test110FixResourceAndTestConnection() throws Exception { */ @Test public void test120BreakResourceAndTestConnection() throws Exception { - final String TEST_NAME = "test120BreakResourceAndTestConnection"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); @@ -217,11 +208,8 @@ public void test120BreakResourceAndTestConnection() throws Exception { */ @Test public void test130FixResourceAndSearchObjects() throws Exception { - final String TEST_NAME = "test130FixResourceAndSearchObjects"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_OK.getPath(), result); @@ -283,14 +271,10 @@ public void test130FixResourceAndSearchObjects() throws Exception { */ @Test public void test140TwoMoreStatusChanges() throws Exception { - final String TEST_NAME = "test140TwoMoreStatusChanges"; - TestUtil.displayTestTitle(TEST_NAME); - - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); - // WHEN long before = System.currentTimeMillis(); setCsvFile(RESOURCE_CSV_BROKEN.oid, CSV_FILE_NON_EXISTING.getPath(), result); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java index d297382c807..9e634b4970e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvGuid.java @@ -115,8 +115,4 @@ protected void assertAccountJackAttributesRepo(ShadowType repoShadowType) { assertEquals("Wrong uname (repo)", ACCOUNT_JACK_UNAME, getAttributeValue(repoShadowType, ATTR_UNAME_QNAME)); } - @Override - protected QName getQNameOfUID() { - return ATTR_GUID_QNAME; - } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java index 594a44cbd82..4238e4ed075 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/csv/TestCsvUsername.java @@ -98,8 +98,4 @@ protected void assertAccountJackAttributesRepo(ShadowType repoShadowType) { assertEquals("Wrong identifier (repo)", ACCOUNT_JACK_USERNAME, getAttributeValue(repoShadowType, ATTR_USERNAME_QNAME)); } - @Override - protected QName getQNameOfUID() { - return ATTR_USERNAME_QNAME; - } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java index 67b6bb14454..d7b61005b2c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java @@ -5,34 +5,21 @@ * and European Union Public License. See LICENSE file for details. */ -/* - * - */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static com.evolveum.midpoint.test.IntegrationTestTools.assertProvisioningAccountShadow; -import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; +import static org.testng.AssertJUnit.*; +import static com.evolveum.midpoint.test.IntegrationTestTools.assertProvisioningAccountShadow; import static com.evolveum.midpoint.test.asserter.predicate.StringAssertionPredicates.startsWith; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; +import static com.evolveum.midpoint.test.asserter.predicate.TimeAssertionPredicates.approximatelyCurrent; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; - import org.apache.commons.lang.StringUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -47,33 +34,22 @@ import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.Containerable; -import com.evolveum.midpoint.prism.Definition; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.EncryptionException; import com.evolveum.midpoint.prism.delta.DiffUtil; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.match.MatchingRule; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.ProvisioningContext; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.provisioning.ucf.api.AttributesToReturn; import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; import com.evolveum.midpoint.provisioning.util.ProvisioningUtil; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.DeltaConvertor; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; @@ -84,31 +60,16 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; -import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaTestConstants; -import com.evolveum.midpoint.schema.util.ShadowUtil; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ObjectChecker; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.RunAsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** @@ -122,8 +83,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class AbstractBasicDummyTest extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractBasicDummyTest.class); - protected CachingMetadataType capabilitiesCachingMetadataType; protected String willIcfUid; protected XMLGregorianCalendar lastPasswordModifyStart; @@ -146,22 +105,18 @@ protected int getExpectedRefinedSchemaDefinitions() { } @AfterClass - public static void assertCleanShutdown() throws Exception { + public static void assertCleanShutdown() { dummyResource.assertNoConnections(); } @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResource.toString()); assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result) .asObjectable(); @@ -184,10 +139,8 @@ public void test000Integrity() throws Exception { */ @Test public void test010ListConnectors() throws Exception { - final String TEST_NAME = "test010ListConnectors"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN List> connectors = repositoryService.searchObjects(ConnectorType.class, @@ -222,8 +175,7 @@ public void test010ListConnectors() throws Exception { PrismContainerDefinition definition = schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); assertNotNull("Definition of property container not found", definition); - PrismContainerDefinition pcd = (PrismContainerDefinition) definition; - assertFalse("Empty definition", pcd.isEmpty()); + assertFalse("Empty definition", definition.isEmpty()); } } @@ -233,15 +185,13 @@ public void test010ListConnectors() throws Exception { */ @Test public void test012ConnectorRediscovery() { - final String TEST_NAME = "test012ConnectorRediscovery"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + given(); + OperationResult result = createOperationalResult(); - // WHEN + when(); Set discoverLocalConnectors = connectorManager.discoverLocalConnectors(result); - // THEN + then(); assertSuccess("discoverLocalConnectors failed", result); assertTrue("Rediscovered something", discoverLocalConnectors.isEmpty()); } @@ -252,10 +202,8 @@ public void test012ConnectorRediscovery() { */ @Test public void test015ListResourcesNoFetch() throws Exception { - final String TEST_NAME = "test015ListResourcesNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + Task task = createPlainTask(); OperationResult result = task.getResult(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -275,7 +223,7 @@ public void test015ListResourcesNoFetch() throws Exception { XmlSchemaType xmlSchemaType = resourceType.getSchema(); if (xmlSchemaType != null) { Element xsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(resourceType); - assertNull("Found schema in "+resource, xsdSchemaElement); + assertNull("Found schema in " + resource, xsdSchemaElement); } } @@ -289,17 +237,15 @@ public void test015ListResourcesNoFetch() throws Exception { /** * This should be the very first test that works with the resource. - * + *

* The original repository object does not have resource schema. The schema * should be generated from the resource on the first use. This is the test * that executes testResource and checks whether the schema was generated. */ @Test public void test020Connection() throws Exception { - final String TEST_NAME = "test020Connection"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyResource.assertNoConnections(); @@ -350,19 +296,19 @@ public void test020Connection() throws Exception { assertResource(resourceRepoAfter, "Resource after test") .display() .operationalState() - .assertAny() - .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) - .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) - .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) - .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")) - .end() + .assertAny() + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")) + .end() .operationalStateHistory() - .assertSize(1) - .value(0) - .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) - .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) - .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) - .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")); + .assertSize(1) + .value(0) + .assertPropertyEquals(OperationalStateType.F_LAST_AVAILABILITY_STATUS, AvailabilityStatusType.UP) + .assertPropertyEquals(OperationalStateType.F_NODE_ID, localNodeId) + .assertPropertyValueSatisfies(OperationalStateType.F_TIMESTAMP, approximatelyCurrent(60000)) + .assertPropertyValueSatisfies(OperationalStateType.F_MESSAGE, startsWith("Status set to UP")); XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema(); assertNotNull("No schema after test connection", xmlSchemaTypeAfter); @@ -407,16 +353,14 @@ protected void assertResourceAfterTest() { @Test public void test021Configuration() throws Exception { - final String TEST_NAME = "test021Configuration"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + given(); + OperationResult result = createOperationalResult(); - // WHEN + when(); resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); resourceType = resource.asObjectable(); - // THEN + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 0); @@ -460,12 +404,7 @@ protected void assertConfigurationProperty(PrismProperty confProp) { @Test public void test022ParsedSchema() throws Exception { - final String TEST_NAME = "test022ParsedSchema"; - displayTestTitle(TEST_NAME); - // GIVEN - - // THEN - // The returned type should have the schema pre-parsed + expect("The returned type should have the schema pre-parsed"); assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); // Also test if the utility method returns the same thing @@ -490,8 +429,6 @@ public void test022ParsedSchema() throws Exception { @Test public void test023RefinedSchema() throws Exception { - final String TEST_NAME = "test023RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -538,7 +475,7 @@ public void test023RefinedSchema() throws Exception { assertTrue("No NAME read", nameDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef)); // MID-3144 - assertEquals("Wrong NAME displayOrder", (Integer)110, nameDef.getDisplayOrder()); + assertEquals("Wrong NAME displayOrder", (Integer) 110, nameDef.getDisplayOrder()); assertEquals("Wrong NAME displayName", "Username", nameDef.getDisplayName()); RefinedAttributeDefinition fullnameDef = accountDef.findAttributeDefinition("fullname"); @@ -559,9 +496,9 @@ public void test023RefinedSchema() throws Exception { rememberRefinedResourceSchema(refinedSchema); - for (Definition def: refinedSchema.getDefinitions()) { + for (Definition def : refinedSchema.getDefinitions()) { if (!(def instanceof RefinedObjectClassDefinition)) { - fail("Non-refined definition sneaked into resource schema: "+def); + fail("Non-refined definition sneaked into resource schema: " + def); } } @@ -578,8 +515,6 @@ public void test023RefinedSchema() throws Exception { */ @Test public void test024ParsedSchemaAgain() throws Exception { - final String TEST_NAME = "test024ParsedSchemaAgain"; - displayTestTitle(TEST_NAME); // GIVEN // THEN @@ -598,18 +533,14 @@ public void test024ParsedSchemaAgain() throws Exception { @Test public void test028Capabilities() throws Exception { - final String TEST_NAME = "test028Capabilities"; - displayTestTitle(TEST_NAME); + given(); + OperationResult result = createOperationalResult(); - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); - - // WHEN + when(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); ResourceType resourceType = resource.asObjectable(); - // THEN + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -732,12 +663,8 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr */ @Test public void test029CapabilitiesRepo() throws Exception { - final String TEST_NAME = "test029CapabilitiesRepo"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN PrismObject resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -797,19 +724,15 @@ public void test029CapabilitiesRepo() throws Exception { * Create steady state of the system by invoking test connection again. * Previous operations may have modified the resource, which may have changed * resource version which might have interfered with caching. - * @throws Exception */ @Test public void test030ResourceAndConnectorCachingTestConnection() throws Exception { - final String TEST_NAME = "test030ResourceAndConnectorCachingTestConnection"; - displayTestTitle(TEST_NAME); + Task task = getTestTask(); - Task task = createTask(TEST_NAME); - - // WHEN + when(); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task); - // THEN + then(); display("Test result", testResult); assertSuccess(testResult); @@ -839,11 +762,8 @@ public void test030ResourceAndConnectorCachingTestConnection() throws Exception @Test public void test032ResourceAndConnectorCaching() throws Exception { - final String TEST_NAME = "test032ResourceAndConnectorCaching"; - displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance( resource, ReadCapabilityType.class, false, result); assertNotNull("No configuredConnectorInstance", configuredConnectorInstance); @@ -851,12 +771,12 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertNotNull("No resource schema", resourceSchema); // WHEN - displayWhen(TEST_NAME); - PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, - null, null, result); + when(); + PrismObject resourceAgain = provisioningService.getObject( + ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -890,7 +810,7 @@ public void test032ResourceAndConnectorCaching() throws Exception { resourceAgain.asObjectable().setFetchResult(null); ObjectDelta dummyResourceDiff = DiffUtil.diff(resource, resourceAgain); display("Dummy resource diff", dummyResourceDiff); - assertTrue("The resource read again is not the same as the original. diff:"+dummyResourceDiff, dummyResourceDiff.isEmpty()); + assertTrue("The resource read again is not the same as the original. diff:" + dummyResourceDiff, dummyResourceDiff.isEmpty()); // Now we stick our nose deep inside the provisioning impl. But we need // to make sure that the @@ -901,13 +821,12 @@ public void test032ResourceAndConnectorCaching() throws Exception { assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works. - OperationResult testResult = new OperationResult(TestOpenDj.class.getName() + "."+TEST_NAME+".test"); + OperationResult testResult = createOperationalResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); // Test connection should also refresh the connector by itself. So check if it has been refreshed - ConnectorInstance configuredConnectorInstanceAfterTest = resourceManager.getConfiguredConnectorInstance( resourceAgain, ReadCapabilityType.class, false, result); assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAfterTest); @@ -918,7 +837,6 @@ public void test032ResourceAndConnectorCaching() throws Exception { @Test public void test034ResourceAndConnectorCachingForceFresh() throws Exception { - displayTestTitle("test034ResourceAndConnectorCachingForceFresh"); // GIVEN OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() @@ -959,8 +877,7 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { assertTrue("Connector instance was changed", configuredConnectorInstance == configuredConnectorInstanceAgain); // Check if the connector still works - OperationResult testResult = new OperationResult(TestOpenDj.class.getName() - + ".test011ResourceAndConnectorCachingForceFresh.test"); + OperationResult testResult = createOperationalResult("test"); configuredConnectorInstanceAgain.test(testResult); testResult.computeStatus(); TestUtil.assertSuccess("Connector test failed", testResult); @@ -972,14 +889,10 @@ public void test034ResourceAndConnectorCachingForceFresh() throws Exception { assertSteadyResource(); } - @Test public void test040ApplyDefinitionShadow() throws Exception { - final String TEST_NAME = "test040ApplyDefinitionShadow"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(getAccountWillFile()); @@ -993,7 +906,7 @@ public void test040ApplyDefinitionShadow() throws Exception { TestUtil.assertSuccess(result); account.checkConsistence(true, true); - ShadowUtil.checkConsistence(account, TEST_NAME); + ShadowUtil.checkConsistence(account, getTestNameShort()); TestUtil.assertSuccess("applyDefinition(account) result", result); assertSteadyResource(); @@ -1001,11 +914,8 @@ public void test040ApplyDefinitionShadow() throws Exception { @Test public void test041ApplyDefinitionAddShadowDelta() throws Exception { - final String TEST_NAME = "test041ApplyDefinitionAddShadowDelta"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(getAccountWillFile()); @@ -1028,11 +938,8 @@ public void test041ApplyDefinitionAddShadowDelta() throws Exception { @Test public void test042ApplyDefinitionResource() throws Exception { - final String TEST_NAME = "test042ApplyDefinitionResource"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(getResourceDummyFile()); @@ -1058,11 +965,8 @@ public void test042ApplyDefinitionResource() throws Exception { @Test public void test043ApplyDefinitionAddResourceDelta() throws Exception { - final String TEST_NAME = "test043ApplyDefinitionAddResourceDelta"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = PrismTestUtil.parseObject(getResourceDummyFile()); @@ -1088,13 +992,10 @@ public void test043ApplyDefinitionAddResourceDelta() throws Exception { } @Test - public void test050SelfTest() throws Exception { - final String TEST_NAME = "test050SelfTest"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050SelfTest() { // GIVEN - Task task = createTask(TEST_NAME); - OperationResult testResult = new OperationResult(AbstractBasicDummyTest.class + "." + TEST_NAME); + Task task = getTestTask(); + OperationResult testResult = task.getResult(); // WHEN provisioningService.provisioningSelfTest(testResult, task); @@ -1106,7 +1007,7 @@ public void test050SelfTest() throws Exception { // There may be warning about illegal key size on some platforms. As far as it is warning and not error we are OK // the system will fall back to a interoperable key size if (testResult.getStatus() != OperationResultStatus.SUCCESS && testResult.getStatus() != OperationResultStatus.WARNING) { - AssertJUnit.fail("Self-test failed: "+testResult); + AssertJUnit.fail("Self-test failed: " + testResult); } } @@ -1115,9 +1016,6 @@ public void test050SelfTest() throws Exception { @Test public void test080TestAttributesToReturn() throws Exception { - final String TEST_NAME = "test080TestAttributesToReturn"; - displayTestTitle(TEST_NAME); - // GIVEN Task task = taskManager.createTaskInstance(); OperationResult result = task.getResult(); @@ -1132,7 +1030,7 @@ public void test080TestAttributesToReturn() throws Exception { display("attributesToReturn", attributesToReturn); assertFalse("wrong isReturnDefaultAttributes", attributesToReturn.isReturnDefaultAttributes()); Collection attrs = new ArrayList<>(); - for (ResourceAttributeDefinition attributeToReturnDef: attributesToReturn.getAttributesToReturn()) { + for (ResourceAttributeDefinition attributeToReturnDef : attributesToReturn.getAttributesToReturn()) { attrs.add(attributeToReturnDef.getItemName().getLocalPart()); } // No "memebers" attribute here @@ -1143,10 +1041,8 @@ public void test080TestAttributesToReturn() throws Exception { @Test public void test090ConnectorStatsAfterSomeUse() throws Exception { - final String TEST_NAME = "test090ConnectorStatsAfterSomeUse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1162,24 +1058,21 @@ public void test090ConnectorStatsAfterSomeUse() throws Exception { assertEquals("Wrong connectorClassName", getDummyConnectorClass().getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)1, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); assertSteadyResource(); } - @Test public void test100AddAccountWill() throws Exception { - final String TEST_NAME = "test100AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1191,11 +1084,11 @@ public void test100AddAccountWill() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -1214,8 +1107,8 @@ public void test100AddAccountWill() throws Exception { ActivationType activationRepo = accountRepo.asObjectable().getActivation(); if (supportsActivation()) { - assertNotNull("No activation in "+accountRepo+" (repo)", activationRepo); - assertEquals("Wrong activation enableTimestamp in "+accountRepo+" (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp()); + assertNotNull("No activation in " + accountRepo + " (repo)", activationRepo); + assertEquals("Wrong activation enableTimestamp in " + accountRepo + " (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp()); } else { assertNull("Activation sneaked in (repo)", activationRepo); } @@ -1238,10 +1131,10 @@ public void test100AddAccountWill() throws Exception { ActivationType activationProvisioning = accountTypeProvisioning.getActivation(); if (supportsActivation()) { - assertNotNull("No activation in "+accountProvisioning+" (provisioning)", activationProvisioning); - assertEquals("Wrong activation administrativeStatus in "+accountProvisioning+" (provisioning)", + assertNotNull("No activation in " + accountProvisioning + " (provisioning)", activationProvisioning); + assertEquals("Wrong activation administrativeStatus in " + accountProvisioning + " (provisioning)", ActivationStatusType.ENABLED, activationProvisioning.getAdministrativeStatus()); - TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in "+accountProvisioning+" (provisioning)", + TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in " + accountProvisioning + " (provisioning)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationProvisioning.getEnableTimestamp()); } else { assertNull("Activation sneaked in (provisioning)", activationProvisioning); @@ -1307,7 +1200,7 @@ protected void checkRepoAccountShadowWillBasic(PrismObject accountRe protected void assertPrimaryIdentifierValue(PrismObject shadow, String expected) { if (shadow.asObjectable().getLifecycleState() == null || shadow.asObjectable().getLifecycleState().equals(SchemaConstants.LIFECYCLE_ACTIVE)) { - assertEquals("Wrong primaryIdentifierValue in "+shadow, expected, shadow.asObjectable().getPrimaryIdentifierValue()); + assertEquals("Wrong primaryIdentifierValue in " + shadow, expected, shadow.asObjectable().getPrimaryIdentifierValue()); } } @@ -1328,11 +1221,8 @@ protected void checkRepoAccountShadowWill(PrismObject accountRepo, X @Test public void test102GetAccount() throws Exception { - final String TEST_NAME = "test102GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -1369,11 +1259,8 @@ public void test102GetAccount() throws Exception { @Test public void test103GetAccountNoFetch() throws Exception { - final String TEST_NAME="test103GetAccountNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() - + "."+TEST_NAME); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); GetOperationOptions rootOptions = new GetOperationOptions(); @@ -1387,7 +1274,6 @@ public void test103GetAccountNoFetch() throws Exception { ACCOUNT_WILL_OID, options, null, result); // THEN - XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar(); display("getObject result", result); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -1396,7 +1282,7 @@ public void test103GetAccountNoFetch() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountShadow(shadow, result, false, startTs, endTs); + checkAccountShadow(shadow, result, false); // This is noFetch. Therefore the read should NOT update the caching timestamp checkRepoAccountShadowWill(shadow, null, startTs); @@ -1407,11 +1293,8 @@ public void test103GetAccountNoFetch() throws Exception { @Test public void test105ApplyDefinitionModifyDelta() throws Exception { - final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectModificationType changeAddRoleCaptain = PrismTestUtil.parseAtomicValue(MODIFY_ACCOUNT_FILE, @@ -1437,10 +1320,8 @@ public void test105ApplyDefinitionModifyDelta() throws Exception { */ @Test public void test106GetModifiedAccount() throws Exception { - final String TEST_NAME = "test106GetModifiedAccount"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME); + OperationResult result = createOperationalResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); @@ -1451,11 +1332,11 @@ public void test106GetModifiedAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -1490,20 +1371,17 @@ public void test106GetModifiedAccount() throws Exception { } @Test - public void test999Shutdown() throws Exception { - final String TEST_NAME = "test999Shutdown"; - displayTestTitle(TEST_NAME); - - // WHEN + public void test999Shutdown() { + when(); provisioningService.shutdown(); - // THEN + then(); dummyResource.assertNoConnections(); } protected void checkAccountWill(PrismObject shadow, OperationResult result, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException, EncryptionException { - checkAccountShadow(shadow, result, true, startTs, endTs); + checkAccountShadow(shadow, result, true); Collection> attributes = ShadowUtil.getAttributes(shadow); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); @@ -1514,49 +1392,47 @@ protected void checkAccountWill(PrismObject shadow, OperationResult /** * We do not know what the timestamp should be */ - protected void assertRepoCachingMetadata(PrismObject shadowRepo) { - assertNull("Unexpected caching metadata in "+shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); - } - protected void assertRepoCachingMetadata(PrismObject shadowRepo, XMLGregorianCalendar start, XMLGregorianCalendar end) { - assertNull("Unexpected caching metadata in "+shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); + assertNull("Unexpected caching metadata in " + shadowRepo, shadowRepo.asObjectable().getCachingMetadata()); } protected void assertCachingMetadata(PrismObject shadow, boolean expectedCached, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) { - assertNull("Unexpected caching metadata in "+shadow, shadow.asObjectable().getCachingMetadata()); + assertNull("Unexpected caching metadata in " + shadow, shadow.asObjectable().getCachingMetadata()); } - protected void checkAccountShadow(PrismObject shadowType, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, - XMLGregorianCalendar endTs) throws SchemaException { + protected void checkAccountShadow( + PrismObject shadowType, OperationResult parentResult, boolean fullShadow) + throws SchemaException { ObjectChecker checker = createShadowChecker(fullShadow); ShadowUtil.checkConsistence(shadowType, parentResult.getOperation()); - IntegrationTestTools.checkAccountShadow(shadowType.asObjectable(), resourceType, repositoryService, checker, getUidMatchingRule(), prismContext, parentResult); + IntegrationTestTools.checkAccountShadow(shadowType.asObjectable(), resourceType, + repositoryService, checker, getUidMatchingRule(), prismContext, parentResult); } protected ObjectChecker createShadowChecker(final boolean fullShadow) { return (shadow) -> { - String icfName = ShadowUtil.getSingleStringAttributeValue(shadow, - SchemaTestConstants.ICFS_NAME); - assertNotNull("No ICF NAME", icfName); - assertEquals("Wrong shadow name ("+shadow.getName()+")", StringUtils.lowerCase(icfName), StringUtils.lowerCase(shadow.getName().getOrig())); - assertNotNull("No kind in "+shadow, shadow.getKind()); - - if (shadow.getKind() == ShadowKindType.ACCOUNT) { - if (fullShadow) { - assertNotNull( - "Missing fullname attribute", - ShadowUtil.getSingleStringAttributeValue(shadow, - new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "fullname"))); - if (supportsActivation()) { - assertNotNull("no activation", shadow.getActivation()); - assertNotNull("no activation status", shadow.getActivation().getAdministrativeStatus()); - assertEquals("not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); - } + String icfName = ShadowUtil.getSingleStringAttributeValue(shadow, + SchemaTestConstants.ICFS_NAME); + assertNotNull("No ICF NAME", icfName); + assertEquals("Wrong shadow name (" + shadow.getName() + ")", StringUtils.lowerCase(icfName), StringUtils.lowerCase(shadow.getName().getOrig())); + assertNotNull("No kind in " + shadow, shadow.getKind()); + + if (shadow.getKind() == ShadowKindType.ACCOUNT) { + if (fullShadow) { + assertNotNull( + "Missing fullname attribute", + ShadowUtil.getSingleStringAttributeValue(shadow, + new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "fullname"))); + if (supportsActivation()) { + assertNotNull("no activation", shadow.getActivation()); + assertNotNull("no activation status", shadow.getActivation().getAdministrativeStatus()); + assertEquals("not enabled", ActivationStatusType.ENABLED, shadow.getActivation().getAdministrativeStatus()); } - - assertProvisioningAccountShadow(shadow.asPrismObject(), resourceType, RefinedAttributeDefinition.class); } - }; + + assertProvisioningAccountShadow(shadow.asPrismObject(), resourceType, RefinedAttributeDefinition.class); + } + }; } protected void assertRepoShadowCachedAttributeValue(PrismObject shadowRepo, String attrName, T... attrValues) { @@ -1570,7 +1446,7 @@ protected void assertRepoShadowCacheActivation(PrismObject shadowRep return; } ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus(); - assertNull("Unexpected activation administrativeStatus in repo shadow "+shadowRepo+": "+administrativeStatus, administrativeStatus); + assertNull("Unexpected activation administrativeStatus in repo shadow " + shadowRepo + ": " + administrativeStatus, administrativeStatus); } protected void assertRepoShadowCredentials(PrismObject shadowRepo, String expectedPassword) throws SchemaException, EncryptionException { @@ -1578,12 +1454,12 @@ protected void assertRepoShadowCredentials(PrismObject shadowRepo, S if (expectedPassword == null && credentials == null) { return; } - assertNotNull("Missing credentendials in repo shadow "+shadowRepo, credentials); + assertNotNull("Missing credentendials in repo shadow " + shadowRepo, credentials); PasswordType passwordType = credentials.getPassword(); if (expectedPassword == null && passwordType == null) { return; } - assertNotNull("Missing password credential in repo shadow "+shadowRepo, passwordType); + assertNotNull("Missing password credential in repo shadow " + shadowRepo, passwordType); // TODO: assert password meta-data assertRepoShadowPasswordValue(shadowRepo, passwordType, expectedPassword); } @@ -1591,8 +1467,7 @@ protected void assertRepoShadowCredentials(PrismObject shadowRepo, S protected void assertRepoShadowPasswordValue(PrismObject shadowRepo, PasswordType passwordType, String expectedPassword) throws SchemaException, EncryptionException { ProtectedStringType passwordValue = passwordType.getValue(); - assertNull("Unexpected password value in repo shadow "+shadowRepo, passwordValue); + assertNull("Unexpected password value in repo shadow " + shadowRepo, passwordValue); } - } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java index aefc077a7f1..36b03b41744 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractDummyTest.java @@ -427,7 +427,8 @@ protected void checkRepoAccountShadow(PrismObject shadowFromRepo) { } protected void assertDummyConnectorInstances(int expectedConnectorInstances) throws NumberFormatException, IOException, InterruptedException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractDummyTest.class.getName() + ".assertDummyConnectorInstances"); + AbstractDummyTest.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); List stats = provisioningService.getConnectorOperationalStatus(RESOURCE_DUMMY_OID, task, result); display("Resource connector stats", stats); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java index f3098a8ba12..27545cf345d 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummy.java @@ -6,31 +6,18 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME; import static com.evolveum.midpoint.test.DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.FileNotFoundException; import java.net.ConnectException; import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; - +import java.util.*; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.query.*; import org.apache.commons.lang.ArrayUtils; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -38,15 +25,12 @@ import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import com.evolveum.icf.dummy.resource.ConflictException; -import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyDelta; -import com.evolveum.icf.dummy.resource.DummyDeltaType; -import com.evolveum.icf.dummy.resource.DummyGroup; -import com.evolveum.icf.dummy.resource.DummyPrivilege; -import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.icf.dummy.resource.SchemaViolationException; +import com.evolveum.icf.dummy.resource.*; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.query.*; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; @@ -54,19 +38,10 @@ import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; -import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; @@ -79,27 +54,9 @@ import com.evolveum.midpoint.test.ProvisioningScriptSpec; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.Holder; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * The test of Provisioning service on the API level. The test is using dummy @@ -122,8 +79,6 @@ public class TestDummy extends AbstractBasicDummyTest { private static final String GROUP_CORSAIRS_NAME = "corsairs"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummy.class); - private String drakeAccountOid; protected String morganIcfUid; @@ -169,7 +124,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test101AddAccountWithoutName() throws Exception { final String TEST_NAME = "test101AddAccountWithoutName"; - displayTestTitle(TEST_NAME); // GIVEN Task syncTask = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -180,11 +134,11 @@ public void test101AddAccountWithoutName() throws Exception { display("Adding shadow", account.asPrismObject()); // WHEN - displayWhen(TEST_NAME, "add"); + when("add"); String addedObjectOid = provisioningService.addObject(account.asPrismObject(), null, null, syncTask, result); // THEN - displayThen(TEST_NAME, "add"); + then("add"); result.computeStatus(); display("add object result", result); TestUtil.assertSuccess("addObject has failed (result)", result); @@ -197,12 +151,12 @@ public void test101AddAccountWithoutName() throws Exception { syncServiceMock.assertNotifySuccessOnly(); // WHEN - displayWhen(TEST_NAME, "get"); + when("get"); PrismObject provisioningAccount = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, syncTask, result); // THEN - displayThen(TEST_NAME, "get"); + then("get"); display("account from provisioning", provisioningAccount); ShadowType provisioningAccountType = provisioningAccount.asObjectable(); PrismAsserts.assertEqualsPolyString("Account name was not generated (provisioning)", transformNameFromResource(ACCOUNT_MORGAN_NAME), @@ -246,15 +200,14 @@ public void test101AddAccountWithoutName() throws Exception { /** * Make a native modification to an account and read it with max staleness option. * As there is no caching enabled this should throw an error. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test public void test107AGetModifiedAccountFromCacheMax() throws Exception { final String TEST_NAME = "test107AGetModifiedAccountFromCacheMax"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -270,7 +223,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); try { @@ -279,7 +232,7 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { assertNotReached(); } catch (ConfigurationException e) { // Caching is disabled, this is expected. - displayThen(TEST_NAME); + then(); display("Expected exception", e); assertFailure(result); } @@ -301,15 +254,14 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { /** * Make a native modification to an account and read it with high staleness option. * In this test there is no caching enabled, so this should return fresh data. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception { final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -324,12 +276,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -360,7 +312,6 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { @Test public void test108GetAccountLowStaleness() throws Exception { final String TEST_NAME = "test106GetModifiedAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -371,11 +322,11 @@ public void test108GetAccountLowStaleness() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -387,7 +338,7 @@ public void test108GetAccountLowStaleness() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountShadow(shadow, result, true, startTs, endTs); + checkAccountShadow(shadow, result, true); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); @@ -417,7 +368,6 @@ public void test108GetAccountLowStaleness() throws Exception { @Test public void test109ModifiedAccountCleanup() throws Exception { final String TEST_NAME = "test109ModifiedAccountCleanup"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -456,9 +406,8 @@ public void test109ModifiedAccountCleanup() throws Exception { } @Test - public void test110SeachIterative() throws Exception { + public void test110SearchIterative() throws Exception { final String TEST_NAME = "test110SeachIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -494,7 +443,7 @@ public boolean handle(PrismObject object, OperationResult parentResu assertTrue(object.canRepresent(ShadowType.class)); try { - checkAccountShadow(object, parentResult, true, startTs, endTs); + checkAccountShadow(object, parentResult, true); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -541,7 +490,6 @@ public boolean handle(PrismObject object, OperationResult parentResu DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook"); assertRepoCachingMetadata(shadowMeathook, startTs, endTs); - // And again ... foundObjects.clear(); @@ -577,7 +525,6 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test111SeachIterativeNoFetch() throws Exception { final String TEST_NAME = "test111SeachIterativeNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -590,23 +537,23 @@ public void test111SeachIterativeNoFetch() throws Exception { final List> foundObjects = new ArrayList<>(); ResultHandler handler = (shadow, parentResult) -> { - foundObjects.add(shadow); + foundObjects.add(shadow); - assertTrue(shadow.canRepresent(ShadowType.class)); - try { - checkCachedAccountShadow(shadow, parentResult, false, null, startTs); - } catch (SchemaException e) { - throw new SystemException(e.getMessage(), e); - } + assertTrue(shadow.canRepresent(ShadowType.class)); + try { + checkCachedAccountShadow(shadow, parentResult, false, null, startTs); + } catch (SchemaException e) { + throw new SystemException(e.getMessage(), e); + } - assertRepoCachingMetadata(shadow, null, startTs); + assertRepoCachingMetadata(shadow, null, startTs); - if (shadow.asObjectable().getName().getOrig().equals("meathook")) { - assertRepoShadowCachedAttributeValue(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey"); - } + if (shadow.asObjectable().getName().getOrig().equals("meathook")) { + assertRepoShadowCachedAttributeValue(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey"); + } - return true; - }; + return true; + }; Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); @@ -632,7 +579,6 @@ public void test111SeachIterativeNoFetch() throws Exception { @Test public void test112SeachIterativeKindIntent() throws Exception { final String TEST_NAME = "test112SeachIterativeKindIntent"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -647,11 +593,11 @@ public void test112SeachIterativeKindIntent() throws Exception { // WHEN provisioningService.searchObjectsIterative(ShadowType.class, query, null, - (object, parentResult) -> { - foundObjects.add(object); - return true; + (object, parentResult) -> { + foundObjects.add(object); + return true; }, - null, result); + null, result); // THEN result.computeStatus(); @@ -675,9 +621,9 @@ protected void assertProtected(List> shado private int countProtected(List> shadows) { int count = 0; - for (PrismObject shadow: shadows) { + for (PrismObject shadow : shadows) { if (shadow.asObjectable().isProtectedObject() != null && shadow.asObjectable().isProtectedObject()) { - count ++; + count++; } } return count; @@ -685,7 +631,6 @@ private int countProtected(List> shadows) @Test public void test113SearchAllShadowsInRepository() throws Exception { - displayTestTitle("test113SearchAllShadowsInRepository"); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + ".test113SearchAllShadowsInRepository"); @@ -711,7 +656,6 @@ public void test113SearchAllShadowsInRepository() throws Exception { @Test public void test114SearchAllAccounts() throws Exception { final String TEST_NAME = "test114SearchAllAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -742,7 +686,6 @@ public void test114SearchAllAccounts() throws Exception { @Test public void test115CountAllAccounts() throws Exception { final String TEST_NAME = "test115CountAllAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); ObjectQuery query = IntegrationTestTools.createAllShadowsQuery(resourceType, @@ -750,11 +693,11 @@ public void test115CountAllAccounts() throws Exception { display("All shadows query", query); // WHEN - displayWhen(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found " + count + " shadows"); @@ -771,7 +714,6 @@ protected Integer getTest115ExpectedCount() { @Test public void test116SearchNullQueryResource() throws Exception { final String TEST_NAME = "test116SearchNullQueryResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -795,7 +737,6 @@ public void test116SearchNullQueryResource() throws Exception { @Test public void test117CountNullQueryResource() throws Exception { - displayTestTitle("test117CountNullQueryResource"); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + ".test117CountNullQueryResource"); @@ -824,7 +765,6 @@ public void test117CountNullQueryResource() throws Exception { @Test public void test118SearchAllAccountsLongStaleness() throws Exception { final String TEST_NAME = "test118SearchAllAccountsLongStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -864,15 +804,14 @@ public void test118SearchAllAccountsLongStaleness() throws Exception { * This is supposed to return only cached data. Therefore * repo search is performed. But as caching is * not enabled in this test only errors will be returned. - * + *

* Note: This test is overridden in TestDummyCaching - * + *

* MID-3481 */ @Test public void test119SearchAllAccountsMaxStaleness() throws Exception { final String TEST_NAME = "test119SearchAllAccountsMaxStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -899,11 +838,11 @@ public void test119SearchAllAccountsMaxStaleness() throws Exception { assertFalse("No shadows found", allShadows.isEmpty()); assertEquals("Wrong number of results", 4, allShadows.size()); - for (PrismObject shadow: allShadows) { + for (PrismObject shadow : allShadows) { display("Found shadow (error expected)", shadow); OperationResultType fetchResult = shadow.asObjectable().getFetchResult(); - assertNotNull("No fetch result status in "+shadow, fetchResult); - assertEquals("Wrong fetch result status in "+shadow, OperationResultStatusType.FATAL_ERROR, fetchResult.getStatus()); + assertNotNull("No fetch result status in " + shadow, fetchResult); + assertEquals("Wrong fetch result status in " + shadow, OperationResultStatusType.FATAL_ERROR, fetchResult.getStatus()); } assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -916,9 +855,8 @@ public void test119SearchAllAccountsMaxStaleness() throws Exception { @Test public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -928,17 +866,17 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); syncServiceMock.assertNotifySuccessOnly(); @@ -948,9 +886,8 @@ public void test120ModifyWillReplaceFullname() throws Exception { @Test public void test121ModifyObjectAddPirate() throws Exception { final String TEST_NAME = "test121ModifyObjectAddPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -962,12 +899,12 @@ public void test121ModifyObjectAddPirate() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -983,9 +920,8 @@ public void test121ModifyObjectAddPirate() throws Exception { @Test public void test122ModifyObjectAddCaptain() throws Exception { final String TEST_NAME = "test122ModifyObjectAddCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -997,12 +933,12 @@ public void test122ModifyObjectAddCaptain() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -1018,9 +954,8 @@ public void test122ModifyObjectAddCaptain() throws Exception { @Test public void test123ModifyObjectDeletePirate() throws Exception { final String TEST_NAME = "test123ModifyObjectDeletePirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1031,12 +966,12 @@ public void test123ModifyObjectDeletePirate() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -1056,9 +991,8 @@ public void test123ModifyObjectDeletePirate() throws Exception { @Test public void test124ModifyAccountWillAddCaptainAgain() throws Exception { final String TEST_NAME = "test124ModifyAccountWillAddCaptainAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1069,12 +1003,12 @@ public void test124ModifyAccountWillAddCaptainAgain() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -1093,7 +1027,6 @@ public void test124ModifyAccountWillAddCaptainAgain() throws Exception { @Test public void test125CompareAccountWillPassword() throws Exception { final String TEST_NAME = "test125CompareAccountWillPassword"; - displayTestTitle(TEST_NAME); testComparePassword(TEST_NAME, "match", ACCOUNT_WILL_OID, accountWillCurrentPassword, getExpectedPasswordComparisonResultMatch()); testComparePassword(TEST_NAME, "mismatch", ACCOUNT_WILL_OID, "I woulD NeVeR ever USE this PASSword", getExpectedPasswordComparisonResultMismatch()); @@ -1107,9 +1040,8 @@ public void test125CompareAccountWillPassword() throws Exception { @Test public void test126ModifyAccountWillPassword() throws Exception { final String TEST_NAME = "test126ModifyAccountWillPassword"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1117,17 +1049,17 @@ public void test126ModifyAccountWillPassword() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertPassword(ACCOUNT_WILL_PASSWORD_123) - .assertLastModifier(null); + .assertPassword(ACCOUNT_WILL_PASSWORD_123) + .assertLastModifier(null); accountWillCurrentPassword = ACCOUNT_WILL_PASSWORD_123; @@ -1150,7 +1082,6 @@ public void test126ModifyAccountWillPassword() throws Exception { @Test public void test127CompareAccountWillPassword() throws Exception { final String TEST_NAME = "test125CompareAccountWillPassword"; - displayTestTitle(TEST_NAME); testComparePassword(TEST_NAME, "match", ACCOUNT_WILL_OID, accountWillCurrentPassword, getExpectedPasswordComparisonResultMatch()); testComparePassword(TEST_NAME, "mismatch old password", ACCOUNT_WILL_OID, ACCOUNT_WILL_PASSWORD, getExpectedPasswordComparisonResultMismatch()); @@ -1160,21 +1091,21 @@ public void test127CompareAccountWillPassword() throws Exception { } protected void testComparePassword(final String TEST_NAME, String tag, String shadowOid, String expectedPassword, ItemComparisonResult expectedResult) throws Exception { - Task task = createTask(TEST_NAME+".tag"); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN (match) - displayWhen(TEST_NAME); + when(); ItemComparisonResult comparisonResult = provisioningService.compare(ShadowType.class, shadowOid, SchemaConstants.PATH_PASSWORD_VALUE, expectedPassword, task, result); // THEN (match) - displayThen(TEST_NAME); + then(); assertSuccess(result); - display("Comparison result ("+tag+")", comparisonResult); - assertEquals("Wrong comparison result ("+tag+")", expectedResult, comparisonResult); + display("Comparison result (" + tag + ")", comparisonResult); + assertEquals("Wrong comparison result (" + tag + ")", expectedResult, comparisonResult); syncServiceMock.assertNoNotifcations(); } @@ -1185,9 +1116,8 @@ protected void testComparePassword(final String TEST_NAME, String tag, String sh @Test public void test129NullAttributeValue() throws Exception { final String TEST_NAME = "test129NullAttributeValue"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1195,11 +1125,11 @@ public void test129NullAttributeValue() throws Exception { willDummyAccount.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, null); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject accountWill = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(accountWill); @@ -1214,7 +1144,6 @@ public void test129NullAttributeValue() throws Exception { @Test public void test131AddScript() throws Exception { final String TEST_NAME = "test131AddScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1268,10 +1197,8 @@ public void test131AddScript() throws Exception { // MID-1113 @Test public void test132ModifyScript() throws Exception { - final String TEST_NAME = "test132ModifyScript"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.purgeScriptHistory(); @@ -1315,7 +1242,6 @@ public void test132ModifyScript() throws Exception { @Test public void test133ModifyScriptNoExec() throws Exception { final String TEST_NAME = "test133ModifyScriptNoExec"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1357,7 +1283,6 @@ public void test133ModifyScriptNoExec() throws Exception { @Test public void test134DeleteScript() throws Exception { final String TEST_NAME = "test134DeleteScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1394,7 +1319,6 @@ public void test134DeleteScript() throws Exception { @Test public void test135ExecuteScript() throws Exception { final String TEST_NAME = "test135ExecuteScript"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1425,7 +1349,6 @@ public void test135ExecuteScript() throws Exception { @Test public void test150DisableAccount() throws Exception { final String TEST_NAME = "test150DisableAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1460,7 +1383,7 @@ public void test150DisableAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is enabled, expected disabled", dummyAccount.isEnabled()); + assertFalse("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is enabled, expected disabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1470,7 +1393,6 @@ public void test150DisableAccount() throws Exception { @Test public void test151SearchDisabledAccounts() throws Exception { final String TEST_NAME = "test151SearchDisabledAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1503,7 +1425,6 @@ public void test151SearchDisabledAccounts() throws Exception { @Test public void test152ActivationStatusUndefinedAccount() throws Exception { final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1526,12 +1447,12 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1539,7 +1460,7 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" enabled flag", + assertEquals("Wrong dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " enabled flag", null, dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1550,7 +1471,6 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { @Test public void test154EnableAccount() throws Exception { final String TEST_NAME = "test154EnableAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1584,7 +1504,7 @@ public void test154EnableAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1594,7 +1514,6 @@ public void test154EnableAccount() throws Exception { @Test public void test155SearchDisabledAccounts() throws Exception { final String TEST_NAME = "test155SearchDisabledAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1621,11 +1540,9 @@ public void test155SearchDisabledAccounts() throws Exception { assertSteadyResource(); } - @Test public void test156SetValidFrom() throws Exception { final String TEST_NAME = "test156SetValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1642,8 +1559,6 @@ public void test156SetValidFrom() throws Exception { syncServiceMock.reset(); - long millis = VALID_FROM_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS)); @@ -1661,8 +1576,8 @@ public void test156SetValidFrom() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertEquals("Wrong account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1672,7 +1587,6 @@ public void test156SetValidFrom() throws Exception { @Test public void test157SetValidTo() throws Exception { final String TEST_NAME = "test157SetValidTo"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1689,20 +1603,18 @@ public void test157SetValidTo() throws Exception { syncServiceMock.reset(); - long millis = VALID_TO_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS)); delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1710,9 +1622,9 @@ public void test157SetValidTo() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertEquals("Wrong account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); - assertEquals("Wrong account validTo in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_TO_MILLIS), dummyAccount.getValidTo()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertEquals("Wrong account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_FROM_MILLIS), dummyAccount.getValidFrom()); + assertEquals("Wrong account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME), new Date(VALID_TO_MILLIS), dummyAccount.getValidTo()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1722,7 +1634,6 @@ public void test157SetValidTo() throws Exception { @Test public void test158DeleteValidToValidFrom() throws Exception { final String TEST_NAME = "test158DeleteValidToValidFrom"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1753,12 +1664,12 @@ public void test158DeleteValidToValidFrom() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1766,9 +1677,9 @@ public void test158DeleteValidToValidFrom() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertNull("Unexpected account validTo in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo()); - assertNull("Unexpected account validFrom in account "+transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom()); - assertTrue("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is disabled, expected enabled", dummyAccount.isEnabled()); + assertNull("Unexpected account validTo in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo()); + assertNull("Unexpected account validFrom in account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom()); + assertTrue("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is disabled, expected enabled", dummyAccount.isEnabled()); syncServiceMock.assertNotifySuccessOnly(); @@ -1778,7 +1689,6 @@ public void test158DeleteValidToValidFrom() throws Exception { @Test public void test159GetLockedoutAccount() throws Exception { final String TEST_NAME = "test159GetLockedoutAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -1789,11 +1699,11 @@ public void test159GetLockedoutAccount() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -1806,7 +1716,7 @@ public void test159GetLockedoutAccount() throws Exception { if (supportsActivation()) { PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, - LockoutStatusType.LOCKED); + LockoutStatusType.LOCKED); } else { PrismAsserts.assertNoItem(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS); } @@ -1821,7 +1731,6 @@ public void test159GetLockedoutAccount() throws Exception { @Test public void test160SearchLockedAccounts() throws Exception { final String TEST_NAME = "test160SearchLockedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1854,7 +1763,6 @@ public void test160SearchLockedAccounts() throws Exception { @Test public void test162UnlockAccount() throws Exception { final String TEST_NAME = "test162UnlockAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1877,12 +1785,12 @@ public void test162UnlockAccount() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -1890,7 +1798,7 @@ public void test162UnlockAccount() throws Exception { delta.checkConsistence(); // check if activation was changed dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); - assertFalse("Dummy account "+transformNameFromResource(ACCOUNT_WILL_USERNAME)+" is locked, expected unlocked", dummyAccount.isLockout()); + assertFalse("Dummy account " + transformNameFromResource(ACCOUNT_WILL_USERNAME) + " is locked, expected unlocked", dummyAccount.isLockout()); syncServiceMock.assertNotifySuccessOnly(); @@ -1900,7 +1808,6 @@ public void test162UnlockAccount() throws Exception { @Test public void test163GetAccount() throws Exception { final String TEST_NAME = "test163GetAccount"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -1923,7 +1830,7 @@ public void test163GetAccount() throws Exception { if (supportsActivation()) { PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, - ActivationStatusType.ENABLED); + ActivationStatusType.ENABLED); PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); } else { @@ -1941,7 +1848,6 @@ public void test163GetAccount() throws Exception { @Test public void test163SearchLockedAccounts() throws Exception { final String TEST_NAME = "test163SearchLockedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -1970,36 +1876,27 @@ public void test163SearchLockedAccounts() throws Exception { @Test public void test170SearchNull() throws Exception { - final String TEST_NAME = "test170SearchNull"; - displayTestTitle(TEST_NAME); - testSeachIterative(TEST_NAME, null, null, true, true, false, + testSeachIterative(null, null, true, true, false, "meathook", "daemon", transformNameFromResource("morgan"), transformNameFromResource("Will")); } @Test public void test171SearchShipSeaMonkey() throws Exception { - final String TEST_NAME = "test171SearchShipSeaMonkey"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey", null, true, "meathook"); } // See MID-1460 - @Test(enabled=false) + @Test(enabled = false) public void test172SearchShipNull() throws Exception { - final String TEST_NAME = "test172SearchShipNull"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, null, null, true, "daemon", "Will"); } @Test public void test173SearchWeaponCutlass() throws Exception { - final String TEST_NAME = "test173SearchWeaponCutlass"; - displayTestTitle(TEST_NAME); - // Make sure there is an account on resource that the provisioning has // never seen before, so there is no shadow // for it yet. @@ -2012,17 +1909,15 @@ public void test173SearchWeaponCutlass() throws Exception { IntegrationTestTools.display("dummy", dummyResource.debugDump()); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", null, true, transformNameFromResource("morgan"), "carla"); } @Test public void test175SearchUidExact() throws Exception { - final String TEST_NAME = "test175SearchUidExact"; - displayTestTitle(TEST_NAME); dummyResource.setDisableNameHintChecks(true); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, willIcfUid, null, true, transformNameFromResource("Will")); dummyResource.setDisableNameHintChecks(false); @@ -2030,18 +1925,14 @@ public void test175SearchUidExact() throws Exception { @Test public void test176SearchUidExactNoFetch() throws Exception { - final String TEST_NAME = "test176SearchUidExactNoFetch"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_UID, willIcfUid, + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); } @Test public void test177SearchIcfNameRepoized() throws Exception { - final String TEST_NAME = "test177SearchIcfNameRepoized"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @@ -2049,11 +1940,10 @@ SchemaConstants.ICFS_NAME, getWillRepoIcfName(), null, true, @Test public void test180SearchNullPagingOffset0Size3() throws Exception { final String TEST_NAME = "test180SearchNullPagingSize5"; - displayTestTitle(TEST_NAME); - ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(0, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18x(0,3)); + getSortedUsernames18x(0, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @@ -2064,33 +1954,30 @@ public void test180SearchNullPagingOffset0Size3() throws Exception { @Test public void test181SearchNullPagingOffset0Size3Desc() throws Exception { final String TEST_NAME = "test181SearchNullPagingOffset0Size3Desc"; - displayTestTitle(TEST_NAME); - ObjectPaging paging = prismContext.queryFactory().createPaging(0,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(0, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18xDesc(0,3)); + getSortedUsernames18xDesc(0, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @Test public void test182SearchNullPagingOffset1Size2() throws Exception { final String TEST_NAME = "test182SearchNullPagingOffset1Size2"; - displayTestTitle(TEST_NAME); - ObjectPaging paging = prismContext.queryFactory().createPaging(1,2); + ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18x(1,2)); + getSortedUsernames18x(1, 2)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @Test public void test183SearchNullPagingOffset2Size3Desc() throws Exception { final String TEST_NAME = "test183SearchNullPagingOffset1Size3Desc"; - displayTestTitle(TEST_NAME); - ObjectPaging paging = prismContext.queryFactory().createPaging(2,3); + ObjectPaging paging = prismContext.queryFactory().createPaging(2, 3); paging.setOrdering(createAttributeOrdering(SchemaConstants.ICFS_NAME, OrderDirection.DESCENDING)); SearchResultMetadata searchMetadata = testSeachIterativePaging(TEST_NAME, null, paging, null, - getSortedUsernames18xDesc(2,3)); + getSortedUsernames18xDesc(2, 3)); assertApproxNumberOfAllResults(searchMetadata, getTest18xApproxNumberOfSearchResults()); } @@ -2122,27 +2009,21 @@ protected ObjectOrdering createAttributeOrdering(QName attrQname, OrderDirection @Test public void test194SearchIcfNameRepoizedNoFetch() throws Exception { - final String TEST_NAME = "test194SearchIcfNameRepoizedNoFetch"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, getWillRepoIcfName(), + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_NAME, getWillRepoIcfName(), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @Test public void test195SearchIcfNameExact() throws Exception { - final String TEST_NAME = "test195SearchIcfNameExact"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), null, true, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @Test public void test196SearchIcfNameExactNoFetch() throws Exception { - final String TEST_NAME = "test196SearchIcfNameExactNoFetch"; - displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), + testSeachIterativeSingleAttrFilter(SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } @@ -2150,21 +2031,16 @@ public void test196SearchIcfNameExactNoFetch() throws Exception { // TEMPORARY todo move to more appropriate place (model-intest?) @Test public void test197SearchIcfNameAndUidExactNoFetch() throws Exception { - final String TEST_NAME = "test197SearchIcfNameAndUidExactNoFetch"; - displayTestTitle(TEST_NAME); - testSeachIterativeAlternativeAttrFilter(TEST_NAME, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), + testSeachIterativeAlternativeAttrFilter(SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME), SchemaConstants.ICFS_UID, willIcfUid, GetOperationOptions.createNoFetch(), false, transformNameFromResource(ACCOUNT_WILL_USERNAME)); } - @Test public void test198SearchNone() throws Exception { - final String TEST_NAME = "test198SearchNone"; - displayTestTitle(TEST_NAME); ObjectFilter attrFilter = FilterCreationUtil.createNone(prismContext); - testSeachIterative(TEST_NAME, attrFilter, null, true, true, false); + testSeachIterative(attrFilter, null, true, true, false); } /** @@ -2175,7 +2051,6 @@ public void test198SearchNone() throws Exception { @Test public void test199SearchOnAndOffResource() throws Exception { final String TEST_NAME = "test199SearchOnAndOffResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2186,7 +2061,7 @@ public void test199SearchOnAndOffResource() throws Exception { ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { - AssertJUnit.fail("Handler called: "+object); + AssertJUnit.fail("Handler called: " + object); return false; } }; @@ -2217,7 +2092,6 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test196SearchOnAndOffResourceNoFetch() throws Exception { final String TEST_NAME = "test196SearchOnAndOffResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2228,7 +2102,7 @@ public void test196SearchOnAndOffResourceNoFetch() throws Exception { ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { - AssertJUnit.fail("Handler called: "+object); + AssertJUnit.fail("Handler called: " + object); return false; } }; @@ -2260,13 +2134,13 @@ private ObjectQuery createOnOffQuery() throws SchemaException { return query; } - protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, String attrName, T attrVal, + protected void testSeachIterativeSingleAttrFilter(String attrName, T attrVal, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountIds) throws Exception { - testSeachIterativeSingleAttrFilter(TEST_NAME, dummyResourceCtl.getAttributeQName(attrName), attrVal, + testSeachIterativeSingleAttrFilter(dummyResourceCtl.getAttributeQName(attrName), attrVal, rootOptions, fullShadow, expectedAccountIds); } - protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, QName attrQName, T attrVal, + protected void testSeachIterativeSingleAttrFilter(QName attrQName, T attrVal, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME); @@ -2274,12 +2148,12 @@ protected void testSeachIterativeSingleAttrFilter(final String TEST_NAME, QN ObjectFilter filter = prismContext.queryFor(ShadowType.class) .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getItemName()).eq(attrVal) .buildFilter(); - testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, true, false, expectedAccountNames); + testSeachIterative(filter, rootOptions, fullShadow, true, false, expectedAccountNames); } - protected void testSeachIterativeAlternativeAttrFilter(final String TEST_NAME, QName attr1QName, T attr1Val, - QName attr2QName, T attr2Val, - GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { + protected void testSeachIterativeAlternativeAttrFilter(QName attr1QName, T attr1Val, + QName attr2QName, T attr2Val, + GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME); ResourceAttributeDefinition attr1Def = objectClassDef.findAttributeDefinition(attr1QName); @@ -2288,14 +2162,14 @@ protected void testSeachIterativeAlternativeAttrFilter(final String TEST_NAM .itemWithDef(attr1Def, ShadowType.F_ATTRIBUTES, attr1Def.getItemName()).eq(attr1Val) .or().itemWithDef(attr2Def, ShadowType.F_ATTRIBUTES, attr2Def.getItemName()).eq(attr2Val) .buildFilter(); - testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, false, true, expectedAccountNames); + testSeachIterative(filter, rootOptions, fullShadow, false, true, expectedAccountNames); } - - private SearchResultMetadata testSeachIterative(final String TEST_NAME, ObjectFilter attrFilter, GetOperationOptions rootOptions, - final boolean fullShadow, boolean useObjectClassFilter, final boolean useRepo, String... expectedAccountNames) throws Exception { - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + private SearchResultMetadata testSeachIterative( + ObjectFilter attrFilter, GetOperationOptions rootOptions, final boolean fullShadow, + boolean useObjectClassFilter, final boolean useRepo, String... expectedAccountNames) + throws Exception { + OperationResult result = createOperationalResult(); ObjectQuery query; if (useObjectClassFilter) { @@ -2328,7 +2202,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu assertTrue(shadow.canRepresent(ShadowType.class)); if (!useRepo) { try { - checkAccountShadow(shadow, parentResult, fullShadow, startTs, endTs); + checkAccountShadow(shadow, parentResult, fullShadow); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -2339,9 +2213,8 @@ public boolean handle(PrismObject shadow, OperationResult parentResu Collection> options = SelectorOptions.createCollection(rootOptions); - // WHEN - displayWhen(TEST_NAME); + when(); SearchResultMetadata searchMetadata; if (useRepo) { searchMetadata = repositoryService.searchObjectsIterative(ShadowType.class, query, handler, null, true, result); @@ -2350,27 +2223,27 @@ public boolean handle(PrismObject shadow, OperationResult parentResu } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); display("found shadows", foundObjects); - for (String expectedAccountId: expectedAccountNames) { + for (String expectedAccountId : expectedAccountNames) { boolean found = false; - for (PrismObject foundObject: foundObjects) { + for (PrismObject foundObject : foundObjects) { if (expectedAccountId.equals(foundObject.asObjectable().getName().getOrig())) { found = true; break; } } if (!found) { - AssertJUnit.fail("Account "+expectedAccountId+" was expected to be found but it was not found (found "+foundObjects.size()+", expected "+expectedAccountNames.length+")"); + AssertJUnit.fail("Account " + expectedAccountId + " was expected to be found but it was not found (found " + foundObjects.size() + ", expected " + expectedAccountNames.length + ")"); } } - assertEquals("Wrong number of found objects ("+foundObjects+"): "+foundObjects, expectedAccountNames.length, foundObjects.size()); + assertEquals("Wrong number of found objects (" + foundObjects + "): " + foundObjects, expectedAccountNames.length, foundObjects.size()); if (!useRepo) { checkUniqueness(foundObjects); } @@ -2386,14 +2259,13 @@ private SearchResultMetadata testSeachIterativePaging(final String TEST_NAME, Ob + "." + TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), - SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext); + SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext); if (attrFilter != null) { AndFilter filter = (AndFilter) query.getFilter(); filter.getConditions().add(attrFilter); } query.setPaging(paging); - display("Query", query); final XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); @@ -2409,7 +2281,7 @@ public boolean handle(PrismObject shadow, OperationResult parentResu assertTrue(shadow.canRepresent(ShadowType.class)); try { - checkAccountShadow(shadow, parentResult, true, startTs, endTs); + checkAccountShadow(shadow, parentResult, true); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } @@ -2419,13 +2291,12 @@ public boolean handle(PrismObject shadow, OperationResult parentResu Collection> options = SelectorOptions.createCollection(rootOptions); - // WHEN - displayWhen(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, options, handler, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("searchObjectsIterative result", result); TestUtil.assertSuccess(result); @@ -2433,15 +2304,15 @@ public boolean handle(PrismObject shadow, OperationResult parentResu display("found shadows", foundObjects); int i = 0; - for (String expectedAccountId: expectedAccountNames) { + for (String expectedAccountId : expectedAccountNames) { PrismObject foundObject = foundObjects.get(i); if (!expectedAccountId.equals(foundObject.asObjectable().getName().getOrig())) { - fail("Account "+expectedAccountId+" was expected to be found on "+i+" position, but it was not found (found "+foundObject.asObjectable().getName().getOrig()+")"); + fail("Account " + expectedAccountId + " was expected to be found on " + i + " position, but it was not found (found " + foundObject.asObjectable().getName().getOrig() + ")"); } i++; } - assertEquals("Wrong number of found objects ("+foundObjects+"): "+foundObjects, expectedAccountNames.length, foundObjects.size()); + assertEquals("Wrong number of found objects (" + foundObjects + "): " + foundObjects, expectedAccountNames.length, foundObjects.size()); checkUniqueness(foundObjects); assertSteadyResource(); @@ -2451,7 +2322,6 @@ public boolean handle(PrismObject shadow, OperationResult parentResu @Test public void test200AddGroup() throws Exception { final String TEST_NAME = "test200AddGroup"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2494,7 +2364,7 @@ public void test200AddGroup() throws Exception { // Check if the group was created in the dummy resource DummyGroup dummyGroup = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid); - assertNotNull("No dummy group "+GROUP_PIRATES_NAME, dummyGroup); + assertNotNull("No dummy group " + GROUP_PIRATES_NAME, dummyGroup); assertEquals("Description is wrong", "Scurvy pirates", dummyGroup.getAttributeValue("description")); assertTrue("The group is not enabled", dummyGroup.isEnabled()); @@ -2514,7 +2384,6 @@ public void test200AddGroup() throws Exception { @Test public void test202GetGroup() throws Exception { final String TEST_NAME = "test202GetGroup"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -2556,11 +2425,10 @@ private void checkGroupPirates(PrismObject shadow, OperationResult r @Test public void test203GetGroupNoFetch() throws Exception { - final String TEST_NAME="test203GetGroupNoFetch"; - displayTestTitle(TEST_NAME); + final String TEST_NAME = "test203GetGroupNoFetch"; // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() - + "."+TEST_NAME); + + "." + TEST_NAME); GetOperationOptions rootOptions = new GetOperationOptions(); rootOptions.setNoFetch(true); @@ -2592,7 +2460,6 @@ public void test203GetGroupNoFetch() throws Exception { @Test public void test205ModifyGroupReplace() throws Exception { final String TEST_NAME = "test205ModifyGroupReplace"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2632,7 +2499,6 @@ public void test205ModifyGroupReplace() throws Exception { @Test public void test210AddPrivilege() throws Exception { final String TEST_NAME = "test210AddPrivilege"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2669,8 +2535,8 @@ public void test210AddPrivilege() throws Exception { // Check if the priv was created in the dummy resource DummyPrivilege dummyPriv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid); - assertNotNull("No dummy priv "+PRIVILEGE_PILLAGE_NAME, dummyPriv); - assertEquals("Wrong privilege power", (Integer)100, dummyPriv.getAttributeValue(DummyResourceContoller.DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class)); + assertNotNull("No dummy priv " + PRIVILEGE_PILLAGE_NAME, dummyPriv); + assertEquals("Wrong privilege power", (Integer) 100, dummyPriv.getAttributeValue(DummyResourceContoller.DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class)); // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) PrismObject shadowFromRepo = getShadowRepo(addedObjectOid); @@ -2686,7 +2552,6 @@ public void test210AddPrivilege() throws Exception { @Test public void test212GetPriv() throws Exception { final String TEST_NAME = "test212GetPriv"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -2725,7 +2590,6 @@ private void checkPrivPillage(PrismObject shadow, OperationResult re @Test public void test214AddPrivilegeBargain() throws Exception { final String TEST_NAME = "test214AddPrivilegeBargain"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2768,7 +2632,7 @@ public void test214AddPrivilegeBargain() throws Exception { // Check if the group was created in the dummy resource DummyPrivilege dummyPriv = getDummyPrivilegeAssert(PRIVILEGE_BARGAIN_NAME, bargainIcfUid); - assertNotNull("No dummy priv "+PRIVILEGE_BARGAIN_NAME, dummyPriv); + assertNotNull("No dummy priv " + PRIVILEGE_BARGAIN_NAME, dummyPriv); // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) PrismObject shadowFromRepo = getShadowRepo(addedObjectOid); @@ -2793,11 +2657,9 @@ private void checkPrivBargain(PrismObject shadow, OperationResult re shadow, new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); } - @Test public void test220EntitleAccountWillPirates() throws Exception { final String TEST_NAME = "test220EntitleAccountWillPirates"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -2812,12 +2674,12 @@ public void test220EntitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -2843,7 +2705,6 @@ public void test220EntitleAccountWillPirates() throws Exception { @Test public void test221GetPirateWill() throws Exception { final String TEST_NAME = "test221GetPirateWill"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -2876,9 +2737,8 @@ public void test221GetPirateWill() throws Exception { @Test public void test222EntitleAccountWillPillage() throws Exception { final String TEST_NAME = "test222EntitleAccountWillPillage"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -2932,9 +2792,8 @@ public void test222EntitleAccountWillPillage() throws Exception { @Test public void test223EntitleAccountWillBargain() throws Exception { final String TEST_NAME = "test223EntitleAccountWillBargain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2980,10 +2839,7 @@ public void test223EntitleAccountWillBargain() throws Exception { */ @Test public void test224GetPillagingPirateWill() throws Exception { - final String TEST_NAME = "test224GetPillagingPirateWill"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3033,11 +2889,8 @@ public void test224GetPillagingPirateWill() throws Exception { */ @Test public void test225GetFoolishPirateWill() throws Exception { - final String TEST_NAME = "test225GetFoolishPirateWill"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupFools = new DummyGroup("fools"); @@ -3104,10 +2957,7 @@ public void test225GetFoolishPirateWill() throws Exception { */ @Test public void test226WillNonsensePrivilege() throws Exception { - final String TEST_NAME = "test226WillNonsensePrivilege"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); @@ -3165,9 +3015,8 @@ public void test226WillNonsensePrivilege() throws Exception { @Test public void test230DetitleAccountWillPirates() throws Exception { final String TEST_NAME = "test230DetitleAccountWillPirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3180,12 +3029,12 @@ public void test230DetitleAccountWillPirates() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3198,9 +3047,8 @@ public void test230DetitleAccountWillPirates() throws Exception { @Test public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test232EntitleAccountWillPiratesIdentifiersName"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3213,12 +3061,12 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3231,9 +3079,8 @@ public void test232EntitleAccountWillPiratesIdentifiersName() throws Exception { @Test public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { final String TEST_NAME = "test233DetitleAccountWillPiratesIdentifiersName"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3246,12 +3093,12 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3264,9 +3111,8 @@ public void test233DetitleAccountWillPiratesIdentifiersName() throws Exception { @Test public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test234EntitleAccountWillPiratesIdentifiersUid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3279,12 +3125,12 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesEntitled(); @@ -3297,9 +3143,8 @@ public void test234EntitleAccountWillPiratesIdentifiersUid() throws Exception { @Test public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { final String TEST_NAME = "test235DetitleAccountWillPiratesIdentifiersUid"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberDummyResourceGroupMembersReadCount(null); @@ -3312,12 +3157,12 @@ public void test235DetitleAccountWillPiratesIdentifiersUid() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); assertAccountPiratesDetitled(); @@ -3351,7 +3196,7 @@ private void assertAccountPiratesDetitled() throws Exception { assertDummyResourceGroupMembersReadCountIncrement(null, 0); syncServiceMock.assertNotifySuccessOnly(); - Task task = createTask("assertAccountPiratesDetitled"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow after", shadow); @@ -3389,7 +3234,7 @@ private void assertAccountPiratesEntitled() throws Exception { assertDummyResourceGroupMembersReadCountIncrement(null, 0); syncServiceMock.assertNotifySuccessOnly(); - Task task = createTask("assertAccountPiratesDetitled"); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); display("Shadow after", shadow); @@ -3402,10 +3247,7 @@ private void assertAccountPiratesEntitled() throws Exception { @Test public void test238DetitleAccountWillPillage() throws Exception { - final String TEST_NAME = "test238DetitleAccountWillPillage"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3445,16 +3287,12 @@ public void test238DetitleAccountWillPillage() throws Exception { display("Shadow after", shadow); assertEntitlementPriv(shadow, PRIVILEGE_BARGAIN_OID); - assertSteadyResource(); } @Test public void test239DetitleAccountWillBargain() throws Exception { - final String TEST_NAME = "test239DetitleAccountWillBargain"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3498,10 +3336,8 @@ public void test239DetitleAccountWillBargain() throws Exception { */ @Test public void test260AddAccountLeChuck() throws Exception { - final String TEST_NAME = "test260AddAccountLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3583,10 +3419,8 @@ public void test260AddAccountLeChuck() throws Exception { */ @Test public void test265DeleteAccountLeChuck() throws Exception { - final String TEST_NAME = "test265DeleteAccountLeChuck"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3634,10 +3468,7 @@ public void test265DeleteAccountLeChuck() throws Exception { @Test public void test298DeletePrivPillage() throws Exception { - final String TEST_NAME = "test298DeletePrivPillage"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3674,10 +3505,7 @@ public void test298DeletePrivPillage() throws Exception { @Test public void test299DeleteGroupPirates() throws Exception { - final String TEST_NAME = "test299DeleteGroupPirates"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3707,7 +3535,7 @@ public void test299DeleteGroupPirates() throws Exception { } DummyGroup dummyAccount = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); - assertNull("Dummy group '"+GROUP_PIRATES_NAME+"' is not gone from dummy resource", dummyAccount); + assertNull("Dummy group '" + GROUP_PIRATES_NAME + "' is not gone from dummy resource", dummyAccount); assertSteadyResource(); } @@ -3715,9 +3543,8 @@ public void test299DeleteGroupPirates() throws Exception { @Test public void test300AccountRename() throws Exception { final String TEST_NAME = "test300AccountRename"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3729,12 +3556,12 @@ public void test300AccountRename() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -3769,9 +3596,8 @@ public void test300AccountRename() throws Exception { @Test public void test310ModifyMorganEnlistTimestamp() throws Exception { final String TEST_NAME = "test310ModifyMorganEnlistTimestamp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3783,12 +3609,12 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); delta.checkConsistence(); @@ -3810,9 +3636,8 @@ public void test310ModifyMorganEnlistTimestamp() throws Exception { @Test public void test330ModifyAccountWillPasswordSelfService() throws Exception { final String TEST_NAME = "test330ModifyAccountWillPasswordSelfService"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -3822,18 +3647,18 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { ProvisioningOperationOptions options = ProvisioningOperationOptions.createRunAsAccountOid(ACCOUNT_WILL_OID); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Check if the account was created in the dummy resource assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertPassword(ACCOUNT_WILL_PASSWORD_321) - .assertLastModifier(getLastModifierName(ACCOUNT_WILL_USERNAME)); + .assertPassword(ACCOUNT_WILL_PASSWORD_321) + .assertLastModifier(getLastModifierName(ACCOUNT_WILL_USERNAME)); accountWillCurrentPassword = ACCOUNT_WILL_PASSWORD_321; @@ -3861,9 +3686,8 @@ public void test330ModifyAccountWillPasswordSelfService() throws Exception { @Test public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { final String TEST_NAME = "test340ModifyWillReplaceGossipBloodAvast"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3873,11 +3697,11 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.ZERO, WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST); @@ -3894,9 +3718,8 @@ public void test340ModifyWillReplaceGossipBloodAvast() throws Exception { @Test public void test342ModifyWillAddGossipEunuch() throws Exception { final String TEST_NAME = "test342ModifyWillAddGossipEunuch"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3906,11 +3729,11 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { List> mods = getGossipDelta(PlusMinusZero.PLUS, WILL_GOSSIP_EUNUCH); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_AVAST, WILL_GOSSIP_EUNUCH); @@ -3927,9 +3750,8 @@ public void test342ModifyWillAddGossipEunuch() throws Exception { @Test public void test344ModifyWillDeleteGossipAvast() throws Exception { final String TEST_NAME = "test344ModifyWillDeleteGossipAvast"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // This turns on recording of the operations @@ -3939,11 +3761,11 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { List> mods = getGossipDelta(PlusMinusZero.MINUS, WILL_GOSSIP_AVAST); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, mods, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertAccountWillGossip(WILL_GOSSIP_BLOOD_OF_A_PIRATE, WILL_GOSSIP_EUNUCH); @@ -3956,7 +3778,7 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { protected List> getGossipDelta(PlusMinusZero plusMinusZero, String... values) throws SchemaException { List> mods = prismContext.deltaFor(ShadowType.class) .property(dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME), null) - .mod(plusMinusZero, values) + .mod(plusMinusZero, values) .asItemDeltas(); display("Modifications", mods); return mods; @@ -3965,7 +3787,7 @@ public void test344ModifyWillDeleteGossipAvast() throws Exception { protected void assertAccountWillGossip(String... values) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { display("Account will", getDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid)); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, values); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, values); } protected void assertWillDummyGossipRecord(PlusMinusZero plusminus, String... expectedValues) { @@ -3980,19 +3802,18 @@ protected void assertWillDummyGossipRecord(PlusMinusZero plusminus, String... ex Collection valuesToConsider = null; switch (plusminus) { case PLUS: - valuesToConsider = (Collection)dummyDelta.getValuesAdded(); + valuesToConsider = (Collection) dummyDelta.getValuesAdded(); break; case MINUS: - valuesToConsider = (Collection)dummyDelta.getValuesDeleted(); + valuesToConsider = (Collection) dummyDelta.getValuesDeleted(); break; case ZERO: - valuesToConsider = (Collection)dummyDelta.getValuesReplaced(); + valuesToConsider = (Collection) dummyDelta.getValuesReplaced(); break; } - PrismAsserts.assertEqualsCollectionUnordered("Wrong values for "+plusminus+" in dummy resource delta", valuesToConsider, expectedValues); + PrismAsserts.assertEqualsCollectionUnordered("Wrong values for " + plusminus + " in dummy resource delta", valuesToConsider, expectedValues); } - protected String getLastModifierName(String expected) { return transformNameToResource(expected); } @@ -4002,22 +3823,19 @@ protected String getLastModifierName(String expected) { @Test public void test500AddProtectedAccount() throws Exception { final String TEST_NAME = "test500AddProtectedAccount"; - displayTestTitle(TEST_NAME); - testAddProtectedAccount(TEST_NAME, ACCOUNT_DAVIEJONES_USERNAME); + testAddProtectedAccount(ACCOUNT_DAVIEJONES_USERNAME); } @Test public void test501GetProtectedAccountShadow() throws Exception { - final String TEST_NAME = "test501GetProtectedAccountShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN PrismObject account = provisioningService.getObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, task, result); - assertEquals(""+account+" is not protected", Boolean.TRUE, account.asObjectable().isProtectedObject()); + assertEquals("" + account + " is not protected", Boolean.TRUE, account.asObjectable().isProtectedObject()); checkUniqueness(account); result.computeStatus(); @@ -4032,10 +3850,8 @@ public void test501GetProtectedAccountShadow() throws Exception { */ @Test public void test502ModifyProtectedAccountShadowAttributes() throws Exception { - final String TEST_NAME = "test502ModifyProtectedAccountShadowAttributes"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4075,7 +3891,6 @@ public void test502ModifyProtectedAccountShadowAttributes() throws Exception { @Test public void test503ModifyProtectedAccountShadowProperty() throws Exception { final String TEST_NAME = "test503ModifyProtectedAccountShadowProperty"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -4084,7 +3899,7 @@ public void test503ModifyProtectedAccountShadowProperty() throws Exception { ObjectDelta shadowDelta = prismContext.deltaFactory().object() .createModificationReplaceProperty(ShadowType.class, ACCOUNT_DAEMON_OID, - ShadowType.F_SYNCHRONIZATION_SITUATION, SynchronizationSituationType.DISPUTED); + ShadowType.F_SYNCHRONIZATION_SITUATION, SynchronizationSituationType.DISPUTED); // WHEN provisioningService.modifyObject(ShadowType.class, ACCOUNT_DAEMON_OID, shadowDelta.getModifications(), null, null, task, result); @@ -4105,23 +3920,22 @@ public void test503ModifyProtectedAccountShadowProperty() throws Exception { @Test public void test509DeleteProtectedAccountShadow() throws Exception { final String TEST_NAME = "test509DeleteProtectedAccountShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); try { // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, null, task, result); AssertJUnit.fail("Expected security exception while deleting 'daemon' account"); } catch (SecurityViolationException e) { // This is expected - displayThen(TEST_NAME); + then(); display("Expected exception", e); } @@ -4137,23 +3951,20 @@ public void test509DeleteProtectedAccountShadow() throws Exception { @Test public void test510AddProtectedAccounts() throws Exception { final String TEST_NAME = "test510AddProtectedAccounts"; - displayTestTitle(TEST_NAME); // GIVEN - testAddProtectedAccount(TEST_NAME, "Xavier"); - testAddProtectedAccount(TEST_NAME, "Xenophobia"); - testAddProtectedAccount(TEST_NAME, "nobody-adm"); - testAddAccount(TEST_NAME, "abcadm"); - testAddAccount(TEST_NAME, "piXel"); - testAddAccount(TEST_NAME, "supernaturalius"); + testAddProtectedAccount("Xavier"); + testAddProtectedAccount("Xenophobia"); + testAddProtectedAccount("nobody-adm"); + testAddAccount("abcadm"); + testAddAccount("piXel"); + testAddAccount("supernaturalius"); } @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { - final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; - displayTestTitle(TEST_NAME); // GIVEN - testAddAccount(TEST_NAME, "xaxa"); - testAddAccount(TEST_NAME, "somebody-ADM"); + testAddAccount("xaxa"); + testAddAccount("somebody-ADM"); } private PrismObject createAccountShadow(String username) throws SchemaException { @@ -4173,8 +3984,8 @@ private PrismObject createAccountShadow(String username) throws Sche return shadow; } - protected void testAddProtectedAccount(final String TEST_NAME, String username) throws Exception { - Task task = createTask(TEST_NAME); + protected void testAddProtectedAccount(String username) throws Exception { + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4183,10 +3994,9 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) // WHEN try { provisioningService.addObject(shadow, null, null, task, result); - AssertJUnit.fail("Expected security exception while adding '"+username+"' account"); + AssertJUnit.fail("Expected security exception while adding '" + username + "' account"); } catch (SecurityViolationException e) { - // This is expected - display("Expected exception", e); + displayExpectedException(e); } result.computeStatus(); @@ -4195,20 +4005,17 @@ protected void testAddProtectedAccount(final String TEST_NAME, String username) syncServiceMock.assertNotifyFailureOnly(); -// checkConsistency(); - assertSteadyResource(); } - private void testAddAccount(final String TEST_NAME, String username) throws Exception { - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); + private void testAddAccount(String username) throws Exception { + OperationResult result = createSubresult("addAccount"); syncServiceMock.reset(); PrismObject shadow = createAccountShadow(username); // WHEN - provisioningService.addObject(shadow, null, null, task, result); + provisioningService.addObject(shadow, null, null, getTestTask(), result); result.computeStatus(); display("addObject result (expected failure)", result); @@ -4216,8 +4023,6 @@ private void testAddAccount(final String TEST_NAME, String username) throws Exce syncServiceMock.assertNotifySuccessOnly(); -// checkConsistency(); - assertSteadyResource(); } @@ -4230,9 +4035,8 @@ private void testAddAccount(final String TEST_NAME, String username) throws Exce @Test public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { final String TEST_NAME = "test520MigrationPrimaryIdentifierValueRefresh"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -4240,16 +4044,16 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { repositoryService.addObject(shadowBefore, null, result); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); - displayThen(TEST_NAME); + then(); assertSuccess(result); assertRepoShadow(ACCOUNT_RELIC_OID) - .assertName(ACCOUNT_RELIC_USERNAME) - .assertPrimaryIdentifierValue(ACCOUNT_RELIC_USERNAME); + .assertName(ACCOUNT_RELIC_USERNAME) + .assertPrimaryIdentifierValue(ACCOUNT_RELIC_USERNAME); assertSteadyResource(); } @@ -4263,7 +4067,6 @@ public void test520MigrationPrimaryIdentifierValueRefresh() throws Exception { @Test public void test600AddAccountAlreadyExist() throws Exception { final String TEST_NAME = "test600AddAccountAlreadyExist"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4277,14 +4080,14 @@ public void test600AddAccountAlreadyExist() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { // This is expected - displayThen(TEST_NAME); + then(); display("Expected exception", e); } @@ -4299,7 +4102,7 @@ public void test600AddAccountAlreadyExist() throws Exception { display("Repository shadow", accountRepo); checkRepoAccountShadow(accountRepo); - assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo)); + assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo)); assertSteadyResource(); } @@ -4309,7 +4112,6 @@ public void test600AddAccountAlreadyExist() throws Exception { @Test public void test800LiveSyncInit() throws Exception { final String TEST_NAME = "test800LiveSyncInit"; - displayTestTitle(TEST_NAME); syncTokenTask = taskManager.createTaskInstance(TestDummy.class.getName() + ".syncTask"); dummyResource.setSyncStyle(DummySyncStyle.DUMB); @@ -4326,7 +4128,7 @@ public void test800LiveSyncInit() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4345,7 +4147,6 @@ public void test800LiveSyncInit() throws Exception { @Test public void test801LiveSyncAddBlackbeard() throws Exception { final String TEST_NAME = "test801LiveSyncAddBlackbeard"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); @@ -4367,7 +4168,7 @@ public void test801LiveSyncAddBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4414,7 +4215,6 @@ public void test801LiveSyncAddBlackbeard() throws Exception { @Test public void test802LiveSyncModifyBlackbeard() throws Exception { final String TEST_NAME = "test802LiveSyncModifyBlackbeard"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4430,7 +4230,7 @@ public void test802LiveSyncModifyBlackbeard() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN @@ -4574,7 +4374,6 @@ public void test849LiveSyncDeleteDrakeSmartAny() throws Exception { } public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4594,11 +4393,11 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl objectClass); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4617,7 +4416,7 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl } else { ObjectDelta objectDelta = lastChange.getObjectDelta(); assertNotNull("Delta present when not expecting it", objectDelta); - assertTrue("Delta is not add: "+objectDelta, objectDelta.isAdd()); + assertTrue("Delta is not add: " + objectDelta, objectDelta.isAdd()); } ShadowType currentShadowType = lastChange.getCurrentShadow().asObjectable(); @@ -4651,7 +4450,6 @@ public void testLiveSyncAddDrake(final String TEST_NAME, DummySyncStyle syncStyl } public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4666,11 +4464,11 @@ public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4709,7 +4507,6 @@ public void testLiveSyncModifyDrake(final String TEST_NAME, DummySyncStyle syncS } public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4727,11 +4524,11 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4752,7 +4549,7 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS } else { ObjectDelta objectDelta = lastChange.getObjectDelta(); assertNotNull("Delta present when not expecting it", objectDelta); - assertTrue("Delta is not add: "+objectDelta, objectDelta.isAdd()); + assertTrue("Delta is not add: " + objectDelta, objectDelta.isAdd()); } ShadowType currentShadowType = lastChange.getCurrentShadow().asObjectable(); @@ -4785,7 +4582,6 @@ public void testLiveSyncAddCorsairs(final String TEST_NAME, DummySyncStyle syncS } public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass, boolean expectReaction) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4804,41 +4600,40 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy objectClass); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); - if (expectReaction) { syncServiceMock.assertNotifyChange(); syncServiceMock - .lastNotifyChange() + .lastNotifyChange() .display() .oldShadow() - .assertOid(corsairsShadowOid) - .attributes() - .assertAttributes(SchemaConstants.ICFS_NAME, SchemaConstants.ICFS_UID) - .assertValue(SchemaConstants.ICFS_NAME, GROUP_CORSAIRS_NAME) - .end() - .end() + .assertOid(corsairsShadowOid) + .attributes() + .assertAttributes(SchemaConstants.ICFS_NAME, SchemaConstants.ICFS_UID) + .assertValue(SchemaConstants.ICFS_NAME, GROUP_CORSAIRS_NAME) + .end() + .end() .delta() - .assertChangeType(ChangeType.DELETE) - .assertObjectTypeClass(ShadowType.class) - .assertOid(corsairsShadowOid) - .end() + .assertChangeType(ChangeType.DELETE) + .assertObjectTypeClass(ShadowType.class) + .assertOid(corsairsShadowOid) + .end() .currentShadow() - .assertOid(corsairsShadowOid) - .assertTombstone(); + .assertOid(corsairsShadowOid) + .assertTombstone(); assertRepoShadow(corsairsShadowOid) - .assertTombstone(); + .assertTombstone(); // Clean slate for next tests repositoryService.deleteObject(ShadowType.class, corsairsShadowOid, result); @@ -4853,7 +4648,6 @@ public void testLiveSyncDeleteCorsairs(final String TEST_NAME, DummySyncStyle sy } public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncStyle, QName objectClass) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4872,11 +4666,11 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS objectClass); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); display("Synchronization result", result); TestUtil.assertSuccess("Synchronization result is not OK", result); @@ -4890,18 +4684,18 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS assertSyncOldShadow(oldShadow, getDrakeRepoIcfName()); syncServiceMock - .lastNotifyChange() + .lastNotifyChange() .delta() - .assertChangeType(ChangeType.DELETE) - .assertObjectTypeClass(ShadowType.class) - .assertOid(drakeAccountOid) - .end() + .assertChangeType(ChangeType.DELETE) + .assertObjectTypeClass(ShadowType.class) + .assertOid(drakeAccountOid) + .end() .currentShadow() - .assertTombstone() - .assertOid(drakeAccountOid); + .assertTombstone() + .assertOid(drakeAccountOid); assertRepoShadow(drakeAccountOid) - .assertTombstone(); + .assertTombstone(); checkAllShadows(); @@ -4914,7 +4708,6 @@ public void testLiveSyncDeleteDrake(final String TEST_NAME, DummySyncStyle syncS @Test public void test890LiveSyncModifyProtectedAccount() throws Exception { final String TEST_NAME = "test890LiveSyncModifyProtectedAccount"; - displayTestTitle(TEST_NAME); // GIVEN Task syncTask = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = syncTask.getResult(); @@ -4928,11 +4721,11 @@ public void test890LiveSyncModifyProtectedAccount() throws Exception { ProvisioningTestUtil.getDefaultAccountObjectClass(resourceType)); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.synchronize(coords, syncTokenTask, null, result); // THEN - displayThen(TEST_NAME); + then(); display("Synchronization result", result); assertSuccess(result); @@ -4949,7 +4742,6 @@ public void test890LiveSyncModifyProtectedAccount() throws Exception { @Test public void test901FailResourceNotFound() throws Exception { final String TEST_NAME = "test901FailResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -4975,7 +4767,7 @@ public void test901FailResourceNotFound() throws Exception { protected void checkCachedAccountShadow(PrismObject shadowType, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException { - checkAccountShadow(shadowType, parentResult, fullShadow, startTs, endTs); + checkAccountShadow(shadowType, parentResult, fullShadow); } private void checkGroupShadow(PrismObject shadow, OperationResult parentResult) throws SchemaException { @@ -4992,14 +4784,11 @@ private void checkEntitlementShadow(PrismObject shadow, OperationRes IntegrationTestTools.checkEntitlementShadow(shadow.asObjectable(), resourceType, repositoryService, checker, objectClassLocalName, getUidMatchingRule(), prismContext, parentResult); } - private void checkAllShadows() throws SchemaException, ObjectNotFoundException, CommunicationException, - ConfigurationException { + private void checkAllShadows() throws SchemaException { ObjectChecker checker = null; IntegrationTestTools.checkAllShadows(resourceType, repositoryService, checker, prismContext); } - - protected void checkRepoEntitlementShadow(PrismObject repoShadow) { ProvisioningTestUtil.checkRepoEntitlementShadow(repoShadow); } @@ -5019,7 +4808,7 @@ protected void assertSyncOldShadow(PrismObject oldShadow, Collection> attributes = attributesContainer.getAttributes(); assertFalse("Attributes container is empty", attributes.isEmpty()); if (expectedNumberOfAttributes != null) { - assertEquals("Unexpected number of attributes", (int)expectedNumberOfAttributes, attributes.size()); + assertEquals("Unexpected number of attributes", (int) expectedNumberOfAttributes, attributes.size()); } ResourceAttribute icfsNameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME); assertNotNull("No ICF name attribute in old shadow", icfsNameAttribute); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java index 848441a51e8..7d1a9fc67c0 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaching.java @@ -95,7 +95,6 @@ protected ItemComparisonResult getExpectedPasswordComparisonResultMismatch() { @Override public void test107AGetModifiedAccountFromCacheMax() throws Exception { final String TEST_NAME = "test107AGetModifiedAccountFromCacheMax"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -111,12 +110,12 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("getObject result", result); TestUtil.assertSuccess(result); @@ -163,7 +162,6 @@ public void test107AGetModifiedAccountFromCacheMax() throws Exception { @Override public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception { final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -178,12 +176,12 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -225,7 +223,6 @@ public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception @Test public void test107CSkipCachingForIncompleteAttributes() throws Exception { final String TEST_NAME = "test107CSkipCachingForIncompleteAttributes"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); @@ -240,13 +237,13 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService .getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1); @@ -298,7 +295,6 @@ public void test107CSkipCachingForIncompleteAttributes() throws Exception { @Override public void test119SearchAllAccountsMaxStaleness() throws Exception { final String TEST_NAME = "test119SearchAllAccountsMaxStaleness"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); @@ -378,18 +374,6 @@ protected void assertRepoShadowPasswordValue(PrismObject shadowRepo, assertProtectedString("Wrong password value in repo shadow "+shadowRepo, expectedPassword, protectedStringType, CredentialsStorageTypeType.HASHING); } - /** - * We do not know what the timestamp should be. But some timestamp should be there. - */ - @Override - protected void assertRepoCachingMetadata(PrismObject shadowFromRepo) { - CachingMetadataType cachingMetadata = shadowFromRepo.asObjectable().getCachingMetadata(); - assertNotNull("No caching metadata in "+shadowFromRepo, cachingMetadata); - - assertNotNull("Missing retrieval timestamp in caching metadata in "+shadowFromRepo, - cachingMetadata.getRetrievalTimestamp()); - } - @Override protected void assertRepoCachingMetadata(PrismObject shadowFromRepo, XMLGregorianCalendar start, XMLGregorianCalendar end) { CachingMetadataType cachingMetadata = shadowFromRepo.asObjectable().getCachingMetadata(); @@ -441,7 +425,7 @@ protected void assertRepoShadowCachedAttributeValue(PrismObject @Override protected void checkCachedAccountShadow(PrismObject shadow, OperationResult parentResult, boolean fullShadow, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException { - super.checkAccountShadow(shadow, parentResult, fullShadow, startTs, endTs); + super.checkAccountShadow(shadow, parentResult, fullShadow); if (fullShadow) { assertCachingMetadata(shadow, true, startTs, endTs); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java index a9fde1225a5..a9a20b0911c 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyCaseIgnore.java @@ -89,18 +89,14 @@ protected boolean isPreFetchResource() { @Test public void test175SearchUidCase() throws Exception { - final String TEST_NAME = "test175SearchUidCase"; - TestUtil.displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, "wIlL", null, true, transformNameFromResource("Will")); } @Test public void test176SearchUidCaseNoFetch() throws Exception { - final String TEST_NAME = "test176SearchUidCaseNoFetch"; - TestUtil.displayTestTitle(TEST_NAME); - testSeachIterativeSingleAttrFilter(TEST_NAME, + testSeachIterativeSingleAttrFilter( SchemaConstants.ICFS_UID, "wIlL", GetOperationOptions.createNoFetch(), false, transformNameFromResource("Will")); } @@ -110,10 +106,7 @@ public void test176SearchUidCaseNoFetch() throws Exception { */ @Test public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception { - final String TEST_NAME = "test280EntitleAccountWillPiratesAlreadyThere"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); @@ -151,11 +144,7 @@ public void test280EntitleAccountWillPiratesAlreadyThere() throws Exception { @Test public void test282DetitleAccountWillPirates() throws Exception { - final String TEST_NAME = "test282DetitleAccountWillPirates"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -192,10 +181,7 @@ public void test282DetitleAccountWillPirates() throws Exception { */ @Test public void test285EntitleAccountWillPiratesAlreadyThereCaseIgnore() throws Exception { - final String TEST_NAME = "test285EntitleAccountWillPiratesAlreadyThereCaseIgnore"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupPirates = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); @@ -233,11 +219,7 @@ public void test285EntitleAccountWillPiratesAlreadyThereCaseIgnore() throws Exce @Test public void test289DetitleAccountWillPirates() throws Exception { - final String TEST_NAME = "test289DetitleAccountWillPirates"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -273,11 +255,9 @@ public void test289DetitleAccountWillPirates() throws Exception { @Test public void test511AddProtectedAccountCaseIgnore() throws Exception { - final String TEST_NAME = "test511AddProtectedAccountCaseIgnore"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - testAddProtectedAccount(TEST_NAME, "xaxa"); - testAddProtectedAccount(TEST_NAME, "somebody-ADM"); - testAddProtectedAccount(TEST_NAME, "everybody-AdM"); + testAddProtectedAccount("xaxa"); + testAddProtectedAccount("somebody-ADM"); + testAddProtectedAccount("everybody-AdM"); } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java index 46e611bbc47..efc65c67e37 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyConsistency.java @@ -6,16 +6,12 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.util.Collection; - import javax.xml.datatype.XMLGregorianCalendar; -import com.evolveum.midpoint.prism.path.ItemPath; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; @@ -25,6 +21,7 @@ import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.provisioning.api.GenericConnectorException; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.PointInTimeType; @@ -37,28 +34,15 @@ import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -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.OperationResultStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationTypeType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; /** * Test for various aspects of provisioning failure handling * (aka "consistency mechanism"). - * - * MID-3603 + *

+ * MID-3603 * * @author Radovan Semancik */ @@ -73,8 +57,6 @@ public class TestDummyConsistency extends AbstractDummyTest { protected static final String ACCOUNT_MORGAN_FULLNAME_HM = "Henry Morgan"; protected static final String ACCOUNT_MORGAN_FULLNAME_CHM = "Captain Henry Morgan"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummyConsistency.class); - private static final String ACCOUNT_JP_MORGAN_FULLNAME = "J.P. Morgan"; private static final String ACCOUNT_BETTY_USERNAME = "betty"; private static final String ACCOUNT_BETTY_FULLNAME = "Betty Rubble"; @@ -94,8 +76,6 @@ public class TestDummyConsistency extends AbstractDummyTest { @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); -// DebugUtil.setDetailedDebugDump(true); -// InternalMonitor.setTraceConnectorOperation(true); } @Override @@ -105,10 +85,7 @@ protected File getResourceDummyFile() { @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); display("Dummy resource instance", dummyResource.toString()); @@ -129,9 +106,8 @@ public void test000Integrity() throws Exception { @Test public void test050AddAccountWill() throws Exception { final String TEST_NAME = "test050AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -140,11 +116,11 @@ public void test050AddAccountWill() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); syncServiceMock.assertNotifySuccessOnly(); @@ -153,10 +129,12 @@ public void test050AddAccountWill() throws Exception { ACCOUNT_WILL_OID, null, task, result); display("Account provisioning", accountProvisioning); + // @formatter:off ShadowAsserter.forShadow(accountProvisioning) .assertNoLegacyConsistency() .pendingOperations() .assertNone(); + // @formatter:on DummyAccount dummyAccount = dummyResource.getAccountByUsername(transformNameFromResource(ACCOUNT_WILL_USERNAME)); assertNotNull("No dummy account", dummyAccount); @@ -171,10 +149,12 @@ public void test050AddAccountWill() throws Exception { display("Repository shadow", shadowFromRepo); checkRepoAccountShadow(shadowFromRepo); + // @formatter:off ShadowAsserter.forShadow(shadowFromRepo) .assertNoLegacyConsistency() .pendingOperations() .assertNone(); + // @formatter:on checkUniqueness(accountProvisioning); assertSteadyResources(); @@ -185,9 +165,8 @@ public void test050AddAccountWill() throws Exception { @Test public void test100AddAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test100AddAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -200,11 +179,11 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertInProgress(result); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); @@ -226,21 +205,17 @@ public void test100AddAccountMorganCommunicationFailure() throws Exception { */ @Test public void test102GetAccountMorganRecovery() throws Exception { - final String TEST_NAME = "test102GetAccountMorganRecovery"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.resetBreakMode(); // WHEN - displayWhen(TEST_NAME); + when(); assertGetUncreatedShadow(ACCOUNT_MORGAN_OID); // THEN - displayThen(TEST_NAME); + then(); syncServiceMock.assertNoNotifcations(); assertUncreatedMorgan(1); @@ -255,9 +230,8 @@ public void test102GetAccountMorganRecovery() throws Exception { @Test public void test104RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test104RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -266,11 +240,11 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -287,9 +261,8 @@ public void test104RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test105GetForceRefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -299,7 +272,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc try { // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, options, task, result); @@ -310,7 +283,7 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc } // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -327,9 +300,8 @@ public void test105GetForceRefreshAccountMorganCommunicationFailure() throws Exc @Test public void test106RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test106RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -343,11 +315,11 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -367,9 +339,8 @@ public void test106RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test108RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -383,11 +354,11 @@ public void test108RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -401,6 +372,7 @@ private void assertMorganDead() throws Exception { PrismObject repoShadow = getShadowRepo(ACCOUNT_MORGAN_OID); assertNotNull("Shadow was not created in the repository", repoShadow); + // @formatter:off assertRepoShadow(ACCOUNT_MORGAN_OID) .pendingOperations() .singleOperation() @@ -470,6 +442,7 @@ private void assertMorganDead() throws Exception { .assertNoPrimaryIdentifier() .assertHasSecondaryIdentifier() .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -493,9 +466,8 @@ private void assertMorganDead() throws Exception { @Test public void test109RefreshAccountMorganDead() throws Exception { final String TEST_NAME = "test109RefreshAccountMorganDead"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -507,11 +479,11 @@ public void test109RefreshAccountMorganDead() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -525,9 +497,8 @@ public void test109RefreshAccountMorganDead() throws Exception { @Test public void test110AddAccountMorganAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test110AddAccountMorganAgainCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -543,11 +514,11 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); shadowMorganOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertInProgress(result); account.checkConsistence(); @@ -566,9 +537,8 @@ public void test110AddAccountMorganAgainCommunicationFailure() throws Exception @Test public void test114RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test114RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -579,11 +549,11 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -600,9 +570,8 @@ public void test114RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test116RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test116RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -616,11 +585,11 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -636,9 +605,8 @@ public void test116RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { final String TEST_NAME = "test120ModifyMorganFullNameCommunicationFailure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -650,12 +618,12 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -674,9 +642,8 @@ public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { @Test public void test124RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test124RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -685,11 +652,11 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -706,9 +673,8 @@ public void test124RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test126RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test126RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -722,11 +688,11 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -746,9 +712,8 @@ public void test126RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test128RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -762,11 +727,11 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -783,9 +748,8 @@ public void test128RefreshAccountMorganCommunicationFailureRetryAgain() throws E @Test public void test129RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test129RefreshAccountMorganFailed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -797,11 +761,11 @@ public void test129RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -812,9 +776,8 @@ public void test129RefreshAccountMorganFailed() throws Exception { @Test public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test130ModifyMorganFullNameAgainCommunicationFailure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.setBreakMode(BreakMode.NETWORK); @@ -826,12 +789,12 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -851,9 +814,8 @@ public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Except @Test public void test132GetAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test132GetAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -862,12 +824,12 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { dummyResource.setBreakMode(BreakMode.NETWORK); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertPartialError(result); syncServiceMock.assertNoNotifcations(); @@ -884,12 +846,11 @@ public void test132GetAccountMorganCommunicationFailure() throws Exception { * Get operation should throw an error, as there is explicit staleness=0 option. * MID-4796 */ - @Test(enabled=false) // MID-4796 + @Test(enabled = false) // MID-4796 public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Exception { final String TEST_NAME = "test133GetAccountMorganStalenessZeroCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -899,7 +860,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex try { // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); @@ -910,7 +871,7 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex } // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertFailure(result); syncServiceMock.assertNoNotifcations(); @@ -920,7 +881,6 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex assertSteadyResources(); } - /** * Use forceRefresh option with get operation to force refresh. * We are over retry interval, therefore provisioning should re-try the operation. @@ -929,9 +889,8 @@ public void test133GetAccountMorganStalenessZeroCommunicationFailure() throws Ex @Test public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throws Exception { final String TEST_NAME = "test134GetAccountMorganForceRefreshRetryCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -942,11 +901,11 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw Collection> options = SelectorOptions.createCollection(GetOperationOptions.createForceRefresh()); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.getObject(ShadowType.class, shadowMorganOid, options, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertPartialError(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -964,9 +923,8 @@ public void test134GetAccountMorganForceRefreshRetryCommunicationFailure() throw @Test public void test136RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test136RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -980,11 +938,11 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1000,9 +958,8 @@ public void test136RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test170DeleteMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test170DeleteMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1014,11 +971,11 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1037,9 +994,8 @@ public void test170DeleteMorganCommunicationFailure() throws Exception { @Test public void test174RefreshAccountMorganCommunicationFailure() throws Exception { final String TEST_NAME = "test174RefreshAccountMorganCommunicationFailure"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1048,11 +1004,11 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1069,9 +1025,8 @@ public void test174RefreshAccountMorganCommunicationFailure() throws Exception { @Test public void test176RefreshAccountMorganCommunicationFailureRetry() throws Exception { final String TEST_NAME = "test176RefreshAccountMorganCommunicationFailureRetry"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1085,11 +1040,11 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1109,9 +1064,8 @@ public void test176RefreshAccountMorganCommunicationFailureRetry() throws Except @Test public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws Exception { final String TEST_NAME = "test178RefreshAccountMorganCommunicationFailureRetryAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1125,11 +1079,11 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); result.computeStatus(); TestUtil.assertResultStatus(result, OperationResultStatus.HANDLED_ERROR); @@ -1145,9 +1099,8 @@ public void test178RefreshAccountMorganCommunicationFailureRetryAgain() throws E @Test public void test179RefreshAccountMorganFailed() throws Exception { final String TEST_NAME = "test179RefreshAccountMorganFailed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1159,11 +1112,11 @@ public void test179RefreshAccountMorganFailed() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); @@ -1174,9 +1127,8 @@ public void test179RefreshAccountMorganFailed() throws Exception { @Test public void test180DeleteMorganCommunicationFailureAgain() throws Exception { final String TEST_NAME = "test180DeleteMorganCommunicationFailureAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1188,11 +1140,11 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { display("ObjectDelta", delta); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject returnedShadow = provisioningService.deleteObject(ShadowType.class, shadowMorganOid, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); @@ -1212,9 +1164,8 @@ public void test180DeleteMorganCommunicationFailureAgain() throws Exception { @Test public void test186RefreshAccountMorganRetrySuccess() throws Exception { final String TEST_NAME = "test186RefreshAccountMorganRetrySuccess"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("PT17M"); @@ -1228,11 +1179,11 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); @@ -1255,9 +1206,8 @@ public void test186RefreshAccountMorganRetrySuccess() throws Exception { @Test public void test190AccountMorganDeadExpireOperation() throws Exception { final String TEST_NAME = "test190AccountMorganDeadExpireOperation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1269,15 +1219,16 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); + // @formatter:off assertRepoShadow(ACCOUNT_MORGAN_OID) .assertKind(ShadowKindType.ACCOUNT) .assertDead() @@ -1311,7 +1262,6 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { .assertHasSecondaryIdentifier() .end(); - assertShadowFutureNoFetch(ACCOUNT_MORGAN_OID) .assertTombstone() .assertNoLegacyConsistency() @@ -1320,6 +1270,7 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { .assertNoPrimaryIdentifier() .assertHasSecondaryIdentifier() .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -1340,9 +1291,8 @@ public void test190AccountMorganDeadExpireOperation() throws Exception { @Test public void test192AccountMorganSecondDeadExpireOperation() throws Exception { final String TEST_NAME = "test192AccountMorganSecondDeadExpireOperation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1354,15 +1304,16 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNoNotifcations(); + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertTombstone() @@ -1393,6 +1344,7 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { assertShadowFutureNoFetch(shadowMorganOid) .assertTombstone(); + // @formatter:on dummyResource.resetBreakMode(); @@ -1408,9 +1360,8 @@ public void test192AccountMorganSecondDeadExpireOperation() throws Exception { @Test public void test194AccountMorganDeadExpireShadow() throws Exception { final String TEST_NAME = "test194AccountMorganDeadExpireShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P10D"); @@ -1422,11 +1373,11 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(ACCOUNT_MORGAN_OID); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1445,9 +1396,8 @@ public void test194AccountMorganDeadExpireShadow() throws Exception { @Test public void test196AccountMorganSecondDeadExpireShadow() throws Exception { final String TEST_NAME = "test196AccountMorganSecondDeadExpireShadow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); @@ -1459,11 +1409,11 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { PrismObject shadowRepoBefore = getShadowRepo(shadowMorganOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowRepoBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); @@ -1483,9 +1433,8 @@ public void test196AccountMorganSecondDeadExpireShadow() throws Exception { @Test public void test800AddAccountMorganAlreadyExists() throws Exception { final String TEST_NAME = "test800AddAccountMorganAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1498,12 +1447,12 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -1514,6 +1463,7 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_MORGAN_NAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); + // @formatter:off ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") .display() .assertBasicRepoProperties() @@ -1549,6 +1499,7 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { .end() .pendingOperations() .assertNone(); + // @formatter:on shadowMorganOid = conflictingShadowRepo.getOid(); @@ -1563,9 +1514,8 @@ public void test800AddAccountMorganAlreadyExists() throws Exception { @Test public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test802AddAccountMorganAlreadyExistsAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1576,12 +1526,12 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -1590,8 +1540,9 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { assertFailure(result); account.checkConsistence(); + // @formatter:off PrismObject conflictingShadowRepo = getShadowRepo(shadowMorganOid); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + ShadowAsserter.forShadow(conflictingShadowRepo,"conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOid(shadowMorganOid) @@ -1640,6 +1591,7 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { .end() .pendingOperations() .assertNone(); + // @formatter:on assertNoRepoShadow(ACCOUNT_MORGAN_OID); assertSteadyResources(); @@ -1648,9 +1600,8 @@ public void test802AddAccountMorganAlreadyExistsAgain() throws Exception { @Test public void test804AddAccountElizabeth() throws Exception { final String TEST_NAME = "test804AddAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1661,16 +1612,16 @@ public void test804AddAccountElizabeth() throws Exception { display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); account.checkConsistence(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_ELIZABETH_USERNAME) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH_FULLNAME); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH_FULLNAME); assertSteadyResources(); } @@ -1682,9 +1633,8 @@ public void test804AddAccountElizabeth() throws Exception { @Test public void test806RenameAccountElizabethAlreadyExists() throws Exception { final String TEST_NAME = "test806RenameAccountElizabethAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1697,22 +1647,23 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + // @formatter:off + ShadowAsserter.forShadow(conflictingShadowRepo,"conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOidDifferentThan(ACCOUNT_ELIZABETH_OID) @@ -1752,6 +1703,7 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { dummyResourceCtl.assertAccountByUsername(ACCOUNT_BETTY_USERNAME) .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_BETTY_FULLNAME); + // @formatter:on assertSteadyResources(); } @@ -1762,9 +1714,8 @@ public void test806RenameAccountElizabethAlreadyExists() throws Exception { @Test public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { final String TEST_NAME = "test808RenameAccountElizabethAlreadyExistsAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1775,22 +1726,23 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { ACCOUNT_BETTY_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); PrismObject conflictingShadowRepo = findAccountShadowByUsername(ACCOUNT_BETTY_USERNAME, getResource(), result); assertNotNull("Shadow for conflicting object was not created in the repository", conflictingShadowRepo); - ShadowAsserter.forShadow(conflictingShadowRepo,"confligting repo shadow") + // @formatter:off + ShadowAsserter.forShadow(conflictingShadowRepo, "conflicting repo shadow") .display() .assertBasicRepoProperties() .assertOidDifferentThan(ACCOUNT_ELIZABETH_OID) @@ -1842,6 +1794,7 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { dummyResourceCtl.assertAccountByUsername(ACCOUNT_BETTY_USERNAME) .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_BETTY_FULLNAME); + // @formatter:on assertSteadyResources(); } @@ -1855,9 +1808,8 @@ public void test808RenameAccountElizabethAlreadyExistsAgain() throws Exception { @Test public void test810GetAccountMorganNotFound() throws Exception { final String TEST_NAME = "test810GetAccountMorganNotFound"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1865,13 +1817,14 @@ public void test810GetAccountMorganNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_MORGAN_NAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -1908,6 +1861,7 @@ public void test810GetAccountMorganNotFound() throws Exception { ShadowAsserter.forShadow(provisioningShadow, "provisioning") .assertTombstone(); + // @formatter:on assertNoRepoShadow(ACCOUNT_MORGAN_OID); assertSteadyResources(); @@ -1922,9 +1876,8 @@ public void test810GetAccountMorganNotFound() throws Exception { @Test public void test812ModifyAccountWillNotFound() throws Exception { final String TEST_NAME = "test812ModifyAccountWillNotFound"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1935,12 +1888,12 @@ public void test812ModifyAccountWillNotFound() throws Exception { ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeFullnamePath(), "Pirate Will Turner"); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, delta.getModifications(), null, null, task, result); assertNotReached(); } catch (ObjectNotFoundException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -1948,6 +1901,7 @@ public void test812ModifyAccountWillNotFound() throws Exception { display("Result", result); assertFailure(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -1982,6 +1936,7 @@ public void test812ModifyAccountWillNotFound() throws Exception { .assertIsNotExists() .pendingOperations() .assertNone(); + // @formatter:on assertSteadyResources(); } @@ -1995,9 +1950,8 @@ public void test812ModifyAccountWillNotFound() throws Exception { @Test public void test814DeleteAccountElizabethNotFound() throws Exception { final String TEST_NAME = "test814DeleteAccountElizabethNotFound"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2005,14 +1959,15 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { dummyResourceCtl.deleteAccount(ACCOUNT_ELIZABETH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertHadnledError(result); + // @formatter:off syncServiceMock .assertNotifyChange() .assertNotifyChangeCalls(1) @@ -2047,6 +2002,7 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { .assertIsNotExists() .pendingOperations() .assertNone(); + // @formatter:on assertSteadyResources(); } @@ -2059,9 +2015,8 @@ public void test814DeleteAccountElizabethNotFound() throws Exception { @Test public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception { final String TEST_NAME = "test816AddAccountElizabethAfterDeathAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2075,18 +2030,19 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception display("Adding shadow", account); // WHEN - displayWhen(TEST_NAME); + when(); try { provisioningService.addObject(account, null, null, task, result); } catch (ObjectAlreadyExistsException e) { - displayThen(TEST_NAME); + then(); display("expected exception", e); } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); + // @formatter:off syncServiceMock .assertNotifyFailureOnly() .assertNotifyChange() @@ -2111,9 +2067,10 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception .end() .pendingOperations() .assertNone(); + // @formatter:on dummyResourceCtl.assertAccountByUsername(ACCOUNT_ELIZABETH_USERNAME) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH2_FULLNAME); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_ELIZABETH2_FULLNAME); assertSteadyResources(); } @@ -2127,9 +2084,8 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception @Test public void test900GetAccountMurrayPending() throws Exception { final String TEST_NAME = "test900GetAccountMurrayPending"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.resetBreakMode(); @@ -2138,11 +2094,11 @@ public void test900GetAccountMurrayPending() throws Exception { repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_PENDING_FILE, result); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_PENDING_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result); accountMurray.checkConsistence(); @@ -2154,6 +2110,7 @@ public void test900GetAccountMurrayPending() throws Exception { private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertIsNotExists() @@ -2202,7 +2159,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { .delta() .assertAdd(); - ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) + ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) .assertIsExists() .assertNotDead() .assertNoPrimaryIdentifierValue() @@ -2214,6 +2171,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(5) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME) .end(); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(asserterFuture.getObject()); @@ -2221,6 +2179,7 @@ private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception { private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { + // @formatter:off assertRepoShadow(shadowMorganOid) .assertKind(ShadowKindType.ACCOUNT) .assertIsExists() @@ -2281,7 +2240,7 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME); - ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) + ShadowAsserter asserterFuture = assertShadowFuture(shadowMorganOid) .assertIsExists() .assertNotDead() .assertPrimaryIdentifierValue(ACCOUNT_MORGAN_NAME) @@ -2293,6 +2252,7 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME) .end(); + // @formatter:on dummyResource.resetBreakMode(); @@ -2300,18 +2260,21 @@ private void assertCreatedMorgan(int expectedAttemptNumber) throws Exception { checkUniqueness(asserterFuture.getObject()); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } - private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) throws Exception { + private void assertUnmodifiedMorgan( + int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) + throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2367,12 +2330,11 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); - OperationResult result = task.getResult(); + Task task = getTestTask(); + OperationResult result = createSubresult("assertUnmodifiedMorgan"); PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2387,7 +2349,7 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2400,24 +2362,28 @@ private void assertUnmodifiedMorgan(int expectedAttemptNumber, int expectenNumbe .assertHasSecondaryIdentifier() .assertSize(3) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } - private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) throws Exception { + private void assertModifiedMorgan( + int expectedAttemptNumber, int expectenNumberOfPendingOperations, String expectedFullName) + throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2476,12 +2442,11 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertModifiedMorgan"); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertModifiedMorgan"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertSuccess(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2495,7 +2460,7 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); PrismObject accountProvisioningFuture = getShadowFuture(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2507,23 +2472,25 @@ private void assertModifiedMorgan(int expectedAttemptNumber, int expectenNumberO .assertHasSecondaryIdentifier() .assertSize(6) .assertValue(dummyResourceCtl.getAttributeFullnameQName(), expectedFullName); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(expectedFullName) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(expectedFullName) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertMorganModifyFailed() throws Exception { PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2576,12 +2543,11 @@ private void assertMorganModifyFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - - Task task1 = createTask("assertUnmodifiedMorgan"); - OperationResult result1 = task1.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task1, result1); - assertPartialError(result1); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + OperationResult result = createSubresult("assertMorganModifyFailed"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); + assertPartialError(result); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2606,16 +2572,17 @@ private void assertMorganModifyFailed() throws Exception { .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations) throws Exception { @@ -2623,7 +2590,8 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2678,12 +2646,11 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertUndeletedMorgan"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2698,7 +2665,7 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsNotExists() @@ -2709,23 +2676,24 @@ private void assertUndeletedMorgan(int expectedAttemptNumber, int expectenNumber .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertMorganDeleteFailed() throws Exception { - PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); + // @formatter:off ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() @@ -2781,12 +2749,11 @@ private void assertMorganDeleteFailed() throws Exception { .assertHasSecondaryIdentifier() .assertSize(2); - - Task task = createTask("assertUnmodifiedMorgan"); - OperationResult result = task.getResult(); - PrismObject accountProvisioning = provisioningService.getObject(ShadowType.class, shadowMorganOid, null, task, result); + OperationResult result = createSubresult("assertMorganDeleteFailed"); + PrismObject accountProvisioning = provisioningService.getObject( + ShadowType.class, shadowMorganOid, null, getTestTask(), result); assertPartialError(result); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioning,"current"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioning, "current"); shadowAsserter .display() .assertIsExists() @@ -2801,7 +2768,7 @@ private void assertMorganDeleteFailed() throws Exception { // TODO: assert caching metadata? PrismObject accountProvisioningFuture = getShadowFuturePartialError(shadowMorganOid); - shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture,"future"); + shadowAsserter = ShadowAsserter.forShadow(accountProvisioningFuture, "future"); shadowAsserter .display() .assertIsExists() @@ -2813,16 +2780,17 @@ private void assertMorganDeleteFailed() throws Exception { .assertHasPrimaryIdentifier() .assertHasSecondaryIdentifier() .assertSize(2); + // @formatter:on // Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it) checkUniqueness(accountProvisioningFuture); dummyResource.resetBreakMode(); dummyResourceCtl.assertAccountByUsername(ACCOUNT_MORGAN_NAME) - .assertName(ACCOUNT_MORGAN_NAME) - .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) - .assertEnabled() - .assertPassword(ACCOUNT_MORGAN_PASSWORD); + .assertName(ACCOUNT_MORGAN_NAME) + .assertFullName(ACCOUNT_MORGAN_FULLNAME_CHM) + .assertEnabled() + .assertPassword(ACCOUNT_MORGAN_PASSWORD); } private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOfPendingOperations) throws Exception { @@ -2830,7 +2798,8 @@ private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOf PrismObject repoShadow = getShadowRepo(shadowMorganOid); assertNotNull("Shadow was not created in the repository", repoShadow); - ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); + // @formatter:off + ShadowAsserter shadowAsserter = ShadowAsserter.forShadow(repoShadow, "repository"); shadowAsserter .display() .pendingOperations() @@ -2882,70 +2851,77 @@ private void assertDeletedMorgan(int expectedAttemptNumber, int expectenNumberOf .assertLastAttemptTimestamp(lastAttemptStartTs, lastAttemptEndTs) .delta() .assertDelete(); + // @formatter:on assertShadowProvisioning(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowFuture(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowFutureNoFetch(shadowMorganOid) - .assertTombstone(); + .assertTombstone(); dummyResource.resetBreakMode(); dummyResourceCtl.assertNoAccountByUsername(ACCOUNT_MORGAN_NAME); } - private void assertResourceStatusChangeCounterIncrements() { assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_MODIFY_COUNT, 1); assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT, 1); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1); } - private void assertGetUncreatedShadow(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("assertGetUncreatedShadow"); - OperationResult result = task.getResult(); + private void assertGetUncreatedShadow(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("assertGetUncreatedShadow"); try { - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, null, task, result); - fail("Expected that get of uncreated shadow fails, but it was successful: "+shadow); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, null, getTestTask(), result); + fail("Expected that get of uncreated shadow fails, but it was successful: " + shadow); } catch (GenericConnectorException e) { // Expected } } - private PrismObject getShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowNoFetch"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); + private PrismObject getShadowNoFetch(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowNoFetch"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + oid, options, getTestTask(), result); assertSuccess(result); return shadow; } - private PrismObject getShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowFuture"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + private PrismObject getShadowFuture(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowFuture"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, options, getTestTask(), result); assertSuccess(result); return shadow; } - private PrismObject getShadowFuturePartialError(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask("getShadowFuture"); - OperationResult result = task.getResult(); - Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); - PrismObject shadow = provisioningService.getObject(ShadowType.class, - oid, options, task, result); + private PrismObject getShadowFuturePartialError(String oid) + throws ObjectNotFoundException, CommunicationException, SchemaException, + ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + OperationResult result = createSubresult("getShadowFuturePartialError"); + Collection> options = + SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); + PrismObject shadow = provisioningService.getObject( + ShadowType.class, oid, options, getTestTask(), result); assertPartialError(result); return shadow; } - // TODO: shadow with legacy postponed operation: shoudl be cleaned up + // TODO: shadow with legacy postponed operation: should be cleaned up // TODO: retries of propagated operations } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java index 4a7bd5049c2..b8e4067bd42 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExpression.java @@ -15,10 +15,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.query.ObjectPaging; -import com.evolveum.midpoint.prism.query.OrderDirection; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java index 8687d52dde9..60e2e3e4daf 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java @@ -105,9 +105,8 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr @Test public void test400AddAccountElizabeth() throws Exception { final String TEST_NAME = "test400AddAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -119,11 +118,11 @@ public void test400AddAccountElizabeth() throws Exception { XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar(); @@ -154,10 +153,7 @@ public void test400AddAccountElizabeth() throws Exception { */ @Test public void test410AssociateCrewWillElizabeth() throws Exception { - final String TEST_NAME = "test410AssociateCrewWillElizabeth"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -168,12 +164,12 @@ public void test410AssociateCrewWillElizabeth() throws Exception { delta.checkConsistence(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -200,10 +196,7 @@ public void test410AssociateCrewWillElizabeth() throws Exception { */ @Test public void test419DisassociateCrewWillElizabeth() throws Exception { - final String TEST_NAME = "test419DisassociateCrewWillElizabeth"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -214,12 +207,12 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { delta.checkConsistence(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); @@ -246,18 +239,17 @@ public void test419DisassociateCrewWillElizabeth() throws Exception { @Test public void test499DeleteAccountElizabeth() throws Exception { final String TEST_NAME = "test499DeleteAccountElizabeth"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_ELIZABETH_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java index 7dac4309c2f..ac46a644ba7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyHacks.java @@ -11,43 +11,17 @@ import java.io.File; -import javax.xml.namespace.QName; - -import com.evolveum.midpoint.prism.PrismContext; - import com.evolveum.midpoint.prism.delta.PlusMinusZero; -import com.evolveum.midpoint.schema.processor.ResourceSchemaImpl; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; -import org.w3c.dom.Element; -import com.evolveum.icf.dummy.resource.DummyObjectClass; -import com.evolveum.icf.dummy.resource.DummyResource; -import com.evolveum.midpoint.prism.ComplexTypeDefinition; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.provisioning.api.ProvisioningService; -import com.evolveum.midpoint.provisioning.impl.ConnectorManager; -import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; /** * The test of Provisioning service on the API level. The test is using dummy resource for speed and flexibility. diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java index dce8cb08e67..c9c3b37b2af 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLegacy.java @@ -12,7 +12,6 @@ import java.io.File; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; @@ -21,6 +20,7 @@ import org.w3c.dom.Element; import com.evolveum.icf.dummy.resource.DummyResource; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.provisioning.api.ProvisioningService; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; @@ -33,16 +33,12 @@ import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType; /** * Test with legacy "ICF" schema. - * */ @ContextConfiguration(locations = "classpath:ctx-provisioning-test-main.xml") @DirtiesContext @@ -58,8 +54,6 @@ public class TestDummyLegacy extends AbstractIntegrationTest { private static final String RESOURCE_DUMMY_LEGACY_OID = "387a3400-4be6-11e5-b41a-001e8c717e5b"; private static final String RESOURCE_DUMMY_LEGACY_INSTANCE_ID = "legacy"; - private static final Trace LOGGER = TraceManager.getTrace(TestDummyLegacy.class); - private static final String OBJECTCLASS_NATIVE_ACCOUNT = "account"; private static final String OBJECTCLASS_NATIVE_GROUP = "group"; private static final String OBJECTCLASS_NATIVE_PRIVILEGE = "privilege"; @@ -78,7 +72,7 @@ public class TestDummyLegacy extends AbstractIntegrationTest { private static DummyResource dummyResourceLegacy; private DummyResourceContoller dummyResourceLegacyCtl; - @Autowired(required = true) + @Autowired private ProvisioningService provisioningService; @Override @@ -98,19 +92,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti dummyResourceLegacyCtl = DummyResourceContoller.create(RESOURCE_DUMMY_LEGACY_INSTANCE_ID); dummyResourceLegacyCtl.setResource(resourceLegacy); dummyResourceLegacy = dummyResourceLegacyCtl.getDummyResource(); -} + } @Test public void test100NativeIntegrity() throws Exception { - final String TEST_NAME = "test100NativeIntegrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceNative.toString()); assertNotNull("Resource is null", resourceNative); assertNotNull("ResourceType is null", resourceTypeNative); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result) @@ -119,11 +110,8 @@ public void test100NativeIntegrity() throws Exception { @Test public void test103NativeTestResource() throws Exception { - final String TEST_NAME = "test103NativeTestResource"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NATIVE_OID, null, result) @@ -159,11 +147,8 @@ public void test103NativeTestResource() throws Exception { @Test public void test105NativeParsedSchema() throws Exception { - final String TEST_NAME = "test105NativeParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -188,15 +173,12 @@ public void test105NativeParsedSchema() throws Exception { @Test public void test200LegacyIntegrity() throws Exception { - final String TEST_NAME = "test200LegacyIntegrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceLegacy.toString()); assertNotNull("Resource is null", resourceLegacy); assertNotNull("ResourceType is null", resourceTypeLegacy); - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result) @@ -205,11 +187,8 @@ public void test200LegacyIntegrity() throws Exception { @Test public void test203LegacyTestResource() throws Exception { - final String TEST_NAME = "test203LegacyTestResource"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result) @@ -245,11 +224,8 @@ public void test203LegacyTestResource() throws Exception { @Test public void test205LegacyParsedSchema() throws Exception { - final String TEST_NAME = "test205LegacyParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -274,12 +250,12 @@ public void test205LegacyParsedSchema() throws Exception { private void assertObjectClass(ResourceSchema schema, String objectClassLocalName) { ObjectClassComplexTypeDefinition ocDef = schema.findObjectClassDefinition(objectClassLocalName); - assertNotNull("No objectclass "+objectClassLocalName+" found in schema", ocDef); + assertNotNull("No objectclass " + objectClassLocalName + " found in schema", ocDef); } private void assertNoObjectClass(ResourceSchema schema, String objectClassLocalName) { ObjectClassComplexTypeDefinition ocDef = schema.findObjectClassDefinition(objectClassLocalName); - assertNull("Objectclass "+objectClassLocalName+" found in schema while not expecting it", ocDef); + assertNull("Objectclass " + objectClassLocalName + " found in schema while not expecting it", ocDef); } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java index 5817c747302..675d93a8937 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyLimited.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; @@ -31,7 +30,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.RunAsCapabilityType; @@ -97,11 +95,9 @@ protected String getLastModifierName(String expected) { @Test @Override public void test150DisableAccount() throws Exception { - final String TEST_NAME = "test150DisableAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -138,17 +134,15 @@ public void test150DisableAccount() throws Exception { } @Override - public void test151SearchDisabledAccounts() throws Exception { + public void test151SearchDisabledAccounts() { // N/A } @Override public void test152ActivationStatusUndefinedAccount() throws Exception { - final String TEST_NAME = "test152ActivationStatusUndefinedAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -188,11 +182,9 @@ public void test152ActivationStatusUndefinedAccount() throws Exception { @Test @Override public void test154EnableAccount() throws Exception { - final String TEST_NAME = "test154EnableAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -230,23 +222,19 @@ public void test154EnableAccount() throws Exception { } @Override - public void test155SearchDisabledAccounts() throws Exception { + public void test155SearchDisabledAccounts() { // N/A } @Test @Override public void test156SetValidFrom() throws Exception { - final String TEST_NAME = "test156SetValidFrom"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); - long millis = VALID_FROM_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_FROM, XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS)); @@ -283,16 +271,12 @@ public void test156SetValidFrom() throws Exception { @Test @Override public void test157SetValidTo() throws Exception { - final String TEST_NAME = "test157SetValidTo"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); - long millis = VALID_TO_MILLIS; - ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS)); @@ -328,11 +312,9 @@ public void test157SetValidTo() throws Exception { @Override public void test158DeleteValidToValidFrom() throws Exception { - final String TEST_NAME = "test158DeleteValidToValidFrom"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -379,23 +361,21 @@ public void test158DeleteValidToValidFrom() throws Exception { @Test @Override - public void test159GetLockedoutAccount() throws Exception { + public void test159GetLockedoutAccount() { // Not relevant } @Override - public void test160SearchLockedAccounts() throws Exception { + public void test160SearchLockedAccounts() { // N/A } @Test @Override public void test162UnlockAccount() throws Exception { - final String TEST_NAME = "test162UnlockAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -418,7 +398,7 @@ public void test162UnlockAccount() throws Exception { // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); display("modifyObject result", result); TestUtil.assertFailure(result); @@ -446,13 +426,13 @@ protected Integer getTest18xApproxNumberOfSearchResults() { @Test @Override - public void test181SearchNullPagingOffset0Size3Desc() throws Exception { + public void test181SearchNullPagingOffset0Size3Desc() { // Nothing to do. No sorting support. So desc sorting won't work at all. } @Test @Override - public void test183SearchNullPagingOffset2Size3Desc() throws Exception { + public void test183SearchNullPagingOffset2Size3Desc() { // Nothing to do. No sorting support. So desc sorting won't work at all. } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java index 690b8116fc3..7a56e106dd7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyNegative.java @@ -6,9 +6,7 @@ */ package com.evolveum.midpoint.provisioning.impl.dummy; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; @@ -30,8 +28,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -44,35 +40,32 @@ @DirtiesContext public class TestDummyNegative extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyNegative.class); - - private static final File ACCOUNT_ELAINE_RESOURCE_NOT_FOUND_FILE = new File(TEST_DIR, "account-elaine-resource-not-found.xml"); + private static final File ACCOUNT_ELAINE_RESOURCE_NOT_FOUND_FILE = + new File(TEST_DIR, "account-elaine-resource-not-found.xml"); @Test public void test110GetResourceBrokenSchemaNetwork() throws Exception { - testGetResourceBrokenSchema(BreakMode.NETWORK, "test110GetResourceBrokenSchemaNetwork"); + testGetResourceBrokenSchema(BreakMode.NETWORK); } @Test public void test111GetResourceBrokenSchemaGeneric() throws Exception { - testGetResourceBrokenSchema(BreakMode.GENERIC, "test111GetResourceBrokenSchemaGeneric"); + testGetResourceBrokenSchema(BreakMode.GENERIC); } @Test public void test112GetResourceBrokenSchemaIo() throws Exception { - testGetResourceBrokenSchema(BreakMode.IO, "test112GetResourceBrokenSchemaIO"); + testGetResourceBrokenSchema(BreakMode.IO); } @Test public void test113GetResourceBrokenSchemaRuntime() throws Exception { - testGetResourceBrokenSchema(BreakMode.RUNTIME, "test113GetResourceBrokenSchemaRuntime"); + testGetResourceBrokenSchema(BreakMode.RUNTIME); } - public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) throws Exception { - TestUtil.displayTestTitle(testName); + public void testGetResourceBrokenSchema(BreakMode breakMode) throws Exception { // GIVEN - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + "."+testName); + OperationResult result = createOperationalResult(); // precondition PrismObject repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result); @@ -106,18 +99,17 @@ public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) th @Test public void test190GetResource() throws Exception { final String TEST_NAME = "test190GetResource"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyResource.setSchemaBreakMode(BreakMode.NONE); syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Resource after", resource); @@ -128,9 +120,8 @@ public void test190GetResource() throws Exception { @Test public void test200AddAccountNullAttributes() throws Exception { final String TEST_NAME = "test200AddAccountNullAttributes"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -142,7 +133,7 @@ public void test200AddAccountNullAttributes() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.addObject(account, null, null, task, result); assertNotReached(); @@ -151,18 +142,15 @@ public void test200AddAccountNullAttributes() throws Exception { display("Expected exception", e); } - displayThen(TEST_NAME); + then(); syncServiceMock.assertNotifyFailureOnly(); } @Test public void test201AddAccountEmptyAttributes() throws Exception { - TestUtil.displayTestTitle("test201AddAccountEmptyAttributes"); // GIVEN - Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() - + ".test201AddAccountEmptyAttributes"); - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + ".test201AddAccountEmptyAttributes"); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -188,12 +176,9 @@ public void test201AddAccountEmptyAttributes() throws Exception { @Test public void test210AddAccountNoObjectclass() throws Exception { - TestUtil.displayTestTitle("test210AddAccountNoObjectclass"); // GIVEN - Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() - + ".test210AddAccountNoObjectclass"); - OperationResult result = new OperationResult(TestDummyNegative.class.getName() - + ".test210AddAccountNoObjectclass"); + Task task =getTestTask(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); ShadowType accountType = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); @@ -222,7 +207,6 @@ public void test210AddAccountNoObjectclass() throws Exception { @Test public void test220AddAccountNoResourceRef() throws Exception { final String TEST_NAME = "test220AddAccountNoResourceRef"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); @@ -254,7 +238,6 @@ public void test220AddAccountNoResourceRef() throws Exception { @Test public void test221DeleteAccountResourceNotFound() throws Exception { final String TEST_NAME = "test221DeleteAccountResourceNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); @@ -291,7 +274,6 @@ public void test221DeleteAccountResourceNotFound() throws Exception { @Test public void test230GetAccountDeletedShadow() throws Exception { final String TEST_NAME = "test230GetAccountDeletedShadow"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyNegative.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java index 2c1a959a5eb..b0a269c8174 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyParallelism.java @@ -12,10 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import org.apache.commons.lang.mutable.MutableBoolean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @@ -33,6 +31,7 @@ import com.evolveum.midpoint.repo.cache.RepositoryCache; import com.evolveum.midpoint.schema.ResultHandler; import com.evolveum.midpoint.schema.SearchResultList; +import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; @@ -48,30 +47,16 @@ import com.evolveum.midpoint.test.util.Counter; import com.evolveum.midpoint.test.util.ParallelTestThread; import com.evolveum.midpoint.util.FailableProducer; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -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.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * The test of Provisioning service on the API level. - * + *

* This test is focused on parallelism and race conditions. * The resource is configured to use proposed shadows and to record all * operations. - * + *

* The test is using dummy resource for speed and flexibility. * * @author Radovan Semancik @@ -81,8 +66,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestDummyParallelism extends AbstractBasicDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyParallelism.class); - @Autowired private CacheConfigurationManager cacheConfigurationManager; public static final File TEST_DIR = new File(TEST_DIR_DUMMY, "dummy-parallelism"); @@ -93,29 +76,28 @@ public class TestDummyParallelism extends AbstractBasicDummyTest { private static final long WAIT_TIMEOUT = 60000L; private static final int DUMMY_OPERATION_DELAY_RANGE = 1500; - - private static final int MESS_RESOURCE_ITERATIONS = 200; + private static final int MESS_RESOURCE_ITERATIONS = 100; private static final Random RND = new Random(); + /** + * Typical base thread count for non-heavy tasks. + */ + protected static final int CONCURRENT_TEST_THREAD_COUNT = 4; + protected static final int CONCURRENT_TEST_THREAD_COUNT_MAX = 15; + protected static final int CONCURRENT_TEST_THREAD_COUNT_HIGH = Math.min( + CONCURRENT_TEST_THREAD_COUNT + Runtime.getRuntime().availableProcessors() / 2, + CONCURRENT_TEST_THREAD_COUNT_MAX); + + protected static final int CONCURRENT_TEST_MAX_START_DELAY_FAST = 10; + protected static final int CONCURRENT_TEST_MAX_START_DELAY_SLOW = 150; + private String accountMorganOid; private String accountElizabethOid; private String accountWallyOid; private String groupScumOid; - protected int getConcurrentTestNumberOfThreads() { - return 5; - } - - protected int getConcurrentTestFastRandomStartDelayRange() { - return 10; - } - - protected int getConcurrentTestSlowRandomStartDelayRange() { - return 150; - } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -131,20 +113,17 @@ protected File getResourceDummyFile() { protected void assertWillRepoShadowAfterCreate(PrismObject repoShadow) { ShadowAsserter.forShadow(repoShadow, "repo") - .assertActiveLifecycleState() - .pendingOperations() + .assertActiveLifecycleState() + .pendingOperations() .singleOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertAdd(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertAdd(); } @Test public void test120ModifyWillReplaceFullname() throws Exception { - final String TEST_NAME = "test120ModifyWillReplaceFullname"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -154,25 +133,25 @@ public void test120ModifyWillReplaceFullname() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) - .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); + .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); assertRepoShadow(ACCOUNT_WILL_OID) - .assertActiveLifecycleState() - .pendingOperations() + .assertActiveLifecycleState() + .pendingOperations() .assertOperations(2) .modifyOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertModify(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertModify(); syncServiceMock.assertNotifySuccessOnly(); @@ -181,36 +160,33 @@ public void test120ModifyWillReplaceFullname() throws Exception { @Test public void test190DeleteWill() throws Exception { - final String TEST_NAME = "test190DeleteWill"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); assertNoDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); assertRepoShadow(ACCOUNT_WILL_OID) - .assertDead() - .assertIsNotExists() - .pendingOperations() + .assertDead() + .assertIsNotExists() + .pendingOperations() .assertOperations(3) .deleteOperation() - .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) - .delta() - .assertDelete(); + .assertExecutionStatus(PendingOperationExecutionStatusType.COMPLETED) + .delta() + .assertDelete(); assertShadowProvisioning(ACCOUNT_WILL_OID) - .assertTombstone(); + .assertTombstone(); assertSteadyResource(); } @@ -221,29 +197,27 @@ public void test190DeleteWill() throws Exception { */ @Test public void test200ParallelCreate() throws Exception { - final String TEST_NAME = "test200ParallelCreate"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(); accountMorganOid = null; - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); ShadowType account = parseObjectType(ACCOUNT_MORGAN_FILE, ShadowType.class); try { - String thisAccountMorganOid = provisioningService.addObject(account.asPrismObject(), null, null, localTask, localResult); + String thisAccountMorganOid = provisioningService.addObject( + account.asPrismObject(), null, null, task, localResult); successCounter.click(); synchronized (dummyResource) { @@ -255,13 +229,13 @@ public void test200ParallelCreate() throws Exception { } } catch (ObjectAlreadyExistsException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } - }, 15, getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -279,16 +253,14 @@ public void test200ParallelCreate() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. */ @Test public void test202ParallelModifyCaptainMorgan() throws Exception { - final String TEST_NAME = "test202ParallelModifyCaptainMorgan"; - - PrismObject shadowAfter = parallelModifyTest(TEST_NAME, + PrismObject shadowAfter = parallelModifyTest( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountMorganOid, dummyResourceCtl.getAttributeFullnamePath(), "Captain Morgan")); @@ -298,16 +270,14 @@ public void test202ParallelModifyCaptainMorgan() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. */ @Test public void test204ParallelModifyDisable() throws Exception { - final String TEST_NAME = "test204ParallelModifyDisable"; - - PrismObject shadowAfter = parallelModifyTest(TEST_NAME, + PrismObject shadowAfter = parallelModifyTest( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountMorganOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED)); @@ -315,38 +285,37 @@ public void test204ParallelModifyDisable() throws Exception { assertActivationAdministrativeStatus(shadowAfter, ActivationStatusType.DISABLED); } - private PrismObject parallelModifyTest(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { - displayTestTitle(TEST_NAME); + private PrismObject parallelModifyTest( + FailableProducer> deltaProducer) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountMorganOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ObjectDelta delta = deltaProducer.run(); display("ObjectDelta", delta); - provisioningService.modifyObject(ShadowType.class, accountMorganOid, delta.getModifications(), null, null, localTask, localResult); + provisioningService.modifyObject(ShadowType.class, accountMorganOid, delta.getModifications(), null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -357,10 +326,10 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila RepositoryCache.exit(); - }, getConcurrentTestNumberOfThreads(), getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountMorganOid, null, task, result); @@ -377,28 +346,25 @@ private PrismObject parallelModifyTest(final String TEST_NAME, Faila @Test public void test209ParallelDelete() throws Exception { - final String TEST_NAME = "test209ParallelDelete"; - displayTestTitle(TEST_NAME); - // GIVEN final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + Task task = getTestTask(); + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); try { - display("Thread "+Thread.currentThread().getName()+" START"); - provisioningService.deleteObject(ShadowType.class, accountMorganOid, null, null, localTask, localResult); + display("Thread " + Thread.currentThread().getName() + " START"); + provisioningService.deleteObject(ShadowType.class, accountMorganOid, null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -410,24 +376,24 @@ public void test209ParallelDelete() throws Exception { } } catch (ObjectNotFoundException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); assertRepoShadow(accountMorganOid) - .assertTombstone(); + .assertTombstone(); assertShadowProvisioning(accountMorganOid) - .assertTombstone(); + .assertTombstone(); assertDummyResourceWriteOperationCountIncrement(null, 1); @@ -436,44 +402,41 @@ public void test209ParallelDelete() throws Exception { @Test public void test210ParallelCreateSlow() throws Exception { - final String TEST_NAME = "test210ParallelCreateSlow"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ShadowType account = parseObjectType(ACCOUNT_ELIZABETH_FILE, ShadowType.class); try { - accountElizabethOid = provisioningService.addObject(account.asPrismObject(), null, null, localTask, localResult); + accountElizabethOid = provisioningService.addObject(account.asPrismObject(), null, null, task, localResult); successCounter.click(); } catch (ObjectAlreadyExistsException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); @@ -489,16 +452,14 @@ public void test210ParallelCreateSlow() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. */ @Test public void test212ParallelModifyElizabethSlow() throws Exception { - final String TEST_NAME = "test212ParallelModifyElizabethSlow"; - - PrismObject shadowAfter = parallelModifyTestSlow(TEST_NAME, + PrismObject shadowAfter = parallelModifyTestSlow( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountElizabethOid, dummyResourceCtl.getAttributeFullnamePath(), "Miss Swan")); @@ -508,16 +469,14 @@ public void test212ParallelModifyElizabethSlow() throws Exception { /** * Create a lot parallel modifications for the same property and the same value. * These should all be eliminated - except for one of them. - * + *

* There is a slight chance that one of the thread starts after the first operation * is finished. But the threads are fast and the operations are slow. So this is * a very slim chance. */ @Test public void test214ParallelModifyDisableSlow() throws Exception { - final String TEST_NAME = "test214ParallelModifyDisableSlow"; - - PrismObject shadowAfter = parallelModifyTestSlow(TEST_NAME, + PrismObject shadowAfter = parallelModifyTestSlow( () -> prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountElizabethOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED)); @@ -525,38 +484,35 @@ public void test214ParallelModifyDisableSlow() throws Exception { assertActivationAdministrativeStatus(shadowAfter, ActivationStatusType.DISABLED); } - private PrismObject parallelModifyTestSlow(final String TEST_NAME, FailableProducer> deltaProducer) throws Exception { - displayTestTitle(TEST_NAME); + private PrismObject parallelModifyTestSlow( + FailableProducer> deltaProducer) throws Exception { - // GIVEN - Task task = createTask(TEST_NAME); + given(); + Task task = getTestTask(); OperationResult result = task.getResult(); final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); - // WHEN - displayWhen(TEST_NAME); - - ParallelTestThread[] threads = multithread(TEST_NAME, + when(); + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountElizabethOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); ObjectDelta delta = deltaProducer.run(); display("ObjectDelta", delta); - provisioningService.modifyObject(ShadowType.class, accountElizabethOid, delta.getModifications(), null, null, localTask, localResult); + provisioningService.modifyObject(ShadowType.class, accountElizabethOid, delta.getModifications(), null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -567,10 +523,10 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F RepositoryCache.exit(); - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject shadowAfter = provisioningService.getObject(ShadowType.class, accountElizabethOid, null, task, result); @@ -585,36 +541,32 @@ private PrismObject parallelModifyTestSlow(final String TEST_NAME, F return shadowAfter; } - @Test public void test229ParallelDeleteSlow() throws Exception { - final String TEST_NAME = "test229ParallelDeleteSlow"; - displayTestTitle(TEST_NAME); - // GIVEN final Counter successCounter = new Counter(); rememberDummyResourceWriteOperationCount(null); // WHEN - displayWhen(TEST_NAME); + when(); - ParallelTestThread[] threads = multithread(TEST_NAME, + Task task = getTestTask(); + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); + OperationResult localResult = task.getResult().createSubresult("thread-" + i); RepositoryCache.enter(cacheConfigurationManager); // Playing with cache, trying to make a worst case PrismObject shadowBefore = repositoryService.getObject(ShadowType.class, accountElizabethOid, null, localResult); - randomDelay(getConcurrentTestSlowRandomStartDelayRange()); - LOGGER.info("{} starting to do some work", Thread.currentThread().getName()); + randomDelay(CONCURRENT_TEST_MAX_START_DELAY_SLOW); + logger.info("{} starting to do some work", Thread.currentThread().getName()); try { - display("Thread "+Thread.currentThread().getName()+" START"); - provisioningService.deleteObject(ShadowType.class, accountElizabethOid, null, null, localTask, localResult); + display("Thread " + Thread.currentThread().getName() + " START"); + provisioningService.deleteObject(ShadowType.class, accountElizabethOid, null, null, task, localResult); localResult.computeStatus(); - display("Thread "+Thread.currentThread().getName()+" DONE, result", localResult); + display("Thread " + Thread.currentThread().getName() + " DONE, result", localResult); if (localResult.isSuccess()) { successCounter.click(); } else if (localResult.isInProgress()) { @@ -624,24 +576,24 @@ public void test229ParallelDeleteSlow() throws Exception { } } catch (ObjectNotFoundException e) { // this is expected ... sometimes - LOGGER.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); + logger.info("Exception (maybe expected): {}: {}", e.getClass().getSimpleName(), e.getMessage()); } finally { RepositoryCache.exit(); } - }, getConcurrentTestNumberOfThreads(), null); + }, CONCURRENT_TEST_THREAD_COUNT, null); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); successCounter.assertCount("Wrong number of successful operations", 1); assertRepoShadow(accountElizabethOid) - .assertTombstone(); + .assertTombstone(); assertShadowProvisioning(accountElizabethOid) - .assertTombstone(); + .assertTombstone(); assertDummyResourceWriteOperationCountIncrement(null, 1); @@ -653,15 +605,13 @@ public void test229ParallelDeleteSlow() throws Exception { * Do that in several threads at once. The group will be "discovered" * by the threads at the same time, each thread trying to create shadow. * There is a chance that the shadows get duplicated. - * + *

* MID-5237 */ @Test public void test230ParallelGroupSearch() throws Exception { - final String TEST_NAME = "test230ParallelGroupSearch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyGroup groupScum = new DummyGroup(GROUP_SCUM_NAME); @@ -675,15 +625,12 @@ public void test230ParallelGroupSearch() throws Exception { dummyResource.setOperationDelayRange(0); dummyResource.setSyncSearchHandlerStart(true); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (i) -> { - Task localTask = createTask(TEST_NAME + ".local"); - OperationResult localResult = localTask.getResult(); - ObjectQuery query = createGroupNameQuery(GROUP_SCUM_NAME); SearchResultList> foundObjects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected number of shadows found: "+foundObjects, 1, foundObjects.size()); + assertEquals("Unexpected number of shadows found: " + foundObjects, 1, foundObjects.size()); successCounter.click(); PrismObject groupShadow = foundObjects.get(0); @@ -703,13 +650,13 @@ public void test230ParallelGroupSearch() throws Exception { Thread.sleep(100); // WHEN - displayWhen(TEST_NAME); + when(); // Unblock the handlers. And here we go! dummyResource.unblockAll(); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); dummyResource.setSyncSearchHandlerStart(false); @@ -745,15 +692,12 @@ private ObjectQuery createGroupNameQuery(String groupName) throws SchemaExceptio * Several threads reading from resource. Couple other threads try to get into the way * by modifying the resource, hence forcing connector re-initialization. * The goal is to detect connector initialization race conditions. - * + *

* MID-5068 */ @Test public void test800ParallelReadAndModifyResource() throws Exception { - final String TEST_NAME = "test800ParallelReadAndModifyResource"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Previous test will max out the connector pool @@ -770,74 +714,69 @@ public void test800ParallelReadAndModifyResource() throws Exception { result.computeStatus(); if (result.getStatus() != OperationResultStatus.SUCCESS) { display("Failed read result (precondition)", result); - fail("Unexpected read status (precondition): "+result.getStatus()); + fail("Unexpected read status (precondition): " + result.getStatus()); } // WHEN - displayWhen(TEST_NAME); + when(); long t0 = System.currentTimeMillis(); MutableBoolean readFinished = new MutableBoolean(); - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (threadIndex) -> { - if (threadIndex <= 6) { - + // roughly half the threads will try to mess with the resource + if (threadIndex < CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { + messResource(threadIndex, i); - messResource(TEST_NAME, threadIndex, i); - - display("T +"+(System.currentTimeMillis() - t0)); + display("T +" + (System.currentTimeMillis() - t0)); if (readFinished.booleanValue()) { break; } - } - } else if (threadIndex == 7) { - + } else if (threadIndex == CONCURRENT_TEST_THREAD_COUNT_HIGH / 2) { for (int i = 0; /* neverending */ ; i++) { - - Task localTask = createTask(TEST_NAME + ".test."+i); - - LOGGER.debug("PAR: TESTing "+threadIndex+"."+i); - + Task localTask = createPlainTask("test-" + i); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, localTask); - display("PAR: TESTed "+threadIndex+"."+i+": "+testResult.getStatus()); + logger.debug("PAR: TESTing " + threadIndex + "." + i); + + display("PAR: TESTed " + threadIndex + "." + i + ": " + testResult.getStatus()); if (testResult.getStatus() != OperationResultStatus.SUCCESS) { display("Failed test resource result", testResult); readFinished.setValue(true); - fail("Unexpected test resource result status: "+testResult.getStatus()); + fail("Unexpected test resource result status: " + testResult.getStatus()); } if (readFinished.booleanValue()) { break; } - } } else { - + // the rest nearly half of the threads will try to do operations try { + // TODO: why is the constant MESS_RESOURCE_ITERATIONS used for operations? for (int i = 0; i < MESS_RESOURCE_ITERATIONS; i++) { - Task localTask = createTask(TEST_NAME + ".op."+i); + Task localTask = createPlainTask("op-" + i); OperationResult localResult = localTask.getResult(); - LOGGER.debug("PAR: OPing "+threadIndex+"."+i); + logger.debug("PAR: OPing " + threadIndex + "." + i); - Object out = doResourceOperation(threadIndex, i, localTask, localResult); + Object out = doResourceOperation(task, localResult); localResult.computeStatus(); - display("PAR: OPed "+threadIndex+"."+i+": " + out.toString() + ": "+localResult.getStatus()); + display("PAR: OPed " + threadIndex + "." + i + ": " + out.toString() + ": " + localResult.getStatus()); if (localResult.getStatus() != OperationResultStatus.SUCCESS) { display("Failed read result", localResult); readFinished.setValue(true); - fail("Unexpected read status: "+localResult.getStatus()); + fail("Unexpected read status: " + localResult.getStatus()); } if (readFinished.booleanValue()) { @@ -849,12 +788,12 @@ public void test800ParallelReadAndModifyResource() throws Exception { } } - display("mischief managed ("+threadIndex+")"); + display("mischief managed (" + threadIndex + ")"); - }, 15, getConcurrentTestFastRandomStartDelayRange()); + }, CONCURRENT_TEST_THREAD_COUNT_HIGH, CONCURRENT_TEST_MAX_START_DELAY_FAST); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, WAIT_TIMEOUT); PrismObject resourceAfter = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result); @@ -868,7 +807,7 @@ public void test800ParallelReadAndModifyResource() throws Exception { assertDummyConnectorInstances(dummyResource.getConnectionCount()); } - private Object doResourceOperation(int threadIndex, int i, Task task, OperationResult result) throws Exception { + private Object doResourceOperation(Task task, OperationResult result) throws Exception { int op = RND.nextInt(3); if (op == 0) { @@ -877,7 +816,10 @@ private Object doResourceOperation(int threadIndex, int i, Task task, OperationR } else if (op == 1) { ObjectQuery query = ObjectQueryUtil.createResourceAndKind(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, prismContext); List> list = new ArrayList<>(); - ResultHandler handler = (o,or) -> { list.add(o); return true; }; + ResultHandler handler = (o, or) -> { + list.add(o); + return true; + }; provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); return list; @@ -888,23 +830,26 @@ private Object doResourceOperation(int threadIndex, int i, Task task, OperationR return null; } - private void messResource(final String TEST_NAME, int threadIndex, int i) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException, ExpressionEvaluationException { - Task task = createTask(TEST_NAME+".mess."+threadIndex+"."+i); + private void messResource(int threadIndex, int i) + throws ObjectNotFoundException, SchemaException, CommunicationException, + ConfigurationException, SecurityViolationException, PolicyViolationException, + ObjectAlreadyExistsException, ExpressionEvaluationException { + Task task = createPlainTask("mess-" + threadIndex + "-" + i); OperationResult result = task.getResult(); - List> deltas = deltaFor(ResourceType.class) - .item(ResourceType.F_DESCRIPTION).replace("Iter "+threadIndex+"."+i) - .asItemDeltas(); + List> deltas = deltaFor(ResourceType.class) + .item(ResourceType.F_DESCRIPTION).replace("Iter " + threadIndex + "." + i) + .asItemDeltas(); - LOGGER.debug("PAR: MESSing "+threadIndex+"."+i); + logger.debug("PAR: MESSing " + threadIndex + "." + i); provisioningService.modifyObject(ResourceType.class, RESOURCE_DUMMY_OID, deltas, null, null, task, result); result.computeStatus(); - display("PAR: MESSed "+threadIndex+"."+i+": "+result.getStatus()); + display("PAR: MESSed " + threadIndex + "." + i + ": " + result.getStatus()); if (result.getStatus() != OperationResultStatus.SUCCESS) { display("Failed mess resource result", result); - fail("Unexpected mess resource result status: "+result.getStatus()); + fail("Unexpected mess resource result status: " + result.getStatus()); } } } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java index 355b1b9c202..36a48e894e9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyPrioritiesAndReadReplace.java @@ -66,8 +66,6 @@ @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestDummyPrioritiesAndReadReplace extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummyPrioritiesAndReadReplace.class); - protected String willIcfUid; public static final File TEST_DIR = new File(TEST_DIR_DUMMY, "dummy-priorities-read-replace"); @@ -93,13 +91,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // copied from TestDummy @Test public void test100AddAccount() throws Exception { - final String TEST_NAME = "test100AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); + OperationResult result = task.getResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(getAccountWillFile()); @@ -176,11 +170,7 @@ public void test100AddAccount() throws Exception { @Test public void test123ModifyObjectReplace() throws Exception { - final String TEST_NAME = "test123ModifyObjectReplace"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummyPrioritiesAndReadReplace.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -273,11 +263,7 @@ private Collection parseUpdatedAttributes(String attributes) { @Test public void test150ModifyObjectAddDelete() throws Exception { - final String TEST_NAME = "test150ModifyObjectAddDelete"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummyPrioritiesAndReadReplace.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java index ef4e9859bfc..adb7fa38a6e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyResourceAndSchemaCaching.java @@ -63,7 +63,6 @@ public class TestDummyResourceAndSchemaCaching extends AbstractDummyTest { @Test public void test010GetResource() throws Exception { final String TEST_NAME = "test010GetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -88,11 +87,11 @@ public void test010GetResource() throws Exception { rememberResourceCacheStats(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resourceProvisioning = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); display("Resource", resource); assertSuccess(result); @@ -133,7 +132,6 @@ public void test010GetResource() throws Exception { @Test public void test011GetResourceAgain() throws Exception { final String TEST_NAME = "test011GetResourceAgain"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -204,7 +202,6 @@ public void test011GetResourceAgain() throws Exception { @Test public void test012AddAccountGetResource() throws Exception { final String TEST_NAME = "test012AddAccountGetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -247,7 +244,6 @@ public void test012AddAccountGetResource() throws Exception { @Test public void test013GetResourceNoFetch() throws Exception { final String TEST_NAME = "test013GetResourceNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -321,7 +317,6 @@ public void test013GetResourceNoFetch() throws Exception { @Test public void test020ModifyAndGetResource() throws Exception { final String TEST_NAME = "test020ModifyAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -383,7 +378,6 @@ public void test020ModifyAndGetResource() throws Exception { @Test public void test022GetAccountGetResource() throws Exception { final String TEST_NAME = "test012AddAccountGetResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -434,7 +428,6 @@ public void test022GetAccountGetResource() throws Exception { @Test public void test023ModifyRepoAndGetResource() throws Exception { final String TEST_NAME = "test023ModifyRepoAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -496,7 +489,6 @@ public void test023ModifyRepoAndGetResource() throws Exception { @Test public void test030ModifyConnectorConfigAndGetResource() throws Exception { final String TEST_NAME = "test030ModifyConnectorConfigAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -527,7 +519,6 @@ public void test030ModifyConnectorConfigAndGetResource() throws Exception { @Test public void test031ModifyConnectorConfigRepoAndGetResource() throws Exception { final String TEST_NAME = "test031ModifyConnectorConfigRepoAndGetResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); @@ -552,7 +543,6 @@ public void test031ModifyConnectorConfigRepoAndGetResource() throws Exception { @Test public void test900DeleteResource() throws Exception { final String TEST_NAME = "test900DeleteResource"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java index c4e9c1733c6..c5058f036eb 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySchemaless.java @@ -62,8 +62,6 @@ import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; @@ -101,9 +99,6 @@ public class TestDummySchemaless extends AbstractProvisioningIntegrationTest { private static final File ACCOUNT_WILL_FILE = new File(TEST_DIR, "account-will.xml"); private static final String ACCOUNT_WILL_OID = "c0c010c0-d34d-b44f-f11d-33322212dddd"; - private static final String ACCOUNT_WILL_ICF_UID = "will"; - - private static final Trace LOGGER = TraceManager.getTrace(TestDummySchemaless.class); private PrismObject resourceSchemaless; private ResourceType resourceTypeSchemaless; @@ -113,7 +108,7 @@ public class TestDummySchemaless extends AbstractProvisioningIntegrationTest { private static DummyResource dummyResourceStaticSchema; private static DummyResourceContoller dummyResourceSchemalessCtl; - @Autowired(required = true) + @Autowired private ProvisioningService provisioningService; public TestDummySchemaless() { @@ -154,9 +149,6 @@ protected PrismObject getResource() { @Test public void test000Integrity() throws Exception { - final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(TEST_NAME); - display("Dummy resource instance", dummyResourceSchemaless.toString()); assertNotNull("Resource is null", resourceSchemaless); @@ -187,10 +179,8 @@ public void test000Integrity() throws Exception { */ @Test public void test003ConnectionSchemaless() throws Exception { - final String TEST_NAME = "test003ConnectionSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is no schema before test (pre-condition) ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, result) @@ -229,10 +219,7 @@ public void test003ConnectionSchemaless() throws Exception { */ @Test public void test005ParsedSchemaSchemaless() throws Exception { - final String TEST_NAME = "test005ParsedSchemaSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -248,11 +235,8 @@ public void test005ParsedSchemaSchemaless() throws Exception { @Test public void test006GetObjectSchemaless() throws Exception { - final String TEST_NAME = "test006GetObjectSchemaless"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); - + OperationResult result = createOperationalResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); ResourceType resourceType = resource.asObjectable(); @@ -262,13 +246,12 @@ public void test006GetObjectSchemaless() throws Exception { @Test public void test020ResourceStaticSchemaTest() throws Exception { - resourceStaticSchemaTest("test020ResourceStaticSchemaTest", 1); + resourceStaticSchemaTest(1); } - public void resourceStaticSchemaTest(final String TEST_NAME, int expectedConnectorInitCount) throws Exception { - displayTestTitle(TEST_NAME); + public void resourceStaticSchemaTest(int expectedConnectorInitCount) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Some connector initialization and other things might happen in previous tests. @@ -356,7 +339,6 @@ public void test030ResourceStatciSchemaResourceAndConnectorCaching() throws Exce } public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME); @@ -386,12 +368,12 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA assertStaticSchemaSanity(resourceSchemaBefore); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); ResourceType resourceTypeAgain = resourceAgain.asObjectable(); @@ -455,20 +437,19 @@ public void resourceStatciSchemaResourceAndConnectorCaching(final String TEST_NA @Test public void test040ReAddResourceStaticSchema() throws Exception { final String TEST_NAME = "test040ReAddResourceStaticSchema"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resourceNew = prismContext.parseObject(RESOURCE_DUMMY_STATIC_SCHEMA_FILE); fillInConnectorRef(resourceNew, IntegrationTestTools.DUMMY_CONNECTOR_TYPE, result); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.addObject(resourceNew, null, ProvisioningOperationOptions.createOverwrite(true), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_FETCH_COUNT, 0); @@ -488,7 +469,7 @@ public void test040ReAddResourceStaticSchema() throws Exception { @Test public void test042ResourceStaticSchemaTestAgain() throws Exception { - resourceStaticSchemaTest("test042ResourceStaticSchemaTestAgain", 0); + resourceStaticSchemaTest(0); } /** @@ -509,10 +490,8 @@ public void test044ResourceStatciSchemaResourceAndConnectorCachingAgain() throws */ @Test public void test103ConnectionStaticSchema() throws Exception { - final String TEST_NAME = "test103ConnectionStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there a schema before test (pre-condition) @@ -550,10 +529,7 @@ public void test103ConnectionStaticSchema() throws Exception { */ @Test public void test105ParsedSchemaStaticSchema() throws Exception { - final String TEST_NAME = "test105ParsedSchemaStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -570,10 +546,8 @@ public void test105ParsedSchemaStaticSchema() throws Exception { @Test public void test106GetObjectStaticSchema() throws Exception { - final String TEST_NAME = "test106GetObjectStaticSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); + OperationResult result = createOperationalResult(); PrismObject resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); @@ -698,18 +672,17 @@ private void assertStaticSchemaSanity(ResourceSchema resorceSchema) { @Test public void test107Capabilities() throws Exception { final String TEST_NAME = "test107Capabilities"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); ResourceType resourceType = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result) .asObjectable(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Check native capabilities @@ -760,10 +733,8 @@ public void test107Capabilities() throws Exception { */ @Test public void test200AddAccount() throws Exception { - final String TEST_NAME = "test200AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ShadowType account = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class); account.asPrismObject().checkConsistence(); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java index 9d7f3656bf2..d9a6e47601e 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummySecurity.java @@ -34,8 +34,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.SchemaException; 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.OperationProvisioningScriptsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -49,18 +47,13 @@ @DirtiesContext public class TestDummySecurity extends AbstractDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestDummySecurity.class); private String willIcfUid; @Test public void test100AddAccountDrink() throws Exception { - final String TEST_NAME = "test100AddAccountDrink"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task syncTask = taskManager.createTaskInstance(TestDummySecurity.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummySecurity.class.getName() - + "." + TEST_NAME); + Task syncTask = getTestTask(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -75,12 +68,10 @@ public void test100AddAccountDrink() throws Exception { provisioningService.addObject(account, null, null, syncTask, result); AssertJUnit.fail("Unexpected success"); - } catch (SecurityViolationException e) { // This is expected display("Expected exception", e); } - } private void setAttribute(PrismObject account, String attrName, T val) throws SchemaException { @@ -93,13 +84,9 @@ private void setAttribute(PrismObject account, String attrName, @Test public void test199AddAccount() throws Exception { - final String TEST_NAME = "test199AddAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task syncTask = taskManager.createTaskInstance(TestDummySecurity.class.getName() - + "." + TEST_NAME); - OperationResult result = new OperationResult(TestDummySecurity.class.getName() - + "." + TEST_NAME); + Task syncTask = getTestTask(); + OperationResult result = getTestOperationResult(); syncServiceMock.reset(); PrismObject account = prismContext.parseObject(ACCOUNT_WILL_FILE); @@ -123,11 +110,7 @@ public void test199AddAccount() throws Exception { @Test public void test200ModifyAccountDrink() throws Exception { - final String TEST_NAME = "test200ModifyAccountDrink"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -157,11 +140,7 @@ public void test200ModifyAccountDrink() throws Exception { @Test public void test201ModifyAccountGossip() throws Exception { - final String TEST_NAME = "test201ModifyAccountGossip"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -191,11 +170,7 @@ public void test201ModifyAccountGossip() throws Exception { @Test public void test210ModifyAccountQuote() throws Exception { - final String TEST_NAME = "test210ModifyAccountQuote"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = taskManager.createTaskInstance(TestDummy.class.getName() - + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -222,11 +197,8 @@ public void test210ModifyAccountQuote() throws Exception { @Test public void test300GetAccount() throws Exception { - final String TEST_NAME = "test300GetAccount"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result); @@ -240,18 +212,15 @@ public void test300GetAccount() throws Exception { assertNotNull("No dummy account", shadow); - checkAccountWill(shadow, result); + checkAccountWill(shadow); checkUniqueness(shadow); } @Test public void test310SearchAllShadows() throws Exception { - final String TEST_NAME = "test310SearchAllShadows"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(TestDummy.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ObjectQuery query = IntegrationTestTools.createAllShadowsQuery(resourceType, SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME, prismContext); display("All shadows query", query); @@ -281,7 +250,7 @@ public void test310SearchAllShadows() throws Exception { // TODO: search - private void checkAccountWill(PrismObject shadow, OperationResult result) { + private void checkAccountWill(PrismObject shadow) { Collection> attributes = ShadowUtil.getAttributes(shadow); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman"); assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE"); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java index bac9d424bdf..e3dc5771c71 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyUuidNonUniqueName.java @@ -86,17 +86,13 @@ protected String getLastModifierName(String expected) { @Test public void test770AddAccountFettuciniAlfredo() throws Exception { - final String TEST_NAME = "test770AddAccountFettuciniAlfredo"; - TestUtil.displayTestTitle(TEST_NAME); - addFettucini(TEST_NAME, ACCOUNT_FETTUCINI_ALFREDO_FILE, ACCOUNT_FETTUCINI_ALFREDO_OID, ACCOUNT_FETTUCINI_ALFREDO_FULLNAME); + addFettucini(ACCOUNT_FETTUCINI_ALFREDO_FILE, ACCOUNT_FETTUCINI_ALFREDO_OID, ACCOUNT_FETTUCINI_ALFREDO_FULLNAME); searchFettucini(1); } @Test public void test772AddAccountFettuciniBill() throws Exception { - final String TEST_NAME = "test772AddAccountFettuciniBill"; - TestUtil.displayTestTitle(TEST_NAME); - addFettucini(TEST_NAME, ACCOUNT_FETTUCINI_BILL_FILE, ACCOUNT_FETTUCINI_BILL_OID, ACCOUNT_FETTUCINI_BILL_FULLNAME); + addFettucini(ACCOUNT_FETTUCINI_BILL_FILE, ACCOUNT_FETTUCINI_BILL_OID, ACCOUNT_FETTUCINI_BILL_FULLNAME); searchFettucini(2); } @@ -105,21 +101,19 @@ public void test772AddAccountFettuciniBill() throws Exception { */ @Test public void test774AddAccountFettuciniCarlo() throws Exception { - final String TEST_NAME = "test774AddAccountFettuciniCarlo"; - TestUtil.displayTestTitle(TEST_NAME); dummyResourceCtl.addAccount(ACCOUNT_FETTUCINI_NAME, ACCOUNT_FETTUCINI_CARLO_FULLNAME); searchFettucini(3); } @Override @Test - public void test600AddAccountAlreadyExist() throws Exception { + public void test600AddAccountAlreadyExist() { // DO nothing. This test is meaningless in non-unique environment } - private String addFettucini(final String TEST_NAME, File file, String oid, String expectedFullName) throws Exception { + private String addFettucini(File file, String oid, String expectedFullName) throws Exception { // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -179,7 +173,8 @@ private String addFettucini(final String TEST_NAME, File file, String oid, Strin } private void searchFettucini(int expectedNumberOfFettucinis) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - Task task = createTask(TestDummy.class.getName() + ".searchFettucini"); + TestDummy.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java index ed66a1e6687..9e54daa18f9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/manual/AbstractManualResourceTest.java @@ -37,7 +37,6 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest; -import com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj; import com.evolveum.midpoint.schema.CapabilityUtil; import com.evolveum.midpoint.schema.GetOperationOptions; import com.evolveum.midpoint.schema.PointInTimeType; @@ -56,8 +55,6 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.asserter.ShadowAsserter; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType; import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; @@ -92,14 +89,11 @@ public abstract class AbstractManualResourceTest extends AbstractProvisioningInt protected static final String RESOURCE_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b"; protected static final File RESOURCE_SEMI_MANUAL_FILE = new File(TEST_DIR, "resource-semi-manual.xml"); - protected static final String RESOURCE_SEMI_MANUAL_OID = "8a8e19de-1a14-11e7-965f-6f995b457a8b"; public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass"); protected static final String MANUAL_CONNECTOR_TYPE = "ManualConnector"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class); - protected static final String NS_MANUAL_CONF = "http://midpoint.evolveum.com/xml/ns/public/connector/builtin-1/bundle/com.evolveum.midpoint.provisioning.ucf.impl.builtin/ManualConnector"; protected static final ItemName CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME = new ItemName(NS_MANUAL_CONF, "defaultAssignee"); @@ -163,14 +157,10 @@ protected boolean supportsBackingStore() { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - assertNotNull("Resource is null", resource); assertNotNull("ResourceType is null", resourceType); - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); ResourceType repoResource = repositoryService.getObject(ResourceType.class, getResourceOid(), null, result).asObjectable(); @@ -188,10 +178,8 @@ public void test000Sanity() throws Exception { @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Check that there is a schema, but no capabilities before test (pre-condition) @@ -241,11 +229,8 @@ public void test003Connection() throws Exception { @Test public void test004Configuration() throws Exception { - final String TEST_NAME = "test004Configuration"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() - + "." + TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result); @@ -266,10 +251,7 @@ public void test004Configuration() throws Exception { @Test public void test005ParsedSchema() throws Exception { - final String TEST_NAME = "test005ParsedSchema"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed @@ -316,11 +298,8 @@ protected int getNumberOfAccountAttributeDefinitions() { @Test public void test006Capabilities() throws Exception { - final String TEST_NAME = "test006Capabilities"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TestOpenDj.class.getName()+"."+TEST_NAME); + OperationResult result = createOperationalResult(); // WHEN ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable(); @@ -354,9 +333,8 @@ public void test006Capabilities() throws Exception { @Test public void test100AddAccountWill() throws Exception { final String TEST_NAME = "test100AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -368,11 +346,11 @@ public void test100AddAccountWill() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(account, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -427,20 +405,19 @@ public void test100AddAccountWill() throws Exception { @Test public void test102GetAccountWillFuture() throws Exception { final String TEST_NAME = "test102GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -462,9 +439,8 @@ public void test102GetAccountWillFuture() throws Exception { @Test public void test104RefreshAccountWill() throws Exception { final String TEST_NAME = "test104RefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -472,11 +448,11 @@ public void test104RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -517,9 +493,8 @@ protected void backingStoreAddWill() throws IOException { @Test public void test106AddToBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test106AddToBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); backingStoreAddWill(); @@ -527,11 +502,11 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { syncServiceMock.reset(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -559,9 +534,8 @@ public void test106AddToBackingStoreAndGetAccountWill() throws Exception { @Test public void test108GetAccountWillFuture() throws Exception { final String TEST_NAME = "test108GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -569,11 +543,11 @@ public void test108GetAccountWillFuture() throws Exception { Collection> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow", shadowProvisioning); @@ -603,16 +577,15 @@ public void test108GetAccountWillFuture() throws Exception { @Test public void test109GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test109GetAccountWillFutureNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); options.setNoFetch(true); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -620,7 +593,7 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -645,9 +618,8 @@ public void test109GetAccountWillFutureNoFetch() throws Exception { @Test public void test110CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test110CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -659,11 +631,11 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -708,9 +680,8 @@ public void test110CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test120RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test120RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -720,11 +691,11 @@ public void test120RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -761,9 +732,8 @@ public void test120RefreshAccountWillAfter5min() throws Exception { @Test public void test130RefreshAccountWillAfter16min() throws Exception { final String TEST_NAME = "test130RefreshAccountWillAfter16min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -773,11 +743,11 @@ public void test130RefreshAccountWillAfter16min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -814,9 +784,8 @@ public void test130RefreshAccountWillAfter16min() throws Exception { @Test public void test132RefreshAccountWillAfter27min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter27min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -826,11 +795,11 @@ public void test132RefreshAccountWillAfter27min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -854,9 +823,8 @@ public void test132RefreshAccountWillAfter27min() throws Exception { @Test public void test200ModifyAccountWillFullname() throws Exception { final String TEST_NAME = "test200ModifyAccountWillFullname"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -868,12 +836,12 @@ public void test200ModifyAccountWillFullname() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -937,9 +905,8 @@ public void test200ModifyAccountWillFullname() throws Exception { @Test public void test202RefreshAccountWill() throws Exception { final String TEST_NAME = "test202RefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -947,11 +914,11 @@ public void test202RefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1018,9 +985,8 @@ public void test202RefreshAccountWill() throws Exception { @Test public void test204CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test204CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1032,11 +998,11 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1112,9 +1078,8 @@ public void test204CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test210RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test210RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1124,11 +1089,11 @@ public void test210RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1181,9 +1146,8 @@ protected void backingStoreUpdateWill(String newFullName, ActivationStatusType n @Test public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test212UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1193,11 +1157,11 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1246,9 +1210,8 @@ public void test212UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test220ModifyAccountWillDisable() throws Exception { final String TEST_NAME = "test220ModifyAccountWillDisable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1260,12 +1223,12 @@ public void test220ModifyAccountWillDisable() throws Exception { accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -1330,9 +1293,8 @@ public void test220ModifyAccountWillDisable() throws Exception { @Test public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { final String TEST_NAME = "test230ModifyAccountWillChangePasswordAndEnable"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1347,12 +1309,12 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willSecondLastCaseOid = assertInProgress(result); @@ -1421,9 +1383,8 @@ public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception { @Test public void test240CloseDisableCaseAndReadAccountWill() throws Exception { final String TEST_NAME = "test240CloseDisableCaseAndReadAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1432,12 +1393,12 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1533,9 +1494,8 @@ public void test240CloseDisableCaseAndReadAccountWill() throws Exception { @Test public void test250RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test250RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1545,11 +1505,11 @@ public void test250RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1621,9 +1581,8 @@ public void test250RefreshAccountWillAfter5min() throws Exception { @Test public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test252UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1633,11 +1592,11 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.DISABLED, ACCOUNT_WILL_PASSWORD_OLD); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1687,9 +1646,8 @@ public void test252UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test260ClosePasswordChangeCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1703,11 +1661,11 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti accountWillSecondCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillSecondCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -1787,9 +1745,8 @@ public void test260ClosePasswordChangeCaseAndRefreshAccountWill() throws Excepti @Test public void test270RefreshAccountWillAfter7min() throws Exception { final String TEST_NAME = "test270RefreshAccountWillAfter7min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1799,11 +1756,11 @@ public void test270RefreshAccountWillAfter7min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1886,9 +1843,8 @@ public void test270RefreshAccountWillAfter7min() throws Exception { @Test public void test271RefreshAccountWillAfter12min() throws Exception { final String TEST_NAME = "test271RefreshAccountWillAfter12min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1898,11 +1854,11 @@ public void test271RefreshAccountWillAfter12min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -1982,9 +1938,8 @@ public void test271RefreshAccountWillAfter12min() throws Exception { @Test public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { final String TEST_NAME = "test272UpdateBackingStoreAndGetAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -1994,11 +1949,11 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { backingStoreUpdateWill(ACCOUNT_WILL_FULLNAME_PIRATE, ActivationStatusType.ENABLED, ACCOUNT_WILL_PASSWORD_NEW); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2047,9 +2002,8 @@ public void test272UpdateBackingStoreAndGetAccountWill() throws Exception { @Test public void test280RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test132RefreshAccountWillAfter10min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2059,11 +2013,11 @@ public void test280RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2136,9 +2090,8 @@ public void test280RefreshAccountWillAfter5min() throws Exception { @Test public void test290RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test134RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2148,11 +2101,11 @@ public void test290RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); @@ -2202,20 +2155,19 @@ public void test290RefreshAccountWillAfter5min() throws Exception { @Test public void test300DeleteAccountWill() throws Exception { final String TEST_NAME = "test300DeleteAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("result", result); willLastCaseOid = assertInProgress(result); @@ -2272,13 +2224,12 @@ public void test300DeleteAccountWill() throws Exception { @Test public void test302GetAccountWillFuture() throws Exception { final String TEST_NAME = "test302GetAccountWillFuture"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), @@ -2286,7 +2237,7 @@ public void test302GetAccountWillFuture() throws Exception { // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future)", shadowProvisioningFuture); @@ -2298,16 +2249,15 @@ public void test302GetAccountWillFuture() throws Exception { @Test public void test303GetAccountWillFutureNoFetch() throws Exception { final String TEST_NAME = "test303GetAccountWillFutureNoFetch"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); GetOperationOptions options = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); options.setNoFetch(true); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(options), @@ -2315,7 +2265,7 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Provisioning shadow (future,noFetch)", shadowProvisioningFuture); @@ -2331,9 +2281,8 @@ public void test303GetAccountWillFutureNoFetch() throws Exception { @Test public void test310CloseCaseAndRefreshAccountWill() throws Exception { final String TEST_NAME = "test310CloseCaseAndRefreshAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2345,11 +2294,11 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar(); @@ -2398,9 +2347,8 @@ public void test310CloseCaseAndRefreshAccountWill() throws Exception { @Test public void test320RefreshAccountWillAfter5min() throws Exception { final String TEST_NAME = "test320RefreshAccountWillAfter5min"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); syncServiceMock.reset(); @@ -2410,11 +2358,11 @@ public void test320RefreshAccountWillAfter5min() throws Exception { display("Shadow before", shadowBefore); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.refreshShadow(shadowBefore, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject shadowRepo = getShadowRepo(ACCOUNT_WILL_OID); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java index 203d757bd99..5e34f210be5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/AbstractOpenDjTest.java @@ -25,7 +25,6 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.util.DOMUtil; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java index 24bf857d3e4..ac1590ab088 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDj.java @@ -6,36 +6,16 @@ */ package com.evolveum.midpoint.provisioning.impl.opendj; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - +import java.util.*; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; -import com.evolveum.midpoint.prism.*; - -import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.*; -import com.evolveum.midpoint.schema.processor.*; - -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.commons.lang.StringUtils; import org.opends.server.types.Entry; import org.opends.server.util.LDIFException; @@ -52,25 +32,29 @@ import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; +import com.evolveum.midpoint.prism.query.ObjectPaging; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.OrderDirection; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.xml.XmlTypeConverter; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.DeltaConvertor; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; +import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; import com.evolveum.midpoint.test.IntegrationTestTools; @@ -89,20 +73,12 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType.Host; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; /** * Test for provisioning service implementation. @@ -162,25 +138,16 @@ protected int getNumberOfBaseContextShadows() { return 0; } - @Override - public void initSystem(Task initTask, OperationResult initResult) throws Exception { - super.initSystem(initTask, initResult); - - openDJController.addEntry("dn: ou=specialgroups,dc=example,dc=com\n"+ - "objectclass: organizationalUnit\n"+ - "ou: specialgroups\n"); - - // This is useful when debugging polystring issues, but too much noise otherwise -// DebugUtil.setDetailedDebugDump(true); - } - @BeforeClass public static void startLdap() throws Exception { LOGGER.info("------------------------------------------------------------------------------"); LOGGER.info("START: ProvisioningServiceImplOpenDJTest"); LOGGER.info("------------------------------------------------------------------------------"); try { - openDJController.startCleanServer(); + openDJController.startCleanServer(); + openDJController.addEntry("dn: ou=specialgroups,dc=example,dc=com\n" + + "objectclass: organizationalUnit\n" + + "ou: specialgroups\n"); } catch (IOException ex) { LOGGER.error("Couldn't start LDAP.", ex); throw ex; @@ -188,7 +155,7 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); LOGGER.info("------------------------------------------------------------------------------"); LOGGER.info("STOP: ProvisioningServiceImplOpenDJTest"); @@ -204,10 +171,7 @@ public static void stopLdap() throws Exception { */ @Test public void test003Connection() throws Exception { - final String TEST_NAME = "test003Connection"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resourceTypeBefore = repositoryService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, result).asObjectable(); assertNotNull("No connector ref",resourceTypeBefore.getConnectorRef()); @@ -262,9 +226,8 @@ public void test003Connection() throws Exception { @Test public void test004ResourceAndConnectorCaching() throws Exception { final String TEST_NAME = "test004ResourceAndConnectorCaching"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); resource = provisioningService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, null, result); @@ -286,19 +249,19 @@ public void test004ResourceAndConnectorCaching() throws Exception { PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); PrismContainer configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain)); - assertTrue("Configurations not equals", configurationContainer.equals(configurationContainerAgain)); + assertEquals("Configurations not equals", configurationContainerAgain, configurationContainer); ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext); assertNotNull("No resource schema (again)", resourceSchemaAgain); assertEquals("Schema serial number mismatch", resourceType.getSchema().getCachingMetadata().getSerialNumber(), resourceTypeAgain.getSchema().getCachingMetadata().getSerialNumber()); - assertTrue("Resource schema was not cached", resourceSchema == resourceSchemaAgain); + assertSame("Resource schema was not cached", resourceSchema, resourceSchemaAgain); // Now we stick our nose deep inside the provisioning impl. But we need to make sure that the // configured connector is properly cached ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance( resourceAgain, ReadCapabilityType.class, false, result); - assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain); + assertSame("Connector instance was not cached", configuredConnectorInstance, configuredConnectorInstanceAgain); assertShadows(1); } @@ -306,10 +269,9 @@ public void test004ResourceAndConnectorCaching() throws Exception { @Test public void test005Capabilities() throws Exception { final String TEST_NAME = "test005Capabilities"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -375,14 +337,12 @@ public void test005Capabilities() throws Exception { } protected void assertPasswordCapability(PasswordCapabilityType capPassword) { - assertTrue("Wrong password capability readable flag: "+capPassword.isReadable(), - capPassword.isReadable() != Boolean.TRUE); + assertNotSame("Wrong password capability readable flag: " + capPassword.isReadable(), capPassword.isReadable(), Boolean.TRUE); } @Test public void test006Schema() throws Exception { final String TEST_NAME = "test006RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -435,7 +395,7 @@ public void test006Schema() throws Exception { assertTrue("No jpegPhoto create", jpegPhoto.canAdd()); assertTrue("No jpegPhoto update", jpegPhoto.canModify()); assertTrue("No jpegPhoto read", jpegPhoto.canRead()); - assertEquals("Wrong jpegPhoto matching rule", null, jpegPhoto.getMatchingRuleQName()); + assertNull("Wrong jpegPhoto matching rule", jpegPhoto.getMatchingRuleQName()); ResourceAttributeDefinition dsDef = accountDef.findAttributeDefinition("ds-pwp-account-disabled"); assertNotNull("No definition for ds-pwp-account-disabled", dsDef); @@ -463,7 +423,7 @@ public void test006Schema() throws Exception { assertTrue("No labeledUri create", labeledUriDef.canAdd()); assertTrue("No labeledUri update", labeledUriDef.canModify()); assertTrue("No labeledUri read", labeledUriDef.canRead()); - assertEquals("Wrong labeledUri matching rule", null, labeledUriDef.getMatchingRuleQName()); + assertNull("Wrong labeledUri matching rule", labeledUriDef.getMatchingRuleQName()); ResourceAttributeDefinition secretaryDef = accountDef.findAttributeDefinition("secretary"); assertNotNull("No definition for secretary", secretaryDef); @@ -482,7 +442,7 @@ public void test006Schema() throws Exception { assertTrue("No createTimestamp read", createTimestampDef.canRead()); assertFalse("Bad createTimestamp create", createTimestampDef.canAdd()); assertFalse("Bad createTimestamp update", createTimestampDef.canModify()); - assertEquals("Wrong createTimestamp matching rule", null, createTimestampDef.getMatchingRuleQName()); + assertNull("Wrong createTimestamp matching rule", createTimestampDef.getMatchingRuleQName()); // MID-5210 ResourceAttributeDefinition descriptionDef = accountDef.findAttributeDefinition(ATTRIBUTE_DESCRIPTION_NAME); @@ -493,7 +453,7 @@ public void test006Schema() throws Exception { assertTrue("No description read", descriptionDef.canRead()); assertTrue("Bad description create", descriptionDef.canAdd()); assertTrue("Bad description update", descriptionDef.canModify()); - assertEquals("Wrong description matching rule", null, descriptionDef.getMatchingRuleQName()); + assertNull("Wrong description matching rule", descriptionDef.getMatchingRuleQName()); assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); @@ -568,8 +528,6 @@ protected void assertPolyStringType(String attrName, ResourceAttributeDefinition @Test public void test007RefinedSchema() throws Exception { - final String TEST_NAME = "test007RefinedSchema"; - displayTestTitle(TEST_NAME); // GIVEN // WHEN @@ -580,8 +538,7 @@ public void test007RefinedSchema() throws Exception { // all over again // Not equals() but == ... we want to really know if exactly the same // object instance is returned - assertTrue("Broken caching", - refinedSchema == RefinedResourceSchemaImpl.getRefinedSchema(resourceType, prismContext)); + assertSame("Broken caching", refinedSchema, RefinedResourceSchemaImpl.getRefinedSchema(resourceType, prismContext)); RefinedObjectClassDefinition accountDef = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); assertNotNull("Account definition is missing", accountDef); @@ -686,9 +643,8 @@ public void test007RefinedSchema() throws Exception { @Test public void test020ListResourceObjects() throws Exception { final String TEST_NAME = "test020ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -707,9 +663,8 @@ public void test020ListResourceObjects() throws Exception { @Test public void test110GetObject() throws Exception { final String TEST_NAME = "test110GetObject"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType objectToAdd = parseObjectType(ACCOUNT_JBOND_FILE, ShadowType.class); @@ -722,11 +677,11 @@ public void test110GetObject() throws Exception { PropertyReferenceListType resolve = new PropertyReferenceListType(); // WHEN - displayWhen(TEST_NAME); + when(); ShadowType provisioningShadow = provisioningService.getObject(ShadowType.class, ACCOUNT_JBOND_OID, null, task, result).asObjectable(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNotNull(provisioningShadow); @@ -799,9 +754,8 @@ protected void assertShadowPassword(ShadowType provisioningShadow) throws Except @Test public void test111GetObjectNotFoundRepo() throws Exception { final String TEST_NAME = "test111GetObjectNotFoundRepo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -834,17 +788,16 @@ public void test111GetObjectNotFoundRepo() throws Exception { @Test public void test112GetObjectNotFoundResource() throws Exception { final String TEST_NAME = "test112GetObjectNotFoundResource"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_BAD_OID, null, task, result); // THEN - displayWhen(TEST_NAME); + when(); ShadowAsserter.forShadow(shadow, "provisioning") .assertTombstone(); @@ -853,9 +806,8 @@ public void test112GetObjectNotFoundResource() throws Exception { @Test public void test119Cleanup() throws Exception { final String TEST_NAME = "test119Cleanup"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); repositoryService.deleteObject(ShadowType.class, ACCOUNT_BAD_OID, result); @@ -867,9 +819,8 @@ public void test119Cleanup() throws Exception { @Test public void test120AddAccountWill() throws Exception { final String TEST_NAME = "test120AddAccountWill"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountBefore = parseObject(ACCOUNT_WILL_FILE); @@ -877,11 +828,11 @@ public void test120AddAccountWill() throws Exception { display("Account before", accountBefore); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertEquals(ACCOUNT_WILL_OID, addedObjectOid); @@ -900,9 +851,8 @@ public void test120AddAccountWill() throws Exception { @Test public void test121RenameAccountWillOnResource() throws Exception{ String TEST_NAME = "test121RenameAccountWillOnResource"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeRenameChange(new File(TEST_DIR, "rename.ldif").getPath()); @@ -929,9 +879,8 @@ public void test121RenameAccountWillOnResource() throws Exception{ @Test public void test125AddObjectNull() throws Exception { final String TEST_NAME = "test125AddObjectNull"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String addedObjectOid = null; @@ -952,9 +901,8 @@ public void test125AddObjectNull() throws Exception { @Test public void test130AddDeleteAccountSparrow() throws Exception { final String TEST_NAME = "test130AddDeleteAccountSparrow"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SPARROW_FILE, ShadowType.class); @@ -966,11 +914,11 @@ public void test130AddDeleteAccountSparrow() throws Exception { assertEquals(ACCOUNT_SPARROW_OID, addedObjectOid); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_SPARROW_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); ShadowType objType = null; try { @@ -997,9 +945,8 @@ public void test130AddDeleteAccountSparrow() throws Exception { @Test public void test140AddAndModifyAccountJack() throws Exception { final String TEST_NAME = "test140AddAndModifyAccountJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = unmarshallValueFromFile(ACCOUNT_JACK_FILE, ShadowType.class); @@ -1024,12 +971,12 @@ public void test140AddAndModifyAccountJack() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1069,9 +1016,8 @@ public void test140AddAndModifyAccountJack() throws Exception { @Test public void test145ModifyAccountJackJpegPhoto() throws Exception { final String TEST_NAME = "test145ModifyAccountJackJpegPhoto"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); byte[] bytesIn = Files.readAllBytes(Paths.get(ProvisioningTestUtil.DOT_JPG_FILENAME)); @@ -1087,12 +1033,12 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -1126,9 +1072,8 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { @Test public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { final String TEST_NAME = "test147ModifyAccountJackGivenNameDuplicit"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PropertyDelta givenNameDelta = prismContext.deltaFactory().property().create( @@ -1148,12 +1093,12 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1178,9 +1123,8 @@ public void test147ModifyAccountJackGivenNameDuplicit() throws Exception { @Test public void test150ChangePassword() throws Exception { final String TEST_NAME = "test150ChangePassword"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_MODIFY_PASSWORD_FILE, ShadowType.class); @@ -1210,11 +1154,11 @@ public void test150ChangePassword() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); // Check if object was modified in LDAP Entry entryAfter = openDJController.searchAndAssertByEntryUuid(uid); @@ -1233,9 +1177,8 @@ public void test150ChangePassword() throws Exception { @Test public void test151AddObjectWithPassword() throws Exception { final String TEST_NAME = "test151AddObjectWithPassword"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_WITH_PASSWORD_FILE, ShadowType.class); @@ -1281,10 +1224,9 @@ public void test151AddObjectWithPassword() throws Exception { @Test public void test160SearchAccountsIterative() throws Exception { final String TEST_NAME = "test160SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1325,11 +1267,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 9, objects.size()); @@ -1346,10 +1288,9 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test161SearchAccountsIterativeOffset2Page3() throws Exception { final String TEST_NAME = "test161SearchAccountsIterativeOffset2Page3"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1373,11 +1314,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1394,10 +1335,9 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test162SearchAccountsIterativeOffsetNullPage5() throws Exception { final String TEST_NAME = "test162SearchAccountsIterativeOffsetNullPage5"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource); @@ -1421,11 +1361,11 @@ public boolean handle(PrismObject prismObject, OperationResult paren }; // WHEN - displayWhen(TEST_NAME); + when(); SearchResultMetadata searchMetadata = provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Count", objects.size()); assertEquals("Unexpected number of shadows", 3, objects.size()); @@ -1455,9 +1395,8 @@ protected void assertShadows(int expectedCount) throws SchemaException { @Test public void test170DisableAccount() throws Exception{ final String TEST_NAME = "test170DisableAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_DISABLE_SIMULATED_FILE, ShadowType.class); @@ -1474,12 +1413,12 @@ public void test170DisableAccount() throws Exception{ display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, taskManager.createTaskInstance(), result).asObjectable(); @@ -1514,9 +1453,8 @@ public void test170DisableAccount() throws Exception{ @Test public void test175AddDisabledAccount() throws Exception { final String TEST_NAME = "test175AddDisabledAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_DISABLED_FILE, ShadowType.class); @@ -1565,9 +1503,8 @@ public void test175AddDisabledAccount() throws Exception { @Test public void test176AddEnabledAccount() throws Exception { final String TEST_NAME = "test176AddEnabledAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_NEW_ENABLED_FILE, ShadowType.class); @@ -1602,9 +1539,8 @@ public void test176AddEnabledAccount() throws Exception { @Test public void test180GetUnlockedAccount() throws Exception { final String TEST_NAME = "test180GetUnlockedAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -1622,9 +1558,8 @@ public void test180GetUnlockedAccount() throws Exception { @Test public void test182GetLockedAccount() throws Exception { final String TEST_NAME = "test182GetLockedAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange( @@ -1649,9 +1584,8 @@ public void test182GetLockedAccount() throws Exception { @Test public void test184UnlockAccount() throws Exception{ final String TEST_NAME = "test184UnlockAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -1689,9 +1623,8 @@ public void test184UnlockAccount() throws Exception{ @Test public void test200SearchObjectsIterative() throws Exception { final String TEST_NAME = "test200SearchObjectsIterative"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SEARCH_ITERATIVE_FILE, ShadowType.class); @@ -1732,9 +1665,8 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test201SearchObjects() throws Exception { final String TEST_NAME = "test201SearchObjects"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_SEARCH_FILE, ShadowType.class); @@ -1769,9 +1701,8 @@ public void test201SearchObjects() throws Exception { @Test public void test202SearchObjectsCompexFilter() throws Exception { final String TEST_NAME = "test202SearchObjectsCompexFilter"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_FILE, QueryType.COMPLEX_TYPE); @@ -1782,12 +1713,12 @@ public void test202SearchObjectsCompexFilter() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1805,9 +1736,8 @@ public void test202SearchObjectsCompexFilter() throws Exception { @Test public void test203SearchObjectsByDnExists() throws Exception { final String TEST_NAME = "test203SearchObjectsByDnExists"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createAccountShadowQuerySecondaryIdentifier(ACCOUNT_BARBOSSA_DN, resource); @@ -1816,12 +1746,12 @@ public void test203SearchObjectsByDnExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1846,9 +1776,8 @@ public void test203SearchObjectsByDnExists() throws Exception { @Test public void test205SearchObjectsByDnNotExists() throws Exception { final String TEST_NAME = "test205SearchObjectsByDnNotExists"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createAccountShadowQuerySecondaryIdentifier( @@ -1858,12 +1787,12 @@ public void test205SearchObjectsByDnNotExists() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1883,9 +1812,8 @@ public void test205SearchObjectsByDnNotExists() throws Exception { @Test public void test206SearchObjectsCompexFilterStartsWith() throws Exception { final String TEST_NAME = "test206SearchObjectsCompexFilterStartsWith"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_STARTS_WITH_FILE, QueryType.COMPLEX_TYPE); @@ -1896,12 +1824,12 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); for (PrismObject objType : objListType) { @@ -1919,9 +1847,8 @@ public void test206SearchObjectsCompexFilterStartsWith() throws Exception { @Test public void test230SearchObjectsPagedNoOffset() throws Exception { final String TEST_NAME = "test230SearchObjectsPagedNoOffset"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -1934,12 +1861,12 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Search resutls", searchResults); @@ -1955,9 +1882,8 @@ public void test230SearchObjectsPagedNoOffset() throws Exception { @Test public void test231SearchObjectsPagedOffsetZero() throws Exception { final String TEST_NAME = "test231SearchObjectsPagedOffsetZero"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -1970,12 +1896,12 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Search resutls", searchResults); @@ -1991,9 +1917,8 @@ public void test231SearchObjectsPagedOffsetZero() throws Exception { @Test public void test232SearchObjectsPagedOffset() throws Exception { final String TEST_NAME = "test232SearchObjectsPagedOffset"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2006,11 +1931,11 @@ public void test232SearchObjectsPagedOffset() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2028,9 +1953,8 @@ public void test232SearchObjectsPagedOffset() throws Exception { @Test public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2045,12 +1969,12 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2067,9 +1991,8 @@ public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception { @Test public void test234SearchObjectsPagedOffsetSortSn() throws Exception { final String TEST_NAME = "test234SearchObjectsPagedOffsetSortSn"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); @@ -2084,12 +2007,12 @@ public void test234SearchObjectsPagedOffsetSortSn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search resutls", searchResults); @@ -2120,20 +2043,19 @@ private void assertSearchResults(List> searchResults, St @Test public void test250CountAccounts() throws Exception { final String TEST_NAME = "test250CountAccounts"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE); ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - displayWhen(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("All accounts count", count); @@ -2147,20 +2069,19 @@ public void test250CountAccounts() throws Exception { @Test public void test252CountLdapGroups() throws Exception { final String TEST_NAME = "test252CountLdapGroups"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_LDAP_GROUPS_FILE, QueryType.COMPLEX_TYPE); ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType); // WHEN - displayWhen(TEST_NAME); + when(); Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("All LDAP groups count", count); @@ -2178,9 +2099,8 @@ protected Integer getExpectedLdapGroupCountTest25x() { @Test public void test300AddObjectObjectAlreadyExistResource() throws Exception { final String TEST_NAME = "test300AddObjectObjectAlreadyExistResource"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_SEARCH_FILE); @@ -2207,9 +2127,8 @@ public void test300AddObjectObjectAlreadyExistResource() throws Exception { @Test public void test310AddObjectNoSn() throws Exception { final String TEST_NAME = "test310AddObjectNoSn"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject account = PrismTestUtil.parseObject(ACCOUNT_NO_SN_FILE); @@ -2239,20 +2158,19 @@ public void test310AddObjectNoSn() throws Exception { @Test public void test320AddAccountPosix() throws Exception { final String TEST_NAME = "test320AddAccountPosix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_POSIX_MCMUTTON_FILE, ShadowType.class); display("Adding account", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(ACCOUNT_POSIX_MCMUTTON_OID, addedObjectOid); ShadowType repoShadowType = getShadowRepo(ACCOUNT_POSIX_MCMUTTON_OID).asObjectable(); @@ -2290,9 +2208,8 @@ public void test320AddAccountPosix() throws Exception { @Test public void test322ModifyAccountPosix() throws Exception { final String TEST_NAME = "test322ModifyAccountPosix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_POSIX_MCMUTTON_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE); @@ -2301,12 +2218,12 @@ public void test322ModifyAccountPosix() throws Exception { display("Object change",delta); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2336,17 +2253,16 @@ public void test322ModifyAccountPosix() throws Exception { @Test public void test329DeleteAccountPosix() throws Exception { final String TEST_NAME = "test329DeleteAccountPosix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); try { provisioningService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, task, result); @@ -2374,9 +2290,8 @@ public void test329DeleteAccountPosix() throws Exception { @Test public void test330SearchForPosixAccount() throws Exception { final String TEST_NAME = "test330SearchForPosixAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_VANHELGEN_FILE, @@ -2391,12 +2306,12 @@ public void test330SearchForPosixAccount() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); List> objListType = provisioningService.searchObjects(ShadowType.class, query, null, null, result); // THEN - displayThen(TEST_NAME); + then(); for (PrismObject objType : objListType) { assertNotNull("Null search result", objType); display("found object", objType); @@ -2422,20 +2337,19 @@ public void test330SearchForPosixAccount() throws Exception { @Test public void test400AddGroupSwashbucklers() throws Exception { final String TEST_NAME = "test400AddGroupSwashbucklers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_SWASHBUCKLERS_FILE, ShadowType.class); display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(GROUP_SWASHBUCKLERS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SWASHBUCKLERS_OID).asObjectable(); @@ -2464,20 +2378,19 @@ public void test400AddGroupSwashbucklers() throws Exception { @Test public void test402AddAccountMorganWithAssociation() throws Exception { final String TEST_NAME = "test402AddAccountMorganWithAssociation"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(ACCOUNT_MORGAN_FILE, ShadowType.class); IntegrationTestTools.display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(ACCOUNT_MORGAN_OID, addedObjectOid); assertRepoShadow(ACCOUNT_MORGAN_OID) @@ -2519,13 +2432,12 @@ public void test402AddAccountMorganWithAssociation() throws Exception { @Test public void test403modifyMorganReplaceAssociation() throws Exception { final String TEST_NAME = "test403modifyMorganReplaceAssociation"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); ObjectModificationType modification = prismContext.parserFor(FILE_MODIFY_ASSOCIATION_REPLACE).parseRealValue(ObjectModificationType.class); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext); try { @@ -2536,7 +2448,7 @@ public void test403modifyMorganReplaceAssociation() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertRepoShadow(ACCOUNT_MORGAN_OID) .assertName(ACCOUNT_MORGAN_DN); @@ -2573,18 +2485,17 @@ public void test403modifyMorganReplaceAssociation() throws Exception { @Test public void test405GetGroupSwashbucklers() throws Exception { final String TEST_NAME = "test405GetGroupSwashbucklers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SWASHBUCKLERS_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); @@ -2606,9 +2517,8 @@ public void test405GetGroupSwashbucklers() throws Exception { @Test public void test410CreateLdapGroupAndSearchGroups() throws Exception { final String TEST_NAME = "test410CreateLdapGroupAndSearchGroups"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.addEntry("dn: cn=seadogs,ou=groups,dc=EXAMPLE,dc=com\n" + @@ -2620,11 +2530,11 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> resultList = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Search result", resultList); @@ -2640,9 +2550,8 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { @Test public void test412CreateLdapGroupWithMemberAndGet() throws Exception { final String TEST_NAME = "test412CreateLdapGroupWithMemberAndGet"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.addEntry("dn: cn=sailor,ou=Groups,dc=example,dc=com\n" + @@ -2655,11 +2564,11 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Account shadow after", shadow); @@ -2678,20 +2587,19 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { @Test public void test414AddGroupCorsairsAssociateUser() throws Exception { final String TEST_NAME = "test414AddGroupCorsairsAssociateUser"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_CORSAIRS_FILE, ShadowType.class); IntegrationTestTools.display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(GROUP_CORSAIRS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_CORSAIRS_OID).asObjectable(); @@ -2705,9 +2613,8 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { @Test public void test416AssociateUserToCorsairs() throws Exception { final String TEST_NAME = "test416AssociateUserToCorsairs"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_MORGAN_OID, @@ -2716,12 +2623,12 @@ public void test416AssociateUserToCorsairs() throws Exception { delta.checkConsistence(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN); display("LDAP group", groupEntry); @@ -2734,17 +2641,16 @@ public void test416AssociateUserToCorsairs() throws Exception { @Test public void test418GetMorgan() throws Exception { final String TEST_NAME = "test418GetMorgan"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); assertSuccess(result); display("Shadow", shadow); @@ -2762,9 +2668,8 @@ public void test418GetMorgan() throws Exception { @Test public void test429DeleteAccountMorgan() throws Exception { final String TEST_NAME = "test429DeleteAccountMorgan"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -2802,9 +2707,8 @@ public void test429DeleteAccountMorgan() throws Exception { @Test public void test450ListGroupsObjectclass() throws Exception { final String TEST_NAME = "test450ListGroupsObjectclass"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_OPENDJ_OID, @@ -2812,11 +2716,11 @@ public void test450ListGroupsObjectclass() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2829,9 +2733,8 @@ public void test450ListGroupsObjectclass() throws Exception { @Test public void test452ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test452ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2839,11 +2742,11 @@ public void test452ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2856,9 +2759,8 @@ public void test452ListLdapGroupsKindIntent() throws Exception { @Test public void test454ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test454ListSpecialGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2866,11 +2768,11 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2885,20 +2787,19 @@ public void test454ListSpecialGroupsKindIntent() throws Exception { @Test public void test456AddGroupSpecialists() throws Exception { final String TEST_NAME = "test456AddGroupSpecialists"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(GROUP_SPECIALISTS_FILE, ShadowType.class); display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(GROUP_SPECIALISTS_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(GROUP_SPECIALISTS_OID).asObjectable(); @@ -2927,9 +2828,8 @@ public void test456AddGroupSpecialists() throws Exception { @Test public void test457ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test457ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2937,11 +2837,11 @@ public void test457ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2954,9 +2854,8 @@ public void test457ListLdapGroupsKindIntent() throws Exception { @Test public void test458ListSpecialGroupsKindIntent() throws Exception { final String TEST_NAME = "test458ListSpecialGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2964,11 +2863,11 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -2989,9 +2888,8 @@ public void test458ListSpecialGroupsKindIntent() throws Exception { @Test public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { final String TEST_NAME = "test460ListOrganizationalUnitPeopleKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, @@ -2999,11 +2897,11 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("found objects", objects); result.computeStatus(); TestUtil.assertSuccess(result); @@ -3021,9 +2919,8 @@ public void test460ListOrganizationalUnitPeopleKindIntent() throws Exception { @Test public void test470AddAccountPolyDescription() throws Exception { final String TEST_NAME = "test470AddAccountPolyDescription"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject accountBefore = parseObject(ACCOUNT_POLY_FILE); @@ -3031,11 +2928,11 @@ public void test470AddAccountPolyDescription() throws Exception { display("Account before", accountBefore); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(accountBefore, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.fetchEntry(ACCOUNT_POLY_DN); @@ -3068,9 +2965,8 @@ public void test470AddAccountPolyDescription() throws Exception { @Test public void test472ModifyAccountJackDescriptionOrig() throws Exception { final String TEST_NAME = "test472ModifyAccountJackDescriptionOrig"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString("Bar"); @@ -3085,12 +2981,12 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3119,9 +3015,8 @@ public void test472ModifyAccountJackDescriptionOrig() throws Exception { @Test public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { final String TEST_NAME = "test474ModifyAccountJackDescriptionLangEnSk"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3137,12 +3032,12 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { display("Modifications", modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3172,9 +3067,8 @@ public void test474ModifyAccountJackDescriptionLangEnSk() throws Exception { @Test public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test476ModifyAccountJackDescriptionLangEnSkRuHr"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3190,12 +3084,12 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3225,9 +3119,8 @@ public void test476ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { @Test public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { final String TEST_NAME = "test478ModifyAccountJackDescriptionLangEnSkRuHr"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3243,12 +3136,12 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3277,9 +3170,8 @@ public void test478ModifyAccountJackDescriptionLangEnSkRuHr() throws Exception { @Test public void test478bModifyAccountJackDeleteDescription() throws Exception { final String TEST_NAME = "test478bModifyAccountJackDeleteDescription"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3295,12 +3187,12 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { display("Modifications", modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3331,9 +3223,8 @@ public void test478bModifyAccountJackDeleteDescription() throws Exception { @Test public void test479ModifyAccountJackDescriptionJack() throws Exception { final String TEST_NAME = "test479ModifyAccountJackDescriptionJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString descriptionBefore = new PolyString(USER_JACK_FULL_NAME); @@ -3348,12 +3239,12 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { display("Modifications",modifications); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = openDJController.searchByUid("rename"); @@ -3378,20 +3269,19 @@ public void test479ModifyAccountJackDescriptionJack() throws Exception { @Test public void test480AddOuSuper() throws Exception { final String TEST_NAME = "test480AddOuSuper"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ShadowType object = parseObjectType(OU_SUPER_FILE, ShadowType.class); display("Adding object", object); // WHEN - displayWhen(TEST_NAME); + when(); String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertEquals(OU_SUPER_OID, addedObjectOid); ShadowType shadowType = getShadowRepo(OU_SUPER_OID).asObjectable(); @@ -3426,19 +3316,18 @@ public void test480AddOuSuper() throws Exception { @Test public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createSubOrg(); // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoRepoShadow(OU_SUPER_OID); @@ -3457,7 +3346,7 @@ protected void createSubOrg() throws IOException, LDIFException { public void test701ConfiguredCapabilityNoRead() throws Exception{ final String TEST_NAME = "test701ConfiguredCapabilityNoRead"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "resource-opendj-no-read.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3476,7 +3365,7 @@ public void test701ConfiguredCapabilityNoRead() throws Exception{ public void test702ConfiguredCapabilityNoCreate() throws Exception{ final String TEST_NAME = "test702ConfiguredCapabilityNoCreate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-create.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3496,7 +3385,7 @@ public void test702ConfiguredCapabilityNoCreate() throws Exception{ public void test703ConfiguredCapabilityNoDelete() throws Exception{ final String TEST_NAME = "test703ConfiguredCapabilityNoDelete"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-delete.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3514,7 +3403,7 @@ public void test703ConfiguredCapabilityNoDelete() throws Exception{ public void test704ConfiguredCapabilityNoUpdate() throws Exception{ final String TEST_NAME = "test704ConfiguredCapabilityNoUpdate"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-update.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); @@ -3533,9 +3422,8 @@ public void test704ConfiguredCapabilityNoUpdate() throws Exception{ @Test public void test710AddResourceOpenDjBadCredentials() throws Exception { final String TEST_NAME = "test710AddResourceOpenDjBadCredentials"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = prismContext.parseObject(RESOURCE_OPENDJ_BAD_CREDENTIALS_FILE); @@ -3555,9 +3443,8 @@ public void test710AddResourceOpenDjBadCredentials() throws Exception { @Test public void test713ConnectionBadCredentials() throws Exception { final String TEST_NAME = "test713ConnectionBadCredentials"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -3577,9 +3464,8 @@ public void test713ConnectionBadCredentials() throws Exception { @Test public void test720AddResourceOpenDjBadBindDn() throws Exception { final String TEST_NAME = "test720AddResourceOpenDjBadBindDn"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject resource = prismContext.parseObject(RESOURCE_OPENDJ_BAD_BIND_DN_FILE); @@ -3599,9 +3485,8 @@ public void test720AddResourceOpenDjBadBindDn() throws Exception { @Test public void test723ConnectionBadBindDn() throws Exception { final String TEST_NAME = "test723ConnectionBadBindDn"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java index 8895a93fd58..46cc1db8b42 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjDumber.java @@ -20,8 +20,6 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import org.testng.annotations.Test; /** @@ -37,8 +35,6 @@ public class TestOpenDjDumber extends TestOpenDj { protected static final File RESOURCE_OPENDJ_DUMBER_FILE = new File(TEST_DIR, "resource-opendj-dumber.xml"); - private static final Trace LOGGER = TraceManager.getTrace(TestOpenDjDumber.class); - @Override protected File getResourceOpenDjFile() { return RESOURCE_OPENDJ_DUMBER_FILE; @@ -84,16 +80,15 @@ protected void assertTimestamp(String attrName, Object timestampValue) { @Override public void test489DeleteOuSuperWithSub() throws Exception { final String TEST_NAME = "test489DeleteOuSuperWithSub"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createSubOrg(); try { // WHEN - displayWhen(TEST_NAME); + when(); provisioningService.deleteObject(ShadowType.class, OU_SUPER_OID, null, null, task, result); assertNotReached(); @@ -102,7 +97,7 @@ public void test489DeleteOuSuperWithSub() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); } diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java index 5ce9c6962e9..6fe75b0d8a7 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjNegative.java @@ -32,7 +32,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.provisioning.api.GenericConnectorException; import com.evolveum.midpoint.schema.DeltaConvertor; @@ -61,7 +60,6 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; @@ -106,9 +104,8 @@ public static void stoptLdap() throws Exception { @Test public void test003Connection() throws Exception { final String TEST_NAME = "test003Connection"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ResourceType resourceTypeBefore = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result).asObjectable(); display("Resource before testResource (repository)", resourceTypeBefore); @@ -141,11 +138,8 @@ public void test003Connection() throws Exception { @Test public void test004ResourceAndConnectorCaching() throws Exception { - TestUtil.displayTestTitle("test004ResourceAndConnectorCaching"); - - OperationResult result = new OperationResult(TestOpenDjNegative.class.getName()+".test004ResourceAndConnectorCaching"); - - Task task = taskManager.createTaskInstance(); + OperationResult result = createOperationalResult(); + Task task = createPlainTask(); // WHEN // This should NOT throw an exception. It should just indicate the failure in results resource = provisioningService.getObject(ResourceType.class,RESOURCE_OPENDJ_OID, null, task, result); @@ -189,7 +183,6 @@ public void test004ResourceAndConnectorCaching() throws Exception { @Test public void test110GetObjectNoShadow() throws Exception { final String TEST_NAME = "test110GetObjectNoShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -216,7 +209,6 @@ public void test110GetObjectNoShadow() throws Exception { @Test public void test111GetObjectShadow() throws Exception { final String TEST_NAME = "test111GetObjectShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -239,7 +231,6 @@ public void test111GetObjectShadow() throws Exception { @Test public void test120ListResourceObjects() throws Exception { final String TEST_NAME = "test120ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -263,7 +254,6 @@ public void test120ListResourceObjects() throws Exception { public void test121SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test121SearchAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -293,7 +283,6 @@ public void test121SearchAccounts() throws SchemaException, ObjectNotFoundExcept public void test122SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test122SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -329,7 +318,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test130AddAccountWill() throws Exception { final String TEST_NAME = "test130AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -356,7 +344,6 @@ public void test130AddAccountWill() throws Exception { @Test public void test140AddDeleteAccountSparrow() throws Exception { final String TEST_NAME = "test140AddDeleteAccountSparrow"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -379,7 +366,6 @@ public void test140AddDeleteAccountSparrow() throws Exception { @Test public void test150ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -406,7 +392,6 @@ public void test150ModifyObject() throws Exception { @Test public void test190Synchronize() throws Exception { final String TEST_NAME = "test190Synhronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -439,7 +424,6 @@ public void test190Synchronize() throws Exception { @Test public void test500ReplaceResource() throws Exception { final String TEST_NAME = "test500ReplaceResource"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -464,7 +448,6 @@ public void test500ReplaceResource() throws Exception { @Test public void test510GetObjectNoShadow() throws Exception { final String TEST_NAME = "test510GetObjectNoShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -492,7 +475,6 @@ public void test510GetObjectNoShadow() throws Exception { @Test public void test511GetObjectShadow() throws Exception { final String TEST_NAME = "test511GetObjectShadow"; - displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -520,7 +502,6 @@ public void test511GetObjectShadow() throws Exception { @Test public void test520ListResourceObjects() throws Exception { final String TEST_NAME = "test520ListResourceObjects"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -543,7 +524,6 @@ public void test520ListResourceObjects() throws Exception { public void test521SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test521SearchAccounts"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -572,7 +552,6 @@ public void test521SearchAccounts() throws SchemaException, ObjectNotFoundExcept public void test522SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception { final String TEST_NAME = "test522SearchAccountsIterative"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); @@ -607,10 +586,9 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test530AddAccountWill() throws Exception { final String TEST_NAME = "test530AddAccountWill"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject object = parseObject(ACCOUNT_WILL_FILE); @@ -657,7 +635,6 @@ public void test530AddAccountWill() throws Exception { @Test public void test540DeleteObject() throws Exception { final String TEST_NAME = "test540DeleteObject"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -695,7 +672,6 @@ public void test540DeleteObject() throws Exception { @Test public void test550ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -738,7 +714,6 @@ public void test550ModifyObject() throws Exception { @Test public void test590Synchronize() throws Exception { final String TEST_NAME = "test590Synhronize"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestOpenDjNegative.class.getName() + "." + TEST_NAME); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java index 6f6e2b65e30..b4728ad35f5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestOpenDjReadablePassword.java @@ -17,8 +17,6 @@ import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -37,8 +35,6 @@ public class TestOpenDjReadablePassword extends TestOpenDj { protected static final File RESOURCE_OPENDJ_READABLE_PASSWORD_FILE = new File(TEST_DIR, "resource-opendj-readable-password.xml"); - private static final Trace LOGGER = TraceManager.getTrace(TestOpenDjReadablePassword.class); - @Override protected File getResourceOpenDjFile() { return RESOURCE_OPENDJ_READABLE_PASSWORD_FILE; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java index 0ef479514be..5768e2a8d90 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/opendj/TestSynchronization.java @@ -7,16 +7,10 @@ package com.evolveum.midpoint.provisioning.impl.opendj; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; +import static org.testng.AssertJUnit.*; import java.io.File; -import com.evolveum.midpoint.schema.RepositoryQueryDiagRequest; -import com.evolveum.midpoint.schema.RepositoryQueryDiagResponse; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.util.QNameUtil; import org.opends.server.core.AddOperation; import org.opends.server.types.Entry; import org.opends.server.types.LDIFImportConfig; @@ -37,13 +31,17 @@ import com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription; import com.evolveum.midpoint.provisioning.impl.ProvisioningTestUtil; import com.evolveum.midpoint.provisioning.impl.mock.SynchronizationServiceMock; +import com.evolveum.midpoint.schema.RepositoryQueryDiagRequest; +import com.evolveum.midpoint.schema.RepositoryQueryDiagResponse; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; +import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.AbstractIntegrationTest; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -65,10 +63,10 @@ public class TestSynchronization extends AbstractIntegrationTest { private ResourceType resourceType; - @Autowired(required=true) + @Autowired private ProvisioningService provisioningService; - @Autowired(required=true) + @Autowired private ResourceObjectChangeListener syncServiceMock; @BeforeClass @@ -77,9 +75,8 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); - } /* @@ -105,10 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { - final String TEST_NAME = "test010Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createOperationalResult(); // WHEN PrismObject resource = provisioningService.getObject(ResourceType.class, resourceType.getOid(), null, taskManager.createTaskInstance(), result); @@ -132,17 +126,14 @@ public void test010Sanity() throws Exception { @Test public void test100SyncAddWill() throws Exception { - final String TEST_NAME = "test100SyncAddWill"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createOperationalResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); assertSyncToken(syncTask, 0, result); - ((SynchronizationServiceMock)syncServiceMock).reset(); + ((SynchronizationServiceMock) syncServiceMock).reset(); - // create add change in embeded LDAP + // create add change in embedded LDAP LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_WILL_FILE.getPath()); LDIFReader ldifReader = new LDIFReader(importConfig); Entry entry = ldifReader.readEntry(); @@ -183,26 +174,23 @@ public void test100SyncAddWill() throws Exception { .qNameToUri(SchemaConstants.SYNC_TOKEN) + "'"); RepositoryQueryDiagResponse valueResponse = repositoryService.executeQueryDiagnostics(valueRequest, result); System.out.println(valueResponse.getQueryResult()); - assertTrue("Unexpected repo query result on sync token: "+ valueResponse.getQueryResult(), valueResponse.getQueryResult().isEmpty()); + assertTrue("Unexpected repo query result on sync token: " + valueResponse.getQueryResult(), valueResponse.getQueryResult().isEmpty()); RepositoryQueryDiagRequest dictionaryRequest = new RepositoryQueryDiagRequest(); dictionaryRequest.setImplementationLevelQuery("select RExtItem i where i.name='" + QNameUtil.qNameToUri(SchemaConstants.SYNC_TOKEN) + "'"); RepositoryQueryDiagResponse dictionaryResponse = repositoryService.executeQueryDiagnostics(valueRequest, result); System.out.println(dictionaryResponse.getQueryResult()); - assertTrue("Unexpected repo query result on sync token definition: "+ dictionaryResponse.getQueryResult(), dictionaryResponse.getQueryResult().isEmpty()); + assertTrue("Unexpected repo query result on sync token definition: " + dictionaryResponse.getQueryResult(), dictionaryResponse.getQueryResult().isEmpty()); } @Test public void test500SyncAddProtected() throws Exception { - final String TEST_NAME = "test500SyncAddProtected"; - TestUtil.displayTestTitle(TEST_NAME); - final OperationResult result = new OperationResult(TestSynchronization.class.getName() - + "." + TEST_NAME); + final OperationResult result = createOperationalResult(); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); assertSyncToken(syncTask, 1, result); - ((SynchronizationServiceMock)syncServiceMock).reset(); + ((SynchronizationServiceMock) syncServiceMock).reset(); // create add change in embedded LDAP LDIFImportConfig importConfig = new LDIFImportConfig(LDIF_CALYPSO_FILE.getPath()); diff --git a/provisioning/ucf-impl-builtin/pom.xml b/provisioning/ucf-impl-builtin/pom.xml index 5fa23ce9403..c8229c2835e 100644 --- a/provisioning/ucf-impl-builtin/pom.xml +++ b/provisioning/ucf-impl-builtin/pom.xml @@ -110,7 +110,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/provisioning/ucf-impl-connid/pom.xml b/provisioning/ucf-impl-connid/pom.xml index 810837423b8..28aa5026ba4 100644 --- a/provisioning/ucf-impl-connid/pom.xml +++ b/provisioning/ucf-impl-connid/pom.xml @@ -105,7 +105,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java index 4c289d00923..e0eab1fe6d3 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/AbstractUcfDummyTest.java @@ -13,7 +13,6 @@ import com.evolveum.midpoint.prism.path.ItemName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.BeforeClass; import com.evolveum.icf.dummy.resource.DummyResource; @@ -28,10 +27,10 @@ import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -45,7 +44,7 @@ * this is a lesser evil for now (MID-392) */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) -public abstract class AbstractUcfDummyTest extends AbstractTestNGSpringContextTests { +public abstract class AbstractUcfDummyTest extends AbstractSpringTest { protected static final File RESOURCE_DUMMY_FILE = new File(UcfTestUtil.TEST_DIR, "resource-dummy.xml"); protected static final File CONNECTOR_DUMMY_FILE = new File(UcfTestUtil.TEST_DIR, "connector-dummy.xml"); @@ -60,14 +59,12 @@ public abstract class AbstractUcfDummyTest extends AbstractTestNGSpringContextTe protected static DummyResource dummyResource; protected static DummyResourceContoller dummyResourceCtl; - @Autowired(required = true) + @Autowired protected ConnectorFactory connectorFactoryIcfImpl; - @Autowired(required = true) + @Autowired protected PrismContext prismContext; - private static final Trace LOGGER = TraceManager.getTrace(AbstractUcfDummyTest.class); - @BeforeClass public void setup() throws Exception { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); @@ -87,6 +84,9 @@ public void setup() throws Exception { connectorType = connector.asObjectable(); } + protected OperationResult createResult() { + return new OperationResult(contextName()); + } protected void assertPropertyDefinition(PrismContainer container, String propName, QName xsdType, int minOccurs, int maxOccurs) { diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java index 2a792f38265..2060849a0ad 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummy.java @@ -6,22 +6,16 @@ */ package com.evolveum.midpoint.provisioning.ucf.impl.connid; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; -import com.evolveum.midpoint.schema.processor.*; -import com.evolveum.midpoint.util.exception.*; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -30,14 +24,8 @@ import com.evolveum.icf.dummy.connector.DummyConnector; import com.evolveum.icf.dummy.resource.DummyAccount; import com.evolveum.icf.dummy.resource.DummySyncStyle; -import com.evolveum.midpoint.prism.Item; -import com.evolveum.midpoint.prism.PrismContainer; -import com.evolveum.midpoint.prism.PrismContainerDefinition; -import com.evolveum.midpoint.prism.PrismContainerValue; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.PrismPropertyDefinition; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -46,6 +34,7 @@ import com.evolveum.midpoint.provisioning.ucf.api.ShadowResultHandler; import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schema.constants.SchemaConstants; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; @@ -54,51 +43,36 @@ import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Simple UCF tests. No real resource, just basic setup and sanity. - * - * @author Radovan Semancik - * + *

* This is an UCF test. It shold not need repository or other things from the midPoint spring context * except from the provisioning beans. But due to a general issue with spring context initialization * this is a lesser evil for now (MID-392) + * + * @author Radovan Semancik */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) public class TestUcfDummy extends AbstractUcfDummyTest { - private static final Trace LOGGER = TraceManager.getTrace(TestUcfDummy.class); - @Test - public void test000PrismContextSanity() throws Exception { - final String TEST_NAME = "test000PrismContextSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test000PrismContextSanity() { SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry(); PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION); - assertNotNull("ICFC schema not found in the context ("+SchemaConstants.NS_ICF_CONFIGURATION+")", schemaIcfc); + assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc); PrismContainerDefinition configurationPropertiesDef = - schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - assertNotNull("icfc:configurationProperties not found in icfc schema ("+ - SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME+")", configurationPropertiesDef); + schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + assertNotNull("icfc:configurationProperties not found in icfc schema (" + + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef); PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA); - assertNotNull("ICFS schema not found in the context ("+SchemaConstants.NS_ICF_SCHEMA+")", schemaIcfs); + assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs); } @Test - public void test001ResourceSanity() throws Exception { - final String TEST_NAME = "test001ResourceSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test001ResourceSanity() { display("Resource", resource); assertEquals("Wrong oid", "ef2bc95b-76e0-59e2-86d6-9999dddddddd", resource.getOid()); @@ -117,21 +91,18 @@ public void test001ResourceSanity() throws Exception { PrismContainer configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertContainerDefinition(configurationContainer, "configuration", ConnectorConfigurationType.COMPLEX_TYPE, 1, 1); PrismContainerValue configContainerValue = configurationContainer.getValue(); - Collection> configItems = configContainerValue.getItems(); + Collection> configItems = configContainerValue.getItems(); assertEquals("Wrong number of config items", 2, configItems.size()); PrismContainer dummyConfigPropertiesContainer = configurationContainer.findContainer( SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No icfc:configurationProperties container", dummyConfigPropertiesContainer); - Collection> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); + Collection> dummyConfigPropItems = dummyConfigPropertiesContainer.getValue().getItems(); assertEquals("Wrong number of dummy ConfigPropItems items", 4, dummyConfigPropItems.size()); } @Test public void test002ConnectorSchema() throws Exception { - final String TEST_NAME = "test002ConnectorSchema"; - TestUtil.displayTestTitle(TEST_NAME); - PrismSchema connectorSchema = connectorFactory.generateConnectorConfigurationSchema(connectorType); IntegrationTestTools.assertConnectorSchemaSanity(connectorSchema, "generated", true); assertEquals("Unexpected number of definitions", 3, connectorSchema.getDefinitions().size()); @@ -141,7 +112,7 @@ public void test002ConnectorSchema() throws Exception { display("Serialized XSD connector schema", DOMUtil.serializeDOMToString(xsdSchemaDom)); // Try to re-parse - PrismSchema reparsedConnectorSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(xsdSchemaDom), true, "schema fetched from "+cc, PrismTestUtil.getPrismContext()); + PrismSchema reparsedConnectorSchema = PrismSchemaImpl.parse(DOMUtil.getFirstChildElement(xsdSchemaDom), true, "schema fetched from " + cc, PrismTestUtil.getPrismContext()); IntegrationTestTools.assertConnectorSchemaSanity(reparsedConnectorSchema, "re-parsed", true); // TODO: 3 definitions would be cleaner. But we can live with this assertEquals("Unexpected number of definitions in re-parsed schema", 6, reparsedConnectorSchema.getDefinitions().size()); @@ -150,14 +121,10 @@ public void test002ConnectorSchema() throws Exception { /** * Test listing connectors. Very simple. Just test that the list is * non-empty and that there are mandatory values filled in. - * @throws CommunicationException */ @Test public void test010ListConnectors() throws Exception { - final String TEST_NAME = "test010ListConnectors"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class+"."+TEST_NAME); + OperationResult result = createResult(); Set connectors = connectorFactory.listConnectors(null, result); System.out.println("---------------------------------------------------------------------"); @@ -180,14 +147,11 @@ public void test010ListConnectors() throws Exception { @Test public void test020CreateConfiguredConnector() throws Exception { - final String TEST_NAME = "test020CreateConfiguredConnector"; - TestUtil.displayTestTitle(TEST_NAME); - cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", "description of dummy test connector instance"); assertNotNull("Failed to instantiate connector", cc); - OperationResult result = new OperationResult(TestUcfDummy.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); PrismContainerValue configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue(); display("Configuration container", configContainer); @@ -201,9 +165,6 @@ public void test020CreateConfiguredConnector() throws Exception { @Test public void test022ConnectorStatsConfigured() throws Exception { - final String TEST_NAME = "test022ConnectorStatsConfigured"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN ConnectorOperationalStatus operationalStatus = cc.getOperationalStatus(); @@ -213,21 +174,18 @@ public void test022ConnectorStatsConfigured() throws Exception { assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)0, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 0, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); } @Test public void test030ResourceSchema() throws Exception { - final String TEST_NAME = "test030ResourceSchema"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); + OperationResult result = createResult(); cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", @@ -263,10 +221,7 @@ public void test030ResourceSchema() throws Exception { @Test public void test031ResourceSchemaAccountObjectClass() throws Exception { - final String TEST_NAME = "test031ResourceSchemaAccountObjectClass"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); + OperationResult result = createResult(); cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", @@ -281,7 +236,6 @@ public void test031ResourceSchemaAccountObjectClass() throws Exception { cc.configure(configContainer, objectClassesToGenerate, result); - // WHEN resourceSchema = cc.fetchResourceSchema(result); @@ -296,9 +250,6 @@ public void test031ResourceSchemaAccountObjectClass() throws Exception { @Test public void test033ConnectorStatsInitialized() throws Exception { - final String TEST_NAME = "test033ConnectorStatsInitialized"; - TestUtil.displayTestTitle(TEST_NAME); - // WHEN ConnectorOperationalStatus operationalStatus = cc.getOperationalStatus(); @@ -308,19 +259,18 @@ public void test033ConnectorStatsInitialized() throws Exception { assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName()); assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize()); - assertEquals("Wrong poolConfigMaxSize", (Integer)10, operationalStatus.getPoolConfigMaxSize()); - assertEquals("Wrong poolConfigMinIdle", (Integer)1, operationalStatus.getPoolConfigMinIdle()); - assertEquals("Wrong poolConfigMaxIdle", (Integer)10, operationalStatus.getPoolConfigMaxIdle()); - assertEquals("Wrong poolConfigWaitTimeout", (Long)150000L, operationalStatus.getPoolConfigWaitTimeout()); - assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long)120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); - assertEquals("Wrong poolStatusNumIdle", (Integer)1, operationalStatus.getPoolStatusNumIdle()); - assertEquals("Wrong poolStatusNumActive", (Integer)0, operationalStatus.getPoolStatusNumActive()); + assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize()); + assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle()); + assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle()); + assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout()); + assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime()); + assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle()); + assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive()); } @Test public void test040AddAccount() throws Exception { final String TEST_NAME = "test040AddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -342,15 +292,13 @@ public void test040AddAccount() throws Exception { // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); - assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); - assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); + assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " was not created", dummyAccount); + assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " has no username", dummyAccount.getName()); } @Test public void test050Search() throws Exception { - final String TEST_NAME = "test050Search"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -369,7 +317,7 @@ public boolean handle(PrismObject shadow) { } }; - OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN cc.search(accountDefinition, null, handler, null, null, null, null, result); @@ -379,17 +327,16 @@ public boolean handle(PrismObject shadow) { } private void checkUcfShadow(PrismObject shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { - assertNotNull("No objectClass in shadow "+shadow, shadow.asObjectable().getObjectClass()); - assertEquals("Wrong objectClass in shadow "+shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); + assertNotNull("No objectClass in shadow " + shadow, shadow.asObjectable().getObjectClass()); + assertEquals("Wrong objectClass in shadow " + shadow, objectClassDefinition.getTypeName(), shadow.asObjectable().getObjectClass()); Collection> attributes = ShadowUtil.getAttributes(shadow); - assertNotNull("No attributes in shadow "+shadow, attributes); - assertFalse("Empty attributes in shadow "+shadow, attributes.isEmpty()); + assertNotNull("No attributes in shadow " + shadow, attributes); + assertFalse("Empty attributes in shadow " + shadow, attributes.isEmpty()); } @Test public void test100FetchEmptyChanges() throws Exception { final String TEST_NAME = "test100FetchEmptyChanges"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -417,7 +364,6 @@ public void test100FetchEmptyChanges() throws Exception { @Test public void test101FetchAddChange() throws Exception { final String TEST_NAME = "test101FetchAddChange"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -451,9 +397,8 @@ public void test101FetchAddChange() throws Exception { } @Test - public void test500SelfTest() throws Exception { + public void test500SelfTest() { final String TEST_NAME = "test500SelfTest"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN OperationResult testResult = new OperationResult(TestUcfDummy.class + "." + TEST_NAME); diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java index c126d877e32..5ddb1efa7da 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfDummyMulti.java @@ -22,7 +22,6 @@ import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.schema.SchemaRegistry; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -59,10 +58,7 @@ public class TestUcfDummyMulti extends AbstractUcfDummyTest { private static final Trace LOGGER = TraceManager.getTrace(TestUcfDummyMulti.class); @Test - public void test000PrismContextSanity() throws Exception { - final String TEST_NAME = "test000PrismContextSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test000PrismContextSanity() { SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry(); PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION); assertNotNull("ICFC schema not found in the context ("+SchemaConstants.NS_ICF_CONFIGURATION+")", schemaIcfc); @@ -76,15 +72,12 @@ public void test000PrismContextSanity() throws Exception { @Test public void test020CreateConfiguredConnector() throws Exception { - final String TEST_NAME = "test020CreateConfiguredConnector"; - TestUtil.displayTestTitle(TEST_NAME); - cc = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(resourceType), "dummy", "description of dummy test connector instance"); assertNotNull("Failed to instantiate connector", cc); - OperationResult result = new OperationResult(TestUcfDummyMulti.class.getName() + "." + TEST_NAME); + OperationResult result = createResult(); PrismContainerValue configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue(); display("Configuration container", configContainer); @@ -102,7 +95,6 @@ public void test020CreateConfiguredConnector() throws Exception { @Test public void test100AddAccount() throws Exception { final String TEST_NAME = "test100AddAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -131,8 +123,6 @@ public void test100AddAccount() throws Exception { @Test public void test110SearchNonBlocking() throws Exception { - final String TEST_NAME = "test100SearchNonBlocking"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); @@ -151,7 +141,7 @@ public boolean handle(PrismObject shadow) { } }; - OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); // WHEN cc.search(accountDefinition, null, handler, null, null, null, null, result); @@ -167,11 +157,9 @@ public boolean handle(PrismObject shadow) { @Test public void test200BlockingSearch() throws Exception { - final String TEST_NAME = "test200BlockingSearch"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN - final OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result = createResult(); final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // Determine object class from the schema @@ -236,15 +224,13 @@ public void run() { @Test public void test210TwoBlockingSearches() throws Exception { - final String TEST_NAME = "test210TwoBlockingSearches"; - TestUtil.displayTestTitle(TEST_NAME); // GIVEN final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); // Determine object class from the schema - final OperationResult result1 = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result1 = createResult(); final List> searchResults1 = new ArrayList<>(); final ShadowResultHandler handler1 = new ShadowResultHandler() { @Override @@ -255,7 +241,7 @@ public boolean handle(PrismObject shadow) { } }; - final OperationResult result2 = new OperationResult(this.getClass().getName() + "." + TEST_NAME); + OperationResult result2 = createResult(); final List> searchResults2 = new ArrayList<>(); final ShadowResultHandler handler2 = new ShadowResultHandler() { @Override diff --git a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java index 8621632b39f..2dfa807d31a 100644 --- a/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java +++ b/provisioning/ucf-impl-connid/src/test/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/TestUcfOpenDj.java @@ -6,11 +6,35 @@ */ package com.evolveum.midpoint.provisioning.ucf.impl.connid; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.assertNotEmpty; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.xml.namespace.QName; + +import org.identityconnectors.framework.common.objects.Name; +import org.identityconnectors.framework.common.objects.Uid; +import org.opends.server.types.Entry; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.Assert; +import org.testng.AssertJUnit; +import org.testng.annotations.*; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.PropertyDelta; -import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -24,49 +48,23 @@ import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.schema.util.SchemaDebugUtil; +import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.ldap.OpenDJController; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.PrettyPrinter; -import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; 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.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType; -import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; -import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; -import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; -import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import com.evolveum.prism.xml.ns._public.types_3.RawType; - -import org.identityconnectors.framework.common.objects.Name; -import org.identityconnectors.framework.common.objects.Uid; -import org.opends.server.types.Entry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.Assert; -import org.testng.AssertJUnit; -import org.testng.annotations.*; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static com.evolveum.midpoint.test.IntegrationTestTools.*; -import static org.testng.AssertJUnit.*; +import com.evolveum.prism.xml.ns._public.types_3.*; /** * Test UCF implementation with OpenDJ and ICF LDAP connector. @@ -76,14 +74,14 @@ * * @author Radovan Semancik * @author Katka Valalikova - *

- * This is an UCF test. It shold not need repository or other things - * from the midPoint spring context except from the provisioning beans. - * But due to a general issue with spring context initialization this is - * a lesser evil for now (MID-392) + *

+ * This is an UCF test. It shold not need repository or other things + * from the midPoint spring context except from the provisioning beans. + * But due to a general issue with spring context initialization this is + * a lesser evil for now (MID-392) */ @ContextConfiguration(locations = { "classpath:ctx-ucf-connid-test.xml" }) -public class TestUcfOpenDj extends AbstractTestNGSpringContextTests { +public class TestUcfOpenDj extends AbstractSpringTest { private static final File RESOURCE_OPENDJ_FILE = new File(UcfTestUtil.TEST_DIR, "resource-opendj.xml"); private static final File RESOURCE_OPENDJ_BAD_FILE = new File(UcfTestUtil.TEST_DIR, "resource-opendj-bad.xml"); @@ -99,11 +97,11 @@ public class TestUcfOpenDj extends AbstractTestNGSpringContextTests { private static final Trace LOGGER = TraceManager.getTrace(TestUcfOpenDj.class); - @Autowired(required = true) + @Autowired ConnectorFactory connectorFactoryIcfImpl; - @Autowired(required = true) + @Autowired Protector protector; - @Autowired(required = true) + @Autowired PrismContext prismContext; protected static OpenDJController openDJController = new OpenDJController(); @@ -123,7 +121,7 @@ public static void startLdap() throws Exception { } @AfterClass - public static void stopLdap() throws Exception { + public static void stopLdap() { openDJController.stop(); LOGGER.info("------------------------------------------------------------------------------"); LOGGER.info("STOP: OpenDjUcfTest"); @@ -132,8 +130,6 @@ public static void stopLdap() throws Exception { @BeforeMethod public void initUcf() throws Exception { - TestUtil.displayTestTitle("initUcf"); - // Resource PrismObject resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE); resourceType = resource.asObjectable(); @@ -169,48 +165,38 @@ public void initUcf() throws Exception { } @AfterMethod - public void shutdownUcf() throws Exception { + public void shutdownUcf() { } - @Test - public void test010ConnectorSchemaSanity() throws Exception { - final String TEST_NAME = "test010ConnectorSchemaSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test010ConnectorSchemaSanity() { IntegrationTestTools.assertConnectorSchemaSanity(connectorSchema, "LDAP connector", true); PrismContainerDefinition configurationDefinition = connectorSchema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); PrismContainerDefinition configurationPropertiesDefinition = - configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - PrismPropertyDefinition propHost = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS,"host")); + PrismPropertyDefinition propHost = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS, "host")); assertNotNull("No definition for configuration property 'host' in connector schema", propHost); - PrismAsserts.assertDefinition(propHost, new QName(UcfTestUtil.CONNECTOR_LDAP_NS,"host"), DOMUtil.XSD_STRING, 1, 1); + PrismAsserts.assertDefinition(propHost, new QName(UcfTestUtil.CONNECTOR_LDAP_NS, "host"), DOMUtil.XSD_STRING, 1, 1); assertEquals("Wrong property 'host' display name", "Host", propHost.getDisplayName()); assertEquals("Wrong property 'host' help", "The name or IP address of the LDAP server host.", propHost.getHelp()); - assertEquals("Wrong property 'host' display order", (Integer)1, propHost.getDisplayOrder()); // MID-2642 + assertEquals("Wrong property 'host' display order", (Integer) 1, propHost.getDisplayOrder()); // MID-2642 - PrismPropertyDefinition propPort = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS,"port")); + PrismPropertyDefinition propPort = configurationPropertiesDefinition.findPropertyDefinition(new ItemName(UcfTestUtil.CONNECTOR_LDAP_NS, "port")); assertNotNull("No definition for configuration property 'port' in connector schema", propPort); - PrismAsserts.assertDefinition(propPort, new QName(UcfTestUtil.CONNECTOR_LDAP_NS,"port"), DOMUtil.XSD_INT, 0, 1); + PrismAsserts.assertDefinition(propPort, new QName(UcfTestUtil.CONNECTOR_LDAP_NS, "port"), DOMUtil.XSD_INT, 0, 1); assertEquals("Wrong property 'port' display name", "Port number", propPort.getDisplayName()); assertEquals("Wrong property 'port' help", "LDAP server port number.", propPort.getHelp()); - assertEquals("Wrong property 'port' display order", (Integer)2, propPort.getDisplayOrder()); // MID-2642 + assertEquals("Wrong property 'port' display order", (Integer) 2, propPort.getDisplayOrder()); // MID-2642 } - @Test - public void test020ResourceSchemaSanity() throws Exception { - final String TEST_NAME = "test020ResourceSchemaSanity"; - TestUtil.displayTestTitle(TEST_NAME); - + public void test020ResourceSchemaSanity() { QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); assertNotNull("No object class definition " + objectClassQname, accountDefinition); -// assertEquals("Object class " + objectClassQname + " is not account", ShadowKindType.ACCOUNT, accountDefinition.getKind()); -// assertTrue("Object class " + objectClassQname + " is not default account", accountDefinition.isDefaultInAKind()); assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isEmpty()); assertFalse("Object class " + objectClassQname + " is empty", accountDefinition.isIgnored()); @@ -220,23 +206,23 @@ public void test020ResourceSchemaSanity() throws Exception { ResourceAttributeDefinition idPrimaryDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME)); - assertNotNull("No definition for attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" in not an identifier",idPrimaryDef.isPrimaryIdentifier(accountDefinition)); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" in not in identifiers list",identifiers.contains(idPrimaryDef)); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" has wrong native name", OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef.getNativeAttributeName()); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" has wrong framework name", Uid.NAME, idPrimaryDef.getFrameworkAttributeName()); + assertNotNull("No definition for attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " in not an identifier", idPrimaryDef.isPrimaryIdentifier(accountDefinition)); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " in not in identifiers list", identifiers.contains(idPrimaryDef)); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " has wrong native name", OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME, idPrimaryDef.getNativeAttributeName()); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME + " has wrong framework name", Uid.NAME, idPrimaryDef.getFrameworkAttributeName()); ResourceAttributeDefinition idSecondaryDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME)); - assertNotNull("No definition for attribute "+SchemaConstants.ICFS_NAME, idSecondaryDef); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not secondary identifier",idSecondaryDef.isSecondaryIdentifier(accountDefinition)); - assertFalse("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in in identifiers list and it should NOT be",identifiers.contains(idSecondaryDef)); - assertTrue("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" in not in secomdary identifiers list",accountDefinition.getSecondaryIdentifiers().contains(idSecondaryDef)); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" has wrong native name", OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME, idSecondaryDef.getNativeAttributeName()); - assertEquals("Attribute "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" has wrong framework name", Name.NAME, idSecondaryDef.getFrameworkAttributeName()); - - assertEquals("Unexpected identifiers: "+identifiers, 1, identifiers.size()); - assertEquals("Unexpected secondary identifiers: "+accountDefinition.getSecondaryIdentifiers(), 1, accountDefinition.getSecondaryIdentifiers().size()); + assertNotNull("No definition for attribute " + SchemaConstants.ICFS_NAME, idSecondaryDef); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in not secondary identifier", idSecondaryDef.isSecondaryIdentifier(accountDefinition)); + assertFalse("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in in identifiers list and it should NOT be", identifiers.contains(idSecondaryDef)); + assertTrue("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " in not in secomdary identifiers list", accountDefinition.getSecondaryIdentifiers().contains(idSecondaryDef)); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " has wrong native name", OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME, idSecondaryDef.getNativeAttributeName()); + assertEquals("Attribute " + OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME + " has wrong framework name", Name.NAME, idSecondaryDef.getFrameworkAttributeName()); + + assertEquals("Unexpected identifiers: " + identifiers, 1, identifiers.size()); + assertEquals("Unexpected secondary identifiers: " + accountDefinition.getSecondaryIdentifiers(), 1, accountDefinition.getSecondaryIdentifiers().size()); } private Collection> addSampleResourceObject(String name, String givenName, String familyName) @@ -245,7 +231,7 @@ private Collection> addSampleResourceObject(String name, St QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); - assertNotNull("No object class definition "+objectClassQname, accountDefinition); + assertNotNull("No object class definition " + objectClassQname, accountDefinition); ResourceAttributeContainer resourceObject = accountDefinition.instantiate(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition attributeDefinition = accountDefinition @@ -279,19 +265,9 @@ private Collection> addSampleResourceObject(String name, St return resourceAttributes; } - private String getEntryUuid(Collection> identifiers) { - for (ResourceAttribute identifier : identifiers) { - if (identifier.getElementName().equals(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME))) { - return identifier.getValue(String.class).getValue(); - } - } - return null; - } - @Test public void test100AddDeleteObject() throws Exception { final String TEST_NAME = "test100AddDeleteObject"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -301,7 +277,7 @@ public void test100AddDeleteObject() throws Exception { for (ResourceAttribute resourceAttribute : identifiers) { if (SchemaConstants.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); - System.out.println("uuuuid:" + uid); + System.out.println("uuid:" + uid); assertNotNull(uid); } } @@ -326,7 +302,6 @@ public void test100AddDeleteObject() throws Exception { @Test public void test110ChangeModifyObject() throws Exception { final String TEST_NAME = "test110ChangeModifyObject"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); @@ -371,7 +346,6 @@ public void test110ChangeModifyObject() throws Exception { @Test public void test200FetchChanges() throws Exception { final String TEST_NAME = "test200FetchChanges"; - TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); @@ -445,16 +419,11 @@ private PropertyModificationOperation createActivationChange(ActivationStatusTyp /** * Simple call to connector test() method. - * - * @throws Exception */ @Test - public void test300TestConnection() throws Exception { - final String TEST_NAME = "test300TestConnection"; - TestUtil.displayTestTitle(this, TEST_NAME); + public void test300TestConnection() { // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); // WHEN @@ -472,16 +441,11 @@ public void test300TestConnection() throws Exception { /** * Simple call to connector test() method. - * - * @throws Exception */ @Test public void test310TestConnectionNegative() throws Exception { - final String TEST_NAME = "test310TestConnectionNegative"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); ConnectorInstance badConnector = factory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(badResourceType), "bad resource", "bad resource description"); @@ -506,17 +470,12 @@ public void test310TestConnectionNegative() throws Exception { /** * Test fetching and translating resource schema. - * - * @throws Exception */ @Test public void test400FetchResourceSchema() throws Exception { - final String TEST_NAME = "test400FetchResourceSchema"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN // WHEN - // The schema was fetched during test init. Now just check if it was OK. // THEN @@ -561,14 +520,10 @@ public void test400FetchResourceSchema() throws Exception { @Test public void test410Capabilities() throws Exception { - final String TEST_NAME = "test410Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = new OperationResult(contextName()); // WHEN - Collection capabilities = cc.fetchCapabilities(result); // THEN @@ -586,7 +541,6 @@ public void test410Capabilities() throws Exception { @Test public void test500FetchObject() throws Exception { final String TEST_NAME = "test500FetchObject"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( @@ -621,7 +575,6 @@ public void test500FetchObject() throws Exception { @Test public void test510Search() throws Exception { final String TEST_NAME = "test510Search"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(OpenDJController.OBJECT_CLASS_INETORGPERSON_NAME); @@ -647,7 +600,6 @@ public boolean handle(PrismObject object) { @Test public void test600CreateAccountWithPassword() throws Exception { final String TEST_NAME = "test600CreateAccountWithPassword"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( "uid=lechuck,ou=people,dc=example,dc=com", "Ghost Pirate LeChuck", "LeChuck"); @@ -687,7 +639,6 @@ public void test600CreateAccountWithPassword() throws Exception { @Test public void test610ChangePassword() throws Exception { final String TEST_NAME = "test610ChangePassword"; - TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( "uid=drake,ou=People,dc=example,dc=com", "Sir Francis Drake", "Drake"); @@ -730,10 +681,10 @@ public void test610ChangePassword() throws Exception { RawType value = new RawType(passPsXnode, prismContext); propMod.getValue().add(value); - //set the modificaion type + //set the modification type propMod.setModificationType(ModificationTypeType.REPLACE); - PropertyDelta passDelta = (PropertyDelta)DeltaConvertor.createItemDelta(propMod, shadow.getDefinition()); + PropertyDelta passDelta = (PropertyDelta) DeltaConvertor.createItemDelta(propMod, shadow.getDefinition()); PropertyModificationOperation passwordModification = new PropertyModificationOperation(passDelta); changes.add(passwordModification); diff --git a/repo/audit-impl/pom.xml b/repo/audit-impl/pom.xml index e92f46b96be..3ebe1d9cf4d 100644 --- a/repo/audit-impl/pom.xml +++ b/repo/audit-impl/pom.xml @@ -99,6 +99,11 @@ 4.1-SNAPSHOT test + + com.evolveum.midpoint.infra + test-util + test + org.forgerock.opendj opendj diff --git a/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java b/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java index b446c824722..f6187298da6 100644 --- a/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java +++ b/repo/audit-impl/src/test/java/com/evolveum/midpoint/audit/impl/TestAuditServiceImpl.java @@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -23,6 +22,7 @@ import com.evolveum.midpoint.common.LoggingConfigurationManager; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.task.api.TaskManager; +import com.evolveum.midpoint.test.util.AbstractSpringTest; /** * @author semancik @@ -34,7 +34,7 @@ "classpath:ctx-repo-cache.xml", "classpath:ctx-repository-test.xml", "classpath:ctx-configuration-test.xml"}) -public class TestAuditServiceImpl extends AbstractTestNGSpringContextTests { +public class TestAuditServiceImpl extends AbstractSpringTest { private static final String LOG_FILENAME = "target/test.log"; @@ -45,7 +45,7 @@ public class TestAuditServiceImpl extends AbstractTestNGSpringContextTests { TaskManager taskManager; @Test - public void testAuditSimple() throws FileNotFoundException, InterruptedException { + public void testAuditSimple() throws FileNotFoundException { // GIVEN AuditEventRecord auditRecord = new AuditEventRecord(AuditEventType.ADD_OBJECT); Task task = taskManager.createTaskInstance(); diff --git a/repo/repo-cache/pom.xml b/repo/repo-cache/pom.xml index d958dfc3fbb..8e880c5616f 100644 --- a/repo/repo-cache/pom.xml +++ b/repo/repo-cache/pom.xml @@ -60,7 +60,7 @@ - + org.springframework spring-context @@ -99,6 +99,11 @@ 4.1-SNAPSHOT test + + com.evolveum.midpoint.infra + test-util + test + org.springframework spring-test diff --git a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java index 0e6fc3eb3c0..dc161b91145 100644 --- a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java +++ b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java @@ -6,6 +6,23 @@ */ package com.evolveum.midpoint.repo.cache; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; + +import java.io.IOException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import javax.annotation.PostConstruct; + +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -16,6 +33,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -25,28 +43,13 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.annotation.PostConstruct; -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; -import static org.testng.AssertJUnit.assertEquals; /** * */ -@SuppressWarnings("SameParameterValue") @ContextConfiguration(locations = {"classpath:ctx-repo-cache-test.xml" }) -public class TestRepositoryCache extends AbstractTestNGSpringContextTests { +@SuppressWarnings("SameParameterValue") +@ContextConfiguration(locations = { "classpath:ctx-repo-cache-test.xml" }) +public class TestRepositoryCache extends AbstractSpringTest { private static final String CLASS_DOT = TestRepositoryCache.class.getName() + "."; diff --git a/repo/repo-common/pom.xml b/repo/repo-common/pom.xml index dfedb60a586..77532bb9728 100644 --- a/repo/repo-common/pom.xml +++ b/repo/repo-common/pom.xml @@ -176,7 +176,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java index e7b2ba70565..2a1bc6bf71d 100644 --- a/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java +++ b/repo/repo-common/src/test/java/com/evolveum/midpoint/repo/common/commandline/TestCommandLine.java @@ -56,24 +56,23 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100PlainExecuteEcho() throws Exception { final String TEST_NAME = "test100PlainExecuteEcho"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); CommandLineScriptType scriptType = getScript(REPORT_PLAIN_ECHO_FILE); // WHEN - displayWhen(TEST_NAME); + when(); commandLineScriptExecutor.executeScript(scriptType, null, "test", task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); } @@ -81,14 +80,13 @@ public void test100PlainExecuteEcho() throws Exception { @Test public void test110RedirExecuteEcho() throws Exception { final String TEST_NAME = "test110RedirExecuteEcho"; - displayTestTitle(TEST_NAME); if (!isOsUnix()) { displaySkip(TEST_NAME); return; } - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); CommandLineScriptType scriptType = getScript(REPORT_REDIR_ECHO_FILE); @@ -97,11 +95,11 @@ public void test110RedirExecuteEcho() throws Exception { VAR_HELLOTEXT, "Hello World", PrimitiveType.STRING); // WHEN - displayWhen(TEST_NAME); + when(); commandLineScriptExecutor.executeScript(scriptType, variables, "test", task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); File targetFile = new File(MidPointTestConstants.TARGET_DIR_PATH, "echo-out"); diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index 35f54a11040..cfe1d19eac7 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -188,7 +188,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java index 92f018c09cb..c99397ee8d8 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java @@ -338,7 +338,7 @@ public void testAddGetSystemConfigFile() throws Exception { PrismObject securityPolicy = prismContext.parseObject(new File(FOLDER_BASIC, "security-policy-special.xml")); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); String securityPolicyOid = "ce74cb86-c8e8-11e9-bee8-b37bf7a7ab4a"; String oid = repositoryService.addObject(securityPolicy, null, result); AssertJUnit.assertNotNull(oid); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java index 71b8a2d4fd7..507cc2166e0 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java @@ -7,6 +7,29 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; +import static com.evolveum.midpoint.schema.constants.MidPointConstants.NS_RI; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; +import javax.xml.namespace.QName; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +import org.testng.AssertJUnit; +import org.testng.annotations.*; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.audit.api.AuditService; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.crypto.Protector; @@ -32,6 +55,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; @@ -40,35 +64,12 @@ import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; - import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.AssertJUnit; -import org.testng.annotations.*; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; -import java.util.*; -import java.util.stream.Collectors; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static com.evolveum.midpoint.schema.constants.MidPointConstants.NS_RI; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; /** * @author lazyman */ -public class BaseSQLRepoTest extends AbstractTestNGSpringContextTests { +public class BaseSQLRepoTest extends AbstractSpringTest { private static final Trace LOGGER = TraceManager.getTrace(BaseSQLRepoTest.class); @@ -93,9 +94,11 @@ public class BaseSQLRepoTest extends AbstractTestNGSpringContextTests { static final ItemName ATTR_MANAGER = new ItemName(NS_RI, "manager"); @Autowired protected LocalSessionFactoryBean sessionFactoryBean; + @Autowired @Qualifier("sqlRepositoryServiceImpl") protected SqlRepositoryServiceImpl sqlRepositoryService; + @Autowired protected RepositoryService repositoryService; @Autowired protected BaseHelper baseHelper; @Autowired protected AuditService auditService; @@ -107,8 +110,6 @@ public class BaseSQLRepoTest extends AbstractTestNGSpringContextTests { @Autowired protected Protector protector; @Autowired protected TestQueryListener queryListener; - private static Set initializedClasses = new HashSet<>(); - protected boolean verbose = false; @BeforeSuite @@ -127,35 +128,33 @@ public void setFactory(SessionFactory factory) { this.factory = factory; } - private boolean isSystemInitialized() { - return initializedClasses.contains(this.getClass()); - } - - private void setSystemInitialized() { - initializedClasses.add(this.getClass()); - } - @BeforeClass public void beforeClass() throws Exception { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START " + getClass().getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName() }); } @AfterClass public void afterClass() { System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> FINISH " + getClass().getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> FINISH {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> FINISH {} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName() }); } + private volatile boolean initSystemExecuted = false; + + // TODO inttest: consider @PostConstruct like in AbstractIntegrationTest @BeforeMethod public void beforeMethod(Method method) throws Exception { + if (initSystemExecuted) { + logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName()); + return; + } + initSystemExecuted = true; System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> START TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> START {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName(), method.getName()}); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>> START {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", + getClass().getName(), method.getName()); - if (!isSystemInitialized()) { - initSystem(); - setSystemInitialized(); - } + initSystem(); } @AfterMethod @@ -172,7 +171,7 @@ public void afterMethod(Method method) { } System.out.println(">>>>>>>>>>>>>>>>>>>>>>>> END TEST" + getClass().getName() + "." + method.getName() + "<<<<<<<<<<<<<<<<<<<<<<<<"); - LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> END {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[]{getClass().getName(), method.getName()}); + LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>> END {}.{} <<<<<<<<<<<<<<<<<<<<<<<<", new Object[] { getClass().getName(), method.getName() }); } protected boolean isH2() { @@ -221,13 +220,13 @@ protected PrismObject getObject(Class type, String return object; } - OperationResult createResult(String testName) { - return new OperationResult(testName); + protected OperationResult createResult() { + return new OperationResult(contextName()); } // TODO: merge with similar methods in AbstractIntegrationTest protected void display(String message, PrismObject object) { - System.out.println("\n"+message+"\n"+object.debugDump(1)); + System.out.println("\n" + message + "\n" + object.debugDump(1)); } protected S_ItemEntry deltaFor(Class objectClass) throws SchemaException { @@ -249,8 +248,10 @@ protected ItemFactory itemFactory() { @NotNull ObjectReference createRepoRef(QName type, String oid) { - return RObjectReference - .copyFromJAXB(createRef(type, oid, SchemaConstants.ORG_DEFAULT), new RObjectReference(), relationRegistry); + return RObjectReference.copyFromJAXB( + createRef(type, oid, SchemaConstants.ORG_DEFAULT), + new RObjectReference(), + relationRegistry); } ObjectReferenceType createRef(QName type, String oid) { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java index 82ca1fcc4c9..07390170b00 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java @@ -66,7 +66,6 @@ public class CertificationTest extends BaseSQLRepoTest { private static final Trace LOGGER = TraceManager.getTrace(CertificationTest.class); private static final File TEST_DIR = new File("src/test/resources/cert"); public static final File CAMPAIGN_1_FILE = new File(TEST_DIR, "cert-campaign-1.xml"); - public static final String CAMPAIGN_1_OID = "e8c07a7a-1b11-11e8-9b32-1715a2e8273b"; public static final File CAMPAIGN_2_FILE = new File(TEST_DIR, "cert-campaign-2.xml"); public static final long CASE_9_ID = 105L; public static final long NEW_CASE_ID = 200L; @@ -208,8 +207,7 @@ public void test240AddCases() throws Exception { @Test public void test250DeleteCase() throws Exception { - final String TEST_NAME = "test250DeleteCase"; - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject campaign10Before = getFullCampaign(campaign1Oid); display("Campaign 10 before", campaign10Before); @@ -582,7 +580,7 @@ private void checkCasesForCampaign(String oid, Integer expected, OperationResult } } - private void checkWorkItemsForCampaign(String oid, int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkWorkItemsForCampaign(String oid, int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -596,7 +594,7 @@ private void checkWorkItemsForCampaign(String oid, int expected, OperationResult assertEquals("Wrong # of certification work items", expected, count); } - private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationWorkItemType.class) .exists(T_PARENT) .block() @@ -611,7 +609,7 @@ private void checkWorkItemsForCampaignAndCase(String oid, long caseId, int expec assertEquals("Wrong # of certification work items", expected, count); } - private void checkCasesTotal(int expected, OperationResult result) throws SchemaException, ObjectNotFoundException { + private void checkCasesTotal(int expected, OperationResult result) throws SchemaException { ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) .build(); List cases = repositoryService.searchContainers(AccessCertificationCaseType.class, query, null, result); @@ -628,7 +626,7 @@ private void assertCasesFound(Integer expected, List workItems = repositoryService.searchContainers(AccessCertificationWorkItemType.class, null, null, result); assertWorkItemsCount(expected, workItems, ""); int count = repositoryService.countContainers(AccessCertificationWorkItemType.class, null, null, result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java index e6eec60e1d0..70c016de7a1 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java @@ -9,31 +9,32 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.*; -import com.evolveum.midpoint.prism.*; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.resetPrismContext; + +import java.io.File; +import java.util.List; -import org.hibernate.query.Query; import org.hibernate.Session; +import org.hibernate.query.Query; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.io.File; -import java.util.List; +import com.evolveum.midpoint.prism.*; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.util.PrismAsserts; +import com.evolveum.midpoint.schema.MidPointPrismContextFactory; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author lazyman */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ModifyAssignmentTest extends BaseSQLRepoTest { @@ -88,7 +89,6 @@ public void test010AddAssignment() throws Exception { .item(RoleType.F_ASSIGNMENT).add(assignment1) .asObjectDeltaCast(ROLE_OID); - OperationResult result = new OperationResult("add assignment"); // WHEN @@ -99,7 +99,7 @@ public void test010AddAssignment() throws Exception { //check role and its assignments and inducements PrismObject repoRole = getObject(RoleType.class, ROLE_OID); - System.out.println("role after: " + repoRole.debugDump()); + System.out.println("role after: " + repoRole.debugDump()); PrismContainer inducement = repoRole.findContainer(RoleType.F_INDUCEMENT); assertNotNull(inducement); @@ -124,7 +124,7 @@ public void test011AddInducement() throws Exception { AssignmentType inducement1 = new AssignmentType(prismContext) .id(5L) .beginConstruction() - .resourceRef(ORIGINAL_INDUCEMENT_5_TARGET_OID, ResourceType.COMPLEX_TYPE) + .resourceRef(ORIGINAL_INDUCEMENT_5_TARGET_OID, ResourceType.COMPLEX_TYPE) .end(); ObjectDelta delta = deltaFor(RoleType.class) @@ -163,7 +163,7 @@ public void test020ModifyAssignment() throws Exception { ObjectDelta delta = deltaFor(RoleType.class) .item(RoleType.F_ASSIGNMENT, 4L, AssignmentType.F_TARGET_REF) - .replace(new ObjectReferenceType().oid(NEW_ASSIGNMENT_4_TARGET_OID).type(RoleType.COMPLEX_TYPE)) + .replace(new ObjectReferenceType().oid(NEW_ASSIGNMENT_4_TARGET_OID).type(RoleType.COMPLEX_TYPE)) .asObjectDeltaCast(ROLE_OID); OperationResult result = new OperationResult("modify assignment"); @@ -199,7 +199,7 @@ public void test021ModifyInducement() throws Exception { ObjectDelta delta = deltaFor(RoleType.class) .item(RoleType.F_INDUCEMENT, 5L, AssignmentType.F_TARGET_REF) - .replace(new ObjectReferenceType().oid(NEW_INDUCEMENT_5_TARGET_OID).type(RoleType.COMPLEX_TYPE)) + .replace(new ObjectReferenceType().oid(NEW_INDUCEMENT_5_TARGET_OID).type(RoleType.COMPLEX_TYPE)) .asObjectDeltaCast(ROLE_OID); OperationResult result = new OperationResult("modify inducement"); @@ -228,7 +228,7 @@ public void test021ModifyInducement() throws Exception { assertEquals(NEW_INDUCEMENT_5_TARGET_OID, refValue.getOid()); assertEquals(RoleType.COMPLEX_TYPE, refValue.getTargetType()); - PrismProperty accConstruction = value5.findProperty(AssignmentType.F_CONSTRUCTION); + PrismProperty accConstruction = value5.findProperty(AssignmentType.F_CONSTRUCTION); AssertJUnit.assertNull(accConstruction); } @@ -262,7 +262,8 @@ public void test030DeleteAssignment() throws Exception { Session session = open(); try { - Query query = session.createNativeQuery("select count(*) from m_assignment where owner_oid=:oid and id=:id"); + Query query = session.createNativeQuery( + "select count(*) from m_assignment where owner_oid=:oid and id=:id"); query.setParameter("oid", delta.getOid()); query.setParameter("id", 4); Number number = (Number) query.uniqueResult(); @@ -318,7 +319,7 @@ public void test040RenameAssignmentToInducement() throws Exception { AssignmentType a = new AssignmentType(prismContext) .id(1L) .beginConstruction() - .resourceRef(MOVED_ASSIGNMENT_TARGET_OID, ResourceType.COMPLEX_TYPE) + .resourceRef(MOVED_ASSIGNMENT_TARGET_OID, ResourceType.COMPLEX_TYPE) .end(); AssignmentType in = a.clone(); @@ -350,10 +351,8 @@ public void test040RenameAssignmentToInducement() throws Exception { @Test public void test100AssignmentAdd() throws Exception { - final String TEST_NAME = "test100AssignmentAdd"; //given - - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject roleBefore = getObject(RoleType.class, ROLE_OID); display("Role before", roleBefore); @@ -380,18 +379,15 @@ public void test100AssignmentAdd() throws Exception { assertEquals("Wrong assignment id", (Long) 7L, assignment.getValues().iterator().next().getId()); } - /** * Add and delete assignment in one operation. Make sure that the container id is not reused. - * + *

* MID-4463 */ @Test public void test110AssignmentAddDeleteIds() throws Exception { - final String TEST_NAME = "test110AssignmentAddDeleteIds"; //given - - OperationResult result = createResult(TEST_NAME); + OperationResult result = createResult(); PrismObject roleBefore = getObject(RoleType.class, ROLE_OID); display("Role before", roleBefore); @@ -406,8 +402,8 @@ public void test110AssignmentAddDeleteIds() throws Exception { List> deltas = deltaFor(RoleType.class) .item(RoleType.F_ASSIGNMENT) - .add(assignmentToAdd) - .delete(assignmentToDelete) + .add(assignmentToAdd) + .delete(assignmentToDelete) .asItemDeltas(); // WHEN diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java index 726dc8b871b..b25246e5a49 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java @@ -74,8 +74,6 @@ import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -92,8 +90,6 @@ public class ModifyTest extends BaseSQLRepoTest { private static final File ACCOUNT_FILE = new File(TEST_DIR, "account.xml"); private static final File MODIFY_USER_ADD_LINK = new File(TEST_DIR, "change-add.xml"); - private static final Trace LOGGER = TraceManager.getTrace(ModifyTest.class); - private static final QName QNAME_LOOT = new QName("http://example.com/p", "loot"); private static final QName QNAME_WEAPON = new QName("http://example.com/p", "weapon"); private static final QName QNAME_FUNERAL_DATE = new QName("http://example.com/p", "funeralDate"); @@ -127,9 +123,6 @@ protected RepoModifyOptions getModifyOptions() { @Test(expectedExceptions = ObjectAlreadyExistsException.class) public void test010ModifyWithExistingName() throws Exception { - final String TEST_NAME = "test010ModifyWithExistingName"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("MODIFY"); File userFile = new File(TEST_DIR, "modify-user.xml"); @@ -157,9 +150,6 @@ public void test010ModifyWithExistingName() throws Exception { @Test(expectedExceptions = ObjectNotFoundException.class) public void test020ModifyNotExistingUser() throws Exception { - final String TEST_NAME = "test020ModifyNotExistingUser"; - TestUtil.displayTestTitle(TEST_NAME); - ObjectModificationType modification = PrismTestUtil.parseAtomicValue( MODIFY_USER_ADD_LINK, ObjectModificationType.COMPLEX_TYPE); @@ -170,9 +160,6 @@ public void test020ModifyNotExistingUser() throws Exception { @Test public void test030ModifyUserOnNonExistingAccountTest() throws Exception { - final String TEST_NAME = "test030ModifyUserOnNonExistingAccountTest"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("MODIFY"); //add user @@ -198,7 +185,7 @@ public void test030ModifyUserOnNonExistingAccountTest() throws Exception { PrismObject userNew = repositoryService.getObject(UserType.class, oid, null, result); ObjectDelta delta = userOld.diff(userNew); - LOGGER.debug("Modify diff \n{}", delta.debugDump(3)); + logger.debug("Modify diff \n{}", delta.debugDump(3)); AssertJUnit.assertTrue("Modify was unsuccessful, diff size: " + delta.getModifications().size(), delta.isEmpty()); AssertJUnit.assertTrue("User is not equivalent.", userOld.equivalent(userNew)); @@ -206,11 +193,8 @@ public void test030ModifyUserOnNonExistingAccountTest() throws Exception { @Test public void test031ModifyUserOnExistingAccountTest() throws Exception { - final String TEST_NAME = "test031ModifyUserOnExistingAccountTest"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); //add account PrismObject account = prismContext.parseObject(ACCOUNT_FILE); @@ -238,7 +222,7 @@ public void test031ModifyUserOnExistingAccountTest() throws Exception { PrismObject userNew = repositoryService.getObject(UserType.class, oid, null, result); ObjectDelta delta = userOld.diff(userNew); - LOGGER.debug("Modify diff \n{}", delta.debugDump(3)); + logger.debug("Modify diff \n{}", delta.debugDump(3)); AssertJUnit.assertTrue("Modify was unsuccessful, diff size: " + delta.getModifications().size(), delta.isEmpty()); AssertJUnit.assertTrue("User is not equivalent.", userOld.equivalent(userNew)); @@ -246,10 +230,7 @@ public void test031ModifyUserOnExistingAccountTest() throws Exception { @Test public void test032ModifyTaskObjectRef() throws Exception { - final String TEST_NAME = "test032ModifyTaskObjectRef"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); File taskFile = new File(TEST_DIR, "task.xml"); System.out.println("ADD"); PrismObject task = prismContext.parseObject(taskFile); @@ -257,8 +238,7 @@ public void test032ModifyTaskObjectRef() throws Exception { final String taskOid = "00000000-0000-0000-0000-123450000001"; AssertJUnit.assertNotNull(taskOid); System.out.println("GET"); - PrismObject getTask = null; - getTask = repositoryService.getObject(TaskType.class, taskOid, null, result); + PrismObject getTask = repositoryService.getObject(TaskType.class, taskOid, null, result); String lastVersion = getTask.getVersion(); AssertJUnit.assertTrue(task.equivalent(getTask)); TaskType taskType = null; @@ -301,7 +281,7 @@ public void test032ModifyTaskObjectRef() throws Exception { AssertJUnit.assertNotNull(taskType.getObjectRef()); objectRef = taskType.getObjectRef(); assertEquals("2", objectRef.getOid()); - LOGGER.info(PrismTestUtil.serializeObjectToString(taskType.asPrismObject())); + logger.info(PrismTestUtil.serializeObjectToString(taskType.asPrismObject())); SqlRepoTestUtil.assertVersionProgress(lastVersion, getTask.getVersion()); lastVersion = getTask.getVersion(); @@ -339,10 +319,7 @@ private void checkReference(String taskOid) { @Test // MID-4801 (this passed even before fixing that issue) public void test035ModifyTaskOwnerRef() throws Exception { - final String TEST_NAME = "test035ModifyTaskOwnerRef"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); TaskType task = new TaskType(prismContext) .oid("035") .name("task035") @@ -361,10 +338,7 @@ public void test035ModifyTaskOwnerRef() throws Exception { @Test // MID-4801 (this failed before fixing that issue) public void test036ModifyTaskOwnerRefAddAndDelete() throws Exception { - final String TEST_NAME = "test036ModifyTaskOwnerRefAddAndDelete"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); TaskType task = new TaskType(prismContext) .oid("036") .name("task036") @@ -385,10 +359,7 @@ public void test036ModifyTaskOwnerRefAddAndDelete() throws Exception { @Test // MID-4801 public void test050ModifyUserEmployeeNumber() throws Exception { - final String TEST_NAME = "test050ModifyUserEmployeeNumber"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("050") .name("user050") @@ -408,10 +379,7 @@ public void test050ModifyUserEmployeeNumber() throws Exception { @Test // MID-4801 public void test055DeleteUserEmployeeNumberWrong() throws Exception { - final String TEST_NAME = "test055DeleteUserEmployeeNumberWrong"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("055") .name("user055") @@ -435,10 +403,7 @@ public void test055DeleteUserEmployeeNumberWrong() throws Exception { @Test // MID-4801 public void test056EmptyUserEmployeeNumberDelta() throws Exception { - final String TEST_NAME = "test056EmptyUserEmployeeNumberDelta"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); UserType user = new UserType(prismContext) .oid("056") .name("user056") @@ -478,9 +443,6 @@ private void assertUserEmployeeNumber(String userOid, String expectedValue) { @Test public void test100ModifyUserAddRole() throws Exception { - final String TEST_NAME = "test100ModifyUserAddRole"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult parentResult = new OperationResult("Modify user -> add roles"); String userToModifyOid = "f65963e3-9d47-4b18-aaf3-bfc98bdfa000"; @@ -529,11 +491,8 @@ public void test100ModifyUserAddRole() throws Exception { */ @Test public void test120ModifyAccountMetadata() throws Exception { - final String TEST_NAME = "test120ModifyAccountMetadata"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createResult(); repositoryService.deleteObject(ShadowType.class, "1234567890", parentResult); // from earlier test @@ -569,12 +528,12 @@ public void test120ModifyAccountMetadata() throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject repoShadow = repositoryService.getObject(ShadowType.class, oid, null, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); System.out.println("\nRepo shadow"); System.out.println(repoShadow.debugDump()); @@ -597,11 +556,11 @@ public void test120ModifyAccountMetadata() throws Exception { modifications.add(pdelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(ShadowType.class, oid, modifications, getModifyOptions(), parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject afterModify = repositoryService.getObject(ShadowType.class, oid, null, parentResult); System.out.println("\nAfter modify 1"); @@ -624,12 +583,12 @@ public void test120ModifyAccountMetadata() throws Exception { prismContext); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(ShadowType.class, oid, syncSituationDeltas, getModifyOptions(), parentResult); // AssertJUnit.assertNull(afterModify.asObjectable().getObjectChange()); // THEN - TestUtil.displayThen(TEST_NAME); + then(); afterModify = repositoryService.getObject(ShadowType.class, oid, null, parentResult); System.out.println("\nAfter modify 2"); @@ -638,9 +597,6 @@ public void test120ModifyAccountMetadata() throws Exception { @Test public void test130ExtensionModify() throws Exception { - final String TEST_NAME = "test130ExtensionModify"; - TestUtil.displayTestTitle(TEST_NAME); - File userFile = new File(TEST_DIR, "user-with-extension.xml"); //add first user PrismObject user = prismContext.parseObject(userFile); @@ -675,9 +631,6 @@ public void test130ExtensionModify() throws Exception { @Test public void test140ModifyAccountSynchronizationSituation() throws Exception { - final String TEST_NAME = "test140ModifyAccountSynchronizationSituation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("testModifyAccountSynchronizationSituation"); //add account @@ -730,10 +683,7 @@ public void test140ModifyAccountSynchronizationSituation() throws Exception { @Test public void test142ModifyAccountAttributeSameValue() throws Exception { - final String TEST_NAME = "test142ModifyAccountAttributeSameValue"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject account = prismContext.parseObject(ACCOUNT_ATTRIBUTE_FILE); repositoryService.addObject(account, null, result); @@ -756,10 +706,7 @@ public void test142ModifyAccountAttributeSameValue() throws Exception { @Test public void test144ModifyAccountAttributeDifferent() throws Exception { - final String TEST_NAME = "test144ModifyAccountAttributeDifferent"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); assertNotNull("account-attribute was not imported in previous tests", accountOid); @@ -780,10 +727,7 @@ public void test144ModifyAccountAttributeDifferent() throws Exception { @Test public void test148ModifyAssignmentExtension() throws Exception { - final String TEST_NAME = "test148ModifyAssignmentExtension"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.parseObject(new File(TEST_DIR, "user-with-assignment-extension.xml")); repositoryService.addObject(user, null, result); @@ -807,10 +751,7 @@ public void test148ModifyAssignmentExtension() throws Exception { @Test public void test150ModifyRoleAddInducements() throws Exception { - final String TEST_NAME = "test150ModifyRoleAddInducements"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); File roleFile = new File(TEST_DIR, "role-modify.xml"); //add first user @@ -858,9 +799,7 @@ public void test150ModifyRoleAddInducements() throws Exception { @Test public void test160ModifyWithPrecondition() throws Exception { - final String TEST_NAME = "test160ModifyWithPrecondition"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -884,9 +823,7 @@ public void test160ModifyWithPrecondition() throws Exception { @Test public void test162ModifyWithPrecondition2() throws Exception { - final String TEST_NAME = "test162ModifyWithPrecondition2"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -911,9 +848,7 @@ public void test162ModifyWithPrecondition2() throws Exception { @Test public void test164ModifyWithVersionPreconditionFalse() throws Exception { - final String TEST_NAME = "test164ModifyWithVersionPreconditionFalse"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -938,9 +873,7 @@ public void test164ModifyWithVersionPreconditionFalse() throws Exception { @Test public void test166ModifyWithVersionPreconditionTrue() throws Exception { - final String TEST_NAME = "test166ModifyWithVersionPreconditionTrue"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); // GIVEN String versionBefore = repositoryService.getVersion(RoleType.class, roleOid, result); @@ -960,10 +893,7 @@ public void test166ModifyWithVersionPreconditionTrue() throws Exception { @Test public void test200ReplaceAttributes() throws Exception { - final String TEST_NAME = "test200ReplaceAttributes"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject account = prismContext.parseObject(ACCOUNT_ATTRIBUTE_FILE); account.setOid(null); @@ -986,11 +916,11 @@ public void test200ReplaceAttributes() throws Exception { Session session = open(); List shadows = session.createQuery("from RShadow").list(); - LOGGER.info("shadows:\n{}", shadows); + logger.info("shadows:\n{}", shadows); //noinspection unchecked List extStrings = session.createQuery("select e.owner.oid, e.itemId, e.value from ROExtString e").list(); for (Object[] extString : extStrings) { - LOGGER.info("-> {}", Arrays.asList(extString)); + logger.info("-> {}", Arrays.asList(extString)); } close(session); @@ -998,7 +928,7 @@ public void test200ReplaceAttributes() throws Exception { .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR1_QNAME), def1).eq("value1") .build(); List list1 = repositoryService.searchObjects(ShadowType.class, query1, null, result); - LOGGER.info("*** query1 result:\n{}", DebugUtil.debugDump(list1)); + logger.info("*** query1 result:\n{}", DebugUtil.debugDump(list1)); assertEquals("Wrong # of query1 results", 1, list1.size()); session = open(); @@ -1058,9 +988,6 @@ private void assertAttribute(PrismObject shadow, QName attrQName @Test public void test210ModifyObjectCollection() throws Exception { - final String TEST_NAME = "test210ModifyObjectCollection"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult("test210ModifyObjectCollection"); ObjectCollectionType collection = prismContext.createObjectable(ObjectCollectionType.class) @@ -1112,11 +1039,8 @@ public void test210ModifyObjectCollection() throws Exception { */ @Test public void test250AddShadowPendingOperations() throws Exception { - final String TEST_NAME = "test250AddShadowPendingOperations"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow1") @@ -1151,11 +1075,8 @@ public void test250AddShadowPendingOperations() throws Exception { */ @Test public void test260DeleteShadowPendingOperations() throws Exception { - final String TEST_NAME = "test260DeleteShadowPendingOperations"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("shadow2") @@ -1192,11 +1113,8 @@ public void test260DeleteShadowPendingOperations() throws Exception { */ @Test public void test300AddCaseWorkItem() throws Exception { - final String TEST_NAME = "test300AddCaseWorkItem"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject caseObject = prismContext.createObjectable(CaseType.class) .name("testcase1") @@ -1228,11 +1146,8 @@ public void test300AddCaseWorkItem() throws Exception { @Test public void test310ModifyCaseWorkItemAssignee() throws Exception { - final String TEST_NAME = "test310ModifyCaseWorkItemAssignee"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); final String OLD_OID = "0f4082cf-c0b6-4cd2-a3db-544c668bab0c"; final String NEW_OID = "4cbdc40b-5693-4174-8634-acd3e0b96168"; @@ -1266,11 +1181,8 @@ public void test310ModifyCaseWorkItemAssignee() throws Exception { @Test public void test320ModifyCaseWorkItemAssigneeAndCandidate() throws Exception { - final String TEST_NAME = "test320ModifyCaseWorkItemAssigneeAndCandidate"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); final String OLD_OID = "d886a44c-732d-44d4-8403-e7c44bbfba8b"; final String OLD2_OID = "9a28119e-1283-4328-9e2f-ef383728a4d1"; @@ -1337,11 +1249,8 @@ private List assertCandidate(String candidateOid, int expected @Test // MID-5104 public void test350ReplaceAssignmentModifyApprover() throws Exception { - final String TEST_NAME = "test350ReplaceAssignmentModifyApprover"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test350") @@ -1368,11 +1277,8 @@ public void test350ReplaceAssignmentModifyApprover() throws Exception { @Test // MID-5105 public void test360ReplaceModifyApprovers() throws Exception { - final String TEST_NAME = "test360ReplaceModifyApprovers"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test360") @@ -1462,11 +1368,8 @@ public void test410RemoveExtensionProtectedStringValueInMemory() throws Exceptio @Test // MID-5516 public void test420RemoveExtensionProtectedStringValueInRepo() throws Exception { - final String TEST_NAME = "test420RemoveExtensionProtectedStringValueInRepo"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ProtectedStringType protectedValue = protector.encryptString("hi"); UserType jack = new UserType(prismContext) @@ -1501,11 +1404,8 @@ public void test420RemoveExtensionProtectedStringValueInRepo() throws Exception @Test // MID-5826 - fortunately, in 4.0 this works due to reworked handling of extension values in repo public void test450ReplaceExtensionItem() throws Exception { - final String TEST_NAME = "test400ReplaceExtensionItem"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("test400") @@ -1543,11 +1443,8 @@ private void assertExtensionDateValue(String objectOid, int expected) { @Test(enabled = false) // MID-5958 public void test500ReferenceTargetNameAdding() throws Exception { - final String TEST_NAME = "test500ReferenceTargetNameAdding"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PolyStringType parentName = new PolyStringType("Parent"); parentName.setNorm("Parent"); @@ -1583,11 +1480,8 @@ public void test500ReferenceTargetNameAdding() throws Exception { */ @Test public void test510ModifySystemConfiguration() throws Exception { - final String TEST_NAME = "test510ModifySystemConfiguration"; - TestUtil.displayTestTitle(TEST_NAME); - // GIVEN - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject before = prismContext.parseObject(SYSTEM_CONFIGURATION_BEFORE_FILE); repositoryService.addObject(before, null, result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java index 683b394c649..fdffc43c7db 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java @@ -15,7 +15,6 @@ import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.repo.api.RepoModifyOptions; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.hibernate.Session; @@ -48,9 +47,7 @@ protected RepoModifyOptions getModifyOptions() { @Test public void testReindexExtensionItem() throws Exception { - final String TEST_NAME = "testReindexExtensionItem"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) .name("unstable") @@ -77,12 +74,10 @@ public void testReindexExtensionItem() throws Exception { @Test // MID-5112 public void testReindexIndexOnlyItem() throws Exception { - final String TEST_NAME = "testReindexIndexOnlyItem"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); PrismObject user = prismContext.createObjectable(UserType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .asPrismObject(); ItemPath INDEX_ONLY_PATH = ItemPath.create(UserType.F_EXTENSION, "indexOnly"); PrismPropertyDefinition indexOnlyDef = user.getDefinition().findPropertyDefinition(INDEX_ONLY_PATH); @@ -113,14 +108,12 @@ public void testReindexIndexOnlyItem() throws Exception { @Test // MID-5112 public void testReindexPhoto() throws Exception { - final String TEST_NAME = "testReindex"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); byte[] PHOTO = new byte[] { 1, 2, 3, 4 }; PrismObject user = prismContext.createObjectable(UserType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .jpegPhoto(PHOTO) .asPrismObject(); @@ -137,14 +130,12 @@ public void testReindexPhoto() throws Exception { @Test // MID-5112 public void testReindexTaskResult() throws Exception { - final String TEST_NAME = "testReindexTaskResult"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); OperationResultType taskOperationResult = new OperationResultType().message("Hello there"); PrismObject task = prismContext.createObjectable(TaskType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .result(taskOperationResult) .asPrismObject(); @@ -161,15 +152,13 @@ public void testReindexTaskResult() throws Exception { @Test // MID-5112 public void testReindexLookupTableRow() throws Exception { - final String TEST_NAME = "testReindexLookupTableRow"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); LookupTableRowType row = new LookupTableRowType(prismContext) .key("key") .label("label"); PrismObject table = prismContext.createObjectable(LookupTableType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .row(row) .asPrismObject(); @@ -187,14 +176,12 @@ public void testReindexLookupTableRow() throws Exception { @Test // MID-5112 public void testReindexCertificationCampaignCase() throws Exception { - final String TEST_NAME = "testReindexCertificationCampaignCase"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); AccessCertificationCaseType aCase = new AccessCertificationCaseType(prismContext) .stageNumber(1); PrismObject campaign = prismContext.createObjectable(AccessCertificationCampaignType.class) - .name(TEST_NAME) + .name(getTestNameShort()) .stageNumber(1) ._case(aCase) .asPrismObject(); @@ -216,9 +203,7 @@ public void testReindexCertificationCampaignCase() throws Exception { */ @Test public void testReindexShadow() throws Exception { - final String TEST_NAME = "testReindexShadow"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); String APPROVER_OID = "9123090439201432"; PrismObject shadow = prismContext.createObjectable(ShadowType.class) diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java index 9324f2beb9f..a4e2d55862f 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java @@ -65,10 +65,7 @@ public void test010Add() throws Exception { @Test public void test020ModifyUser() throws Exception { - final String TEST_NAME = "test020ModifyUser"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -77,11 +74,11 @@ public void test020ModifyUser() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -92,10 +89,7 @@ public void test020ModifyUser() throws Exception { @Test public void test021ModifyUserNoEmpNum() throws Exception { - final String TEST_NAME = "test021ModifyUserNoEmpNum"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002a.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -104,11 +98,11 @@ public void test021ModifyUserNoEmpNum() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -119,10 +113,7 @@ public void test021ModifyUserNoEmpNum() throws Exception { @Test public void test022ModifyUserEmptyEmpNum() throws Exception { - final String TEST_NAME = "test022ModifyUserEmptyEmpNum"; - TestUtil.displayTestTitle(TEST_NAME); - - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createResult(); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002b.xml"), ObjectModificationType.COMPLEX_TYPE); @@ -131,11 +122,11 @@ public void test022ModifyUserEmptyEmpNum() throws Exception { delta.setOid(userOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java index b6e7efcadb2..0eed48ec6b6 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java @@ -556,9 +556,7 @@ public void test009modifyOrgStructRemoveUser() throws Exception { @Test public void test011OrgFilter() throws Exception { - final String TEST_NAME = "test011OrgFilter"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); ObjectQuery query = prismContext.queryFor(ObjectType.class) .isDirectChildOf(ORG_F001_OID) @@ -574,9 +572,7 @@ public void test011OrgFilter() throws Exception { @Test public void test100ParentOrgRefFilterNullRelation() throws Exception { - final String TEST_NAME = "test100ParentOrgRefFilterNullRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); ObjectQuery query = prismContext.queryFor(ObjectType.class) .item(ObjectType.F_PARENT_ORG_REF).ref(itemFactory().createReferenceValue(ORG_F001_OID)) @@ -591,9 +587,7 @@ public void test100ParentOrgRefFilterNullRelation() throws Exception { @Test public void test101ParentOrgRefFilterManagerRelation() throws Exception { - final String TEST_NAME = "test101ParentOrgRefFilterManagerRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); PrismReferenceValue refVal = itemFactory().createReferenceValue(ORG_F001_OID); refVal.setRelation(SchemaConstants.ORG_MANAGER); @@ -610,9 +604,7 @@ public void test101ParentOrgRefFilterManagerRelation() throws Exception { @Test public void test102ParentOrgRefFilterAnyRelation() throws Exception { - final String TEST_NAME = "test102ParentOrgRefFilterAnyRelation"; - TestUtil.displayTestTitle(TEST_NAME); - OperationResult opResult = new OperationResult(TEST_NAME); + OperationResult opResult = createResult(); PrismReferenceValue refVal = itemFactory().createReferenceValue(ORG_F001_OID); refVal.setRelation(PrismConstants.Q_ANY); diff --git a/repo/repo-test-util/pom.xml b/repo/repo-test-util/pom.xml index 421d5215b58..64bc9cc6b23 100644 --- a/repo/repo-test-util/pom.xml +++ b/repo/repo-test-util/pom.xml @@ -79,7 +79,6 @@ com.evolveum.midpoint.infra test-util - ${project.version} com.evolveum.midpoint.infra @@ -129,8 +128,8 @@ testng - org.springframework - spring-test + javax.annotation + javax.annotation-api com.evolveum.midpoint.tools diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java index 93287b23438..61c43773027 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractHigherUnitTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Random; import java.util.stream.Collectors; import javax.xml.bind.JAXBException; @@ -66,6 +65,7 @@ import com.evolveum.midpoint.schema.util.ResourceTypeUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugDumpable; @@ -74,8 +74,6 @@ import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; @@ -101,14 +99,11 @@ * * @author Radovan Semancik */ -public abstract class AbstractHigherUnitTest { +public abstract class AbstractHigherUnitTest extends AbstractUnitTest { public static final String COMMON_DIR_NAME = "common"; public static final File COMMON_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, COMMON_DIR_NAME); - private static final Trace LOGGER = TraceManager.getTrace(AbstractHigherUnitTest.class); - protected static final Random RND = new Random(); - @BeforeSuite public void setup() throws SchemaException, SAXException, IOException { PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); @@ -501,18 +496,6 @@ protected PrismObject parseObject(File file) throws Sc return getPrismContext().parseObject(file); } - protected void displayTestTitle(String testName) { - TestUtil.displayTestTitle(this, testName); - } - - protected void displayWhen(String testName) { - TestUtil.displayWhen(testName); - } - - protected void displayThen(String testName) { - TestUtil.displayThen(testName); - } - protected void displayCleanup(String testName) { TestUtil.displayCleanup(testName); } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index cdc7f42639e..06708a49342 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -6,15 +6,54 @@ */ package com.evolveum.midpoint.test; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.PredefinedTestMethodTracing.OFF; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.time.ZonedDateTime; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; +import org.apache.commons.lang.SystemUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.opends.server.types.Entry; +import org.opends.server.types.SearchResultEntry; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.crypto.password.LdapShaPasswordEncoder; +import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; +import org.springframework.test.context.web.ServletTestExecutionListener; +import org.testng.Assert; +import org.testng.AssertJUnit; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Listeners; +import org.w3c.dom.Element; + import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.common.Clock; import com.evolveum.midpoint.common.LocalizationService; @@ -31,7 +70,8 @@ import com.evolveum.midpoint.prism.delta.builder.S_ItemEntry; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; -import com.evolveum.midpoint.prism.path.*; +import com.evolveum.midpoint.prism.path.ItemName; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -51,9 +91,8 @@ import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.internals.InternalsConfig; -import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.processor.ObjectFactory; -import com.evolveum.midpoint.schema.result.CompiledTracingProfile; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; import com.evolveum.midpoint.schema.util.*; @@ -63,78 +102,29 @@ import com.evolveum.midpoint.test.asserter.AbstractAsserter; import com.evolveum.midpoint.test.asserter.ResourceAsserter; import com.evolveum.midpoint.test.asserter.ShadowAsserter; -import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.asserter.prism.PolyStringAsserter; import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter; import com.evolveum.midpoint.test.asserter.refinedschema.RefinedResourceSchemaAsserter; import com.evolveum.midpoint.test.ldap.OpenDJController; -import com.evolveum.midpoint.test.util.DerbyController; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.MultithreadRunner; -import com.evolveum.midpoint.test.util.ParallelTestThread; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.test.util.*; import com.evolveum.midpoint.tools.testng.CurrentTestResultHolder; +import com.evolveum.midpoint.tools.testng.MidpointTestContext; import com.evolveum.midpoint.util.*; 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.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; import com.evolveum.prism.xml.ns._public.types_3.RawType; -import org.apache.commons.lang.SystemUtils; -import org.jetbrains.annotations.NotNull; -import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.security.crypto.password.LdapShaPasswordEncoder; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Listeners; -import org.w3c.dom.Element; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.namespace.QName; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.lang.reflect.Method; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.time.ZonedDateTime; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static org.testng.AssertJUnit.assertNotNull; - /** * @author Radovan Semancik - * */ @Listeners({ CurrentTestResultHolder.class }) -public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContextTests { +public abstract class AbstractIntegrationTest extends AbstractSpringTest { protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; public static final String COMMON_DIR_NAME = "common"; - @Deprecated - public static final String COMMON_DIR_PATH = MidPointTestConstants.TEST_RESOURCES_PATH + "/" + COMMON_DIR_NAME; public static final File COMMON_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, COMMON_DIR_NAME); protected static final String DEFAULT_INTENT = "default"; @@ -142,34 +132,33 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected static final String OPENDJ_PEOPLE_SUFFIX = "ou=people,dc=example,dc=com"; protected static final String OPENDJ_GROUPS_SUFFIX = "ou=groups,dc=example,dc=com"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractIntegrationTest.class); - protected static final Random RND = new Random(); private static final float FLOAT_EPSILON = 0.001f; - protected static final String ATTR_TASK = "task"; - protected static final String ATTR_RESULT = "result"; - - private static final String UNKNOWN_METHOD = "unknownMethod"; - // Values used to check if something is unchanged or changed properly protected LdapShaPasswordEncoder ldapShaPasswordEncoder = new LdapShaPasswordEncoder(); - private Map lastCountMap = new HashMap<>(); + private Map lastCountMap = new HashMap<>(); private CachingStatistics lastResourceCacheStats; @Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService; - protected static Set initializedClasses = new HashSet<>(); + private long lastDummyResourceGroupMembersReadCount; private long lastDummyResourceWriteOperationCount; @Autowired protected Tracer tracer; + + /** + * Task manager can be used directly in subclasses but prefer various provided methods + * like {@link #getTestTask()}, {@link #createPlainTask}, etc. + */ @Autowired protected TaskManager taskManager; + @Autowired protected Protector protector; @Autowired protected Clock clock; @Autowired protected PrismContext prismContext; @@ -182,8 +171,7 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex protected SimpleObjectResolver repoSimpleObjectResolver; // Controllers for embedded OpenDJ and Derby. The abstract test will configure it, but - // it will not start - // only tests that need OpenDJ or derby should start it + // it will not start only tests that need OpenDJ or derby should start it protected static OpenDJController openDJController = new OpenDJController(); protected static DerbyController derbyController = new DerbyController(); @@ -193,93 +181,129 @@ public abstract class AbstractIntegrationTest extends AbstractTestNGSpringContex */ protected PredefinedTestMethodTracing predefinedTestMethodTracing; + private volatile boolean initSystemExecuted = false; + /** - * Enables automatic task and operation result management in test methods. + * With TestNG+Spring we can use {@code PostConstruct} for class-wide initialization. + * All test methods run on a single instance (unlike with JUnit). + * Using {@code BeforeClass} is not good as the Spring wiring happens later. + *

+ * There is still danger that annotation processor will run this multiple times + * for web/servlet-based tests, see text context attributes + * {@link DependencyInjectionTestExecutionListener#REINJECT_DEPENDENCIES_ATTRIBUTE} + * and {@link ServletTestExecutionListener#RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE} for more. + * That's why we start with the guard enforcing once-only initSystem execution. */ - protected boolean autoTaskManagementEnabled; - - // We need this complicated init as we want to initialize repo only once. - // JUnit will - // create new class instance for every test, so @Before and @PostInit will - // not work - // directly. We also need to init the repo after spring autowire is done, so - // @BeforeClass won't work either. - @BeforeMethod - public void initSystemConditional() throws Exception { + @PostConstruct + public void initSystem() throws Exception { + if (initSystemExecuted) { + logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName()); + return; + } + initSystemExecuted = true; + logger.trace("initSystem: initializing class {}", getClass().getName()); + // Check whether we are already initialized assertNotNull("Repository is not wired properly", repositoryService); assertNotNull("Task manager is not wired properly", taskManager); - LOGGER.trace("initSystemConditional: {} systemInitialized={}", this.getClass(), isSystemInitialized()); - if (!isSystemInitialized()) { - PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); - PrismTestUtil.setPrismContext(prismContext); - LOGGER.trace("initSystemConditional: invoking initSystem"); - Task initTask = taskManager.createTaskInstance(this.getClass().getName() + ".initSystem"); - initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); - OperationResult result = initTask.getResult(); - - InternalMonitor.reset(); - InternalsConfig.setPrismMonitoring(true); - prismContext.setMonitor(new InternalMonitor()); + PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX); + PrismTestUtil.setPrismContext(prismContext); + Task initTask = createPlainTask("INIT"); + initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI); + OperationResult result = initTask.getResult(); - ((LocalizationServiceImpl)localizationService).setOverrideLocale(Locale.US); + InternalMonitor.reset(); + InternalsConfig.setPrismMonitoring(true); + prismContext.setMonitor(new InternalMonitor()); - initSystem(initTask, result); + ((LocalizationServiceImpl) localizationService).setOverrideLocale(Locale.US); - postInitSystem(initTask, result); + initSystem(initTask, result); + postInitSystem(initTask, result); - result.computeStatus(); - IntegrationTestTools.display("initSystem result", result); - TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1); - - setSystemInitialized(); - } + result.computeStatus(); + IntegrationTestTools.display("initSystem result", result); + TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1); } - protected boolean isSystemInitialized() { - return initializedClasses.contains(this.getClass()); + @Override + @Nullable + public MidpointTestContext getTestContext() { + return MidpointTestContextWithTask.get(); } - private void setSystemInitialized() { - initializedClasses.add(this.getClass()); + /** + * Test class initialization. + */ + protected void initSystem(Task task, OperationResult initResult) throws Exception { + // nothing by default } - protected void unsetSystemInitialized() { - initializedClasses.remove(this.getClass()); + /** + * May be used to clean up initialized objects as all of the initialized objects should be + * available at this time. + */ + protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { + // Nothing to do by default } /** - * Creates appropriate task and result and set it into MidpointTestMethodContext. - * - * EXPERIMENTAL. + * Creates test method context which includes customized {@link Task} + * (see {@link #createTask(String)}) and other test related info wrapped as + * {@link MidpointTestContextWithTask} and stores it in thread-local variable for future access. + * This implementation fully overrides version from {@link AbstractSpringTest}. */ @BeforeMethod - public void setTaskAndResult(ITestContext ctx, Method testMethod) throws SchemaException { - if (!isAutoTaskManagementEnabled()) { - return; - } - - String testShortName = testMethod.getDeclaringClass().getSimpleName() + "." + testMethod.getName(); - String testFullName = testMethod.getDeclaringClass().getName() + "." + testMethod.getName(); - TestUtil.displayTestTitle(testShortName); - Task task = createTask(testFullName); - OperationResult rootResult = task.getResult(); - - TracingProfileType tracingProfile = getTestMethodTracingProfile(); - CompiledTracingProfile compiledTracingProfile = tracingProfile != null ? - tracer.compileProfile(tracingProfile, rootResult) : null; - OperationResult result = rootResult.subresult(testFullName + "Run") - .tracingProfile(compiledTracingProfile) - .build(); + public void startTestContext(ITestResult testResult) { + Class testClass = testResult.getMethod().getTestClass().getRealClass(); + String testMethodName = testResult.getMethod().getMethodName(); + + displayTestTitle(testClass.getSimpleName() + "." + testMethodName); + + Task task = createTask(testMethodName); + // TODO inttest do we need that subresult? :-) (Virgo's brave new world) + // If this exist for some "optional richer tracing", why not switch it on with some System property? + // maybe it doesn't break tests, but changes traceability/maintenance? +// OperationResult rootResult = task.getResult(); +// TracingProfileType tracingProfile = getTestMethodTracingProfile(); +// CompiledTracingProfile compiledTracingProfile = tracingProfile != null ? +// tracer.compileProfile(tracingProfile, rootResult) : null; +// OperationResult result = rootResult.subresult(task.getName() + "Run") +// .tracingProfile(compiledTracingProfile) +// .build(); // This is quite a hack. We need to provide traced result to all clients that need to access it via the task. // (I.e. not via the test context.) - task.setResult(result); +// task.setResult(result); + + MidpointTestContextWithTask.create(testClass, testMethodName, task, task.getResult()); + // TODO inttest: remove after fix in TracerImpl + TestNameHolder.setCurrentTestName(contextName()); + } + + /** + * Finish and destroy the test context, output duration and store the operation trace. + * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}. + */ + @AfterMethod + public void finishTestContext(ITestResult testResult) { + MidpointTestContextWithTask context = MidpointTestContextWithTask.get(); + MidpointTestContextWithTask.destroy(); // let's destroy it before anything else in this method - ctx.setAttribute(ATTR_TASK, task); - ctx.setAttribute(ATTR_RESULT, result); + displayDefaultTestFooter(context.getTestName(), testResult); - MidpointTestMethodContext.setup(testMethod.getName(), task, result); + Task task = context.getTask(); + if (task != null) { + OperationResult result = context.getResult(); + if (result != null) { + result.computeStatusIfUnknown(); + if (result.isTraced()) { + System.out.println("Storing the trace."); + tracer.storeTrace(task, result, null); + } + task.getResult().computeStatusIfUnknown(); + } + } } protected TracingProfileType getTestMethodTracingProfile() { @@ -288,31 +312,23 @@ protected TracingProfileType getTestMethodTracingProfile() { } else { TracingProfileType profile; switch (predefinedTestMethodTracing) { - case MODEL_LOGGING: profile = createModelLoggingTracingProfile(); break; - case MODEL_WORKFLOW_LOGGING: profile = createModelAndWorkflowLoggingTracingProfile(); break; - case MODEL_PROVISIONING_LOGGING: profile = createModelAndProvisioningLoggingTracingProfile(); break; - default: throw new AssertionError(predefinedTestMethodTracing.toString()); + case MODEL_LOGGING: + profile = createModelLoggingTracingProfile(); + break; + case MODEL_WORKFLOW_LOGGING: + profile = createModelAndWorkflowLoggingTracingProfile(); + break; + case MODEL_PROVISIONING_LOGGING: + profile = createModelAndProvisioningLoggingTracingProfile(); + break; + default: + throw new AssertionError(predefinedTestMethodTracing.toString()); } return profile .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); } } - /** - * @return Whether automatic task and operation result management is enabled. - * - * Please either override this method or set autoTaskManagementEnabled to true. - * - * This method is a temporary solution until all test methods will use this automatic task/result management. - */ - protected boolean isAutoTaskManagementEnabled() { - return autoTaskManagementEnabled; - } - - public void setAutoTaskManagementEnabled(boolean autoTaskManagementEnabled) { - this.autoTaskManagementEnabled = autoTaskManagementEnabled; - } - public PredefinedTestMethodTracing getPredefinedTestMethodTracing() { return predefinedTestMethodTracing; } @@ -322,130 +338,87 @@ public void setPredefinedTestMethodTracing(PredefinedTestMethodTracing predefine } /** - * Stores a trace of the operation result, if requested. + * Returns default pre-created test-method-scoped {@link Task}. */ - @AfterMethod - public void storeTraceIfRequested(ITestContext ctx, Method testMethod) { - if (!isAutoTaskManagementEnabled()) { - return; - } - - System.out.println("After method: " + testMethod.getName()); - Task task = getTask(ctx); - if (task != null) { - OperationResult result = getResult(ctx); - if (result != null) { - result.computeStatusIfUnknown(); - if (result.isTraced()) { - System.out.println("Storing the trace."); - tracer.storeTrace(task, result, null); - } - task.getResult().computeStatusIfUnknown(); - } - } - - // Beware of any other after methods. They might need this context. - MidpointTestMethodContext.destroy(); - } - - @Deprecated - protected OperationResult getResult(IAttributes attrs) { - return (OperationResult) attrs.getAttribute(ATTR_RESULT); + protected Task getTestTask() { + return MidpointTestContextWithTask.get().getTask(); } - @Deprecated - protected Task getTask(IAttributes attrs) { - return (Task) attrs.getAttribute(ATTR_TASK); + /** + * Creates new {@link Task} with operation name prefixed with {@link #contextName()}. + * For most tests this should be unnecessary and the default test-method-scoped task + * that can be obtained with {@link #getTestTask()} should be enough. + * Even for multi-threaded tests we may not need the whole task - instead + * {@link #createSubresult(String)} should suffice. + */ + protected Task createPlainTask(String operationName) { + String rootOpName = operationName != null + ? contextName() + "." + operationName + : contextName(); + return taskManager.createTaskInstance(rootOpName); } - protected String getTestNameShort() { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getMethodName(); - } else { - return createAdHocTestContext(UNKNOWN_METHOD).getMethodName(); - } + /** + * Creates new {@link Task} with {@link #contextName()} as root operation name. + */ + protected Task createPlainTask() { + return createPlainTask(null); } /** - * Retrieves the task from thread-local test method context; creating the ad-hoc context if it does not exist. - * - * We expect this method to be called on startup of auto-task-managed test methods, therefore "getTask" is more suitable - * name that "getOrCreateTestTask". + * Just like {@link #createPlainTask(String)} but also calls overridable {@link #customizeTask}. */ - protected Task getTask() { - return getOrCreateTestTask(UNKNOWN_METHOD); + protected Task createTask(String operationName) { + Task task = createPlainTask(operationName); + customizeTask(task); + return task; } /** - * Retrieves the task from thread-local test method context; creating the appropriately named ad-hoc context - * if it does not exist. - * - * We expect this method to be called from places where we really don't know if the context exists or not. Hence its name. + * Just like {@link #createPlainTask()} but also calls overridable {@link #customizeTask}. */ - protected Task getOrCreateTestTask(String methodName) { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getTask(); - } else { - return createAdHocTestContext(methodName).getTask(); - } + protected Task createTask() { + return createPlainTask(null); } /** - * Retrieves the task from thread-local test method context; creating the task (but NOT the context) if it does not exist. - * - * The difference to getTask/getOrCreateTestTask is that we use taskManager.createTaskInstance instead of test-specific - * createTask method. So the task created is a simple, plain one -- without all the be bells and whistles provided - * by createTask method. + * Subclasses may override this if test task needs additional customization. + * Each task used or created by the test is customized - this applies to default + * method-scoped task and also to any task created by {@link #createTask(String)}. */ - protected Task getOrCreateSimpleTask(String operationName) { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getTask(); - } else { - return taskManager.createTaskInstance(this.getClass().getName() + "." + operationName); - } + protected void customizeTask(Task task) { + // nothing by default } - protected OperationResult createSubresult(String methodName) { - String className = this.getClass().getName(); - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - OperationResult parent; - if (ctx != null) { - parent = ctx.getResult(); - } else { - parent = new OperationResult(className + ".parent"); - } - return parent.createSubresult(className + "." + methodName); + /** + * Creates new subresult for default pre-created test-method-scoped {@link Task}. + */ + protected OperationResult createSubresult(String subresultSuffix) { + return getTestOperationResult().createSubresult(getTestNameShort() + "." + subresultSuffix); } - protected OperationResult getResult() { - MidpointTestMethodContext ctx = MidpointTestMethodContext.get(); - if (ctx != null) { - return ctx.getResult(); - } else { - return createAdHocTestContext(UNKNOWN_METHOD).getResult(); - } + /** + * Creates new {@link OperationResult} with name equal to {@link #contextName()}. + */ + protected OperationResult createOperationalResult() { + return new OperationResult(contextName()); } - @NotNull - private MidpointTestMethodContext createAdHocTestContext(String methodName) { - LOGGER.warn("No test context for current thread: creating new"); - System.out.println("No test context for current thread: creating new"); - Task task = createTask(methodName); - return MidpointTestMethodContext.setup(methodName, task, task.getResult()); + /** + * Creates new {@link OperationResult} with name prefixed by {@link #contextName()}. + */ + protected OperationResult createOperationalResult(String nameSuffix) { + return new OperationResult(contextName() + "." + nameSuffix); } - abstract public void initSystem(Task initTask, OperationResult initResult) throws Exception; - /** - * May be used to clean up initialized objects as all of the initialized objects should be - * available at this time. + * Returns default {@link OperationResult} for pre-created test-method-scoped {@link Task}. + * This result can be freely used in test for some "main scope", it is not asserted in any + * after method, only displayed. */ - protected void postInitSystem(Task initTask, OperationResult initResult) throws Exception { - // Nothing to do by default - }; + protected OperationResult getTestOperationResult() { + return MidpointTestContextWithTask.get().getResult(); + } public S_ItemEntry deltaFor(Class objectClass) throws SchemaException { return prismContext.deltaFor(objectClass); @@ -466,36 +439,41 @@ protected PrismObject repoAdd(TestResource resource, O return repoAddObjectFromFile(resource.file, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, @SuppressWarnings("unused") Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + return repoAddObjectFromFile(file, false, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, Class type, - boolean metadata, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, @SuppressWarnings("unused") Class type, boolean metadata, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + return repoAddObjectFromFile(file, metadata, parentResult); } - protected PrismObject repoAddObjectFromFile(File file, - boolean metadata, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + protected PrismObject repoAddObjectFromFile( + File file, boolean metadata, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".repoAddObjectFromFile"); result.addParam("file", file.getPath()); - LOGGER.debug("addObjectFromFile: {}", file); + logger.debug("addObjectFromFile: {}", file); PrismObject object; try { object = prismContext.parseObject(file); } catch (SchemaException e) { - throw new SchemaException("Error parsing file "+file.getPath()+": "+e.getMessage(), e); + throw new SchemaException("Error parsing file " + file.getPath() + ": " + e.getMessage(), e); } if (metadata) { addBasicMetadata(object); } - LOGGER.trace("Adding object:\n{}", object.debugDump()); - repoAddObject(object, "from file "+file, result); + logger.trace("Adding object:\n{}", object.debugDump()); + repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; } @@ -506,11 +484,11 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".repoAddShadowFromFile"); result.addParam("file", file.getPath()); - LOGGER.debug("addShadowFromFile: {}", file); + logger.debug("addShadowFromFile: {}", file); PrismObject object = prismContext.parseObject(file); PrismContainer attrCont = object.findContainer(ShadowType.F_ATTRIBUTES); - for (PrismProperty attr: attrCont.getValue().getProperties()) { + for (PrismProperty attr : attrCont.getValue().getProperties()) { if (attr.getDefinition() == null) { ResourceAttributeDefinition attrDef = ObjectFactory.createResourceAttributeDefinition(attr.getElementName(), DOMUtil.XSD_STRING, prismContext); @@ -520,8 +498,8 @@ protected PrismObject repoAddShadowFromFile(File file, OperationResu addBasicMetadata(object); - LOGGER.trace("Adding object:\n{}", object.debugDump()); - repoAddObject(object, "from file "+file, result); + logger.trace("Adding object:\n{}", object.debugDump()); + repoAddObject(object, "from file " + file, result); result.recordSuccess(); return object; } @@ -533,64 +511,61 @@ protected void addBasicMetadata(PrismObject object) { object.asObjectable().setMetadata(metaData); } - protected void repoAddObject(PrismObject object, - OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException { + protected void repoAddObject( + PrismObject object, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException { repoAddObject(object, null, result); } - protected void repoAddObject(PrismObject object, String contextDesc, - OperationResult result) throws SchemaException, ObjectAlreadyExistsException, EncryptionException { + protected void repoAddObject( + PrismObject object, String contextDesc, OperationResult result) + throws SchemaException, ObjectAlreadyExistsException, EncryptionException { if (object.canRepresent(TaskType.class)) { Assert.assertNotNull(taskManager, "Task manager is not initialized"); try { taskManager.addTask((PrismObject) object, result); - } catch (ObjectAlreadyExistsException ex) { - result.recordFatalError(ex.getMessage(), ex); - throw ex; - } catch (SchemaException ex) { + } catch (ObjectAlreadyExistsException | SchemaException ex) { result.recordFatalError(ex.getMessage(), ex); throw ex; } } else { Assert.assertNotNull(repositoryService, "Repository service is not initialized"); - try{ + try { CryptoUtil.encryptValues(protector, object); String oid = repositoryService.addObject(object, null, result); object.setOid(oid); - } catch(ObjectAlreadyExistsException ex){ - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); - throw ex; - } catch(SchemaException ex){ - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); - throw ex; - } catch (EncryptionException ex) { - result.recordFatalError(ex.getMessage()+" while adding "+object+(contextDesc==null?"":" "+contextDesc), ex); + } catch (ObjectAlreadyExistsException | SchemaException | EncryptionException ex) { + result.recordFatalError(ex.getMessage() + " while adding " + object + (contextDesc == null ? "" : " " + contextDesc), ex); throw ex; } } } - protected List> repoAddObjectsFromFile(String filePath, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { + protected List> repoAddObjectsFromFile( + String filePath, Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + return repoAddObjectsFromFile(new File(filePath), type, parentResult); } - protected List> repoAddObjectsFromFile(File file, Class type, - OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { + protected List> repoAddObjectsFromFile( + File file, Class type, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); - LOGGER.trace("addObjectsFromFile: {}", file); + logger.trace("addObjectsFromFile: {}", file); List> objects = (List) prismContext.parserFor(file).parseObjects(); - for (PrismObject object: objects) { + for (PrismObject object : objects) { try { repoAddObject(object, result); } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new ObjectAlreadyExistsException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (SchemaException e) { - new SchemaException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new SchemaException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (EncryptionException e) { - new EncryptionException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new EncryptionException(e.getMessage() + " while adding " + object + " from file " + file, e); } } result.recordSuccess(); @@ -598,21 +573,23 @@ protected List> repoAddObjectsFromFile(Fil } // these objects can be of various types - protected List repoAddObjectsFromFile(File file, OperationResult parentResult) throws SchemaException, ObjectAlreadyExistsException, IOException { - OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName() - + ".addObjectsFromFile"); + protected List repoAddObjectsFromFile(File file, OperationResult parentResult) + throws SchemaException, ObjectAlreadyExistsException, IOException, EncryptionException { + + OperationResult result = parentResult.createSubresult( + AbstractIntegrationTest.class.getName() + ".addObjectsFromFile"); result.addParam("file", file.getPath()); - LOGGER.trace("addObjectsFromFile: {}", file); + logger.trace("addObjectsFromFile: {}", file); List objects = (List) prismContext.parserFor(file).parseObjects(); - for (PrismObject object: objects) { + for (PrismObject object : objects) { try { repoAddObject(object, result); } catch (ObjectAlreadyExistsException e) { - throw new ObjectAlreadyExistsException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new ObjectAlreadyExistsException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (SchemaException e) { - new SchemaException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new SchemaException(e.getMessage() + " while adding " + object + " from file " + file, e); } catch (EncryptionException e) { - new EncryptionException(e.getMessage()+" while adding "+object+" from file "+file, e); + throw new EncryptionException(e.getMessage() + " while adding " + object + " from file " + file, e); } } result.recordSuccess(); @@ -659,8 +636,8 @@ protected PrismObject addResourceFromFile(File file, String connec } protected PrismObject addResourceFromFile(File file, List connectorTypes, boolean overwrite, OperationResult result) - throws JAXBException, SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { - LOGGER.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); + throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException { + logger.trace("addObjectFromFile: {}, connector types {}", file, connectorTypes); PrismObject resource = prismContext.parseObject(file); return addResourceFromObject(resource, connectorTypes, overwrite, result); } @@ -675,13 +652,13 @@ protected PrismObject addResourceFromObject(PrismObject findConnectorByTypeAndVersion(String connec .build(); List> connectors = repositoryService.searchObjects(ConnectorType.class, query, null, result); if (connectors.size() != 1) { - throw new IllegalStateException("Cannot find connector type " + connectorType + ", version "+connectorVersion+", got " + throw new IllegalStateException("Cannot find connector type " + connectorType + ", version " + connectorVersion + ", got " + connectors); } return connectors.get(0); } - protected void fillInConnectorRef(PrismObject resource, String connectorType, OperationResult result) throws SchemaException { ResourceType resourceType = resource.asObjectable(); @@ -731,7 +707,7 @@ protected void fillInAdditionalConnectorRef(PrismObject resource, throws SchemaException { ResourceType resourceType = resource.asObjectable(); PrismObject connectorPrism = findConnectorByType(connectorType, result); - for (ConnectorInstanceSpecificationType additionalConnector: resourceType.getAdditionalConnector()) { + for (ConnectorInstanceSpecificationType additionalConnector : resourceType.getAdditionalConnector()) { if (connectorName.equals(additionalConnector.getName())) { ObjectReferenceType ref = new ObjectReferenceType().oid(connectorPrism.getOid()); additionalConnector.setConnectorRef(ref); @@ -748,8 +724,8 @@ protected void fillInAdditionalConnectorRef(PrismObject resource, additionalConnector.setConnectorRef(ref); } - protected SystemConfigurationType getSystemConfiguration() throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".getSystemConfiguration"); + protected SystemConfigurationType getSystemConfiguration() throws SchemaException { + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".getSystemConfiguration"); try { PrismObject sysConf = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result); result.computeStatus(); @@ -789,7 +765,7 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio if (current.size() != 1 || current.get(0).getConflictResolution().getAction() != action) { ObjectPolicyConfigurationType newPolicy = new ObjectPolicyConfigurationType(prismContext) .beginConflictResolution() - .action(action) + .action(action) .end(); itemDeltas.add(prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION) @@ -801,7 +777,7 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio ObjectPolicyConfigurationType newPolicyForTasks = new ObjectPolicyConfigurationType(prismContext) .type(TaskType.COMPLEX_TYPE) .beginConflictResolution() - .action(ACTION_FOR_TASKS) + .action(ACTION_FOR_TASKS) .end(); itemDeltas.add(prismContext.deltaFor(SystemConfigurationType.class) .item(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION) @@ -819,14 +795,14 @@ protected void assumeConflictResolutionAction(ConflictResolutionActionType actio } } - protected void assumeResourceAssigmentPolicy(String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException{ + protected void assumeResourceAssigmentPolicy(String resourceOid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); applySyncSettings(ResourceType.class, resourceOid, ResourceType.F_PROJECTION, syncSettings); } - protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException{ + protected void deleteResourceAssigmentPolicy(String oid, AssignmentPolicyEnforcementType policy, boolean legalize) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ProjectionPolicyType syncSettings = new ProjectionPolicyType(); syncSettings.setAssignmentPolicyEnforcement(policy); syncSettings.setLegalize(legalize); @@ -876,29 +852,29 @@ protected void invalidateSystemObjectsCache() { } protected void assertNoChanges(ObjectDelta delta) { - assertNull("Unexpected changes: "+ delta, delta); + assertNull("Unexpected changes: " + delta, delta); } protected void assertNoChanges(String desc, ObjectDelta delta) { - assertNull("Unexpected changes in "+desc+": "+ delta, delta); + assertNull("Unexpected changes in " + desc + ": " + delta, delta); } - protected void assertEffectiveActivation(PrismObject focus, ActivationStatusType expected) { + protected void assertEffectiveActivation(PrismObject focus, ActivationStatusType expected) { ActivationType activationType = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activationType); - assertEquals("Wrong effectiveStatus in activation in "+focus, expected, activationType.getEffectiveStatus()); + assertNotNull("No activation in " + focus, activationType); + assertEquals("Wrong effectiveStatus in activation in " + focus, expected, activationType.getEffectiveStatus()); } - protected void assertEffectiveActivation(AssignmentType assignmentType, ActivationStatusType expected) { + protected void assertEffectiveActivation(AssignmentType assignmentType, ActivationStatusType expected) { ActivationType activationType = assignmentType.getActivation(); - assertNotNull("No activation in "+assignmentType, activationType); - assertEquals("Wrong effectiveStatus in activation in "+assignmentType, expected, activationType.getEffectiveStatus()); + assertNotNull("No activation in " + assignmentType, activationType); + assertEquals("Wrong effectiveStatus in activation in " + assignmentType, expected, activationType.getEffectiveStatus()); } - protected void assertValidityStatus(PrismObject focus, TimeIntervalStatusType expected) { + protected void assertValidityStatus(PrismObject focus, TimeIntervalStatusType expected) { ActivationType activationType = focus.asObjectable().getActivation(); - assertNotNull("No activation in "+focus, activationType); - assertEquals("Wrong validityStatus in activation in "+focus, expected, activationType.getValidityStatus()); + assertNotNull("No activation in " + focus, activationType); + assertEquals("Wrong validityStatus in activation in " + focus, expected, activationType.getValidityStatus()); } /** @@ -935,10 +911,10 @@ protected void assertUser(PrismObject user, String oid, String name, S assertEquals("Wrong " + user + " OID (prism)", oid, user.getOid()); assertEquals("Wrong " + user + " OID (jaxb)", oid, userType.getOid()); } - PrismAsserts.assertEqualsPolyString("Wrong "+user+" name", name, userType.getName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" fullName", fullName, userType.getFullName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" givenName", givenName, userType.getGivenName()); - PrismAsserts.assertEqualsPolyString("Wrong "+user+" familyName", familyName, userType.getFamilyName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " name", name, userType.getName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " fullName", fullName, userType.getFullName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " givenName", givenName, userType.getGivenName()); + PrismAsserts.assertEqualsPolyString("Wrong " + user + " familyName", familyName, userType.getFamilyName()); if (location != null) { PrismAsserts.assertEqualsPolyString("Wrong " + user + " location", location, @@ -947,7 +923,7 @@ protected void assertUser(PrismObject user, String oid, String name, S } protected void assertSubtype(PrismObject object, String subtype) { - assertTrue("Object "+object+" does not have subtype "+subtype, FocusTypeUtil.hasSubtype(object, subtype)); + assertTrue("Object " + object + " does not have subtype " + subtype, FocusTypeUtil.hasSubtype(object, subtype)); } protected void assertShadowCommon(PrismObject accountShadow, String oid, String username, ResourceType resourceType, QName objectClass) throws SchemaException { @@ -959,8 +935,8 @@ protected void assertAccountShadowCommon(PrismObject accountShadow, } protected void assertAccountShadowCommon(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers) throws SchemaException { - assertShadowCommon(accountShadow,oid,username,resourceType,getAccountObjectClass(resourceType),nameMatchingRule, requireNormalizedIdentfiers); + MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers) throws SchemaException { + assertShadowCommon(accountShadow, oid, username, resourceType, getAccountObjectClass(resourceType), nameMatchingRule, requireNormalizedIdentfiers); } protected QName getAccountObjectClass(ResourceType resourceType) { @@ -977,7 +953,7 @@ protected void assertShadowCommon(PrismObject shadow, String oid, St } protected void assertShadowCommon(PrismObject shadow, String oid, String username, ResourceType resourceType, - QName objectClass, final MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException { + QName objectClass, final MatchingRule nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException { assertShadowSanity(shadow); if (oid != null) { assertEquals("Shadow OID mismatch (prism)", oid, shadow.getOid()); @@ -989,8 +965,8 @@ protected void assertShadowCommon(PrismObject shadow, String oid, St assertEquals("Shadow objectclass", objectClass, resourceObjectShadowType.getObjectClass()); assertEquals("Shadow resourceRef OID", resourceType.getOid(), shadow.asObjectable().getResourceRef().getOid()); PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("Null attributes in shadow for "+username, attributesContainer); - assertFalse("Empty attributes in shadow for "+username, attributesContainer.isEmpty()); + assertNotNull("Null attributes in shadow for " + username, attributesContainer); + assertFalse("Empty attributes in shadow for " + username, attributesContainer.isEmpty()); if (useMatchingRuleForShadowName) { MatchingRule polyMatchingRule = new MatchingRule() { @@ -1031,14 +1007,14 @@ public PolyString normalize(PolyString original) throws SchemaException { if (ocDef.getSecondaryIdentifiers().isEmpty()) { ResourceAttributeDefinition idDef = ocDef.getPrimaryIdentifiers().iterator().next(); PrismProperty idProp = attributesContainer.findProperty(idDef.getItemName()); - assertNotNull("No primary identifier ("+idDef.getItemName()+") attribute in shadow for "+username, idProp); + assertNotNull("No primary identifier (" + idDef.getItemName() + ") attribute in shadow for " + username, idProp); if (nameMatchingRule == null) { - assertEquals("Unexpected primary identifier in shadow for "+username, username, idProp.getRealValue()); + assertEquals("Unexpected primary identifier in shadow for " + username, username, idProp.getRealValue()); } else { if (requireNormalizedIdentfiers) { - assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule.normalize(username), idProp.getRealValue()); + assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue()); } else { - PrismAsserts.assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule, username, idProp.getRealValue()); + PrismAsserts.assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue()); } } } else { @@ -1048,10 +1024,10 @@ public PolyString normalize(PolyString original) throws SchemaException { expected = nameMatchingRule.normalize(username); } List wasValues = new ArrayList<>(); - for (ResourceAttributeDefinition idSecDef: ocDef.getSecondaryIdentifiers()) { + for (ResourceAttributeDefinition idSecDef : ocDef.getSecondaryIdentifiers()) { PrismProperty idProp = attributesContainer.findProperty(idSecDef.getItemName()); wasValues.addAll(idProp.getRealValues()); - assertNotNull("No secondary identifier ("+idSecDef.getItemName()+") attribute in shadow for "+username, idProp); + assertNotNull("No secondary identifier (" + idSecDef.getItemName() + ") attribute in shadow for " + username, idProp); if (nameMatchingRule == null) { if (username.equals(idProp.getRealValue())) { found = true; @@ -1070,7 +1046,7 @@ public PolyString normalize(PolyString original) throws SchemaException { } } if (!found) { - fail("Unexpected secondary identifier in shadow for "+username+", expected "+expected+" but was "+wasValues); + fail("Unexpected secondary identifier in shadow for " + username + ", expected " + expected + " but was " + wasValues); } } } @@ -1081,17 +1057,17 @@ protected void assertShadowSecondaryIdentifier(PrismObject shadow, S ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next(); PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); PrismProperty idProp = attributesContainer.findProperty(idSecDef.getItemName()); - assertNotNull("No secondary identifier ("+idSecDef.getItemName()+") attribute in shadow for "+expectedIdentifier, idProp); + assertNotNull("No secondary identifier (" + idSecDef.getItemName() + ") attribute in shadow for " + expectedIdentifier, idProp); if (nameMatchingRule == null) { - assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, expectedIdentifier, idProp.getRealValue()); + assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue()); } else { - PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for "+expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); + PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue()); } } protected void assertShadowName(PrismObject shadow, String expectedName) { - PrismAsserts.assertEqualsPolyString("Shadow name is wrong in "+shadow, expectedName, shadow.asObjectable().getName()); + PrismAsserts.assertEqualsPolyString("Shadow name is wrong in " + shadow, expectedName, shadow.asObjectable().getName()); } protected void assertShadowName(ShadowType shadowType, String expectedName) { @@ -1099,7 +1075,7 @@ protected void assertShadowName(ShadowType shadowType, String expectedName) { } protected void assertShadowRepo(String oid, String username, ResourceType resourceType, QName objectClass) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertShadowRepo"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertShadowRepo"); PrismObject shadow = repositoryService.getObject(ShadowType.class, oid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1107,11 +1083,11 @@ protected void assertShadowRepo(String oid, String username, ResourceType resour } protected void assertAccountShadowRepo(String oid, String username, ResourceType resourceType) throws ObjectNotFoundException, SchemaException { - assertShadowRepo(oid,username,resourceType,getAccountObjectClass(resourceType)); + assertShadowRepo(oid, username, resourceType, getAccountObjectClass(resourceType)); } protected void assertShadowRepo(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass) throws SchemaException { + QName objectClass) throws SchemaException { assertShadowRepo(accountShadow, oid, username, resourceType, objectClass, null); } @@ -1124,10 +1100,10 @@ protected void assertAccountShadowRepo(PrismObject accountShadow, St } protected void assertShadowRepo(PrismObject accountShadow, String oid, String username, ResourceType resourceType, - QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { + QName objectClass, MatchingRule nameMatchingRule) throws SchemaException { assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, true); PrismContainer attributesContainer = accountShadow.findContainer(ShadowType.F_ATTRIBUTES); - Collection> attributes = attributesContainer.getValue().getItems(); + Collection> attributes = attributesContainer.getValue().getItems(); // Collection secIdentifiers = ShadowUtil.getSecondaryIdentifiers(accountShadow); RefinedResourceSchema refinedSchema = null; try { @@ -1137,27 +1113,26 @@ protected void assertShadowRepo(PrismObject accountShadow, String oi } ObjectClassComplexTypeDefinition objClassDef = refinedSchema.getRefinedDefinition(objectClass); Collection secIdentifiers = objClassDef.getSecondaryIdentifiers(); - if (secIdentifiers == null){ + if (secIdentifiers == null) { AssertJUnit.fail("No secondary identifiers in repo shadow"); } // repo shadow should contains all secondary identifiers + ICF_UID - assertRepoShadowAttributes(attributes, secIdentifiers.size()+1); + assertRepoShadowAttributes(attributes, secIdentifiers.size() + 1); } - protected void assertRepoShadowAttributes(Collection> attributes, int expectedNumberOfIdentifiers) { + protected void assertRepoShadowAttributes(Collection> attributes, int expectedNumberOfIdentifiers) { assertEquals("Unexpected number of attributes in repo shadow", expectedNumberOfIdentifiers, attributes.size()); } protected String getIcfUid(PrismObject shadow) { PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("Null attributes in "+shadow, attributesContainer); - assertFalse("Empty attributes in "+shadow, attributesContainer.isEmpty()); + assertNotNull("Null attributes in " + shadow, attributesContainer); + assertFalse("Empty attributes in " + shadow, attributesContainer.isEmpty()); PrismProperty icfUidProp = attributesContainer.findProperty(new ItemName(SchemaConstants.NS_ICF_SCHEMA, "uid")); - assertNotNull("No ICF name attribute in "+shadow, icfUidProp); + assertNotNull("No ICF name attribute in " + shadow, icfUidProp); return icfUidProp.getRealValue(); } - protected void rememberCounter(InternalCounters counter) { lastCountMap.put(counter, InternalMonitor.getCount(counter)); } @@ -1178,21 +1153,21 @@ protected long getCounterIncrement(InternalCounters counter) { protected void assertCounterIncrement(InternalCounters counter, int expectedIncrement) { long currentCount = InternalMonitor.getCount(counter); long actualIncrement = currentCount - getLastCount(counter); - assertEquals("Unexpected increment in "+counter.getLabel(), (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + counter.getLabel(), (long) expectedIncrement, actualIncrement); lastCountMap.put(counter, currentCount); } protected void assertCounterIncrement(InternalCounters counter, int expectedIncrementMin, int expectedIncrementMax) { long currentCount = InternalMonitor.getCount(counter); long actualIncrement = currentCount - getLastCount(counter); - assertTrue("Unexpected increment in "+counter.getLabel()+". Expected " - +expectedIncrementMin+"-"+expectedIncrementMax+" but was "+actualIncrement, - actualIncrement >= expectedIncrementMin && actualIncrement <= expectedIncrementMax); + assertTrue("Unexpected increment in " + counter.getLabel() + ". Expected " + + expectedIncrementMin + "-" + expectedIncrementMax + " but was " + actualIncrement, + actualIncrement >= expectedIncrementMin && actualIncrement <= expectedIncrementMax); lastCountMap.put(counter, currentCount); } protected void rememberResourceCacheStats() { - lastResourceCacheStats = InternalMonitor.getResourceCacheStats().clone(); + lastResourceCacheStats = InternalMonitor.getResourceCacheStats().clone(); } protected void assertResourceCacheHitsIncrement(int expectedIncrement) { @@ -1205,13 +1180,13 @@ protected void assertResourceCacheMissesIncrement(int expectedIncrement) { protected void assertCacheHits(CachingStatistics lastStats, CachingStatistics currentStats, String desc, int expectedIncrement) { long actualIncrement = currentStats.getHits() - lastStats.getHits(); - assertEquals("Unexpected increment in "+desc+" hit count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + desc + " hit count", (long) expectedIncrement, actualIncrement); lastStats.setHits(currentStats.getHits()); } protected void assertCacheMisses(CachingStatistics lastStats, CachingStatistics currentStats, String desc, int expectedIncrement) { long actualIncrement = currentStats.getMisses() - lastStats.getMisses(); - assertEquals("Unexpected increment in "+desc+" miss count", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in " + desc + " miss count", (long) expectedIncrement, actualIncrement); lastStats.setMisses(currentStats.getMisses()); } @@ -1238,24 +1213,24 @@ protected void rememberSteadyResources() { } protected void rememberDummyResourceGroupMembersReadCount(String instanceName) { - lastDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); + lastDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); } protected void assertDummyResourceGroupMembersReadCountIncrement(String instanceName, int expectedIncrement) { long currentDummyResourceGroupMembersReadCount = DummyResource.getInstance(instanceName).getGroupMembersReadCount(); long actualIncrement = currentDummyResourceGroupMembersReadCount - lastDummyResourceGroupMembersReadCount; - assertEquals("Unexpected increment in group members read count in dummy resource '"+instanceName+"'", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in group members read count in dummy resource '" + instanceName + "'", (long) expectedIncrement, actualIncrement); lastDummyResourceGroupMembersReadCount = currentDummyResourceGroupMembersReadCount; } protected void rememberDummyResourceWriteOperationCount(String instanceName) { - lastDummyResourceWriteOperationCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); + lastDummyResourceWriteOperationCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); } protected void assertDummyResourceWriteOperationCountIncrement(String instanceName, int expectedIncrement) { long currentCount = DummyResource.getInstance(instanceName).getWriteOperationCount(); long actualIncrement = currentCount - lastDummyResourceWriteOperationCount; - assertEquals("Unexpected increment in write operation count in dummy resource '"+instanceName+"'", (long)expectedIncrement, actualIncrement); + assertEquals("Unexpected increment in write operation count in dummy resource '" + instanceName + "'", (long) expectedIncrement, actualIncrement); lastDummyResourceWriteOperationCount = currentCount; } @@ -1282,13 +1257,13 @@ protected PrismObject createShadow(PrismObject resourc shadowType.setObjectClass(objectClassDefinition.getTypeName()); ResourceAttributeContainer attrContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); if (uid != null) { - RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"uid")); + RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "uid")); ResourceAttribute uidAttr = uidAttrDef.instantiate(); uidAttr.setRealValue(uid); attrContainer.add(uidAttr); } if (name != null) { - RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"name")); + RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "name")); ResourceAttribute nameAttr = nameAttrDef.instantiate(); nameAttr.setRealValue(name); attrContainer.add(nameAttr); @@ -1302,19 +1277,19 @@ protected PrismObject findAccountShadowByUsername(String username, P if (accounts.isEmpty()) { return null; } - assert accounts.size() == 1 : "Too many accounts found for username "+username+" on "+resource+": "+accounts; + assert accounts.size() == 1 : "Too many accounts found for username " + username + " on " + resource + ": " + accounts; return accounts.iterator().next(); } protected PrismObject findShadowByName(ShadowKindType kind, String intent, String name, PrismObject resource, OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); - RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind,intent); + RefinedObjectClassDefinition rOcDef = rSchema.getRefinedDefinition(kind, intent); ObjectQuery query = createShadowQuerySecondaryIdentifier(rOcDef, name, resource); List> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); if (shadows.isEmpty()) { return null; } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; return shadows.iterator().next(); } @@ -1326,7 +1301,7 @@ protected PrismObject findShadowByName(QName objectClass, String nam if (shadows.isEmpty()) { return null; } - assert shadows.size() == 1 : "Too many shadows found for name "+name+" on "+resource+": "+shadows; + assert shadows.size() == 1 : "Too many shadows found for name " + name + " on " + resource + ": " + shadows; return shadows.iterator().next(); } @@ -1334,7 +1309,7 @@ protected ObjectQuery createAccountShadowQuery(String identifier, PrismObject identifierDefs = rAccount.getPrimaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); //TODO: set matching rule instead of null return prismContext.queryFor(ShadowType.class) @@ -1352,7 +1327,7 @@ protected ObjectQuery createAccountShadowQuerySecondaryIdentifier(String identif protected ObjectQuery createShadowQuerySecondaryIdentifier(ObjectClassComplexTypeDefinition rAccount, String identifier, PrismObject resource) throws SchemaException { Collection identifierDefs = rAccount.getSecondaryIdentifiers(); - assert identifierDefs.size() == 1 : "Unexpected identifier set in "+resource+" refined schema: "+identifierDefs; + assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs; ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next(); //TODO: set matching rule instead of null return prismContext.queryFor(ShadowType.class) @@ -1401,9 +1376,9 @@ protected PrismObjectDefinition getShadowDefinition() { // objectClassName may be null protected RefinedAttributeDefinition getAttributeDefinition(ResourceType resourceType, - ShadowKindType kind, - QName objectClassName, - String attributeLocalName) throws SchemaException { + ShadowKindType kind, + QName objectClassName, + String attributeLocalName) throws SchemaException { RefinedResourceSchema refinedResourceSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); RefinedObjectClassDefinition refinedObjectClassDefinition = refinedResourceSchema.findRefinedDefinitionByObjectClassQName(kind, objectClassName); @@ -1412,34 +1387,34 @@ protected RefinedAttributeDefinition getAttributeDefinition(ResourceType resourc protected void assertPassword(ShadowType shadow, String expectedPassword) throws SchemaException, EncryptionException { CredentialsType credentials = shadow.getCredentials(); - assertNotNull("No credentials in "+shadow, credentials); + assertNotNull("No credentials in " + shadow, credentials); PasswordType password = credentials.getPassword(); - assertNotNull("No password in "+shadow, password); + assertNotNull("No password in " + shadow, password); ProtectedStringType passwordValue = password.getValue(); - assertNotNull("No password value in "+shadow, passwordValue); + assertNotNull("No password value in " + shadow, passwordValue); protector.decrypt(passwordValue); - assertEquals("Wrong password in "+shadow, expectedPassword, passwordValue.getClearValue()); + assertEquals("Wrong password in " + shadow, expectedPassword, passwordValue.getClearValue()); } protected void assertPasswordDelta(ObjectDelta shadowDelta) { ItemDelta passwordDelta = shadowDelta.findItemDelta(SchemaConstants.PATH_PASSWORD_VALUE); - assertNotNull("No password delta in "+shadowDelta, passwordDelta); + assertNotNull("No password delta in " + shadowDelta, passwordDelta); } protected void assertFilter(ObjectFilter filter, Class expectedClass) { if (expectedClass == null) { - assertNull("Expected that filter is null, but it was "+filter, filter); + assertNull("Expected that filter is null, but it was " + filter, filter); } else { - assertNotNull("Expected that filter is of class "+expectedClass.getName()+", but it was null", filter); + assertNotNull("Expected that filter is of class " + expectedClass.getName() + ", but it was null", filter); if (!(expectedClass.isAssignableFrom(filter.getClass()))) { - AssertJUnit.fail("Expected that filter is of class "+expectedClass.getName()+", but it was "+filter); + AssertJUnit.fail("Expected that filter is of class " + expectedClass.getName() + ", but it was " + filter); } } } protected void assertSyncToken(String syncTaskOid, Object expectedValue) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); assertSyncToken(task, expectedValue, result); result.computeStatus(); @@ -1458,8 +1433,8 @@ protected void assertSyncToken(Task task, Object expectedValue, OperationResult } Object syncTokenPropertyValue = syncTokenProperty.getAnyRealValue(); if (!MiscUtil.equals(expectedValue, syncTokenPropertyValue)) { - AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue==null?"":(", "+expectedValue.getClass().getName())) + - ", was: "+ syncTokenPropertyValue + (syncTokenPropertyValue==null?"":(", "+syncTokenPropertyValue.getClass().getName()))); + AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue == null ? "" : (", " + expectedValue.getClass().getName())) + + ", was: " + syncTokenPropertyValue + (syncTokenPropertyValue == null ? "" : (", " + syncTokenPropertyValue.getClass().getName()))); } } @@ -1486,15 +1461,15 @@ protected void assertShadows(int expected, OperationResult result) throws Schema } protected void assertShadowDead(PrismObject shadow) { - assertEquals("Shadow not dead: "+shadow, Boolean.TRUE, shadow.asObjectable().isDead()); + assertEquals("Shadow not dead: " + shadow, Boolean.TRUE, shadow.asObjectable().isDead()); } protected void assertShadowNotDead(PrismObject shadow) { - assertTrue("Shadow not dead, but should not be: "+shadow, shadow.asObjectable().isDead() == null || Boolean.FALSE.equals(shadow.asObjectable().isDead())); + assertTrue("Shadow not dead, but should not be: " + shadow, shadow.asObjectable().isDead() == null || Boolean.FALSE.equals(shadow.asObjectable().isDead())); } protected void assertShadowExists(PrismObject shadow, Boolean expectedValue) { - assertEquals("Wrong shadow 'exists': "+shadow, expectedValue, shadow.asObjectable().isExists()); + assertEquals("Wrong shadow 'exists': " + shadow, expectedValue, shadow.asObjectable().isExists()); } protected void assertActivationAdministrativeStatus(PrismObject shadow, ActivationStatusType expectedStatus) { @@ -1503,10 +1478,10 @@ protected void assertActivationAdministrativeStatus(PrismObject shad if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected activation administrative status of "+shadow+" to be "+expectedStatus+", but there was no activation administrative status"); + AssertJUnit.fail("Expected activation administrative status of " + shadow + " to be " + expectedStatus + ", but there was no activation administrative status"); } } else { - assertEquals("Wrong activation administrative status of "+shadow, expectedStatus, activationType.getAdministrativeStatus()); + assertEquals("Wrong activation administrative status of " + shadow, expectedStatus, activationType.getAdministrativeStatus()); } } @@ -1516,10 +1491,10 @@ protected void assertShadowLockout(PrismObject shadow, LockoutStatus if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected lockout status of "+shadow+" to be "+expectedStatus+", but there was no lockout status"); + AssertJUnit.fail("Expected lockout status of " + shadow + " to be " + expectedStatus + ", but there was no lockout status"); } } else { - assertEquals("Wrong lockout status of "+shadow, expectedStatus, activationType.getLockoutStatus()); + assertEquals("Wrong lockout status of " + shadow, expectedStatus, activationType.getLockoutStatus()); } } @@ -1529,10 +1504,10 @@ protected void assertUserLockout(PrismObject user, LockoutStatusType e if (expectedStatus == null) { return; } else { - AssertJUnit.fail("Expected lockout status of "+user+" to be "+expectedStatus+", but there was no lockout status"); + AssertJUnit.fail("Expected lockout status of " + user + " to be " + expectedStatus + ", but there was no lockout status"); } } else { - assertEquals("Wrong lockout status of "+user, expectedStatus, activationType.getLockoutStatus()); + assertEquals("Wrong lockout status of " + user, expectedStatus, activationType.getLockoutStatus()); } } @@ -1552,12 +1527,12 @@ protected ItemPath getExtensionPath(QName propName) { protected void assertNumberOfAttributes(PrismObject shadow, Integer expectedNumberOfAttributes) { PrismContainer attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); - Collection> attributes = attributesContainer.getValue().getItems(); + assertNotNull("No attributes in repo shadow " + shadow, attributesContainer); + Collection> attributes = attributesContainer.getValue().getItems(); - assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); + assertFalse("Empty attributes in repo shadow " + shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { - assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); + assertEquals("Unexpected number of attributes in repo shadow " + shadow, (int) expectedNumberOfAttributes, attributes.size()); } } @@ -1594,7 +1569,7 @@ protected CredentialsStorageTypeType getPasswordHistoryStorageType() { } protected void assertEncryptedUserPassword(String userOid, String expectedClearPassword) throws EncryptionException, ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertEncryptedUserPassword"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertEncryptedUserPassword"); PrismObject user = repositoryService.getObject(UserType.class, userOid, null, result); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1612,21 +1587,21 @@ protected PasswordType assertUserPassword(PrismObject user, String exp protected PasswordType assertUserPassword(PrismObject user, String expectedClearPassword, CredentialsStorageTypeType storageType) throws EncryptionException, SchemaException { UserType userType = user.asObjectable(); CredentialsType creds = userType.getCredentials(); - assertNotNull("No credentials in "+user, creds); + assertNotNull("No credentials in " + user, creds); PasswordType password = creds.getPassword(); - assertNotNull("No password in "+user, password); + assertNotNull("No password in " + user, password); ProtectedStringType protectedActualPassword = password.getValue(); - assertProtectedString("Password for "+user, expectedClearPassword, protectedActualPassword, storageType); + assertProtectedString("Password for " + user, expectedClearPassword, protectedActualPassword, storageType); return password; } - protected void assertUserNoPassword(PrismObject user) throws EncryptionException, SchemaException { + protected void assertUserNoPassword(PrismObject user) { UserType userType = user.asObjectable(); CredentialsType creds = userType.getCredentials(); if (creds != null) { PasswordType password = creds.getPassword(); if (password != null) { - assertNull("Unexpected password value in "+user, password.getValue()); + assertNull("Unexpected password value in " + user, password.getValue()); } } } @@ -1663,16 +1638,16 @@ protected boolean compareProtectedString(String expectedClearValue, ProtectedStr return protector.compareCleartext(actualValue, expectedPs); default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } protected void assertPasswordHistoryEntries(PrismObject focus, String... changedPasswords) { CredentialsType credentials = focus.asObjectable().getCredentials(); - assertNotNull("Null credentials in "+focus, credentials); + assertNotNull("Null credentials in " + focus, credentials); PasswordType passwordType = credentials.getPassword(); - assertNotNull("Null passwordType in "+focus, passwordType); + assertNotNull("Null passwordType in " + focus, passwordType); assertPasswordHistoryEntries(focus.toString(), passwordType.getHistoryEntry(), getPasswordHistoryStorageType(), changedPasswords); } @@ -1694,8 +1669,8 @@ protected void assertPasswordHistoryEntries(String message, List historyEntriesType) { return historyEntriesType.stream() - .map(historyEntry -> { - try { - return getHumanReadablePassword(historyEntry.getValue()); - } catch (EncryptionException e) { - throw new SystemException(e.getMessage(), e); - } - }) - .collect(Collectors.joining(", ")); + .map(historyEntry -> { + try { + return getHumanReadablePassword(historyEntry.getValue()); + } catch (EncryptionException e) { + throw new SystemException(e.getMessage(), e); + } + }) + .collect(Collectors.joining(", ")); } protected String getHumanReadablePassword(ProtectedStringType ps) throws EncryptionException { @@ -1738,29 +1713,29 @@ protected String getHumanReadablePassword(ProtectedStringType ps) throws Encrypt return null; } if (ps.isEncrypted()) { - return "[E:"+protector.decryptString(ps)+"]"; + return "[E:" + protector.decryptString(ps) + "]"; } if (ps.isHashed()) { - return "[H:"+ps.getHashedDataType().getDigestValue().length*8+"bit]"; + return "[H:" + ps.getHashedDataType().getDigestValue().length * 8 + "bit]"; } return ps.getClearValue(); } protected void logTrustManagers() throws NoSuchAlgorithmException, KeyStoreException { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init((KeyStore)null); + trustManagerFactory.init((KeyStore) null); for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { - X509TrustManager x509TrustManager = (X509TrustManager)trustManager; - LOGGER.debug("TrustManager(X509): {}", x509TrustManager); + X509TrustManager x509TrustManager = (X509TrustManager) trustManager; + logger.debug("TrustManager(X509): {}", x509TrustManager); X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers(); if (acceptedIssuers != null) { - for (X509Certificate acceptedIssuer: acceptedIssuers) { - LOGGER.debug(" acceptedIssuer: {}", acceptedIssuer); + for (X509Certificate acceptedIssuer : acceptedIssuers) { + logger.debug(" acceptedIssuer: {}", acceptedIssuer); } } } else { - LOGGER.debug("TrustManager: {}", trustManager); + logger.debug("TrustManager: {}", trustManager); } } } @@ -1784,13 +1759,13 @@ protected void setPassword(PrismObject user, String password) { protected void assertIncompleteShadowPassword(PrismObject shadow) { PrismProperty passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); - assertNotNull("No password value property in "+shadow, passValProp); - assertTrue("Password value property does not have 'incomplete' flag in "+shadow, passValProp.isIncomplete()); + assertNotNull("No password value property in " + shadow, passValProp); + assertTrue("Password value property does not have 'incomplete' flag in " + shadow, passValProp.isIncomplete()); } protected void assertNoShadowPassword(PrismObject shadow) { PrismProperty passValProp = shadow.findProperty(SchemaConstants.PATH_PASSWORD_VALUE); - assertNull("Unexpected password value property in "+shadow+": "+passValProp, passValProp); + assertNull("Unexpected password value property in " + shadow + ": " + passValProp, passValProp); } protected PrismObject instantiateObject(Class type) throws SchemaException { @@ -1828,12 +1803,12 @@ protected void assertMetadata(String message, MetadataType metadataType, boolean protected void assertShadowPasswordMetadata(PrismObject shadow, boolean passwordCreated, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal, String actorOid, String channel) { CredentialsType creds = shadow.asObjectable().getCredentials(); - assertNotNull("No credentials in shadow "+shadow, creds); + assertNotNull("No credentials in shadow " + shadow, creds); PasswordType password = creds.getPassword(); - assertNotNull("No password in shadow "+shadow, password); + assertNotNull("No password in shadow " + shadow, password); MetadataType metadata = password.getMetadata(); - assertNotNull("No metadata in shadow "+shadow, metadata); - assertMetadata("Password metadata in "+shadow, metadata, passwordCreated, false, startCal, endCal, actorOid, channel); + assertNotNull("No metadata in shadow " + shadow, metadata); + assertMetadata("Password metadata in " + shadow, metadata, passwordCreated, false, startCal, endCal, actorOid, channel); } protected void assertLastProvisioningTimestamp( @@ -1849,34 +1824,6 @@ protected PrismObject parseObject(File file) throws Sc return prismContext.parseObject(file); } - protected void displayTestTitle(String testName) { - TestUtil.displayTestTitle(this, testName); - } - - protected void displayWhen() { - displayWhen(getTestNameShort()); - } - - protected void displayWhen(String testName) { - TestUtil.displayWhen(testName); - } - - protected void displayWhen(String testName, String stage) { - TestUtil.displayWhen(testName + " ("+stage+")"); - } - - protected void displayThen() { - displayThen(getTestNameShort()); - } - - protected void displayThen(String testName) { - TestUtil.displayThen(testName); - } - - protected void displayThen(String testName, String stage) { - TestUtil.displayThen(testName + " ("+stage+")"); - } - protected void displayCleanup(String testName) { TestUtil.displayCleanup(testName); } @@ -1889,6 +1836,7 @@ protected void displaySkip(String testName) { * Used to display string HEREHERE both in test output and in logfiles. This can be used * to conveniently correlate a place in the test, output and logfiles. */ + @SuppressWarnings("unused") protected void displayHEREHERE() { IntegrationTestTools.display("HEREHERE"); } @@ -1913,7 +1861,7 @@ public static void display(String message, ObjectType o) { IntegrationTestTools.display(message, o); } - public static void display(String message, Collection collection) { + public static void display(String message, Collection collection) { IntegrationTestTools.display(message, collection); } @@ -1961,6 +1909,10 @@ public static void display(String title, Throwable e) { IntegrationTestTools.display(title, e); } + public static void displayExpectedException(Throwable e) { + IntegrationTestTools.displayExpectedException(e); + } + public static void displayPrismValuesCollection(String message, Collection collection) { IntegrationTestTools.displayPrismValuesCollection(message, collection); } @@ -1988,7 +1940,7 @@ protected void assertBetween(String message, Long start, Long end, } protected void assertFloat(String message, Integer expectedIntPercentage, Float actualPercentage) { - assertFloat(message, expectedIntPercentage==null?null:new Float(expectedIntPercentage), actualPercentage); + assertFloat(message, expectedIntPercentage == null ? null : new Float(expectedIntPercentage), actualPercentage); } protected void assertFloat(String message, Float expectedPercentage, Float actualPercentage) { @@ -1996,23 +1948,15 @@ protected void assertFloat(String message, Float expectedPercentage, Float actua if (actualPercentage == null) { return; } else { - fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); + fail(message + ", expected: " + expectedPercentage + ", but was " + actualPercentage); } } - if (actualPercentage > expectedPercentage + FLOAT_EPSILON || actualPercentage < expectedPercentage - FLOAT_EPSILON) { - fail(message + ", expected: " + expectedPercentage + ", but was "+actualPercentage); + //noinspection ConstantConditions + if (actualPercentage > expectedPercentage + FLOAT_EPSILON || (actualPercentage < (expectedPercentage - FLOAT_EPSILON))) { + fail(message + ", expected: " + expectedPercentage + ", but was " + actualPercentage); } } - protected Task createTask(String operationName) { - if (!operationName.contains(".")) { - operationName = this.getClass().getName() + "." + operationName; - } - Task task = taskManager.createTaskInstance(operationName); -// setModelAndProvisioningLoggingTracing(task); - return task; - } - protected void setDefaultTracing(Task task) { setTracing(task, createDefaultTracingProfile()); } @@ -2045,18 +1989,18 @@ protected void setTracing(Task task, TracingProfileType profile) { protected TracingProfileType createModelLoggingTracingProfile() { return createDefaultTracingProfile() .beginLoggingOverride() - .beginLevelOverride() - .logger("com.evolveum.midpoint.model") - .level(LoggingLevelType.TRACE) - .end() + .beginLevelOverride() + .logger("com.evolveum.midpoint.model") + .level(LoggingLevelType.TRACE) + .end() .end(); } protected TracingProfileType addWorkflowLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.wf") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.wf") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -2064,8 +2008,8 @@ protected TracingProfileType addWorkflowLogging(TracingProfileType profile) { protected TracingProfileType addNotificationsLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.notifications") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.notifications") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -2081,8 +2025,8 @@ protected TracingProfileType createModelAndProvisioningLoggingTracingProfile() { protected TracingProfileType addProvisioningLogging(TracingProfileType profile) { return profile.getLoggingOverride() .beginLevelOverride() - .logger("com.evolveum.midpoint.provisioning") - .level(LoggingLevelType.TRACE) + .logger("com.evolveum.midpoint.provisioning") + .level(LoggingLevelType.TRACE) .end() .end(); } @@ -2090,14 +2034,14 @@ protected TracingProfileType addProvisioningLogging(TracingProfileType profile) protected TracingProfileType createHibernateLoggingTracingProfile() { return createDefaultTracingProfile() .beginLoggingOverride() - .beginLevelOverride() - .logger("org.hibernate.SQL") - .level(LoggingLevelType.TRACE) - .end() - .beginLevelOverride() - .logger("org.hibernate.type") - .level(LoggingLevelType.TRACE) - .end() + .beginLevelOverride() + .logger("org.hibernate.SQL") + .level(LoggingLevelType.TRACE) + .end() + .beginLevelOverride() + .logger("org.hibernate.type") + .level(LoggingLevelType.TRACE) + .end() .end(); } @@ -2105,7 +2049,7 @@ protected TracingProfileType createDefaultTracingProfile() { return new TracingProfileType() .collectLogEntries(true) .beginTracingTypeProfile() - .level(TracingLevelType.NORMAL) + .level(TracingLevelType.NORMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN); } @@ -2113,7 +2057,7 @@ protected TracingProfileType createDefaultTracingProfile() { protected TracingProfileType createPerformanceTracingProfile() { return new TracingProfileType() .beginTracingTypeProfile() - .level(TracingLevelType.MINIMAL) + .level(TracingLevelType.MINIMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN); } @@ -2124,18 +2068,8 @@ protected Task createTracedTask(String operationName) { task.setTracingProfile(new TracingProfileType() .collectLogEntries(true) .createRepoObject(false) // to avoid influencing repo statistics -// .beginLoggingOverride() -// .beginLevelOverride() -// .logger("org.hibernate.SQL") -// .level(LoggingLevelType.TRACE) -// .end() -// .beginLevelOverride() -// .logger("org.hibernate.type") -// .level(LoggingLevelType.TRACE) -// .end() -// .end() .beginTracingTypeProfile() - .level(TracingLevelType.NORMAL) + .level(TracingLevelType.NORMAL) .end() .fileNamePattern(DEFAULT_TRACING_FILENAME_PATTERN)); return task; @@ -2189,7 +2123,7 @@ protected String assertInProgress(OperationResult result) { } if (!OperationResultStatus.IN_PROGRESS.equals(result.getStatus())) { String message = "Expected operation " + result.getOperation() + " status IN_PROGRESS, but result status was " + result.getStatus(); - display (message, result); + display(message, result); fail(message); } return result.getAsynchronousOperationReference(); @@ -2235,7 +2169,7 @@ protected void assertTestResourceNotApplicable(OperationResult testResult, Conne protected void assertAttribute(ShadowType shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected void assertAttribute(ResourceType resourceType, ShadowType shadowType, String attrName, @@ -2252,7 +2186,7 @@ protected void assertAttribute(PrismObject resource, ShadowTyp protected void assertAttribute(PrismObject resource, ShadowType shadow, MatchingRule matchingRule, QName attrQname, T... expectedValues) throws SchemaException { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, matchingRule, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, matchingRule, actualValues, expectedValues); } protected void assertNoAttribute(ShadowType shadow, QName attrQname) { @@ -2261,7 +2195,7 @@ protected void assertNoAttribute(ShadowType shadow, QName attrQname) { return; } PrismProperty attribute = attributesContainer.findProperty(ItemName.fromQName(attrQname)); - assertNull("Unexpected attribute "+attrQname+" in "+shadow+": "+attribute, attribute); + assertNull("Unexpected attribute " + attrQname + " in " + shadow + ": " + attribute, attribute); } protected void assertNoAttribute(PrismObject resource, ShadowType shadow, String attrName) { @@ -2271,7 +2205,7 @@ protected void assertNoAttribute(PrismObject resource, ShadowType protected void assertNoPendingOperation(PrismObject shadow) { List pendingOperations = shadow.asObjectable().getPendingOperation(); - assertEquals("Wrong number of pending operations in "+shadow, 0, pendingOperations.size()); + assertEquals("Wrong number of pending operations in " + shadow, 0, pendingOperations.size()); } protected void assertCaseState(String oid, String expectedState) throws ObjectNotFoundException, SchemaException { @@ -2318,10 +2252,10 @@ protected void addAccountLinkRef(PrismObject user, File accountFile) t user.asObjectable().getLinkRef().add(linkRef); } - protected void assertLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { + protected void assertLinks(PrismObject focus, int expectedNumLinks) { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); if (linkRef == null) { - assert expectedNumLinks == 0 : "Expected "+expectedNumLinks+" but "+focus+" has no linkRef"; + assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no linkRef"; return; } assertEquals("Wrong number of links in " + focus, expectedNumLinks, linkRef.size()); @@ -2341,11 +2275,11 @@ protected void assertLinked(PrismObject focus, PrismObj assertLinked(focus, projection.getOid()); } - protected void assertLinked(PrismObject focus, String projectionOid) throws ObjectNotFoundException, SchemaException { + protected void assertLinked(PrismObject focus, String projectionOid) { PrismReference linkRef = focus.findReference(FocusType.F_LINK_REF); - assertNotNull("No linkRefs in "+focus, linkRef); + assertNotNull("No linkRefs in " + focus, linkRef); boolean found = false; - for (PrismReferenceValue val: linkRef.getValues()) { + for (PrismReferenceValue val : linkRef.getValues()) { if (val.getOid().equals(projectionOid)) { found = true; } @@ -2363,13 +2297,13 @@ protected void assertNotLinked(PrismObject user, PrismO assertNotLinked(user, account.getOid()); } - protected void assertNotLinked(PrismObject user, String accountOid) throws ObjectNotFoundException, SchemaException { + protected void assertNotLinked(PrismObject user, String accountOid) { PrismReference linkRef = user.findReference(FocusType.F_LINK_REF); if (linkRef == null) { return; } boolean found = false; - for (PrismReferenceValue val: linkRef.getValues()) { + for (PrismReferenceValue val : linkRef.getValues()) { if (val.getOid().equals(accountOid)) { found = true; } @@ -2382,14 +2316,14 @@ protected void assertNoLinkedAccount(PrismObject user) if (accountRef == null) { return; } - assert accountRef.isEmpty() : "Expected that "+user+" has no linked account but it has "+accountRef.size()+" linked accounts: " - + accountRef.getValues(); + assert accountRef.isEmpty() : "Expected that " + user + " has no linked account but it has " + accountRef.size() + " linked accounts: " + + accountRef.getValues(); } - protected void assertPersonaLinks(PrismObject focus, int expectedNumLinks) throws ObjectNotFoundException, SchemaException { + protected void assertPersonaLinks(PrismObject focus, int expectedNumLinks) { PrismReference linkRef = focus.findReference(FocusType.F_PERSONA_REF); if (linkRef == null) { - assert expectedNumLinks == 0 : "Expected "+expectedNumLinks+" but "+focus+" has no personaRef"; + assert expectedNumLinks == 0 : "Expected " + expectedNumLinks + " but " + focus + " has no personaRef"; return; } assertEquals("Wrong number of persona links in " + focus, expectedNumLinks, linkRef.size()); @@ -2409,35 +2343,30 @@ protected void removeLinks(PrismObject focus) throws Ob } protected void assertObjectOids(String message, Collection> objects, String... oids) { - List objectOids = objects.stream().map( o -> o.getOid()).collect(Collectors.toList()); + List objectOids = objects.stream().map(o -> o.getOid()).collect(Collectors.toList()); PrismAsserts.assertEqualsCollectionUnordered(message, objectOids, oids); } protected void assertExpression(PrismProperty prop, String evaluatorName) { PrismPropertyValue pval = prop.getValue(); ExpressionWrapper expressionWrapper = pval.getExpression(); - assertNotNull("No expression wrapper in "+prop, expressionWrapper); + assertNotNull("No expression wrapper in " + prop, expressionWrapper); Object expressionObj = expressionWrapper.getExpression(); - assertNotNull("No expression in "+prop, expressionObj); - assertTrue("Wrong expression type: " +expressionObj.getClass(), expressionObj instanceof ExpressionType); - ExpressionType expressionType = (ExpressionType)expressionObj; + assertNotNull("No expression in " + prop, expressionObj); + assertTrue("Wrong expression type: " + expressionObj.getClass(), expressionObj instanceof ExpressionType); + ExpressionType expressionType = (ExpressionType) expressionObj; JAXBElement evaluatorElement = expressionType.getExpressionEvaluator().iterator().next(); assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); } - protected void assertNoRepoObject(Class type, String oid) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(AbstractIntegrationTest.class.getName() + ".assertNoRepoObject"); - assertNoRepoObject(type, oid, task, task.getResult()); - } - - protected void assertNoRepoObject(Class type, String oid, Task task, OperationResult result) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { + protected void assertNoRepoObject(Class type, String oid) throws SchemaException { try { + OperationResult result = createSubresult("assertNoRepoObject"); PrismObject object = repositoryService.getObject(type, oid, null, result); - AssertJUnit.fail("Expected that "+object+" does not exist, in repo but it does"); + AssertJUnit.fail("Expected that " + object + " does not exist, in repo but it does"); } catch (ObjectNotFoundException e) { // This is expected - return; } } @@ -2451,24 +2380,24 @@ protected void assertNoAssociation(PrismObject shadow, QName associa protected void assertRoleMembershipRef(PrismObject focus, String... roleOids) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { + for (ObjectReferenceType ref : focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); - assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); + assertNotNull("Missing type in roleMembershipRef " + ref.getOid() + " in " + focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } - PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); + PrismAsserts.assertSets("Wrong values in roleMembershipRef in " + focus, refOids, roleOids); } protected void assertRoleMembershipRefs(PrismObject focus, Collection roleOids) { List refOids = new ArrayList<>(); - for (ObjectReferenceType ref: focus.asObjectable().getRoleMembershipRef()) { + for (ObjectReferenceType ref : focus.asObjectable().getRoleMembershipRef()) { refOids.add(ref.getOid()); - assertNotNull("Missing type in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getType()); + assertNotNull("Missing type in roleMembershipRef " + ref.getOid() + " in " + focus, ref.getType()); // Name is not stored now // assertNotNull("Missing name in roleMembershipRef "+ref.getOid()+" in "+focus, ref.getTargetName()); } - PrismAsserts.assertSets("Wrong values in roleMembershipRef in "+focus, refOids, roleOids); + PrismAsserts.assertSets("Wrong values in roleMembershipRef in " + focus, refOids, roleOids); } protected void assertRoleMembershipRef(PrismObject focus, QName relation, String... roleOids) { @@ -2482,35 +2411,35 @@ protected void assertRoleMembershipRef(PrismObject focu } return true; })) { - AssertJUnit.fail("Wrong values in roleMembershipRef in "+focus - +", expected relation "+relation+", OIDs "+Arrays.toString(roleOids) - +", but was "+focus.asObjectable().getRoleMembershipRef()); + AssertJUnit.fail("Wrong values in roleMembershipRef in " + focus + + ", expected relation " + relation + ", OIDs " + Arrays.toString(roleOids) + + ", but was " + focus.asObjectable().getRoleMembershipRef()); } } protected void assertRoleMembershipRefs(PrismObject focus, int expectedNumber) { List roleMembershipRefs = focus.asObjectable().getRoleMembershipRef(); - assertEquals("Wrong number of roleMembershipRefs in "+focus, expectedNumber, roleMembershipRefs.size()); + assertEquals("Wrong number of roleMembershipRefs in " + focus, expectedNumber, roleMembershipRefs.size()); } protected void assertNoRoleMembershipRef(PrismObject focus) { PrismReference memRef = focus.findReference(FocusType.F_ROLE_MEMBERSHIP_REF); - assertNull("No roleMembershipRef expected in "+focus+", but found: "+memRef, memRef); + assertNull("No roleMembershipRef expected in " + focus + ", but found: " + memRef, memRef); } - protected void generateRoles(int numberOfRoles, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { + protected void generateRoles(int numberOfRoles, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { generateObjects(RoleType.class, numberOfRoles, nameFormat, oidFormat, mutator, role -> repositoryService.addObject(role, null, result), result); } - protected void generateUsers(int numberOfUsers, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { + protected void generateUsers(int numberOfUsers, String nameFormat, String oidFormat, BiConsumer mutator, OperationResult result) throws Exception { generateObjects(UserType.class, numberOfUsers, nameFormat, oidFormat, mutator, user -> repositoryService.addObject(user, null, result), result); } - protected void generateObjects(Class type, int numberOfObjects, String nameFormat, String oidFormat, BiConsumer mutator, FailableProcessor> adder, OperationResult result) throws Exception { + protected void generateObjects(Class type, int numberOfObjects, String nameFormat, String oidFormat, BiConsumer mutator, FailableProcessor> adder, OperationResult result) throws Exception { long startMillis = System.currentTimeMillis(); PrismObjectDefinition objectDefinition = getObjectDefinition(type); - for(int i=0; i < numberOfObjects; i++) { + for (int i = 0; i < numberOfObjects; i++) { PrismObject object = objectDefinition.instantiate(); O objectType = object.asObjectable(); String name = String.format(nameFormat, i); @@ -2522,32 +2451,32 @@ protected void generateObjects(Class type, int numberO if (mutator != null) { mutator.accept(objectType, i); } - LOGGER.info("Adding {}:\n{}", object, object.debugDump(1)); + logger.info("Adding {}:\n{}", object, object.debugDump(1)); adder.process(object); } long endMillis = System.currentTimeMillis(); long duration = (endMillis - startMillis); - display(type.getSimpleName() + " import", "import of "+numberOfObjects+" roles took "+(duration/1000)+" seconds ("+(duration/numberOfObjects)+"ms per object)"); + display(type.getSimpleName() + " import", "import of " + numberOfObjects + " roles took " + (duration / 1000) + " seconds (" + (duration / numberOfObjects) + "ms per object)"); } protected String assignmentSummary(PrismObject user) { - Map assignmentRelations = new HashMap<>(); - for (AssignmentType assignment: user.asObjectable().getAssignment()) { + Map assignmentRelations = new HashMap<>(); + for (AssignmentType assignment : user.asObjectable().getAssignment()) { relationToMap(assignmentRelations, assignment.getTargetRef()); } - Map memRelations = new HashMap<>(); - for (ObjectReferenceType ref: user.asObjectable().getRoleMembershipRef()) { + Map memRelations = new HashMap<>(); + for (ObjectReferenceType ref : user.asObjectable().getRoleMembershipRef()) { relationToMap(memRelations, ref); } - Map parents = new HashMap<>(); - for (ObjectReferenceType ref: user.asObjectable().getParentOrgRef()) { + Map parents = new HashMap<>(); + for (ObjectReferenceType ref : user.asObjectable().getParentOrgRef()) { relationToMap(parents, ref); } - return "User "+user - +"\n "+user.asObjectable().getAssignment().size()+" assignments\n "+assignmentRelations - +"\n "+user.asObjectable().getRoleMembershipRef().size()+" roleMembershipRefs\n "+memRelations - +"\n "+user.asObjectable().getParentOrgRef().size()+" parentOrgRefs\n "+parents; + return "User " + user + + "\n " + user.asObjectable().getAssignment().size() + " assignments\n " + assignmentRelations + + "\n " + user.asObjectable().getRoleMembershipRef().size() + " roleMembershipRefs\n " + memRelations + + "\n " + user.asObjectable().getParentOrgRef().size() + " parentOrgRefs\n " + parents; } private void relationToMap(Map map, ObjectReferenceType ref) { @@ -2571,19 +2500,19 @@ protected S_FilterEntryOrEmpty queryFor(Class queryClas protected void displayCounters(InternalCounters... counters) { StringBuilder sb = new StringBuilder(); - for (InternalCounters counter: counters) { + for (InternalCounters counter : counters) { sb - .append(" ") - .append(counter.getLabel()).append(": ") - .append("+").append(getCounterIncrement(counter)) - .append(" (").append(InternalMonitor.getCount(counter)).append(")") - .append("\n"); + .append(" ") + .append(counter.getLabel()).append(": ") + .append("+").append(getCounterIncrement(counter)) + .append(" (").append(InternalMonitor.getCount(counter)).append(")") + .append("\n"); } display("Counters", sb.toString()); } protected void assertMessageContains(String message, String string) { - assert message.contains(string) : "Expected message to contain '"+string+"' but it does not; message: " + message; + assert message.contains(string) : "Expected message to contain '" + string + "' but it does not; message: " + message; } protected void assertExceptionUserFriendly(CommonException e, String expectedMessage) { @@ -2592,8 +2521,8 @@ protected void assertExceptionUserFriendly(CommonException e, String expectedMes assertEquals("Unexpected user friendly exception fallback message", expectedMessage, userFriendlyMessage.getFallbackMessage()); } - protected ParallelTestThread[] multithread(final String TEST_NAME, MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { - return TestUtil.multithread(TEST_NAME, lambda, numberOfThreads, randomStartDelayRange); + protected ParallelTestThread[] multithread(MultithreadRunner lambda, int numberOfThreads, Integer randomStartDelayRange) { + return TestUtil.multithread(lambda, numberOfThreads, randomStartDelayRange); } protected void randomDelay(Integer range) { @@ -2654,7 +2583,7 @@ protected ObjectDelta createModifyAccountShadowReplaceAttributeDelta return createModifyAccountShadowReplaceDelta(accountOid, resource, ItemPath.create(ShadowType.F_ATTRIBUTES, attributeName), newRealValue); } - protected ObjectDelta createModifyAccountShadowReplaceDelta(String accountOid, PrismObject resource, ItemPath itemPath, Object... newRealValue) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + protected ObjectDelta createModifyAccountShadowReplaceDelta(String accountOid, PrismObject resource, ItemPath itemPath, Object... newRealValue) throws SchemaException { if (itemPath.startsWithName(ShadowType.F_ATTRIBUTES)) { PropertyDelta attributeDelta = createAttributeReplaceDelta(resource, ItemPath.toName(itemPath.last()), newRealValue); ObjectDelta accountDelta = prismContext.deltaFactory().object() @@ -2674,7 +2603,7 @@ protected PropertyDelta createAttributeReplaceDelta(PrismObject PropertyDelta createAttributeReplaceDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2687,7 +2616,7 @@ protected PropertyDelta createAttributeAddDelta(PrismObject protected PropertyDelta createAttributeAddDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationAddProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2700,7 +2629,7 @@ protected PropertyDelta createAttributeDeleteDelta(PrismObject PropertyDelta createAttributeDeleteDelta(PrismObject resource, QName attributeQName, T... newRealValue) throws SchemaException { PrismPropertyDefinition attributeDefinition = getAttributeDefinition(resource, attributeQName); if (attributeDefinition == null) { - throw new SchemaException("No definition for attribute "+ attributeQName+ " in " + resource); + throw new SchemaException("No definition for attribute " + attributeQName + " in " + resource); } return prismContext.deltaFactory().property().createModificationDeleteProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeQName), attributeDefinition, newRealValue); @@ -2709,7 +2638,7 @@ protected PropertyDelta createAttributeDeleteDelta(PrismObject resource, QName attributeName) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); if (refinedSchema == null) { - throw new SchemaException("No refined schema for "+resource); + throw new SchemaException("No refined schema for " + resource); } RefinedObjectClassDefinition accountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); return accountDefinition.findAttributeDefinition(attributeName); @@ -2738,7 +2667,7 @@ protected ObjectDelta createAccountPaswordDelta(String shadowOid, St oldPasswordPs.setClearValue(oldPassword); } return deltaFor(ShadowType.class) - .item(SchemaConstants.PATH_PASSWORD_VALUE) + .item(SchemaConstants.PATH_PASSWORD_VALUE) .oldRealValue(oldPasswordPs) .replace(newPasswordPs) .asObjectDelta(shadowOid); @@ -2748,15 +2677,15 @@ protected PrismObject getShadowRepo(String shadowOid) throws ObjectN OperationResult result = new OperationResult("getShadowRepo"); // We need to read the shadow as raw, so repo will look for some kind of rudimentary attribute // definitions here. Otherwise we will end up with raw values for non-indexed (cached) attributes - LOGGER.info("Getting repo shadow {}", shadowOid); + logger.info("Getting repo shadow {}", shadowOid); PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowOid, GetOperationOptions.createRawCollection(), result); - LOGGER.info("Got repo shadow\n{}", shadow.debugDumpLazily(1)); + logger.info("Got repo shadow\n{}", shadow.debugDumpLazily(1)); assertSuccess(result); return shadow; } protected Collection> createDetlaCollection(ObjectDelta... deltas) { - return (Collection)MiscUtil.createCollection(deltas); + return (Collection) MiscUtil.createCollection(deltas); } public static String getAttributeValue(ShadowType repoShadow, QName name) { @@ -2773,13 +2702,13 @@ protected T getAttributeValue(PrismObject shadow, QNam return (T) value; } if (expectedClass.isAssignableFrom(value.getClass())) { - return (T)value; + return (T) value; } if (value instanceof RawType) { - T parsedRealValue = ((RawType)value).getParsedRealValue(expectedClass); + T parsedRealValue = ((RawType) value).getParsedRealValue(expectedClass); return parsedRealValue; } - fail("Expected that attribute "+attrName+" is "+expectedClass+", but it was "+value.getClass()+": "+value); + fail("Expected that attribute " + attrName + " is " + expectedClass + ", but it was " + value.getClass() + ": " + value); return null; // not reached } @@ -2788,7 +2717,7 @@ protected void assertApproxNumberOfAllResults(SearchResultMetadata searchMetadat if (searchMetadata == null) { return; } - assertNull("Unexpected approximate number of search results in search metadata, expected null but was "+searchMetadata.getApproxNumberOfAllResults(), searchMetadata.getApproxNumberOfAllResults()); + assertNull("Unexpected approximate number of search results in search metadata, expected null but was " + searchMetadata.getApproxNumberOfAllResults(), searchMetadata.getApproxNumberOfAllResults()); } else { assertEquals("Wrong approximate number of search results in search metadata", expectedNumber, searchMetadata.getApproxNumberOfAllResults()); } @@ -2799,7 +2728,7 @@ protected void assertEqualTime(String message, String isoTime, ZonedDateTime act } protected void assertEqualTime(String message, ZonedDateTime expectedTime, ZonedDateTime actualTime) { - assertTrue(message+"; expected "+expectedTime+", but was "+actualTime, expectedTime.isEqual(actualTime)); + assertTrue(message + "; expected " + expectedTime + ", but was " + actualTime, expectedTime.isEqual(actualTime)); } protected XMLGregorianCalendar getTimestamp(String duration) { @@ -2815,8 +2744,8 @@ protected void clockForward(String duration) { protected void assertRelationDef(List relations, QName qname, String expectedLabel) { RelationDefinitionType relDef = ObjectTypeUtil.findRelationDefinition(relations, qname); - assertNotNull("No definition for relation "+qname, relDef); - assertEquals("Wrong relation "+qname+" label", expectedLabel, relDef.getDisplay().getLabel().getOrig()); + assertNotNull("No definition for relation " + qname, relDef); + assertEquals("Wrong relation " + qname + " label", expectedLabel, relDef.getDisplay().getLabel().getOrig()); } protected void initializeAsserter(AbstractAsserter asserter) { @@ -2834,13 +2763,13 @@ protected PolyStringAsserter assertPolyString(PolyString polystring, Strin protected RefinedResourceSchemaAsserter assertRefinedResourceSchema(PrismObject resource, String details) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext); - assertNotNull("No refined schema for "+resource+" ("+details+")", refinedSchema); - RefinedResourceSchemaAsserter asserter = new RefinedResourceSchemaAsserter(refinedSchema, resource.toString() + " ("+details+")"); + assertNotNull("No refined schema for " + resource + " (" + details + ")", refinedSchema); + RefinedResourceSchemaAsserter asserter = new RefinedResourceSchemaAsserter(refinedSchema, resource.toString() + " (" + details + ")"); initializeAsserter(asserter); return asserter; } - protected ShadowAsserter assertShadow(PrismObject shadow, String details) throws ObjectNotFoundException, SchemaException { + protected ShadowAsserter assertShadow(PrismObject shadow, String details) throws ObjectNotFoundException { ShadowAsserter asserter = ShadowAsserter.forShadow(shadow, details); initializeAsserter(asserter); asserter.display(); @@ -2859,20 +2788,15 @@ protected void assertNoRepoShadow(String oid) throws SchemaException { OperationResult result = new OperationResult("assertNoRepoShadow"); try { PrismObject shadow = repositoryService.getObject(ShadowType.class, oid, GetOperationOptions.createRawCollection(), result); - fail("Expected that shadow "+oid+" will not be in the repo. But it was: "+shadow); + fail("Expected that shadow " + oid + " will not be in the repo. But it was: " + shadow); } catch (ObjectNotFoundException e) { // Expected assertFailure(result); } } - protected RawType rawize(QName attrName, T value) { - return new RawType(prismContext.itemFactory().createPropertyValue(value), attrName, prismContext); - } - protected void markShadowTombstone(String oid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { - Task task = createTask("markShadowTombstone"); - OperationResult result = task.getResult(); + OperationResult result = createSubresult("markShadowTombstone"); List> deadModifications = deltaFor(ShadowType.class) .item(ShadowType.F_DEAD).replace(true) .item(ShadowType.F_EXISTS).replace(false) @@ -2911,8 +2835,8 @@ protected GetOperationOptionsBuilder getOperationOptionsBuilder() { @NotNull protected Collection> retrieveTaskResult() { return getOperationOptionsBuilder() - .item(TaskType.F_RESULT).retrieve() - .build(); + .item(TaskType.F_RESULT).retrieve() + .build(); } // use only if necessary (use ItemPath.create instead) diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java index ae4482ebe63..55e39b0dce6 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/IntegrationTestTools.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.test; +import static org.testng.AssertJUnit.*; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.*; +import java.util.stream.Collectors; +import javax.xml.namespace.QName; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.opends.server.types.Entry; +import org.opends.server.types.SearchResultEntry; +import org.testng.AssertJUnit; +import org.w3c.dom.Element; + import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.icf.dummy.resource.ScriptHistoryEntry; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; @@ -14,13 +30,13 @@ import com.evolveum.midpoint.prism.crypto.EncryptionException; import com.evolveum.midpoint.prism.crypto.Protector; import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.schema.PrismSchema; -import com.evolveum.midpoint.prism.impl.schema.PrismSchemaImpl; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.prism.util.PrismUtil; @@ -30,56 +46,26 @@ import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.ConnectorTestOperation; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttribute; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; -import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; -import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.schema.processor.*; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.result.OperationResultStatus; -import com.evolveum.midpoint.schema.util.ConnectorTypeUtil; -import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.schema.util.ShadowUtil; -import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.schema.util.SchemaDebugUtil; -import com.evolveum.midpoint.schema.util.SchemaTestConstants; +import com.evolveum.midpoint.schema.util.*; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.util.exception.CommonException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SystemException; 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.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; -import org.testng.AssertJUnit; -import org.w3c.dom.Element; - -import javax.xml.namespace.QName; - -import java.io.IOException; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -import static org.testng.AssertJUnit.*; - /** * @author Radovan Semancik - * */ public class IntegrationTestTools { @@ -95,7 +81,7 @@ public class IntegrationTestTools { public static final String LDAP_CONNECTOR_TYPE = "com.evolveum.polygon.connector.ldap.LdapConnector"; public static final String NS_RESOURCE_DUMMY_CONFIGURATION = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"; - public static final QName RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME = new QName(NS_RESOURCE_DUMMY_CONFIGURATION ,"uselessString"); + public static final QName RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME = new QName(NS_RESOURCE_DUMMY_CONFIGURATION, "uselessString"); // public and not final - to allow changing it in tests public static final Trace LOGGER = TraceManager.getTrace(IntegrationTestTools.class); @@ -120,20 +106,20 @@ private static List getConnectorSubresults(OperationResult test public static void assertTestResourceSuccess(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - TestUtil.assertSuccess("Test resource failed (result): "+operation, opResult, 1); + assertNotNull("No result for " + operation, opResult); + TestUtil.assertSuccess("Test resource failed (result): " + operation, opResult, 1); } public static void assertTestResourceFailure(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - TestUtil.assertFailure("Test resource succeeded while expected failure (result): "+operation, opResult); + assertNotNull("No result for " + operation, opResult); + TestUtil.assertFailure("Test resource succeeded while expected failure (result): " + operation, opResult); } public static void assertTestResourceNotApplicable(OperationResult testResult, ConnectorTestOperation operation) { OperationResult opResult = testResult.findSubresult(operation.getOperation()); - assertNotNull("No result for "+operation, opResult); - assertEquals("Test resource status is not 'not applicable', it is "+opResult.getStatus()+": "+operation, + assertNotNull("No result for " + operation, opResult); + assertEquals("Test resource status is not 'not applicable', it is " + opResult.getStatus() + ": " + operation, OperationResultStatus.NOT_APPLICABLE, opResult.getStatus()); } @@ -169,8 +155,8 @@ public static void assertNotEmpty(String s) { public static void assertNotEmpty(String message, QName qname) { assertNotNull(message, qname); - assertNotEmpty(message,qname.getNamespaceURI()); - assertNotEmpty(message,qname.getLocalPart()); + assertNotEmpty(message, qname.getNamespaceURI()); + assertNotEmpty(message, qname.getLocalPart()); } public static void assertNotEmpty(QName qname) { @@ -179,57 +165,68 @@ public static void assertNotEmpty(QName qname) { assertNotEmpty(qname.getLocalPart()); } - public static void assertAttribute(ShadowType shadow, ResourceType resource, String name, - T... expectedValues) { - assertAttribute("Wrong attribute " + name + " in "+shadow, shadow, + @SafeVarargs + public static void assertAttribute( + ShadowType shadow, ResourceType resource, String name, T... expectedValues) { + assertAttribute("Wrong attribute " + name + " in " + shadow, shadow, new QName(ResourceTypeUtil.getResourceNamespace(resource), name), expectedValues); } - public static void assertAttribute(PrismObject shadow, ResourceType resource, String name, - T... expectedValues) { - assertAttribute("Wrong attribute " + name + " in "+shadow, shadow, + @SafeVarargs + public static void assertAttribute(PrismObject shadow, + ResourceType resource, String name, T... expectedValues) { + assertAttribute("Wrong attribute " + name + " in " + shadow, shadow, new QName(ResourceTypeUtil.getResourceNamespace(resource), name), expectedValues); } + @SafeVarargs public static void assertAttribute(ShadowType shadowType, QName name, T... expectedValues) { assertAttribute(shadowType.asPrismObject(), name, expectedValues); } - public static void assertAttribute(PrismObject shadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute( + PrismObject shadow, QName name, T... expectedValues) { Collection values = getAttributeValues(shadow, name); - assertEqualsCollection("Wrong value for attribute "+name+" in "+shadow, expectedValues, values); + assertEqualsCollection("Wrong value for attribute " + name + " in " + shadow, expectedValues, values); } - public static void assertAttribute(String message, ShadowType repoShadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute( + String message, ShadowType repoShadow, QName name, T... expectedValues) { Collection values = getAttributeValues(repoShadow, name); assertEqualsCollection(message, expectedValues, values); } - public static void assertAttribute(String message, PrismObject repoShadow, QName name, T... expectedValues) { + @SafeVarargs + public static void assertAttribute(String message, + PrismObject repoShadow, QName name, T... expectedValues) { Collection values = getAttributeValues(repoShadow, name); assertEqualsCollection(message, expectedValues, values); } - public static void assertNoAttribute(PrismObject shadow, QName name) { - assertNull("Found attribute "+name+" in "+shadow+" while not expecting it", getAttributeValues(shadow, name)); + public static void assertNoAttribute(PrismObject shadow, QName name) { + assertNull("Found attribute " + name + " in " + shadow + " while not expecting it", getAttributeValues(shadow, name)); } public static void assertEqualsCollection(String message, Collection expectedValues, Collection actualValues) { if (expectedValues == null && actualValues == null) { return; } - assert !(expectedValues == null && actualValues != null) : "Expecting null values but got "+actualValues; - assert actualValues != null : message+": Expecting "+expectedValues+" but got null"; - assertEquals(message+": Wrong number of values in " + actualValues, expectedValues.size(), actualValues.size()); - for (T actualValue: actualValues) { + + assert !(expectedValues == null) : "Expecting null values but got " + actualValues; + assert actualValues != null : message + ": Expecting " + expectedValues + " but got null"; + assertEquals(message + ": Wrong number of values in " + actualValues, expectedValues.size(), actualValues.size()); + for (T actualValue : actualValues) { boolean found = false; - for (T value: expectedValues) { + for (T value : expectedValues) { if (value.equals(actualValue)) { found = true; + break; } } if (!found) { - fail(message + ": Unexpected value "+actualValue+"; expected "+expectedValues+"; has "+actualValues); + fail(message + ": Unexpected value " + actualValue + "; expected " + expectedValues + "; has " + actualValues); } } } @@ -256,13 +253,13 @@ public static String getSecondaryIdentifier(PrismObject shadow) { return null; } if (secondaryIdentifiers.size() > 1) { - throw new IllegalArgumentException("Too many secondary indentifiers in "+shadow); + throw new IllegalArgumentException("Too many secondary indentifiers in " + shadow); } return (String) secondaryIdentifiers.iterator().next().getRealValue(); } public static void assertSecondaryIdentifier(PrismObject repoShadow, String value) { - assertEquals("Wrong secondary indetifier in "+repoShadow, value, getSecondaryIdentifier(repoShadow)); + assertEquals("Wrong secondary indetifier in " + repoShadow, value, getSecondaryIdentifier(repoShadow)); } public static void assertIcfsNameAttribute(ShadowType repoShadow, String value) { @@ -275,21 +272,21 @@ public static void assertIcfsNameAttribute(PrismObject repoShadow, S public static void assertAttributeNotNull(PrismObject repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(1, values.size()); assertNotNull(values.iterator().next()); } public static void assertAttributeNotNull(ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(1, values.size()); assertNotNull(values.iterator().next()); } public static void assertAttributeNotNull(String message, ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); - assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); + assertFalse("No values for " + name + " in " + repoShadow, values == null || values.isEmpty()); assertEquals(message, 1, values.size()); assertNotNull(message, values.iterator().next()); } @@ -298,48 +295,48 @@ public static void assertAttributeDefinition(ResourceAttribute attr, QName ex boolean canRead, boolean canCreate, boolean canUpdate, Class expectedAttributeDefinitionClass) { ResourceAttributeDefinition definition = attr.getDefinition(); QName attrName = attr.getElementName(); - assertNotNull("No definition for attribute "+attrName, definition); + assertNotNull("No definition for attribute " + attrName, definition); //assertEquals("Wrong class of definition for attribute"+attrName, expetcedAttributeDefinitionClass, definition.getClass()); - assertTrue("Wrong class of definition for attribute"+attrName+" (expected: " + expectedAttributeDefinitionClass - + ", real: " + definition.getClass() + ")", + assertTrue("Wrong class of definition for attribute" + attrName + " (expected: " + expectedAttributeDefinitionClass + + ", real: " + definition.getClass() + ")", expectedAttributeDefinitionClass.isAssignableFrom(definition.getClass())); - assertEquals("Wrong type in definition for attribute"+attrName, expectedType, definition.getTypeName()); - assertEquals("Wrong minOccurs in definition for attribute"+attrName, minOccurs, definition.getMinOccurs()); - assertEquals("Wrong maxOccurs in definition for attribute"+attrName, maxOccurs, definition.getMaxOccurs()); - assertEquals("Wrong canRead in definition for attribute"+attrName, canRead, definition.canRead()); - assertEquals("Wrong canCreate in definition for attribute"+attrName, canCreate, definition.canAdd()); - assertEquals("Wrong canUpdate in definition for attribute"+attrName, canUpdate, definition.canModify()); + assertEquals("Wrong type in definition for attribute" + attrName, expectedType, definition.getTypeName()); + assertEquals("Wrong minOccurs in definition for attribute" + attrName, minOccurs, definition.getMinOccurs()); + assertEquals("Wrong maxOccurs in definition for attribute" + attrName, maxOccurs, definition.getMaxOccurs()); + assertEquals("Wrong canRead in definition for attribute" + attrName, canRead, definition.canRead()); + assertEquals("Wrong canCreate in definition for attribute" + attrName, canCreate, definition.canAdd()); + assertEquals("Wrong canUpdate in definition for attribute" + attrName, canUpdate, definition.canModify()); } public static void assertProvisioningAccountShadow(PrismObject account, ResourceType resourceType, Class expetcedAttributeDefinitionClass) { - assertProvisioningShadow(account,resourceType,expetcedAttributeDefinitionClass, - new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME)); + assertProvisioningShadow(account, expetcedAttributeDefinitionClass, + new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaTestConstants.ICF_ACCOUNT_OBJECT_CLASS_LOCAL_NAME)); } - public static void assertProvisioningShadow(PrismObject account, ResourceType resourceType, - Class expetcedAttributeDefinitionClass, QName objectClass) { + public static void assertProvisioningShadow(PrismObject account, + Class expectedAttributeDefinitionClass, QName objectClass) { // Check attribute definition PrismContainer attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES); PrismAsserts.assertClass("Wrong attributes container class", ResourceAttributeContainer.class, attributesContainer); - ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer)attributesContainer; + ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer) attributesContainer; PrismContainerDefinition attrsDef = attributesContainer.getDefinition(); assertNotNull("No attributes container definition", attrsDef); - assertTrue("Wrong attributes definition class "+attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition); - ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition)attrsDef; + assertTrue("Wrong attributes definition class " + attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition); + ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition) attrsDef; ObjectClassComplexTypeDefinition objectClassDef = rAttrsDef.getComplexTypeDefinition(); assertNotNull("No object class definition in attributes definition", objectClassDef); assertEquals("Wrong object class in attributes definition", objectClass, objectClassDef.getTypeName()); ResourceAttributeDefinition primaryIdDef = objectClassDef.getPrimaryIdentifiers().iterator().next(); ResourceAttribute primaryIdAttr = rAttributesContainer.findAttribute(primaryIdDef.getItemName()); - assertNotNull("No primary ID "+primaryIdDef.getItemName()+" in "+account, primaryIdAttr); - assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expetcedAttributeDefinitionClass); + assertNotNull("No primary ID " + primaryIdDef.getItemName() + " in " + account, primaryIdAttr); + assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expectedAttributeDefinitionClass); ResourceAttributeDefinition secondaryIdDef = objectClassDef.getSecondaryIdentifiers().iterator().next(); ResourceAttribute secondaryIdAttr = rAttributesContainer.findAttribute(secondaryIdDef.getItemName()); - assertNotNull("No secondary ID "+secondaryIdDef.getItemName()+" in "+account, secondaryIdAttr); - assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expetcedAttributeDefinitionClass); + assertNotNull("No secondary ID " + secondaryIdDef.getItemName() + " in " + account, secondaryIdAttr); + assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expectedAttributeDefinitionClass); } public static Collection getAttributeValues(ShadowType shadowType, QName name) { @@ -365,10 +362,10 @@ public static String getAttributeValue(ShadowType repoShadow, QName name) { Collection values = getAttributeValues(repoShadow, name); if (values == null || values.isEmpty()) { - AssertJUnit.fail("Attribute "+name+" not found in shadow "+ObjectTypeUtil.toShortString(repoShadow)); + AssertJUnit.fail("Attribute " + name + " not found in shadow " + ObjectTypeUtil.toShortString(repoShadow)); } if (values.size() > 1) { - AssertJUnit.fail("Too many values for attribute "+name+" in shadow "+ObjectTypeUtil.toShortString(repoShadow)); + AssertJUnit.fail("Too many values for attribute " + name + " in shadow " + ObjectTypeUtil.toShortString(repoShadow)); } return values.iterator().next(); } @@ -399,11 +396,11 @@ public static void waitFor(String message, Checker checker, long startTime, long } } // we have timeout - println("Timeout while "+message); + println("Timeout while " + message); LOGGER.error(LOG_MESSAGE_PREFIX + "Timeout while " + message); // Invoke callback checker.timeout(); - throw new RuntimeException("Timeout while "+message); + throw new RuntimeException("Timeout while " + message); } public static void displayJaxb(String title, Object o, QName defaultElementName) throws SchemaException { @@ -432,7 +429,7 @@ public static void display(Entry response) { public static void display(String message, Task task) { println(OBJECT_TITLE_OUT_PREFIX + message); println(task.debugDump()); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + "\n" + task.debugDump()); } @@ -443,15 +440,15 @@ public static void display(String message, ObjectType o) { + ObjectTypeUtil.dump(o)); } - public static void display(String message, Collection collection) { + public static void display(String message, Collection collection) { String dump; if (collection == null) { dump = ": null"; } else { dump = " (" + collection.size() + ")\n" + DebugUtil.dump(collection); } - println(OBJECT_TITLE_OUT_PREFIX + message + dump); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + dump); + println(OBJECT_TITLE_OUT_PREFIX + message + dump); + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message + dump); } public static void display(String title, Entry entry) { @@ -461,7 +458,7 @@ public static void display(String title, Entry entry) { ldif = entry.toLDIFString(); } println(ldif); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + ldif); } @@ -473,14 +470,14 @@ public static void display(String message, PrismContainer propertyContainer) } public static void display(OperationResult result) { - display("Result of "+result.getOperation(), result); + display("Result of " + result.getOperation(), result); } public static void display(String title, OperationResult result) { println(OBJECT_TITLE_OUT_PREFIX + title); String debugDump = result != null ? result.debugDump() : "(null)"; println(debugDump); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + debugDump); } @@ -491,7 +488,7 @@ public static void display(String title, OperationResultType result) throws Sche public static void display(String title, List elements) { println(OBJECT_TITLE_OUT_PREFIX + title); LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title); - for(Element e : elements) { + for (Element e : elements) { String s = DOMUtil.serializeDOMToString(e); println(s); LOGGER.debug(s); @@ -501,7 +498,7 @@ public static void display(String title, List elements) { public static void display(String title, DebugDumpable dumpable) { println(OBJECT_TITLE_OUT_PREFIX + title); println(dumpable == null ? "null" : dumpable.debugDump(1)); - LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + title + "\n" + (dumpable == null ? "null" : dumpable.debugDump(1))); } @@ -531,13 +528,25 @@ public static void display(String title, Containerable value) { } } + /** + * Displays throwable with title including full stacktrace. + * Use for "bad" exceptions, for expected exceptions use {@link #displayExpectedException}. + */ public static void display(String title, Throwable e) { String stackTrace = ExceptionUtils.getStackTrace(e); - println(OBJECT_TITLE_OUT_PREFIX + title + ": "+e.getClass() + " " + e.getMessage()); + println(OBJECT_TITLE_OUT_PREFIX + title + ": " + e.getClass() + " " + e.getMessage()); println(stackTrace); LOGGER.debug("{}{}: {} {}\n{}", OBJECT_TITLE_LOG_PREFIX, title, e.getClass(), e.getMessage(), stackTrace); } + /** + * Displays expected exception without stacktrace (seeing it is rather confusing/disturbing). + */ + public static void displayExpectedException(Throwable e) { + println(OBJECT_TITLE_OUT_PREFIX + "Expected exception: " + e.getClass() + " " + e.getMessage()); + LOGGER.debug("{}Expected exception: {} {}", OBJECT_TITLE_LOG_PREFIX, e.getClass(), e.getMessage()); + } + public static void displayPrismValuesCollection(String message, Collection collection) { println(OBJECT_TITLE_OUT_PREFIX + message); LOGGER.debug(OBJECT_TITLE_LOG_PREFIX + message); @@ -586,22 +595,23 @@ public static void displayObjectTypeCollection(String message, Collection void assertSearchResultNames(SearchResultList> resultList, MatchingRule matchingRule, String... expectedNames) throws SchemaException { List names = new ArrayList<>(expectedNames.length); - for(PrismObject obj: resultList) { + for (PrismObject obj : resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", matchingRule, names, expectedNames); } - public static void assertSearchResultNames(SearchResultList> resultList, String... expectedNames) { + public static void assertSearchResultNames( + SearchResultList> resultList, String... expectedNames) { List names = new ArrayList<>(expectedNames.length); - for(PrismObject obj: resultList) { + for (PrismObject obj : resultList) { names.add(obj.asObjectable().getName().getOrig()); } PrismAsserts.assertSets("Unexpected search result", names, expectedNames); } public static void checkAllShadows(ResourceType resourceType, RepositoryService repositoryService, - ObjectChecker checker, PrismContext prismContext) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { + ObjectChecker checker, PrismContext prismContext) throws SchemaException { OperationResult result = new OperationResult(IntegrationTestTools.class.getName() + ".checkAllShadows"); ObjectQuery query = createAllShadowsQuery(resourceType, prismContext); @@ -609,29 +619,29 @@ public static void checkAllShadows(ResourceType resourceType, RepositoryService List> allShadows = repositoryService.searchObjects(ShadowType.class, query, GetOperationOptions.createRawCollection(), result); LOGGER.trace("Checking {} shadows, query:\n{}", allShadows.size(), query.debugDump()); - for (PrismObject shadow: allShadows) { + for (PrismObject shadow : allShadows) { checkShadow(shadow.asObjectable(), resourceType, repositoryService, checker, prismContext, result); } } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, PrismContext prismContext) { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .build(); } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .and().item(ShadowType.F_OBJECT_CLASS).eq(objectClass) .build(); } - public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, String objectClassLocalName, PrismContext prismContext) throws SchemaException { + public static ObjectQuery createAllShadowsQuery( + ResourceType resourceType, String objectClassLocalName, PrismContext prismContext) { return createAllShadowsQuery(resourceType, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), objectClassLocalName), prismContext); } - public static void checkAccountShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker checker, PrismContext prismContext, OperationResult parentResult) throws SchemaException { checkAccountShadow(shadowType, resourceType, repositoryService, checker, null, prismContext, parentResult); @@ -663,52 +673,52 @@ public static void checkShadow(ShadowType shadowType, ResourceType resourceType, public static void checkShadow(ShadowType shadowType, ResourceType resourceType, RepositoryService repositoryService, ObjectChecker checker, MatchingRule uidMatchingRule, PrismContext prismContext, OperationResult parentResult) throws SchemaException { - LOGGER.trace("Checking shadow:\n{}",shadowType.asPrismObject().debugDump()); + LOGGER.trace("Checking shadow:\n{}", shadowType.asPrismObject().debugDump()); shadowType.asPrismObject().checkConsistence(true, true, ConsistencyCheckScope.THOROUGH); - assertNotNull("no OID",shadowType.getOid()); - assertNotNull("no name",shadowType.getName()); + assertNotNull("no OID", shadowType.getOid()); + assertNotNull("no name", shadowType.getName()); assertEquals(resourceType.getOid(), shadowType.getResourceRef().getOid()); PrismContainer attrs = shadowType.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); - assertNotNull("no attributes",attrs); - assertFalse("empty attributes",attrs.isEmpty()); + assertNotNull("no attributes", attrs); + assertFalse("empty attributes", attrs.isEmpty()); RefinedResourceSchema rschema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); ObjectClassComplexTypeDefinition objectClassDef = rschema.findObjectClassDefinition(shadowType); - assertNotNull("cannot determine object class for "+shadowType, objectClassDef); + assertNotNull("cannot determine object class for " + shadowType, objectClassDef); String icfUid = ShadowUtil.getSingleStringAttributeValue(shadowType, SchemaTestConstants.ICFS_UID); if (icfUid == null) { Collection identifierDefs = objectClassDef.getPrimaryIdentifiers(); - assertFalse("No identifiers for "+objectClassDef, identifierDefs == null || identifierDefs.isEmpty()); - for (ResourceAttributeDefinition idDef: identifierDefs) { + assertFalse("No identifiers for " + objectClassDef, identifierDefs == null || identifierDefs.isEmpty()); + for (ResourceAttributeDefinition idDef : identifierDefs) { String id = ShadowUtil.getSingleStringAttributeValue(shadowType, idDef.getItemName()); - assertNotNull("No identifier "+idDef.getItemName()+" in "+shadowType, id); + assertNotNull("No identifier " + idDef.getItemName() + " in " + shadowType, id); } } String resourceOid = ShadowUtil.getResourceOid(shadowType); - assertNotNull("No resource OID in "+shadowType, resourceOid); + assertNotNull("No resource OID in " + shadowType, resourceOid); - assertNotNull("Null OID in "+shadowType, shadowType.getOid()); + assertNotNull("Null OID in " + shadowType, shadowType.getOid()); PrismObject repoShadow = null; try { repoShadow = repositoryService.getObject(ShadowType.class, shadowType.getOid(), null, parentResult); } catch (Exception e) { - AssertJUnit.fail("Got exception while trying to read "+shadowType+ - ": "+e.getCause()+": "+e.getMessage()); + AssertJUnit.fail("Got exception while trying to read " + shadowType + + ": " + e.getCause() + ": " + e.getMessage()); } checkShadowUniqueness(shadowType, objectClassDef, repositoryService, uidMatchingRule, prismContext, parentResult); String repoResourceOid = ShadowUtil.getResourceOid(repoShadow.asObjectable()); - assertNotNull("No resource OID in the repository shadow "+repoShadow); + assertNotNull("No resource OID in the repository shadow " + repoShadow, repoResourceOid); assertEquals("Resource OID mismatch", resourceOid, repoResourceOid); try { repositoryService.getObject(ResourceType.class, resourceOid, null, parentResult); } catch (Exception e) { - AssertJUnit.fail("Got exception while trying to read resource "+resourceOid+" as specified in current shadow "+shadowType+ - ": "+e.getCause()+": "+e.getMessage()); + AssertJUnit.fail("Got exception while trying to read resource " + resourceOid + " as specified in current shadow " + shadowType + + ": " + e.getCause() + ": " + e.getMessage()); } if (checker != null) { @@ -726,13 +736,13 @@ private static void checkShadowUniqueness(ShadowType resourceShadow, ObjectClass List> results = repositoryService.searchObjects(ShadowType.class, query, null, parentResult); LOGGER.trace("Shadow check with filter\n{}\n found {} objects", query.debugDump(), results.size()); if (results.size() == 0) { - AssertJUnit.fail("No shadow found with query:\n"+query.debugDump()); + AssertJUnit.fail("No shadow found with query:\n" + query.debugDump()); } if (results.size() == 1) { return; } if (results.size() > 1) { - for (PrismObject result: results) { + for (PrismObject result : results) { LOGGER.trace("Search result:\n{}", result.debugDump()); } LOGGER.error("More than one shadows found for " + resourceShadow); @@ -744,13 +754,16 @@ private static void checkShadowUniqueness(ShadowType resourceShadow, ObjectClass } } - private static ObjectQuery createShadowQuery(ShadowType resourceShadow, ObjectClassComplexTypeDefinition objectClassDef, MatchingRule uidMatchingRule, PrismContext prismContext) throws SchemaException { + private static ObjectQuery createShadowQuery( + ShadowType resourceShadow, ObjectClassComplexTypeDefinition objectClassDef, + MatchingRule uidMatchingRule, PrismContext prismContext) + throws SchemaException { PrismContainer attributesContainer = resourceShadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); QName identifierName = objectClassDef.getPrimaryIdentifiers().iterator().next().getItemName(); PrismProperty identifier = attributesContainer.findProperty(ItemName.fromQName(identifierName)); if (identifier == null) { - throw new SchemaException("No identifier in "+resourceShadow); + throw new SchemaException("No identifier in " + resourceShadow); } String identifierValue = identifier.getRealValue(); if (uidMatchingRule != null) { @@ -770,7 +783,7 @@ public static void applyResourceSchema(ShadowType accountType, ResourceType reso } public static void assertInMessageRecursive(Throwable e, String substring) { - assert hasInMessageRecursive(e, substring) : "The substring '"+substring+"' was NOT found in the message of exception "+e+" (including cause exceptions)"; + assert hasInMessageRecursive(e, substring) : "The substring '" + substring + "' was NOT found in the message of exception " + e + " (including cause exceptions)"; } public static boolean hasInMessageRecursive(Throwable e, String substring) { @@ -784,7 +797,7 @@ public static boolean hasInMessageRecursive(Throwable e, String substring) { } public static void assertNotInMessageRecursive(Throwable e, String substring) { - assert !e.getMessage().contains(substring) : "The substring '"+substring+"' was found in the message of exception "+e+": "+e.getMessage(); + assert !e.getMessage().contains(substring) : "The substring '" + substring + "' was found in the message of exception " + e + ": " + e.getMessage(); if (e.getCause() != null) { assertNotInMessageRecursive(e.getCause(), substring); } @@ -800,7 +813,7 @@ public static void assertScripts(List scriptsHistory, Provis displayScripts(scriptsHistory); assertEquals("Wrong number of scripts executed", expectedScripts.length, scriptsHistory.size()); Iterator historyIter = scriptsHistory.iterator(); - for (ProvisioningScriptSpec expecedScript: expectedScripts) { + for (ProvisioningScriptSpec expecedScript : expectedScripts) { ScriptHistoryEntry actualScript = historyIter.next(); assertEquals("Wrong script code", expecedScript.getCode(), actualScript.getCode()); if (expecedScript.getLanguage() == null) { @@ -809,10 +822,10 @@ public static void assertScripts(List scriptsHistory, Provis assertEquals("Wrong script language", expecedScript.getLanguage(), actualScript.getLanguage()); } assertEquals("Wrong number of arguments", expecedScript.getArgs().size(), actualScript.getParams().size()); - for (java.util.Map.Entry expectedEntry: expecedScript.getArgs().entrySet()) { + for (java.util.Map.Entry expectedEntry : expecedScript.getArgs().entrySet()) { Object expectedValue = expectedEntry.getValue(); Object actualVal = actualScript.getParams().get(expectedEntry.getKey()); - assertEquals("Wrong value for argument '"+expectedEntry.getKey()+"'", expectedValue, actualVal); + assertEquals("Wrong value for argument '" + expectedEntry.getKey() + "'", expectedValue, actualVal); } } } @@ -823,23 +836,25 @@ public static void displayScripts(List scriptsHistory) { } } - public static void assertExtensionProperty(PrismObject object, QName propertyName, T... expectedValues) { + public static void assertExtensionProperty( + PrismObject object, QName propertyName, T... expectedValues) { PrismContainer extension = object.getExtension(); PrismAsserts.assertPropertyValue(extension, ItemName.fromQName(propertyName), expectedValues); } - public static void assertNoExtensionProperty(PrismObject object, QName propertyName) { + public static void assertNoExtensionProperty( + PrismObject object, QName propertyName) { PrismContainer extension = object.getExtension(); PrismAsserts.assertNoItem(extension, ItemName.fromQName(propertyName)); } public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) { - assertNotNull("No resource schema in "+resourceType, resourceSchema); + assertNotNull("No resource schema in " + resourceType, resourceSchema); QName objectClassQname = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass"); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); - assertNotNull("No object class definition for "+objectClassQname+" in resource schema", accountDefinition); + assertNotNull("No object class definition for " + objectClassQname + " in resource schema", accountDefinition); ObjectClassComplexTypeDefinition accountDef = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); - assertTrue("Mismatched account definition: "+accountDefinition+" <-> "+accountDef, accountDefinition == accountDef); + assertSame("Mismatched account definition: " + accountDefinition + " <-> " + accountDef, accountDefinition, accountDef); assertNotNull("No object class definition " + objectClassQname, accountDefinition); assertEquals("Object class " + objectClassQname + " is not account", ShadowKindType.ACCOUNT, accountDefinition.getKind()); @@ -851,24 +866,23 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertNotNull("Null identifiers for " + objectClassQname, identifiers); assertFalse("Empty identifiers for " + objectClassQname, identifiers.isEmpty()); - ResourceAttributeDefinition uidAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_UID); - assertNotNull("No definition for attribute "+SchemaTestConstants.ICFS_UID, uidAttributeDefinition); - assertTrue("Attribute "+SchemaTestConstants.ICFS_UID+" in not an identifier",uidAttributeDefinition.isPrimaryIdentifier(accountDefinition)); - assertTrue("Attribute "+SchemaTestConstants.ICFS_UID+" in not in identifiers list",identifiers.contains(uidAttributeDefinition)); - assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_UID, "ConnId UID", uidAttributeDefinition.getDisplayName()); - assertEquals("Wrong displayOrder for attribute "+SchemaTestConstants.ICFS_UID, (Integer)100, uidAttributeDefinition.getDisplayOrder()); + assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_UID, uidAttributeDefinition); + assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not an identifier", uidAttributeDefinition.isPrimaryIdentifier(accountDefinition)); + assertTrue("Attribute " + SchemaTestConstants.ICFS_UID + " in not in identifiers list", identifiers.contains(uidAttributeDefinition)); + assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidAttributeDefinition.getDisplayName()); + assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidAttributeDefinition.getDisplayOrder()); Collection secondaryIdentifiers = accountDefinition.getSecondaryIdentifiers(); assertNotNull("Null secondary identifiers for " + objectClassQname, secondaryIdentifiers); assertFalse("Empty secondary identifiers for " + objectClassQname, secondaryIdentifiers.isEmpty()); ResourceAttributeDefinition nameAttributeDefinition = accountDefinition.findAttributeDefinition(SchemaTestConstants.ICFS_NAME); - assertNotNull("No definition for attribute "+SchemaTestConstants.ICFS_NAME, nameAttributeDefinition); - assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not an identifier",nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); - assertTrue("Attribute "+SchemaTestConstants.ICFS_NAME+" in not in identifiers list",secondaryIdentifiers.contains(nameAttributeDefinition)); - assertEquals("Wrong displayName for attribute "+SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName()); - assertEquals("Wrong displayOrder for attribute "+SchemaTestConstants.ICFS_NAME, (Integer)110, nameAttributeDefinition.getDisplayOrder()); + assertNotNull("No definition for attribute " + SchemaTestConstants.ICFS_NAME, nameAttributeDefinition); + assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not an identifier", nameAttributeDefinition.isSecondaryIdentifier(accountDefinition)); + assertTrue("Attribute " + SchemaTestConstants.ICFS_NAME + " in not in identifiers list", secondaryIdentifiers.contains(nameAttributeDefinition)); + assertEquals("Wrong displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameAttributeDefinition.getDisplayName()); + assertEquals("Wrong displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameAttributeDefinition.getDisplayOrder()); assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers()); assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty()); @@ -883,11 +897,11 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertEquals(0, uidDef.getMinOccurs()); assertFalse("No UID display name", StringUtils.isBlank(uidDef.getDisplayName())); assertFalse("UID has create", uidDef.canAdd()); - assertFalse("UID has update",uidDef.canModify()); - assertTrue("No UID read",uidDef.canRead()); + assertFalse("UID has update", uidDef.canModify()); + assertTrue("No UID read", uidDef.canRead()); assertTrue("UID definition not in identifiers", accountDef.getPrimaryIdentifiers().contains(uidDef)); - assertEquals("Wrong refined displayName for attribute "+SchemaTestConstants.ICFS_UID, "ConnId UID", uidDef.getDisplayName()); - assertEquals("Wrong refined displayOrder for attribute "+SchemaTestConstants.ICFS_UID, (Integer)100, uidDef.getDisplayOrder()); + assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_UID, "ConnId UID", uidDef.getDisplayName()); + assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_UID, (Integer) 100, uidDef.getDisplayOrder()); ResourceAttributeDefinition nameDef = accountDef .findAttributeDefinition(SchemaTestConstants.ICFS_NAME); @@ -895,13 +909,13 @@ public static void assertIcfResourceSchemaSanity(ResourceSchema resourceSchema, assertEquals(1, nameDef.getMinOccurs()); assertFalse("No NAME displayName", StringUtils.isBlank(nameDef.getDisplayName())); assertTrue("No NAME create", nameDef.canAdd()); - assertTrue("No NAME update",nameDef.canModify()); - assertTrue("No NAME read",nameDef.canRead()); + assertTrue("No NAME update", nameDef.canModify()); + assertTrue("No NAME read", nameDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef)); - assertEquals("Wrong refined displayName for attribute "+SchemaTestConstants.ICFS_NAME, "ConnId Name", nameDef.getDisplayName()); - assertEquals("Wrong refined displayOrder for attribute "+SchemaTestConstants.ICFS_NAME, (Integer)110, nameDef.getDisplayOrder()); + assertEquals("Wrong refined displayName for attribute " + SchemaTestConstants.ICFS_NAME, "ConnId Name", nameDef.getDisplayName()); + assertEquals("Wrong refined displayOrder for attribute " + SchemaTestConstants.ICFS_NAME, (Integer) 110, nameDef.getDisplayOrder()); - assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaTestConstants.NS_ICFS,"password"))); + assertNull("The _PASSSWORD_ attribute sneaked into schema", accountDef.findAttributeDefinition(new QName(SchemaTestConstants.NS_ICFS, "password"))); } //TODO: add language parameter..for now, use xml serialization @@ -966,16 +980,16 @@ public static void assertGroupMember(DummyGroup group, String accountId) { public static void assertGroupMember(DummyGroup group, String accountId, boolean caseIgnore) { Collection members = group.getMembers(); - assertNotNull("No members in group "+group.getName()+", expected that "+accountId+" will be there", members); + assertNotNull("No members in group " + group.getName() + ", expected that " + accountId + " will be there", members); if (caseIgnore) { - for (String member: members) { + for (String member : members) { if (StringUtils.equalsIgnoreCase(accountId, member)) { return; } } - AssertJUnit.fail("Account "+accountId+" is not member of group "+group.getName()+", members: "+members); + AssertJUnit.fail("Account " + accountId + " is not member of group " + group.getName() + ", members: " + members); } else { - assertTrue("Account "+accountId+" is not member of group "+group.getName()+", members: "+members, members.contains(accountId)); + assertTrue("Account " + accountId + " is not member of group " + group.getName() + ", members: " + members, members.contains(accountId)); } } @@ -984,27 +998,27 @@ public static void assertNoGroupMember(DummyGroup group, String accountId) { if (members == null) { return; } - assertFalse("Account "+accountId+" IS member of group "+group.getName()+" while not expecting it, members: "+members, members.contains(accountId)); + assertFalse("Account " + accountId + " IS member of group " + group.getName() + " while not expecting it, members: " + members, members.contains(accountId)); } public static void assertNoGroupMembers(DummyGroup group) { Collection members = group.getMembers(); - assertTrue("Group "+group.getName()+" has members while not expecting it, members: "+members, members == null || members.isEmpty()); + assertTrue("Group " + group.getName() + " has members while not expecting it, members: " + members, members == null || members.isEmpty()); } public static ShadowAssociationType assertAssociation(PrismObject shadow, QName associationName, String entitlementOid) { ShadowType accountType = shadow.asObjectable(); List associations = accountType.getAssociation(); - assertNotNull("Null associations in "+shadow, associations); - assertFalse("Empty associations in "+shadow, associations.isEmpty()); - for (ShadowAssociationType association: associations) { + assertNotNull("Null associations in " + shadow, associations); + assertFalse("Empty associations in " + shadow, associations.isEmpty()); + for (ShadowAssociationType association : associations) { if (associationName.equals(association.getName()) && association.getShadowRef() != null && entitlementOid.equals(association.getShadowRef().getOid())) { return association; } } - AssertJUnit.fail("No association for entitlement "+entitlementOid+" in "+shadow); + AssertJUnit.fail("No association for entitlement " + entitlementOid + " in " + shadow); throw new IllegalStateException("not reached"); } @@ -1014,16 +1028,16 @@ public static void assertNoAssociation(PrismObject shadow, QName ass if (associations == null) { return; } - for (ShadowAssociationType association: associations) { + for (ShadowAssociationType association : associations) { if (associationName.equals(association.getName()) && entitlementOid.equals(association.getShadowRef().getOid())) { - AssertJUnit.fail("Unexpected association for entitlement "+entitlementOid+" in "+shadow); + AssertJUnit.fail("Unexpected association for entitlement " + entitlementOid + " in " + shadow); } } } public static void assertNoSchema(ResourceType resourceType) { - assertNoSchema("Found schema in resource "+resourceType+" while not expecting it", resourceType); + assertNoSchema("Found schema in resource " + resourceType + " while not expecting it", resourceType); } public static void assertNoSchema(String message, ResourceType resourceType) { @@ -1033,44 +1047,44 @@ public static void assertNoSchema(String message, ResourceType resourceType) { public static void assertConnectorSchemaSanity(ConnectorType conn, PrismContext prismContext) throws SchemaException { XmlSchemaType xmlSchemaType = conn.getSchema(); - assertNotNull("xmlSchemaType is null",xmlSchemaType); + assertNotNull("xmlSchemaType is null", xmlSchemaType); Element connectorXsdSchemaElement = ConnectorTypeUtil.getConnectorXsdSchema(conn); assertNotNull("No schema", connectorXsdSchemaElement); Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaType); - assertNotNull("No xsd:schema element in xmlSchemaType",xsdElement); - display("XSD schema of "+conn, DOMUtil.serializeDOMToString(xsdElement)); + assertNotNull("No xsd:schema element in xmlSchemaType", xsdElement); + display("XSD schema of " + conn, DOMUtil.serializeDOMToString(xsdElement)); // Try to parse the schema - PrismSchema schema = null; + PrismSchema schema; try { - schema = PrismSchemaImpl.parse(xsdElement, true, "schema of "+conn, prismContext); + schema = PrismSchemaImpl.parse(xsdElement, true, "schema of " + conn, prismContext); } catch (SchemaException e) { - throw new SchemaException("Error parsing schema of "+conn+": "+e.getMessage(),e); + throw new SchemaException("Error parsing schema of " + conn + ": " + e.getMessage(), e); } assertConnectorSchemaSanity(schema, conn.toString(), SchemaConstants.ICF_FRAMEWORK_URI.equals(conn.getFramework())); } public static void assertConnectorSchemaSanity(PrismSchema schema, String connectorDescription, boolean expectConnIdSchema) { - assertNotNull("Cannot parse connector schema of "+connectorDescription,schema); - assertFalse("Empty connector schema in "+connectorDescription,schema.isEmpty()); - display("Parsed connector schema of "+connectorDescription,schema); + assertNotNull("Cannot parse connector schema of " + connectorDescription, schema); + assertFalse("Empty connector schema in " + connectorDescription, schema.isEmpty()); + display("Parsed connector schema of " + connectorDescription, schema); // Local schema namespace is used here. PrismContainerDefinition configurationDefinition = - schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); - assertNotNull("Definition of property container not found in connector schema of "+connectorDescription, + schema.findItemDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), PrismContainerDefinition.class); + assertNotNull("Definition of property container not found in connector schema of " + connectorDescription, configurationDefinition); - assertFalse("Empty definition of property container in connector schema of "+connectorDescription, + assertFalse("Empty definition of property container in connector schema of " + connectorDescription, configurationDefinition.isEmpty()); if (expectConnIdSchema) { // ICFC schema is used on other elements PrismContainerDefinition configurationPropertiesDefinition = - configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); - assertNotNull("Definition of property container not found in connector schema of "+connectorDescription, + configurationDefinition.findContainerDefinition(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); + assertNotNull("Definition of property container not found in connector schema of " + connectorDescription, configurationPropertiesDefinition); - assertFalse("Empty definition of property container in connector schema of "+connectorDescription, + assertFalse("Empty definition of property container in connector schema of " + connectorDescription, configurationPropertiesDefinition.isEmpty()); - assertFalse("No definitions in in "+connectorDescription, configurationPropertiesDefinition.getDefinitions().isEmpty()); + assertFalse("No definitions in in " + connectorDescription, configurationPropertiesDefinition.getDefinitions().isEmpty()); // TODO: other elements } @@ -1087,58 +1101,60 @@ public static void assertProtectedString(String message, String expectedClearVal switch (storageType) { case NONE: - assertNull(message+": unexpected value: "+actualValue, actualValue); + assertNull(message + ": unexpected value: " + actualValue, actualValue); break; case ENCRYPTION: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": unencrypted value: "+actualValue, actualValue.isEncrypted()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": unencrypted value: " + actualValue, actualValue.isEncrypted()); String actualClearPassword = protector.decryptString(actualValue); - assertEquals(message+": wrong value", expectedClearValue, actualClearPassword); - assertFalse(message+": unexpected hashed value: "+actualValue, actualValue.isHashed()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertEquals(message + ": wrong value", expectedClearValue, actualClearPassword); + assertFalse(message + ": unexpected hashed value: " + actualValue, actualValue.isHashed()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; case HASHING: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": value not hashed: "+actualValue, actualValue.isHashed()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": value not hashed: " + actualValue, actualValue.isHashed()); ProtectedStringType expectedPs = new ProtectedStringType(); expectedPs.setClearValue(expectedClearValue); - assertTrue(message+": hash does not match, expected "+expectedClearValue+", but was "+actualValue, + assertTrue(message + ": hash does not match, expected " + expectedClearValue + ", but was " + actualValue, protector.compareCleartext(actualValue, expectedPs)); - assertFalse(message+": unexpected encrypted value: "+actualValue, actualValue.isEncrypted()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertFalse(message + ": unexpected encrypted value: " + actualValue, actualValue.isEncrypted()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } - public static void assertHasProtectedString(String message, ProtectedStringType actualValue, CredentialsStorageTypeType storageType, Protector protector) throws EncryptionException, SchemaException { + public static void assertHasProtectedString(String message, + ProtectedStringType actualValue, CredentialsStorageTypeType storageType, Protector protector) + throws EncryptionException { switch (storageType) { case NONE: - assertNull(message+": unexpected value: "+actualValue, actualValue); + assertNull(message + ": unexpected value: " + actualValue, actualValue); break; case ENCRYPTION: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": unencrypted value: "+actualValue, actualValue.isEncrypted()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": unencrypted value: " + actualValue, actualValue.isEncrypted()); protector.decryptString(actualValue); // just checking it can be decrypted - assertFalse(message+": unexpected hashed value: "+actualValue, actualValue.isHashed()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertFalse(message + ": unexpected hashed value: " + actualValue, actualValue.isHashed()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; case HASHING: - assertNotNull(message+": no value", actualValue); - assertTrue(message+": value not hashed: "+actualValue, actualValue.isHashed()); - assertFalse(message+": unexpected encrypted value: "+actualValue, actualValue.isEncrypted()); - assertNull(message+": unexpected clear value: "+actualValue, actualValue.getClearValue()); + assertNotNull(message + ": no value", actualValue); + assertTrue(message + ": value not hashed: " + actualValue, actualValue.isHashed()); + assertFalse(message + ": unexpected encrypted value: " + actualValue, actualValue.isEncrypted()); + assertNull(message + ": unexpected clear value: " + actualValue, actualValue.getClearValue()); break; default: - throw new IllegalArgumentException("Unknown storage "+storageType); + throw new IllegalArgumentException("Unknown storage " + storageType); } } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestContextWithTask.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestContextWithTask.java new file mode 100644 index 00000000000..615e2fe610f --- /dev/null +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestContextWithTask.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2019 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.test; + +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.tools.testng.MidpointTestContext; + +/** + * Value object carrying test context information like task, result and method name. + *

+ * Static methods are used for creating the context and working with it via {@link ThreadLocal}. + * It is important to to call {@link #destroy()} at the end (in some after-method). + */ +public final class MidpointTestContextWithTask implements MidpointTestContext { + + private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = + new ThreadLocal<>(); + + /** + * Actual test class - not abstract (where method may be implemented) but executed test class. + */ + private final Class testClass; + + /** + * Test method name. + */ + private final String methodName; + + /** + * Task used to execute the test. + */ + private final Task task; + + /** + * Top-level operation result for test execution. + */ + private final OperationResult result; + + private MidpointTestContextWithTask( + Class testClass, String methodName, Task task, OperationResult result) { + + this.testClass = testClass; + this.methodName = methodName; + this.task = task; + this.result = result; + } + + @Override + public Class getTestClass() { + return testClass; + } + + @Override + public String getTestMethodName() { + return methodName; + } + + public Task getTask() { + return task; + } + + public OperationResult getResult() { + return result; + } + + public static MidpointTestContextWithTask create( + Class testClass, String methodName, Task task, OperationResult result) { + + MidpointTestContextWithTask ctx = + new MidpointTestContextWithTask(testClass, methodName, task, result); + TEST_CONTEXT_THREAD_LOCAL.set(ctx); + return ctx; + } + + public static MidpointTestContextWithTask get() { + return TEST_CONTEXT_THREAD_LOCAL.get(); + } + + public static void destroy() { + TEST_CONTEXT_THREAD_LOCAL.remove(); + } +} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java deleted file mode 100644 index 6dd864dcbe2..00000000000 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/MidpointTestMethodContext.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2019 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.test; - -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; - -/** - * Thread-local context for midPoint test method. - */ -public final class MidpointTestMethodContext { - - private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = new ThreadLocal<>(); - - /** - * Test method name. - */ - private final String methodName; - - /** - * Task used to execute the test. - */ - private final Task task; - - /** - * Top-level operation result for test execution. - */ - private final OperationResult result; - - private MidpointTestMethodContext(String methodName, Task task, OperationResult result) { - this.methodName = methodName; - this.task = task; - this.result = result; - } - - public String getMethodName() { - return methodName; - } - - public Task getTask() { - return task; - } - - public OperationResult getResult() { - return result; - } - - public static MidpointTestMethodContext get() { - return TEST_CONTEXT_THREAD_LOCAL.get(); - } - - public static MidpointTestMethodContext setup(String methodName, Task task, OperationResult result) { - MidpointTestMethodContext ctx = new MidpointTestMethodContext(methodName, task, result); - TEST_CONTEXT_THREAD_LOCAL.set(ctx); - return ctx; - } - - public static void destroy() { - TEST_CONTEXT_THREAD_LOCAL.remove(); - } -} diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java index 52e83703e06..257403dda09 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/asserter/ResourceAsserter.java @@ -6,6 +6,12 @@ */ package com.evolveum.midpoint.test.asserter; +import static org.testng.AssertJUnit.assertNotNull; + +import static com.evolveum.midpoint.prism.Containerable.asPrismContainerValue; + +import org.w3c.dom.Element; + import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; @@ -16,16 +22,11 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import org.w3c.dom.Element; - -import static com.evolveum.midpoint.prism.Containerable.asPrismContainerValue; - -import static org.testng.AssertJUnit.assertNotNull; /** * @author Radovan Semancik */ -public class ResourceAsserter extends PrismObjectAsserter { +public class ResourceAsserter extends PrismObjectAsserter { public ResourceAsserter(PrismObject resource) { super(resource); @@ -85,11 +86,10 @@ public ResourceAsserter assertActiveLifecycleState() { public ResourceAsserter assertHasSchema() { Element schemaElement = ResourceTypeUtil.getResourceXsdSchema(getObject()); - assertNotNull("No schema in "+desc(), schemaElement); + assertNotNull("No schema in " + desc(), schemaElement); return this; } - @Override public ResourceAsserter display() { super.display(); @@ -135,7 +135,8 @@ public PrismContainerValueAsserter> o } public PrismContainerAsserter> operationalStateHistory() { - PrismContainer operationalStateHistory = getObject().findContainer(ResourceType.F_OPERATIONAL_STATE_HISTORY); + PrismContainer operationalStateHistory = + getObject().findContainer(ResourceType.F_OPERATIONAL_STATE_HISTORY); PrismContainerAsserter> asserter = new PrismContainerAsserter<>(operationalStateHistory, this, getDetails()); copySetupTo(asserter); diff --git a/repo/security-impl/pom.xml b/repo/security-impl/pom.xml index 9d147f3e0d6..76f0cffe90d 100644 --- a/repo/security-impl/pom.xml +++ b/repo/security-impl/pom.xml @@ -115,7 +115,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java index bd31481ce81..13767a27c58 100644 --- a/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java +++ b/repo/security-impl/src/test/java/com/evolveum/midpoint/security/impl/TestEmpty.java @@ -75,16 +75,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(TEST_NAME); - // TODO } @Test public void test020GuiProfiledPrincipalManagerMockUsername() throws Exception { final String TEST_NAME = "test020GuiProfiledPrincipalManagerMockUsername"; - displayTestTitle(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME, UserType.class); assertPrincipalJack(principal); diff --git a/repo/system-init/pom.xml b/repo/system-init/pom.xml index 58a0ce9786d..5390bb8c3ef 100644 --- a/repo/system-init/pom.xml +++ b/repo/system-init/pom.xml @@ -120,7 +120,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java b/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java index f5d016c3ea1..225dccce2b9 100644 --- a/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java +++ b/repo/system-init/src/test/java/com/evolveum/midpoint/init/TestConfigurationLoad.java @@ -7,32 +7,24 @@ package com.evolveum.midpoint.init; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import static org.testng.Assert.*; -import static org.testng.Assert.assertTrue; import java.io.File; import java.util.Iterator; -import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; import org.apache.commons.configuration2.Configuration; import org.testng.annotations.Test; +import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; - -public class TestConfigurationLoad { +import com.evolveum.midpoint.tools.testng.AbstractUnitTest; - private static final Trace LOGGER = TraceManager.getTrace(TestConfigurationLoad.class); +public class TestConfigurationLoad extends AbstractUnitTest { @Test public void test010SimpleConfigTest() { - LOGGER.info("---------------- test010SimpleConfigTest -----------------"); - System.clearProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY); - LOGGER.info("midpoint.home => {}", System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); + logger.info("midpoint.home => {}", System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); assertNull(System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY), "midpoint.home"); @@ -41,15 +33,15 @@ public void test010SimpleConfigTest() { Configuration c = sc.getConfiguration(MidpointConfiguration.REPOSITORY_CONFIGURATION); assertEquals(c.getString("repositoryServiceFactoryClass"), "com.evolveum.midpoint.repo.sql.SqlRepositoryFactory"); - LOGGER.info("{}", sc); + logger.info("{}", sc); Iterator i = c.getKeys(); while (i.hasNext()) { String key = i.next(); - LOGGER.info(" " + key + " = " + c.getString(key)); + logger.info(" " + key + " = " + c.getString(key)); } - assertEquals(c.getBoolean("asServer"), true); + assertTrue(c.getBoolean("asServer")); assertEquals(c.getString("baseDir"), System.getProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY)); } @@ -58,20 +50,18 @@ public void test010SimpleConfigTest() { */ @Test public void test020DirectoryAndExtractionTest() throws Exception { - LOGGER.info("---------------- test020DirectoryAndExtractionTest -----------------"); - File midpointHome = new File("target/midPointHome"); System.setProperty(MidpointConfiguration.MIDPOINT_HOME_PROPERTY, "target/midPointHome/"); StartupConfiguration sc = new StartupConfiguration(); sc.init(); assertNotNull(midpointHome); - assertTrue(midpointHome.exists(), "existence"); - assertTrue(midpointHome.isDirectory(), "type directory"); + assertTrue(midpointHome.exists(), "existence"); + assertTrue(midpointHome.isDirectory(), "type directory"); File configFile = new File(midpointHome, "config.xml"); - assertTrue(configFile.exists(), "existence"); - assertTrue(configFile.isFile(), "type file"); + assertTrue(configFile.exists(), "existence"); + assertTrue(configFile.isFile(), "type file"); TestUtil.assertPrivateFilePermissions(configFile); ConfigurableProtectorFactory keystoreFactory = new ConfigurableProtectorFactory(); @@ -79,8 +69,8 @@ public void test020DirectoryAndExtractionTest() throws Exception { keystoreFactory.init(); File keystoreFile = new File(midpointHome, "keystore.jceks"); - assertTrue(keystoreFile.exists(), "existence"); - assertTrue(keystoreFile.isFile(), "type file"); + assertTrue(keystoreFile.exists(), "existence"); + assertTrue(keystoreFile.isFile(), "type file"); TestUtil.assertPrivateFilePermissions(keystoreFile); //cleanup diff --git a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java index 36813c22268..cb8510e7a85 100644 --- a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java +++ b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java @@ -218,7 +218,7 @@ void modifyTask(String oid, Collection modifications, Opera /** * Creates new transient, running task instance. * - * This is fact creates usual "synchronous" task. + * This in fact creates usual "synchronous" task. * * This is useful for normal day-to-day tasks that are either * synchronous or start as a synchronous and are switched to diff --git a/repo/task-quartz-impl/pom.xml b/repo/task-quartz-impl/pom.xml index 25a818127e7..defcac15c63 100644 --- a/repo/task-quartz-impl/pom.xml +++ b/repo/task-quartz-impl/pom.xml @@ -165,13 +165,11 @@ com.evolveum.midpoint.tools test-ng - 4.1-SNAPSHOT test com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java index ed5e43b7970..94001b1a922 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/tracing/TracerImpl.java @@ -362,6 +362,7 @@ private Map createTemplateParameters(Task task, OperationResult rv.put(MACRO_OPERATION_NAME, operationName); rv.put(MACRO_OPERATION_NAME_SHORT, shorten(operationName)); String testName; + // TODO inttest: subclass TracerImpl in test scope with change here (use template method) if (TestNameHolder.getCurrentTestName() != null) { testName = TestNameHolder.getCurrentTestName(); } else { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java index b6bc3b72346..af26ad6c483 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/AbstractTaskManagerTest.java @@ -7,6 +7,21 @@ package com.evolveum.midpoint.task.quartzimpl; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import static com.evolveum.midpoint.test.IntegrationTestTools.waitFor; + +import java.io.File; +import java.io.IOException; +import java.math.BigInteger; +import java.util.*; + +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.BeforeSuite; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -21,33 +36,15 @@ import com.evolveum.midpoint.task.api.TaskDebugUtil; import com.evolveum.midpoint.task.api.TaskExecutionStatus; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.test.util.AbstractSpringTest; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testng.annotations.BeforeSuite; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; -import java.math.BigInteger; -import java.util.*; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static com.evolveum.midpoint.test.IntegrationTestTools.waitFor; -import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; -import static org.testng.AssertJUnit.*; -/** - * @author mederly - */ -public class AbstractTaskManagerTest extends AbstractTestNGSpringContextTests { +public class AbstractTaskManagerTest extends AbstractSpringTest { protected static final String CYCLE_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/cycle-task-handler"; protected static final String CYCLE_FINISHING_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/cycle-finishing-task-handler"; @@ -62,7 +59,6 @@ public class AbstractTaskManagerTest extends AbstractTestNGSpringContextTests { protected static final String L1_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l1-task-handler"; protected static final String L2_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l2-task-handler"; protected static final String L3_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/l3-task-handler"; - protected static final String WAIT_FOR_SUBTASKS_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/wait-for-subtasks-task-handler"; protected static final String PARALLEL_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/parallel-task-handler"; protected static final String LONG_TASK_HANDLER_URI = "http://midpoint.evolveum.com/test/long-task-handler"; @@ -87,8 +83,7 @@ public class AbstractTaskManagerTest extends AbstractTestNGSpringContextTests { protected MockParallelTaskHandler parallelTaskHandler; protected MockLongTaskHandler longTaskHandler; - protected static OperationResult createResult(String test, Trace logger) { - TestUtil.displayTestTitle(test); + protected static OperationResult createResult(String test) { return new OperationResult(TestQuartzTaskManagerContract.class.getName() + ".test" + test); } @@ -151,7 +146,7 @@ protected PrismObject addObjectFromFile(String filePat OperationResult result = new OperationResult(TestQuartzTaskManagerContract.class.getName() + ".addObjectFromFile"); try { add(object, result); - } catch(ObjectAlreadyExistsException e) { + } catch (ObjectAlreadyExistsException e) { delete(object, result); add(object, result); } @@ -162,7 +157,7 @@ protected PrismObject addObjectFromFile(String filePat protected void add(PrismObject object, OperationResult result) throws ObjectAlreadyExistsException, SchemaException { if (object.canRepresent(TaskType.class)) { - taskManager.addTask((PrismObject)object, result); + taskManager.addTask((PrismObject) object, result); } else { repositoryService.addObject(object, null, result); } @@ -216,12 +211,12 @@ protected void waitForTaskCloseCheckingSubtasks(String taskOid, OperationResult } protected void waitForTaskStart(String oid, OperationResult result, long timeoutInterval, long sleepInterval) throws CommonException { - waitFor("Waiting for task manager to start the task", () -> { - Task task = taskManager.getTaskWithResult(oid, result); - IntegrationTestTools.display("Task while waiting for task manager to start the task", task); - return task.getLastRunStartTimestamp() != null && task.getLastRunStartTimestamp() != 0L; - }, timeoutInterval, sleepInterval); - } + waitFor("Waiting for task manager to start the task", () -> { + Task task = taskManager.getTaskWithResult(oid, result); + IntegrationTestTools.display("Task while waiting for task manager to start the task", task); + return task.getLastRunStartTimestamp() != null && task.getLastRunStartTimestamp() != 0L; + }, timeoutInterval, sleepInterval); + } protected void waitForTaskProgress(String taskOid, OperationResult result, long timeoutInterval, long sleepInterval, int threshold) throws CommonException { @@ -232,17 +227,6 @@ protected void waitForTaskProgress(String taskOid, OperationResult result, long }, timeoutInterval, sleepInterval); } - protected void waitForTaskNextRun(String taskOid, OperationResult result, long timeoutInterval, long sleepInterval) throws Exception { - TaskQuartzImpl taskBefore = taskManager.getTaskWithResult(taskOid, result); - waitFor("Waiting for task manager to execute the task", () -> { - Task task = taskManager.getTaskWithResult(taskOid, result); - IntegrationTestTools.display("Task while waiting for task manager to execute the task", task); - return task.getLastRunStartTimestamp() != null && - (taskBefore.getLastRunStartTimestamp() == null || task.getLastRunStartTimestamp() > taskBefore.getLastRunStartTimestamp()); - }, timeoutInterval, sleepInterval); - } - - protected void suspendAndDeleteTasks(String... oids) { taskManager.suspendAndDeleteTasks(Arrays.asList(oids), 20000L, true, new OperationResult("dummy")); } diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java index 8c521ff929d..c605c2f01b6 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/CleanupTest.java @@ -7,45 +7,40 @@ package com.evolveum.midpoint.task.quartzimpl; -import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.repo.api.RepositoryService; -import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.io.File; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; -import javax.xml.datatype.XMLGregorianCalendar; - -import java.io.File; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; +import com.evolveum.midpoint.prism.Objectable; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.test.util.AbstractSpringTest; +import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; /** * @author lazyman */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class CleanupTest extends AbstractTestNGSpringContextTests { - - private static final Trace LOGGER = TraceManager.getTrace(CleanupTest.class); +public class CleanupTest extends AbstractSpringTest { public static final File FOLDER_BASIC = new File("./src/test/resources/basic"); @@ -54,7 +49,7 @@ public class CleanupTest extends AbstractTestNGSpringContextTests { @Autowired private RepositoryService repositoryService; @Autowired - private PrismContext prismContext; + private PrismContext prismContext; @Test public void testTasksCleanup() throws Exception { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java index 53fc7d11fbd..c315ffc22fa 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestMiscellaneous.java @@ -6,6 +6,24 @@ */ package com.evolveum.midpoint.task.quartzimpl; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.display; +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.xml.namespace.QName; + +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; + import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.MidPointPrismContextFactory; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -16,29 +34,10 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionLimitationsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskGroupExecutionLimitationType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import javax.xml.namespace.QName; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.display; -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.testng.AssertJUnit.assertEquals; - -/** - * - */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TestMiscellaneous { +public class TestMiscellaneous extends AbstractTaskManagerTest { @BeforeSuite public void setup() throws SchemaException, SAXException, IOException { diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java index e2a62db2dd5..734ac14fcd1 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestPartitioning.java @@ -99,7 +99,7 @@ public void test000Integrity() { @Test public void test100DurableRecurring() throws Exception { final String TEST_NAME = "test100DurableRecurring"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); // WHEN addObjectFromFile(taskFilename(TEST_NAME, "m")); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java index 38dccd32d87..ce1d4ab6745 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestQuartzTaskManagerContract.java @@ -112,7 +112,7 @@ public void test000Integrity() { @Test public void test003GetProgress() throws Exception { String TEST_NAME = "test003GetProgress"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -126,7 +126,7 @@ public void test003GetProgress() throws Exception { @Test(enabled=false) // this is probably OK to fail, so do not enable it (at least for now) public void test004aTaskBigProperty() throws Exception { String TEST_NAME = "test004aTaskBigProperty"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); String string300 = "123456789-123456789-123456789-123456789-123456789-" + "123456789-123456789-123456789-123456789-123456789-" @@ -190,7 +190,7 @@ public void test004aTaskBigProperty() throws Exception { @Test public void test004bTaskBigProperty() throws Exception { String TEST_NAME = "test004aTaskBigProperty"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); String string300 = "123456789-123456789-123456789-123456789-123456789-" + "123456789-123456789-123456789-123456789-123456789-" @@ -248,7 +248,7 @@ public void test004bTaskBigProperty() throws Exception { @Test(enabled = false) public void test004cReferenceInExtension() throws Exception { // ok to fail String TEST_NAME = "test004cReferenceInExtension"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = getTask(taskOid(TEST_NAME), result); @@ -270,7 +270,7 @@ public void test004cReferenceInExtension() throws Exception { // o @Test(enabled = false) public void test004TaskProperties() throws Exception { String TEST_NAME = "test004TaskProperties"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -435,7 +435,7 @@ public void test004TaskProperties() throws Exception { @Test public void test005Single() throws Exception { final String TEST_NAME = "test005Single"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on the handler singleHandler1.resetHasRun(); @@ -512,7 +512,7 @@ public void test005Single() throws Exception { @Test public void test006Cycle() throws Exception { final String TEST_NAME = "test006Cycle"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // But before that check sanity ... a known problem with xsi:type PrismObject object = addObjectFromFile(taskFilename(TEST_NAME)); @@ -593,7 +593,7 @@ private void assertSuccessOrInProgress(Task task) { @Test public void test008MoreHandlers() throws Exception { final String TEST_NAME = "test008MoreHandlers"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers singleHandler1.resetHasRun(); @@ -649,7 +649,7 @@ public void test008MoreHandlers() throws Exception { @Test public void test009CycleLoose() throws Exception { final String TEST_NAME = "test009CycleLoose"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -694,7 +694,7 @@ public void test009CycleLoose() throws Exception { @Test public void test010CycleCronLoose() throws Exception { final String TEST_NAME = "test010CycleCronLoose"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -732,7 +732,7 @@ public void test010CycleCronLoose() throws Exception { @Test public void test011MoreHandlersAndSchedules() throws Exception { final String TEST_NAME = "test011MoreHandlersAndSchedules"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers l1Handler.resetHasRun(); @@ -800,7 +800,7 @@ public void test011MoreHandlersAndSchedules() throws Exception { @Test public void test012Suspend() throws Exception { final String TEST_NAME = "test012Suspend"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -846,7 +846,7 @@ public void test012Suspend() throws Exception { @Test public void test013ReleaseAndSuspendLooselyBound() throws Exception { final String TEST_NAME = "test013ReleaseAndSuspendLooselyBound"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -903,7 +903,7 @@ public void test013ReleaseAndSuspendLooselyBound() throws Exception { @Test public void test014SuspendLongRunning() throws Exception { final String TEST_NAME = "test014SuspendLongRunning"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -962,7 +962,7 @@ public void test014SuspendLongRunning() throws Exception { @Test public void test015DeleteTaskFromRepo() throws Exception { final String TEST_NAME = "test015DeleteTaskFromRepo"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); String oid = taskOid(TEST_NAME); @@ -998,7 +998,7 @@ public void timeout() { @Test public void test016WaitForSubtasks() throws Exception { final String TEST_NAME = "test016WaitForSubtasks"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); //taskManager.getClusterManager().startClusterManagerThread(); @@ -1080,7 +1080,7 @@ public void test016WaitForSubtasks() throws Exception { @Test public void test017WaitForSubtasksEmpty() throws Exception { final String TEST_NAME = "test017WaitForSubtasksEmpty"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getClusterManager().startClusterManagerThread(); @@ -1096,7 +1096,7 @@ public void test017WaitForSubtasksEmpty() throws Exception { @Test public void test018TaskResult() throws Exception { final String TEST_NAME = "test018RefreshingResult"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); Task task = taskManager.createTaskInstance(); task.setInitialExecutionStatus(TaskExecutionStatus.SUSPENDED); @@ -1123,7 +1123,7 @@ public void test018TaskResult() throws Exception { @Test public void test019FinishedHandler() throws Exception { final String TEST_NAME = "test019FinishedHandler"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); // reset 'has run' flag on handlers singleHandler1.resetHasRun(); @@ -1172,7 +1172,7 @@ public void test019FinishedHandler() throws Exception { @Test public void test020QueryByExecutionStatus() throws Exception { final String TEST_NAME = "test020QueryByExecutionStatus"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.createTaskInstance((PrismObject) (PrismObject) addObjectFromFile(taskFilename(TEST_NAME)), result); @@ -1192,7 +1192,7 @@ public void test020QueryByExecutionStatus() throws Exception { @Test public void test021DeleteTaskTree() throws Exception { final String TEST_NAME = "test021DeleteTaskTree"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); PrismObject parentTaskPrism = addObjectFromFile(taskFilename(TEST_NAME)); PrismObject childTask1Prism = addObjectFromFile(taskFilename(TEST_NAME+"-child1")); @@ -1247,7 +1247,7 @@ public void test021DeleteTaskTree() throws Exception { @Test public void test022ExecuteRecurringOnDemand() throws Exception { final String TEST_NAME = "test022ExecuteRecurringOnDemand"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1292,7 +1292,7 @@ public void test022ExecuteRecurringOnDemand() throws Exception { @Test public void test100LightweightSubtasks() throws Exception { final String TEST_NAME = "test100LightweightSubtasks"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1340,7 +1340,7 @@ private void checkTaskStateRepeatedly(String taskOid, OperationResult result, in @Test public void test105LightweightSubtasksSuspension() throws Exception { final String TEST_NAME = "test105LightweightSubtasksSuspension"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); @@ -1389,7 +1389,7 @@ public void test105LightweightSubtasksSuspension() throws Exception { @Test public void test108SecondaryGroupLimit() throws Exception { final String TEST_NAME = "test108SecondaryGroupLimit"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); TaskType task1 = (TaskType) addObjectFromFile(taskFilename(TEST_NAME)).asObjectable(); waitForTaskStart(task1.getOid(), result, 10000, 500); @@ -1448,7 +1448,7 @@ protected void assertNextRetryTimeSet(TaskType task, OperationResult result) @Test public void test110GroupLimit() throws Exception { final String TEST_NAME = "test110GroupLimit"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getExecutionManager().setLocalExecutionLimitations((TaskExecutionLimitationsType) null); @@ -1487,7 +1487,7 @@ private TaskType getTaskType(String oid, OperationResult result) throws SchemaEx @Test public void test120NodeAllowed() throws Exception { final String TEST_NAME = "test120NodeAllowed"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); taskManager.getExecutionManager().setLocalExecutionLimitations( new TaskExecutionLimitationsType() @@ -1504,7 +1504,7 @@ public void test120NodeAllowed() throws Exception { @Test public void test130NodeNotAllowed() throws Exception { final String TEST_NAME = "test130NodeNotAllowed"; - final OperationResult result = createResult(TEST_NAME, LOGGER); + final OperationResult result = createResult(TEST_NAME); TaskType task = (TaskType) addObjectFromFile(taskFilename(TEST_NAME)).asObjectable(); Thread.sleep(10000); @@ -1516,7 +1516,7 @@ public void test130NodeNotAllowed() throws Exception { @Test public void test999CheckingLeftovers() throws Exception { String TEST_NAME = "test999CheckingLeftovers"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); ArrayList leftovers = new ArrayList<>(); checkLeftover(leftovers, "test005", result); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java index 4996019d20d..e863887be25 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkBucketStrategies.java @@ -113,7 +113,7 @@ public void test000Integrity() { @Test public void test100NumericExplicitBuckets() throws Exception { final String TEST_NAME = "test100NumericExplicitBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -194,7 +194,7 @@ public void test100NumericExplicitBuckets() throws Exception { @Test public void test110FilterExplicitBuckets() throws Exception { final String TEST_NAME = "test110FilterExplicitBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -282,7 +282,7 @@ public void test110FilterExplicitBuckets() throws Exception { @Test public void test120StringPrefixBuckets() throws Exception { final String TEST_NAME = "test120StringPrefixBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -338,7 +338,7 @@ public void test120StringPrefixBuckets() throws Exception { @Test public void test125StringExactValueBuckets() throws Exception { final String TEST_NAME = "test125StringExactValueBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -394,7 +394,7 @@ public void test125StringExactValueBuckets() throws Exception { @Test public void test130StringIntervalBuckets() throws Exception { final String TEST_NAME = "test130StringIntervalBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -444,7 +444,7 @@ public void test130StringIntervalBuckets() throws Exception { @Test public void test140OidBuckets() throws Exception { final String TEST_NAME = "test140OidBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -463,7 +463,7 @@ public void test140OidBuckets() throws Exception { @Test public void test150OidBucketsTwice() throws Exception { final String TEST_NAME = "test150OidBucketsTwice"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java index 34b33de474f..8413a7e0918 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkDistribution.java @@ -117,7 +117,7 @@ public void test000Integrity() { @Test public void test100AllocateBucket() throws Exception { final String TEST_NAME = "test100AllocateBucket"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); @@ -150,7 +150,7 @@ public void test100AllocateBucket() throws Exception { @Test public void test105AllocateBucketStandalone() throws Exception { final String TEST_NAME = "test105AllocateBucketStandalone"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -177,7 +177,7 @@ public void test105AllocateBucketStandalone() throws Exception { @Test public void test107AllocateBucketStandaloneBatched() throws Exception { final String TEST_NAME = "test107AllocateBucketStandaloneBatched"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -204,7 +204,7 @@ public void test107AllocateBucketStandaloneBatched() throws Exception { public void test110AllocateTwoBucketsStandalone() throws Exception { final String TEST_NAME = "test110AllocateTwoBucketsStandalone"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl standalone = taskManager.getTask(taskOid(TEST_NAME), result); @@ -271,7 +271,7 @@ public void test110AllocateTwoBucketsStandalone() throws Exception { @Test public void test120UnspecifiedBuckets() throws Exception { final String TEST_NAME = "test120UnspecifiedBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(taskFilename(TEST_NAME)); TaskQuartzImpl task = taskManager.getTask(taskOid(TEST_NAME), result); @@ -288,7 +288,7 @@ public void test120UnspecifiedBuckets() throws Exception { @Test public void test130AllocateReleaseCompleteSequence() throws Exception { final String TEST_NAME = "test130AllocateReleaseCompleteSequence"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -516,7 +516,7 @@ public void test130AllocateReleaseCompleteSequence() throws Exception { @Test public void test200OneWorkerTask() throws Exception { final String TEST_NAME = "test200OneWorkerTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); @@ -544,7 +544,7 @@ public void test200OneWorkerTask() throws Exception { @Test public void test210ThreeWorkersTask() throws Exception { final String TEST_NAME = "test210ThreeWorkersTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -596,7 +596,7 @@ public void test210ThreeWorkersTask() throws Exception { @Test public void test220WorkerSuspend() throws Exception { final String TEST_NAME = "test220WorkerSuspend"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -623,13 +623,13 @@ public void test220WorkerSuspend() throws Exception { }); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); taskManager.resumeTask(worker1, result); taskManager.resumeTask(worker2, result); taskManager.resumeTask(worker3, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); waitFor("waiting for all items to be processed", () -> getTotalItemsProcessed(coordinatorTaskOid) == 107 - 6, DEFAULT_TIMEOUT, 500); @@ -656,7 +656,7 @@ public void test220WorkerSuspend() throws Exception { // TODO other asserts // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); workBucketsTaskHandler.setDelayProcessor(50); @@ -665,7 +665,7 @@ public void test220WorkerSuspend() throws Exception { taskManager.deleteTask(oidToDelete, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Waiting for coordinator task close"); waitForTaskClose(coordinatorTaskOid, result, DEFAULT_TIMEOUT, 200); @@ -685,7 +685,7 @@ public void test220WorkerSuspend() throws Exception { @Test public void test230WorkerException() throws Exception { final String TEST_NAME = "test230WorkerException"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(taskFilename(TEST_NAME, "1")); addObjectFromFile(taskFilename(TEST_NAME, "2")); @@ -708,13 +708,13 @@ public void test230WorkerException() throws Exception { }); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); taskManager.resumeTask(worker1, result); taskManager.resumeTask(worker2, result); taskManager.resumeTask(worker3, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); waitFor("waiting for all items to be processed", () -> getTotalItemsProcessed(coordinatorTaskOid) == 107 - 6, DEFAULT_TIMEOUT, 500); @@ -741,7 +741,7 @@ public void test230WorkerException() throws Exception { // TODO other asserts // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); workBucketsTaskHandler.setDelayProcessor(50); @@ -750,7 +750,7 @@ public void test230WorkerException() throws Exception { taskManager.closeTask(taskManager.getTask(oidToClose, result), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Waiting for coordinator task close"); waitForTaskClose(coordinatorTaskOid, result, DEFAULT_TIMEOUT, 200); @@ -778,7 +778,7 @@ public void test230WorkerException() throws Exception { @Test public void test300NarrowQueryOneWorkerTask() throws Exception { final String TEST_NAME = "test300NarrowQueryOneWorkerTask"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); addObjectFromFile(workerTaskFilename(TEST_NAME)); diff --git a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java index 7db345d6add..1b3a2913d9a 100644 --- a/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java +++ b/repo/task-quartz-impl/src/test/java/com/evolveum/midpoint/task/quartzimpl/TestWorkersManagement.java @@ -6,6 +6,22 @@ */ package com.evolveum.midpoint.task.quartzimpl; +import static java.util.Collections.singleton; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.test.IntegrationTestTools.display; + +import java.util.List; +import javax.annotation.PostConstruct; +import javax.xml.namespace.QName; + +import org.jetbrains.annotations.NotNull; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.schema.cache.CacheConfigurationManager; import com.evolveum.midpoint.schema.result.OperationResult; @@ -14,27 +30,7 @@ import com.evolveum.midpoint.task.quartzimpl.work.WorkStateManager; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; -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 org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import javax.annotation.PostConstruct; -import javax.xml.namespace.QName; -import java.util.List; - -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static com.evolveum.midpoint.test.util.TestUtil.displayThen; -import static com.evolveum.midpoint.test.util.TestUtil.displayWhen; -import static java.util.Collections.singleton; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; /** * Tests task handlers for workers creation and for task partitioning. @@ -42,11 +38,10 @@ * @author mederly */ -@ContextConfiguration(locations = {"classpath:ctx-task-test.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-task-test.xml" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class TestWorkersManagement extends AbstractTaskManagerTest { - private static final Trace LOGGER = TraceManager.getTrace(TestWorkersManagement.class); private static final long DEFAULT_SLEEP_INTERVAL = 250L; private static final long DEFAULT_TIMEOUT = 30000L; @@ -116,7 +111,7 @@ public void test000Integrity() { @Test public void test100CreateWorkersSingle() throws Exception { final String TEST_NAME = "test100CreateWorkersSingle"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); workBucketsTaskHandler.resetBeforeTest(); workBucketsTaskHandler.setDelayProcessor(DEFAULT_SLEEP_INTERVAL); @@ -177,19 +172,19 @@ private void displayBucketOpStatistics(String label, Task task) throws SchemaExc @Test public void test110CreateWorkersRecurring() throws Exception { final String TEST_NAME = "test110CreateWorkersRecurring"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); workBucketsTaskHandler.resetBeforeTest(); workBucketsTaskHandler.setDelayProcessor(DEFAULT_SLEEP_INTERVAL); // (1) ------------------------------------------------------------------------------------ WHEN (import task) - displayWhen(TEST_NAME, "1: import task"); + when("1: import task"); addObjectFromFile(coordinatorTaskFilename(TEST_NAME)); String coordinatorTaskOid = coordinatorTaskOid(TEST_NAME); try { // THEN (worker is created and executed) - displayThen(TEST_NAME, "1: import task"); + then("1: import task"); waitForTaskProgress(coordinatorTaskOid, result, DEFAULT_TIMEOUT, DEFAULT_SLEEP_INTERVAL, 1); TaskQuartzImpl coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); @@ -207,12 +202,12 @@ public void test110CreateWorkersRecurring() throws Exception { // coordinator should run automatically in cca 15 seconds // (2) ------------------------------------------------------------------------------------ WHEN (wait for coordinator next run) - displayWhen(TEST_NAME, "2: wait for coordinator next run"); + when("2: wait for coordinator next run"); // TODO adapt this when the coordinator progress will be reported in other ways waitForTaskProgress(coordinatorTaskOid, result, 30000, DEFAULT_SLEEP_INTERVAL, 2); // THEN (worker is still present and executed) - displayThen(TEST_NAME, "2: wait for coordinator next run"); + then("2: wait for coordinator next run"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -225,11 +220,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong # of items processed", 8, workBucketsTaskHandler.getItemsProcessed()); // (3) ------------------------------------------------------------------------------------ WHEN (suspend the tree while work is done) - displayWhen(TEST_NAME, "3: suspend the tree while work is done"); + when("3: suspend the tree while work is done"); boolean stopped = taskManager.suspendTaskTree(coordinatorTaskOid, DEFAULT_TIMEOUT, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "3: suspend the tree while work is done"); + then("3: suspend the tree while work is done"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -250,11 +245,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong state-before-suspend of worker", null, worker.getStateBeforeSuspend()); // (4) ------------------------------------------------------------------------------------ WHEN (resume the tree) - displayWhen(TEST_NAME, "4: resume the tree"); + when("4: resume the tree"); taskManager.resumeTaskTree(coordinatorTaskOid, result); // THEN (tasks are resumed) - displayThen(TEST_NAME, "4: resume the tree"); + then("4: resume the tree"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -271,12 +266,12 @@ public void test110CreateWorkersRecurring() throws Exception { assertEquals("Wrong state-before-suspend of worker", null, worker.getStateBeforeSuspend()); // (5) ------------------------------------------------------------------------------------ WHEN (suspend the tree while worker is executing) - displayWhen(TEST_NAME, "5: suspend the tree while worker is executing"); + when("5: suspend the tree while worker is executing"); waitForTaskProgress(coordinatorTaskOid, result, DEFAULT_TIMEOUT, DEFAULT_SLEEP_INTERVAL, 3); stopped = taskManager.suspendTaskTree(coordinatorTaskOid, DEFAULT_TIMEOUT, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "5: suspend the tree while worker is executing"); + then("5: suspend the tree while worker is executing"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -297,11 +292,11 @@ public void test110CreateWorkersRecurring() throws Exception { assertTrue("tasks were not stopped", stopped); // (6) ------------------------------------------------------------------------------------ WHEN (resume after 2nd suspend) - displayWhen(TEST_NAME, "6: resume after 2nd suspend"); + when("6: resume after 2nd suspend"); taskManager.resumeTaskTree(coordinatorTaskOid, result); // THEN (tasks are suspended) - displayThen(TEST_NAME, "6: resume after 2nd suspend"); + then("6: resume after 2nd suspend"); coordinatorTask = taskManager.getTask(coordinatorTaskOid(TEST_NAME), result); workers = coordinatorTask.listSubtasks(result); assertEquals("Wrong # of workers", 1, workers.size()); @@ -327,7 +322,7 @@ public void test110CreateWorkersRecurring() throws Exception { @Test public void test200SimplePartitioning() throws Exception { final String TEST_NAME = "test200SimplePartitioning"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setEnsureSingleRunner(true); @@ -377,7 +372,7 @@ public void test200SimplePartitioning() throws Exception { @Test public void test210PartitioningToWorkersSingleBucket() throws Exception { final String TEST_NAME = "test210PartitioningToWorkersSingleBucket"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setEnsureSingleRunner(true); @@ -442,7 +437,7 @@ public void test210PartitioningToWorkersSingleBucket() throws Exception { @Test public void test220PartitioningToWorkersMoreBuckets() throws Exception { final String TEST_NAME = "test220PartitioningToWorkersMoreBuckets"; - OperationResult result = createResult(TEST_NAME, LOGGER); + OperationResult result = createResult(TEST_NAME); partitionedWorkBucketsTaskHandler.resetBeforeTest(); partitionedWorkBucketsTaskHandler.setDelayProcessor(50L); diff --git a/testing/conntest/pom.xml b/testing/conntest/pom.xml index c97091cf160..f4055defe2d 100644 --- a/testing/conntest/pom.xml +++ b/testing/conntest/pom.xml @@ -19,6 +19,11 @@ midPoint Testing - Resource Connection Tests + + + true + + com.evolveum.midpoint.infra @@ -170,7 +175,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -214,29 +218,23 @@ - - - - - conntest - - - - maven-surefire-plugin - - false - alphabetical - - - - maven-failsafe-plugin - - false - alphabetical - - - - - - + + + + maven-surefire-plugin + + + true + alphabetical + + + + maven-failsafe-plugin + + ${skipConnTests} + alphabetical + + + + diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java index 348c7f16f3b..9b06ca531fd 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsDnTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,33 +6,20 @@ */ package com.evolveum.midpoint.testing.conntest; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; -import java.io.File; - import javax.xml.namespace.QName; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; -import com.evolveum.midpoint.schema.processor.ResourceSchema; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik - * */ @Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) public abstract class Abstract389DsDnTest extends Abstract389DsTest { @@ -53,10 +40,7 @@ protected boolean isUsingGroupShortcutAttribute() { } @Test - public void test025SchemaDn() throws Exception { - final String TEST_NAME = "test025SchemaDn"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test025SchemaDn() { ResourceAttributeDefinition dnDef = accountObjectClassDefinition.findAttributeDefinition("dn"); display("DN defintion", dnDef); PrismAsserts.assertDefinition(dnDef, new QName(MidPointConstants.NS_RI, "dn"), DOMUtil.XSD_STRING, 1, 1); @@ -68,5 +52,4 @@ public void test025SchemaDn() throws Exception { assertTrue("Secodary identifiers are not empty: "+accountObjectClassDefinition.getSecondaryIdentifiers(), accountObjectClassDefinition.getSecondaryIdentifiers().isEmpty()); } - } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java index 70caf582e39..73234988f07 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsNsUniqueIdTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java index 1f5558a4afc..8a34a8f3aa7 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Abstract389DsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java index 371f8397923..f8a5f33bb80 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractEDirTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,20 +6,15 @@ */ package com.evolveum.midpoint.testing.conntest; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.*; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; import java.io.File; import java.io.IOException; import java.util.Collection; - import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; @@ -31,6 +26,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.SearchResultMetadata; @@ -49,23 +45,14 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractEDirTest extends AbstractLdapTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "edir"); @@ -165,10 +152,9 @@ private QName getAssociationGroupQName() { } protected String getOrgGroupsLdapSuffix() { - return "ou=orggroups,"+getLdapSuffix(); + return "ou=orggroups," + getLdapSuffix(); } - @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); @@ -187,9 +173,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertLdapPassword(ACCOUNT_JACK_UID, ACCOUNT_JACK_PASSWORD); assertEDirGroupMember(ACCOUNT_JACK_UID, GROUP_PIRATES_NAME); cleanupDelete(toAccountDn(USER_BARBOSSA_USERNAME)); @@ -200,10 +183,7 @@ public void test000Sanity() throws Exception { } @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); @@ -215,11 +195,8 @@ public void test050Capabilities() throws Exception { @Test public void test100SeachJackByLdapUid() throws Exception { - final String TEST_NAME = "test100SeachJackByLdapUid"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -228,21 +205,21 @@ public void test100SeachJackByLdapUid() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); assertAccountShadow(shadow, toAccountDn(ACCOUNT_JACK_UID)); assertShadowLockout(shadow, LockoutStatusType.NORMAL); jackAccountOid = shadow.getOid(); - assertNotNull("Null OID in "+shadow, jackAccountOid); + assertNotNull("Null OID in " + shadow, jackAccountOid); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -255,11 +232,8 @@ public void test100SeachJackByLdapUid() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -269,14 +243,14 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -293,11 +267,8 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -306,7 +277,7 @@ public void test110GetJack() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN @@ -326,11 +297,8 @@ public void test110GetJack() throws Exception { @Test public void test120JackLockout() throws Exception { - final String TEST_NAME = "test120JackLockout"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); makeBadLoginAttempt(ACCOUNT_JACK_UID); @@ -346,15 +314,15 @@ public void test120JackLockout() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -375,16 +343,13 @@ public void test120JackLockout() throws Exception { */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, NUMBER_OF_ACCOUNTS, task, result); + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -397,18 +362,15 @@ public void test150SeachAllAccounts() throws Exception { @Test public void test190SeachLockedAccounts() throws Exception { - final String TEST_NAME = "test190SeachLockedAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassFilterPrefix(getResourceOid(), getAccountObjectClass(), prismContext) .and().item(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS).eq(LockoutStatusType.LOCKED) .build(); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 1, task, result); + SearchResultList> searchResultList = doSearch(query, 1, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -426,20 +388,17 @@ public void test190SeachLockedAccounts() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -455,7 +414,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes()), accountBarbossaIcfUid); @@ -463,19 +422,16 @@ public void test200AssignAccountBarbossa() throws Exception { assertPasswordAllowChange(shadow, null); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimestamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); Long createTimestamp = createTimestampAttribute.getRealValue(); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-1000, roundTsUp(tsEnd)+1000, createTimestamp); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 1000, roundTsUp(tsEnd) + 1000, createTimestamp); } @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -487,11 +443,11 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { delta.addModification(attrDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -505,22 +461,19 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue("hereThereBeMonsters"); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -535,19 +488,16 @@ public void test220ModifyUserBarbossaPassword() throws Exception { @Test public void test230DisableBarbossa() throws Exception { - final String TEST_NAME = "test230DisableBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -564,19 +514,16 @@ public void test230DisableBarbossa() throws Exception { @Test public void test239EnableBarbossa() throws Exception { - final String TEST_NAME = "test239EnableBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -596,11 +543,8 @@ public void test239EnableBarbossa() throws Exception { */ @Test public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Exception { - final String TEST_NAME = "test240ModifyAccountBarbossaPasswordAllowChangeFalse"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -612,11 +556,11 @@ public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Except delta.addModification(attrDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -638,21 +582,18 @@ public void test240ModifyAccountBarbossaPasswordAllowChangeFalse() throws Except */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -673,19 +614,16 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -704,19 +642,16 @@ public void test260EnableGyubrush() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -737,19 +672,16 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); renameObject(UserType.class, USER_BARBOSSA_OID, USER_CPTBARBOSSA_USERNAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -772,11 +704,8 @@ public void test390ModifyUserBarbossaRename() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate(); @@ -790,11 +719,11 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -809,19 +738,16 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -839,19 +765,16 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { @Test public void test520RenameOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test520RenameOrgMeleeIsland"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); renameObject(OrgType.class, orgMeleeIslandOid, GROUP_MELA_NOVA_NAME, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -866,21 +789,18 @@ public void test520RenameOrgMeleeIsland() throws Exception { // Wait until the lockout of Jack expires, check status @Test public void test800JackLockoutExpires() throws Exception { - final String TEST_NAME = "test800JackLockoutExpires"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long now = System.currentTimeMillis(); - long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS*1000; + long lockoutExpires = jackLockoutTimestamp + LOCKOUT_EXPIRATION_SECONDS * 1000; if (now < lockoutExpires) { - display("Sleeping for "+(lockoutExpires-now)+"ms (waiting for lockout expiration)"); - Thread.sleep(lockoutExpires-now); + display("Sleeping for " + (lockoutExpires - now) + "ms (waiting for lockout expiration)"); + Thread.sleep(lockoutExpires - now); } now = System.currentTimeMillis(); - display("Time is now "+now); + display("Time is now " + now); ObjectQuery query = createUidQuery(ACCOUNT_JACK_UID); @@ -888,15 +808,15 @@ public void test800JackLockoutExpires() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -914,17 +834,14 @@ public void test800JackLockoutExpires() throws Exception { @Test public void test810SeachLockedAccounts() throws Exception { - final String TEST_NAME = "test810SeachLockedAccounts"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassFilterPrefix(getResourceOid(), getAccountObjectClass(), prismContext) .and().item(ShadowType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS).eq(LockoutStatusType.LOCKED) .build(); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 0, task, result); + SearchResultList> searchResultList = doSearch(query, 0, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -932,11 +849,8 @@ public void test810SeachLockedAccounts() throws Exception { @Test public void test820JackLockoutAndUnlock() throws Exception { - final String TEST_NAME = "test820JackLockoutAndUnlock"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); makeBadLoginAttempt(ACCOUNT_JACK_UID); @@ -952,7 +866,7 @@ public void test820JackLockoutAndUnlock() throws Exception { SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadowLocked = shadows.get(0); display("Locked shadow", shadowLocked); assertAccountShadow(shadowLocked, toAccountDn(ACCOUNT_JACK_UID)); @@ -962,12 +876,12 @@ public void test820JackLockoutAndUnlock() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(ShadowType.class, shadowLocked.getOid(), PATH_ACTIVATION_LOCKOUT_STATUS, task, result, LockoutStatusType.NORMAL); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -994,21 +908,18 @@ public void test820JackLockoutAndUnlock() throws Exception { @Test public void test890UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test890UnAssignBarbossaPirates"; - TestUtil.displayTestTitle(this, TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1029,19 +940,16 @@ public void test890UnAssignBarbossaPirates() throws Exception { @Test public void test899UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test899UnAssignAccountBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1058,21 +966,21 @@ public void test899UnAssignAccountBarbossa() throws Exception { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9]+")); } protected void assertPasswordAllowChange(PrismObject shadow, Boolean expected) throws SchemaException { Boolean passwordAllowChange = ShadowUtil.getAttributeValue(shadow, new QName(MidPointConstants.NS_RI, "passwordAllowChange")); - assertEquals("Wrong passwordAllowChange in "+shadow, expected, passwordAllowChange); + assertEquals("Wrong passwordAllowChange in " + shadow, expected, passwordAllowChange); } private void makeBadLoginAttempt(String uid) throws LdapException, IOException { try { LdapNetworkConnection conn = ldapConnect(toAccountDn(uid), "thisIsAwRoNgPASSW0RD"); if (conn.isAuthenticated()) { - AssertJUnit.fail("Bad authentication went good for "+uid); + AssertJUnit.fail("Bad authentication went good for " + uid); } } catch (SecurityException e) { // this is expected @@ -1102,6 +1010,6 @@ private void assertEDirNoGroupMember(Entry accountEntry, String groupName) throw } protected String toOrgGroupDn(String cn) { - return "cn="+cn+","+getOrgGroupsLdapSuffix(); + return "cn=" + cn + "," + getOrgGroupsLdapSuffix(); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java index 9d78ba1afa9..856ab66fb89 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java @@ -1,44 +1,36 @@ -package com.evolveum.midpoint.testing.conntest; /* * 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.testing.conntest; +import static org.testng.AssertJUnit.*; import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; import java.io.File; import java.io.IOException; import java.util.Collection; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.util.MiscUtil; - +import org.apache.commons.lang.mutable.MutableInt; +import org.apache.directory.api.ldap.model.entry.Entry; +import org.apache.directory.api.ldap.model.exception.LdapException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import org.apache.commons.lang.mutable.MutableInt; -import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.api.ldap.model.exception.LdapException; +import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -58,33 +50,19 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -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.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractLdapConnTest extends AbstractLdapSynchronizationTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapConnTest.class); - protected static final String ACCOUNT_IDM_DN = "uid=idm,ou=Administrators,dc=example,dc=com"; protected static final String ACCOUNT_0_UID = "u00000000"; protected static final String ACCOUNT_19_UID = "u00000019"; @@ -105,10 +83,10 @@ public abstract class AbstractLdapConnTest extends AbstractLdapSynchronizationTe private static final String USER_LARGO_GIVEN_NAME = "Largo"; private static final String USER_LARGO_FAMILY_NAME = "LaGrande"; - protected static final File ROLE_UNDEAD_FILE = new File (COMMON_DIR, "role-undead.xml"); + protected static final File ROLE_UNDEAD_FILE = new File(COMMON_DIR, "role-undead.xml"); protected static final String ROLE_UNDEAD_OID = "54885c40-ffcc-11e5-b782-63b3e4e2a69d"; - protected static final File ROLE_EVIL_FILE = new File (COMMON_DIR, "role-evil.xml"); + protected static final File ROLE_EVIL_FILE = new File(COMMON_DIR, "role-evil.xml"); protected static final String ROLE_EVIL_OID = "624b43ec-ffcc-11e5-8297-f392afa54704"; protected static final String GROUP_UNDEAD_CN = "undead"; @@ -149,7 +127,7 @@ protected File getResourceFile() { protected abstract String getAccount0Cn(); protected int getNumberOfAllAccounts() { - return NUMBER_OF_GENERATED_ACCOUNTS + (isIdmAdminInteOrgPerson()?1:0); + return NUMBER_OF_GENERATED_ACCOUNTS + (isIdmAdminInteOrgPerson() ? 1 : 0); } protected boolean hasAssociationShortcut() { @@ -191,8 +169,8 @@ public void test000Sanity() throws Exception { cleanupDelete(toGroupDn(GROUP_EVIL_CN)); if (needsGroupFakeMemeberEntry()) { - addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); - addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); + addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); + addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); } else { addLdapGroup(GROUP_UNDEAD_CN, GROUP_UNDEAD_DESCRIPTION); addLdapGroup(GROUP_EVIL_CN, GROUP_EVIL_DESCRIPTION); @@ -201,11 +179,8 @@ public void test000Sanity() throws Exception { @Test public void test100SeachAccount0ByLdapUid() throws Exception { - final String TEST_NAME = "test100SeachAccount0ByLdapUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_0_UID); @@ -214,10 +189,10 @@ public void test100SeachAccount0ByLdapUid() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertAccountShadow(shadow, toAccountDn(ACCOUNT_0_UID)); @@ -238,16 +213,13 @@ public void test100SeachAccount0ByLdapUid() throws Exception { */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, getNumberOfAllAccounts(), task, result); + SearchResultList> searchResultList = doSearch(query, getNumberOfAllAccounts(), task, result); assertConnectorOperationIncrement(1, getNumberOfAllAccounts() + 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -264,16 +236,13 @@ public void test150SeachAllAccounts() throws Exception { @Test public void test151CountAllAccounts() throws Exception { - final String TEST_NAME = "test151CountAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); - displayWhen(TEST_NAME); + when(); Integer count = modelService.countObjects(ShadowType.class, query, null, task, result); assertCountAllAccounts(count); @@ -282,7 +251,7 @@ public void test151CountAllAccounts() throws Exception { } protected void assertCountAllAccounts(Integer count) { - assertEquals("Wrong account count", (Integer)getNumberOfAllAccounts(), count); + assertEquals("Wrong account count", (Integer) getNumberOfAllAccounts(), count); } /** @@ -290,11 +259,8 @@ protected void assertCountAllAccounts(Integer count) { */ @Test public void test152SeachFirst50Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst50Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -303,7 +269,7 @@ public void test152SeachFirst50Accounts() throws Exception { paging.setMaxSize(50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -324,11 +290,8 @@ public void test152SeachFirst50Accounts() throws Exception { */ @Test public void test154SeachFirst222Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst222Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -337,7 +300,7 @@ public void test154SeachFirst222Accounts() throws Exception { paging.setMaxSize(222); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> searchResultList = doSearch(query, 222, task, result); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -358,11 +321,8 @@ public void test154SeachFirst222Accounts() throws Exception { */ @Test public void test156SeachThroughEnd() throws Exception { - final String TEST_NAME = "test156SeachBeyondEnd"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -372,7 +332,7 @@ public void test156SeachThroughEnd() throws Exception { paging.setMaxSize(333); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 150, task, result); + SearchResultList> searchResultList = doSearch(query, 150, task, result); assertConnectorOperationIncrement(1, 151); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -390,11 +350,8 @@ public void test156SeachThroughEnd() throws Exception { */ @Test public void test158SeachBeyondEnd() throws Exception { - final String TEST_NAME = "test158SeachBeyondEnd"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -408,7 +365,7 @@ public void test158SeachBeyondEnd() throws Exception { if (isVlvSearchBeyondEndResurnsLastEntry()) { expectedEntries = 1; } - SearchResultList> searchResultList = doSearch(TEST_NAME, query, expectedEntries, task, result); + SearchResultList> searchResultList = doSearch(query, expectedEntries, task, result); // Fails for 389ds tests. For some unknown reason. And this is not that important. There are similar asserts in other tests that are passing. // assertConnectorOperationIncrement(1); @@ -425,11 +382,8 @@ public void test158SeachBeyondEnd() throws Exception { @Test public void test162SeachFirst50AccountsOffset0() throws Exception { - final String TEST_NAME = "test152SeachFirst50Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -439,7 +393,7 @@ public void test162SeachFirst50AccountsOffset0() throws Exception { paging.setMaxSize(50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -462,11 +416,8 @@ public void test162SeachFirst50AccountsOffset0() throws Exception { */ @Test public void test172Search50AccountsOffset20() throws Exception { - final String TEST_NAME = "test172Search50AccountsOffset20"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -474,7 +425,7 @@ public void test172Search50AccountsOffset20() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(20, 50); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> searchResultList = doSearch(query, 50, task, result); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -494,11 +445,8 @@ public void test172Search50AccountsOffset20() throws Exception { */ @Test public void test174SeachFirst222AccountsOffset20() throws Exception { - final String TEST_NAME = "test174SeachFirst222AccountsOffset20"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -506,7 +454,7 @@ public void test174SeachFirst222AccountsOffset20() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(20, 222); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> searchResultList = doSearch(query, 222, task, result); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -526,11 +474,8 @@ public void test174SeachFirst222AccountsOffset20() throws Exception { */ @Test public void test182Search50AccountsOffset20SortUid() throws Exception { - final String TEST_NAME = "test182Search50AccountsOffset20SortUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -539,10 +484,10 @@ public void test182Search50AccountsOffset20SortUid() throws Exception { paging.setOrdering(getAttributePath(resource, "uid"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 50, task, result); + SearchResultList> shadows = doSearch(query, 50, task, result); - assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_19_UID:ACCOUNT_20_UID)); - assertAccountShadow(shadows.get(49), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_68_UID:ACCOUNT_69_UID)); + assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_19_UID : ACCOUNT_20_UID)); + assertAccountShadow(shadows.get(49), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_68_UID : ACCOUNT_69_UID)); assertConnectorOperationIncrement(1, 51); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -562,11 +507,8 @@ public void test182Search50AccountsOffset20SortUid() throws Exception { */ @Test public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { - final String TEST_NAME = "test184SeachFirst222AccountsOffset20SortUid"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -575,10 +517,10 @@ public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { paging.setOrdering(getAttributePath(resource, "uid"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 222, task, result); + SearchResultList> shadows = doSearch(query, 222, task, result); - assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_19_UID:ACCOUNT_20_UID)); - assertAccountShadow(shadows.get(221), toAccountDn(isIdmAdminInteOrgPerson()?ACCOUNT_240_UID:ACCOUNT_241_UID)); + assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_19_UID : ACCOUNT_20_UID)); + assertAccountShadow(shadows.get(221), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_240_UID : ACCOUNT_241_UID)); assertConnectorOperationIncrement(1, 223); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -597,17 +539,14 @@ public void test184SearchFirst222AccountsOffset20SortUid() throws Exception { */ @Test public void test190SeachAllAccountsSizelimit() throws Exception { - final String TEST_NAME = "test190SeachAllAccountsSizelimit"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); query.setAllowPartialResults(true); - SearchResultList> resultList = doSearch(TEST_NAME, query, getSearchSizeLimit(), task, result); + SearchResultList> resultList = doSearch(query, getSearchSizeLimit(), task, result); assertConnectorOperationIncrement(1, getSearchSizeLimit() + 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -627,16 +566,13 @@ public void test190SeachAllAccountsSizelimit() throws Exception { */ @Test public void test195SearchInferno() throws Exception { - final String TEST_NAME = "test195SearchInferno"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); // WHEN - displayWhen(TEST_NAME); + when(); singleInfernoSearch(query, 30, 10, 30, "uid", task, result); singleInfernoSearch(query, 40, 5, 40, "cn", task, result); singleInfernoSearch(query, 15, 2, 15, "sn", task, result); @@ -674,20 +610,17 @@ public boolean handle(PrismObject object, OperationResult parentResu @Test public void test200AssignAccountToBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountToBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -705,29 +638,26 @@ public void test200AssignAccountToBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); accountBarbossaEntryId = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaEntryId); + assertNotNull("No identifier in " + shadow, accountBarbossaEntryId); assertEquals("Wrong ICFS UID", getAttributeAsString(entry, getPrimaryIdentifierAttributeName()), accountBarbossaEntryId); assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimestamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-1000, roundTsUp(tsEnd)+1000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 1000, roundTsUp(tsEnd) + 1000, createTimestampMillis); assertLdapConnectorInstances(1, 2); } @Test public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaReplaceTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -739,11 +669,11 @@ public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -763,11 +693,8 @@ public void test210ModifyAccountBarbossaReplaceTitle() throws Exception { */ @Test public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaAddTitleDuplicate"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -779,11 +706,11 @@ public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -803,11 +730,8 @@ public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception { */ @Test public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Exception { - final String TEST_NAME = "test213ModifyAccountBarbossaAddTitleDuplicateCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -819,11 +743,11 @@ public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Ex delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -839,22 +763,19 @@ public void test213ModifyAccountBarbossaAddTitleDuplicateCapitalized() throws Ex @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_2); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -871,19 +792,16 @@ public void test220ModifyUserBarbossaPassword() throws Exception { @Test public void test230ModifyUserBarbossaEmployeeType() throws Exception { - final String TEST_NAME = "test230ModifyUserBarbossaEmployeeType"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "Pirate"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -899,19 +817,16 @@ public void test230ModifyUserBarbossaEmployeeType() throws Exception { @Test public void test232ModifyUserBarbossaEmployeeTypeAgain() throws Exception { - final String TEST_NAME = "test232ModifyUserBarbossaEmployeeTypeAgain"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "Pirate"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -927,19 +842,16 @@ public void test232ModifyUserBarbossaEmployeeTypeAgain() throws Exception { @Test public void test234ModifyUserBarbossaEmployeeTypeAgainCapitalized() throws Exception { - final String TEST_NAME = "test234ModifyUserBarbossaEmployeeTypeAgainCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_EMPLOYEE_TYPE, task, result, "PIRATE"); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -955,19 +867,16 @@ public void test234ModifyUserBarbossaEmployeeTypeAgainCapitalized() throws Excep @Test public void test290ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test290ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_USERNAME)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -999,22 +908,19 @@ public void test290ModifyUserBarbossaRename() throws Exception { */ @Test public void test292ModifyUserBarbossaRenameCapitalized() throws Exception { - final String TEST_NAME = "test292ModifyUserBarbossaRenameCapitalized"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_CPTBARBOSSA_USERNAME.toUpperCase())); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1044,19 +950,16 @@ public void test292ModifyUserBarbossaRenameCapitalized() throws Exception { @Test public void test299UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test299UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1070,23 +973,20 @@ public void test299UnAssignAccountBarbossa() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test300AssignRoleEvilToLechuck() throws Exception { - final String TEST_NAME = "test300AssignRoleEvilToLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LECHUCK_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1112,23 +1012,20 @@ public void test300AssignRoleEvilToLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test302AssignRoleUndeadToLechuck() throws Exception { - final String TEST_NAME = "test302AssignRoleUndeadToLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_LECHUCK_OID, ROLE_UNDEAD_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1151,23 +1048,20 @@ public void test302AssignRoleUndeadToLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test306UnassignRoleEvilFromLechuck() throws Exception { - final String TEST_NAME = "test306UnassignRoleEvilFromLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LECHUCK_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1190,23 +1084,20 @@ public void test306UnassignRoleEvilFromLechuck() throws Exception { } /** - * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups + * MID-2853: Unexpected association behaviour - removing roles does not always remove from groups */ @Test public void test309UnassignRoleUndeadFromLechuck() throws Exception { - final String TEST_NAME = "test309UnassignRoleUndeadFromLechuck"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_LECHUCK_OID, ROLE_UNDEAD_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1230,11 +1121,8 @@ public void test309UnassignRoleUndeadFromLechuck() throws Exception { @Test public void test310SeachGroupEvilByCn() throws Exception { - final String TEST_NAME = "test310SeachGroupEvilByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); ObjectQueryUtil.filterAnd(query.getFilter(), createAttributeFilter("cn", GROUP_EVIL_CN), prismContext); @@ -1243,10 +1131,10 @@ public void test310SeachGroupEvilByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertGroupShadow(shadow, toGroupDn(GROUP_EVIL_CN)); @@ -1265,23 +1153,20 @@ public void test310SeachGroupEvilByCn() throws Exception { } /** - * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity + * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity */ @Test public void test312AssignRoleEvilToBarbossa() throws Exception { - final String TEST_NAME = "test312AssignRoleEvilToBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_EVIL_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1298,7 +1183,7 @@ public void test312AssignRoleEvilToBarbossa() throws Exception { Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); accountBarbossaEntryId = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaEntryId); + assertNotNull("No identifier in " + shadow, accountBarbossaEntryId); Entry ldapEntryEvil = getLdapEntry(toGroupDn(GROUP_EVIL_CN)); display("Evil group", ldapEntryEvil); @@ -1314,15 +1199,12 @@ public void test312AssignRoleEvilToBarbossa() throws Exception { } /** - * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity + * MID-3209: Rename does not change group membership for associations, when resource does not implement its own referential integrity */ @Test public void test314ModifyUserBarbossaRenameBack() throws Exception { - final String TEST_NAME = "test314ModifyUserBarbossaRenameBack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_BARBOSSA_OID); @@ -1330,11 +1212,11 @@ public void test314ModifyUserBarbossaRenameBack() throws Exception { assertNotNull(userBefore); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(USER_BARBOSSA_USERNAME)); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1374,11 +1256,8 @@ public void test314ModifyUserBarbossaRenameBack() throws Exception { */ @Test public void test320AddEvilUserLargo() throws Exception { - final String TEST_NAME = "test320AddEvilUserLargo"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_LARGO_NAME, USER_LARGO_GIVEN_NAME, USER_LARGO_FAMILY_NAME, true); @@ -1387,11 +1266,11 @@ public void test320AddEvilUserLargo() throws Exception { display("user before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1421,30 +1300,28 @@ public void test320AddEvilUserLargo() throws Exception { } @Test - public void test350SeachInvisibleAccount() throws Exception { - final String TEST_NAME = "test350SeachInvisibleAccount"; - displayTestTitle(TEST_NAME); - + public void test350SearchInvisibleAccount() throws Exception { // GIVEN createBilboEntry(); - SearchResultList> shadows = searchBilbo(TEST_NAME); + SearchResultList> shadows = searchBilbo(); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); assertAccountShadow(shadow, toAccountDn(ACCOUNT_BILBO_UID)); } protected Entry createBilboEntry() throws LdapException, IOException { - Entry entry = createAccountEntry(ACCOUNT_BILBO_UID, ACCOUNT_BILBO_CN, ACCOUNT_BILBO_GIVENNAME, ACCOUNT_BILBO_SN); + Entry entry = createAccountEntry( + ACCOUNT_BILBO_UID, ACCOUNT_BILBO_CN, ACCOUNT_BILBO_GIVENNAME, ACCOUNT_BILBO_SN); entry.add(LDAP_ATTRIBUTE_ROOM_NUMBER, ROOM_NUMBER_INVISIBLE); addLdapEntry(entry); return entry; } - protected SearchResultList> searchBilbo(final String TEST_NAME) throws Exception { - Task task = createTask(TEST_NAME); + protected SearchResultList> searchBilbo() throws Exception { + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createUidQuery(ACCOUNT_BILBO_UID); @@ -1453,15 +1330,15 @@ protected SearchResultList> searchBilbo(final String TES rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Bilbos", shadows); - assertLdapConnectorInstances(1,2); + assertLdapConnectorInstances(1, 2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); return shadows; diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java index dae58f0e751..86996c24951 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapSynchronizationTest.java @@ -6,20 +6,11 @@ * and European Union Public License. See LICENSE file for details. */ - -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; import java.util.List; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; import org.apache.directory.api.ldap.model.entry.DefaultModification; import org.apache.directory.api.ldap.model.entry.Modification; import org.apache.directory.api.ldap.model.entry.ModificationOperation; @@ -29,6 +20,10 @@ import org.apache.directory.api.ldap.model.message.ModifyDnResponse; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; @@ -37,8 +32,6 @@ import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -46,14 +39,11 @@ /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapSynchronizationTest extends AbstractLdapTest { - private static final Trace LOGGER = TraceManager.getTrace(AbstractLdapSynchronizationTest.class); - protected static final String ACCOUNT_HT_UID = "ht"; protected static final String ACCOUNT_HT_CN = "Herman Toothrot"; protected static final String ACCOUNT_HT_GIVENNAME = "Herman"; @@ -69,7 +59,6 @@ public abstract class AbstractLdapSynchronizationTest extends AbstractLdapTest { protected static final String GROUP_FOOLS_CN = "fools"; protected static final String GROUP_FOOLS_DESCRIPTION = "not quite the shilling"; - protected abstract void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException; protected boolean syncCanDetectDelete() { @@ -98,21 +87,18 @@ protected void assertAdditionalCapabilities(List nativeCapabilities) { @Test public void test800ImportSyncTask() throws Exception { - final String TEST_NAME = "test800ImportSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -125,22 +111,19 @@ public void test800ImportSyncTask() throws Exception { @Test public void test801SyncAddAccountHt() throws Exception { - final String TEST_NAME = "test801SyncAddAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -148,7 +131,7 @@ public void test801SyncAddAccountHt() throws Exception { displayUsers(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); assertStepSyncToken(getSyncTaskOid(), 1, tsStart, tsEnd); @@ -160,17 +143,14 @@ public void test801SyncAddAccountHt() throws Exception { */ @Test public void test802ModifyAccountHtSn() throws Exception { - final String TEST_NAME = "test802ModifyAccountHtSn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); Modification modSn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED); connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modSn); @@ -179,13 +159,13 @@ public void test802ModifyAccountHtSn() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd); @@ -194,52 +174,46 @@ public void test802ModifyAccountHtSn() throws Exception { @Test public void test810SyncAddGroupMonkeys() throws Exception { - final String TEST_NAME = "test810SyncAddGroupMonkeys"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); if (needsGroupFakeMemeberEntry()) { - addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION, "uid=fake,"+getPeopleLdapSuffix()); + addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION, "uid=fake," + getPeopleLdapSuffix()); } else { addLdapGroup(GROUP_MONKEYS_CN, GROUP_MONKEYS_DESCRIPTION); } waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject role = findObjectByName(RoleType.class, GROUP_MONKEYS_CN); display("Role", role); - assertNotNull("no role "+GROUP_MONKEYS_CN, role); + assertNotNull("no role " + GROUP_MONKEYS_CN, role); PrismAsserts.assertPropertyValue(role, RoleType.F_DESCRIPTION, GROUP_MONKEYS_DESCRIPTION); - assertNotNull("No role "+GROUP_MONKEYS_CN+" created", role); + assertNotNull("No role " + GROUP_MONKEYS_CN + " created", role); assertStepSyncToken(getSyncTaskOid(), 3, tsStart, tsEnd); } @Test public void test817RenameAccount() throws Exception { - final String TEST_NAME = "test817RenameAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); ModifyDnRequest modDnRequest = new ModifyDnRequestImpl(); @@ -247,7 +221,7 @@ public void test817RenameAccount() throws Exception { modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); modDnRequest.setDeleteOldRdn(true); ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest); - display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" -> "+toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)+": "+modDnResponse); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse); doAdditionalRenameModifications(connection); @@ -256,15 +230,15 @@ public void test817RenameAccount() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); - assertNotNull("No user "+ACCOUNT_HTM_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); assertStepSyncToken(getSyncTaskOid(), 4, tsStart, tsEnd); @@ -280,11 +254,8 @@ protected void doAdditionalRenameModifications(LdapNetworkConnection connection) @Test public void test818DeleteAccountHtm() throws Exception { - final String TEST_NAME = "test818DeleteAccountHtm"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); @@ -292,21 +263,21 @@ public void test818DeleteAccountHtm() throws Exception { long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); long tsEnd = System.currentTimeMillis(); if (syncCanDetectDelete()) { - assertNull("User "+ACCOUNT_HTM_UID+" still exist", findUserByUsername(ACCOUNT_HTM_UID)); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HTM_UID + " still exist", findUserByUsername(ACCOUNT_HTM_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); } else { // Just delete the user so we have consistent state for subsequent tests deleteObject(UserType.class, user.getOid(), task, result); @@ -315,24 +286,20 @@ public void test818DeleteAccountHtm() throws Exception { assertStepSyncToken(getSyncTaskOid(), 5, tsStart, tsEnd); } - // TODO: sync with "ALL" object class @Test public void test819DeleteSyncTask() throws Exception { - final String TEST_NAME = "test819DeleteSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(TaskType.class, getSyncTaskOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -341,21 +308,18 @@ public void test819DeleteSyncTask() throws Exception { @Test public void test820ImportSyncTaskInetOrgPerson() throws Exception { - final String TEST_NAME = "test820ImportSyncTaskInetOrgPerson"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(getSyncTaskInetOrgPersonFile(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -371,22 +335,19 @@ public void test820ImportSyncTaskInetOrgPerson() throws Exception { @Test public void test821SyncAddAccountHt() throws Exception { - final String TEST_NAME = "test821SyncAddAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapAccount(ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -395,7 +356,7 @@ public void test821SyncAddAccountHt() throws Exception { displayUsers(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN); assertStepSyncToken(getSyncTaskOid(), 6, tsStart, tsEnd); @@ -403,17 +364,14 @@ public void test821SyncAddAccountHt() throws Exception { @Test public void test822ModifyAccountHt() throws Exception { - final String TEST_NAME = "test822ModifyAccountHt"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED); connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn); @@ -422,14 +380,14 @@ public void test822ModifyAccountHt() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HT_UID); - assertNotNull("No user "+ACCOUNT_HT_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HT_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd); @@ -440,45 +398,39 @@ public void test822ModifyAccountHt() throws Exception { */ @Test public void test830AddGroupFools() throws Exception { - final String TEST_NAME = "test830AddGroupFools"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addLdapGroup(GROUP_FOOLS_CN, GROUP_FOOLS_DESCRIPTION, toGroupDn("nobody")); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject roleFools = findObjectByName(RoleType.class, GROUP_FOOLS_CN); - assertNull("Unexpected role "+roleFools, roleFools); + assertNull("Unexpected role " + roleFools, roleFools); assertStepSyncToken(getSyncTaskOid(), 8, tsStart, tsEnd); } @Test public void test837RenameAccount() throws Exception { - final String TEST_NAME = "test837RenameAccount"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); LdapNetworkConnection connection = ldapConnect(); ModifyDnRequest modDnRequest = new ModifyDnRequestImpl(); @@ -486,7 +438,7 @@ public void test837RenameAccount() throws Exception { modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); modDnRequest.setDeleteOldRdn(true); ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest); - display("Modified "+toAccountDn(ACCOUNT_HT_UID,ACCOUNT_HT_CN)+" -> "+toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)+": "+modDnResponse); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse); doAdditionalRenameModifications(connection); @@ -495,15 +447,15 @@ public void test837RenameAccount() throws Exception { waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); - assertNotNull("No user "+ACCOUNT_HTM_UID+" created", user); + assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user); assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); assertStepSyncToken(getSyncTaskOid(), 9, tsStart, tsEnd); @@ -513,11 +465,8 @@ public void test837RenameAccount() throws Exception { @Test public void test838DeleteAccountHtm() throws Exception { - final String TEST_NAME = "test838DeleteAccountHtm"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(ACCOUNT_HTM_UID); @@ -525,20 +474,20 @@ public void test838DeleteAccountHtm() throws Exception { long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); - deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID,ACCOUNT_HTM_CN)); + when(); + deleteLdapEntry(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN)); waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); if (syncCanDetectDelete()) { - assertNull("User "+ACCOUNT_HTM_UID+" still exist", findUserByUsername(ACCOUNT_HTM_UID)); - assertNull("User "+ACCOUNT_HT_UID+" still exist", findUserByUsername(ACCOUNT_HT_UID)); + assertNull("User " + ACCOUNT_HTM_UID + " still exist", findUserByUsername(ACCOUNT_HTM_UID)); + assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID)); } else { // Just delete the user so we have consistent state for subsequent tests deleteObject(UserType.class, user.getOid(), task, result); @@ -549,19 +498,16 @@ public void test838DeleteAccountHtm() throws Exception { @Test public void test839DeleteSyncTask() throws Exception { - final String TEST_NAME = "test839DeleteSyncTask"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(TaskType.class, getSyncTaskOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoObject(TaskType.class, getSyncTaskOid(), task, result); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java index 70a8580a047..900752738bf 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java @@ -6,44 +6,18 @@ * and European Union Public License. See LICENSE file for details. */ +import static org.testng.AssertJUnit.*; import static com.evolveum.midpoint.test.IntegrationTestTools.LDAP_CONNECTOR_TYPE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertNotNull; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; import java.io.File; import java.io.IOException; -import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - +import java.util.*; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import javax.xml.namespace.QName; -import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.prism.PrismConstants; -import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.aspect.ProfilingDataManager; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; -import org.testng.annotations.Test; import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException; @@ -56,33 +30,31 @@ import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; -import org.apache.directory.api.ldap.model.message.BindRequest; -import org.apache.directory.api.ldap.model.message.BindRequestImpl; -import org.apache.directory.api.ldap.model.message.BindResponse; -import org.apache.directory.api.ldap.model.message.Response; -import org.apache.directory.api.ldap.model.message.ResultCodeEnum; -import org.apache.directory.api.ldap.model.message.SearchRequest; -import org.apache.directory.api.ldap.model.message.SearchRequestImpl; -import org.apache.directory.api.ldap.model.message.SearchResultEntry; -import org.apache.directory.api.ldap.model.message.SearchScope; +import org.apache.directory.api.ldap.model.message.*; import org.apache.directory.api.ldap.model.name.Ava; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismConstants; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.match.MatchingRule; import com.evolveum.midpoint.prism.match.MatchingRuleRegistry; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.schema.CapabilityUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.SearchResultMetadata; -import com.evolveum.midpoint.schema.SelectorOptions; +import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; @@ -94,35 +66,18 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.Lsof; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.aspect.ProfilingDataManager; +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.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; +import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*; /** * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapTest extends AbstractModelIntegrationTest { @@ -155,12 +110,12 @@ public abstract class AbstractLdapTest extends AbstractModelIntegrationTest { // Barbossa after rename protected static final String USER_CPTBARBOSSA_USERNAME = "cptbarbossa"; - protected static final File USER_GUYBRUSH_FILE = new File (COMMON_DIR, "user-guybrush.xml"); + protected static final File USER_GUYBRUSH_FILE = new File(COMMON_DIR, "user-guybrush.xml"); protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116"; protected static final String USER_GUYBRUSH_USERNAME = "guybrush"; protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood"; - protected static final File USER_LECHUCK_FILE = new File (COMMON_DIR, "user-lechuck.xml"); + protected static final File USER_LECHUCK_FILE = new File(COMMON_DIR, "user-lechuck.xml"); protected static final String USER_LECHUCK_OID = "0201583e-ffca-11e5-a949-affff1aa5a60"; protected static final String USER_LECHUCK_USERNAME = "lechuck"; protected static final String USER_LECHUCK_FULL_NAME = "LeChuck"; @@ -201,7 +156,6 @@ protected void startResources() throws Exception { stopCommand = getStopSystemCommand(); } - public abstract String getStartSystemCommand(); public abstract String getStopSystemCommand(); @@ -270,11 +224,11 @@ protected String getLdapSuffix() { } protected String getPeopleLdapSuffix() { - return "ou=People,"+getLdapSuffix(); + return "ou=People," + getLdapSuffix(); } protected String getGroupsLdapSuffix() { - return "ou=groups,"+getLdapSuffix(); + return "ou=groups," + getLdapSuffix(); } public String getPrimaryIdentifierAttributeName() { @@ -282,7 +236,7 @@ public String getPrimaryIdentifierAttributeName() { } public QName getPrimaryIdentifierAttributeQName() { - return new QName(MidPointConstants.NS_RI,getPrimaryIdentifierAttributeName()); + return new QName(MidPointConstants.NS_RI, getPrimaryIdentifierAttributeName()); } protected abstract String getLdapGroupObjectClass(); @@ -321,7 +275,9 @@ protected QName getAssociationGroupName() { return new QName(MidPointConstants.NS_RI, "group"); } - protected String getLdapConnectorClassName() { return LDAP_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return LDAP_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -379,18 +335,14 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti } } - @Test public void test010Connection() throws Exception { - final String TEST_NAME = "test010Connection"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); - OperationResult testResult = provisioningService.testResource(getResourceOid(), task); + OperationResult testResult = provisioningService.testResource(getResourceOid(), task); - display("Test connection result",testResult); - TestUtil.assertSuccess("Test connection failed",testResult); + display("Test connection result", testResult); + TestUtil.assertSuccess("Test connection failed", testResult); if (isAssertOpenFiles()) { // Set lsof baseline only after the first connection. @@ -402,16 +354,13 @@ public void test010Connection() throws Exception { @Test public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); display("Resource schema", resourceSchema); RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(getAccountObjectClass()); - assertNotNull("No definition for object class "+getAccountObjectClass(), accountObjectClassDefinition); + assertNotNull("No definition for object class " + getAccountObjectClass(), accountObjectClassDefinition); display("Account object class def", accountObjectClassDefinition); ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); @@ -442,9 +391,6 @@ protected QName getTimestampXsdType() { @Test public void test030Capabilities() throws Exception { - final String TEST_NAME = "test030Capabilities"; - displayTestTitle(TEST_NAME); - CapabilitiesType capabilities = resourceType.getCapabilities(); display("Resource capabilities", capabilities); assertNotNull("Null capabilities", capabilities); @@ -480,12 +426,11 @@ protected void assertAdditionalCapabilities(List nativeCapabilities) { protected void assertCapability(List capabilities, Class capabilityClass) { C capability = CapabilityUtil.getCapability(capabilities, capabilityClass); - assertNotNull("No "+capabilityClass.getSimpleName()+" capability", capability); - assertTrue("Capability "+capabilityClass.getSimpleName()+" is disabled", CapabilityUtil.isCapabilityEnabled(capability)); + assertNotNull("No " + capabilityClass.getSimpleName() + " capability", capability); + assertTrue("Capability " + capabilityClass.getSimpleName() + " is disabled", CapabilityUtil.isCapabilityEnabled(capability)); } - - protected ObjectFilter createAttributeFilter(String attrName, T attrVal) throws SchemaException { + protected ObjectFilter createAttributeFilter(String attrName, T attrVal) { ResourceAttributeDefinition ldapAttrDef = accountObjectClassDefinition.findAttributeDefinition(attrName); return prismContext.queryFor(ShadowType.class) .itemWithDef(ldapAttrDef, ShadowType.F_ATTRIBUTES, ldapAttrDef.getItemName()).eq(attrVal) @@ -498,20 +443,19 @@ protected ObjectQuery createUidQuery(String uid) throws SchemaException { return query; } - protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - return doSearch(TEST_NAME, query, null, expectedSize, task, result); + protected SearchResultList> doSearch(ObjectQuery query, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + return doSearch(query, null, expectedSize, task, result); } - protected SearchResultList> doSearch(final String TEST_NAME, ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final List> foundObjects = new ArrayList>(expectedSize); + protected SearchResultList> doSearch(ObjectQuery query, GetOperationOptions rootOptions, int expectedSize, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + final List> foundObjects = new ArrayList<>(expectedSize); ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { -// LOGGER.trace("Found {}", object); String name = object.asObjectable().getName().getOrig(); - for(PrismObject foundShadow: foundObjects) { + for (PrismObject foundShadow : foundObjects) { if (!allowDuplicateSearchResults() && foundShadow.asObjectable().getName().getOrig().equals(name)) { - AssertJUnit.fail("Duplicate name "+name); + AssertJUnit.fail("Duplicate name " + name); } } foundObjects.add(object); @@ -528,8 +472,8 @@ public boolean handle(PrismObject object, OperationResult parentResu rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); - display("Searching shadows, options="+options+", query", query); + when(); + display("Searching shadows, options=" + options + ", query", query); SearchResultMetadata searchResultMetadata = modelService.searchObjectsIterative(ShadowType.class, query, handler, options, task, result); // THEN @@ -539,19 +483,17 @@ public boolean handle(PrismObject object, OperationResult parentResu if (expectedSize != foundObjects.size()) { if (foundObjects.size() < 10) { display("Found objects", foundObjects); - AssertJUnit.fail("Unexpected number of accounts. Expected "+expectedSize+", found "+foundObjects.size()+": "+foundObjects); + AssertJUnit.fail("Unexpected number of accounts. Expected " + expectedSize + ", found " + foundObjects.size() + ": " + foundObjects); } else { - AssertJUnit.fail("Unexpected number of accounts. Expected "+expectedSize+", found "+foundObjects.size()+" (too many to display)"); + AssertJUnit.fail("Unexpected number of accounts. Expected " + expectedSize + ", found " + foundObjects.size() + " (too many to display)"); } } - SearchResultList> resultList = new SearchResultList<>(foundObjects, searchResultMetadata); - - return resultList; + return new SearchResultList<>(foundObjects, searchResultMetadata); } protected Entry getLdapAccountByUid(String uid) throws LdapException, IOException, CursorException { - return searchLdapAccount("(uid="+uid+")"); + return searchLdapAccount("(uid=" + uid + ")"); } protected Entry getLdapAccountByCn(String cn) throws LdapException, IOException, CursorException { @@ -559,7 +501,7 @@ protected Entry getLdapAccountByCn(String cn) throws LdapException, IOException, } protected Entry getLdapAccountByCn(UserLdapConnectionConfig config, String cn) throws LdapException, IOException, CursorException { - return searchLdapAccount(config, "(cn="+cn+")"); + return searchLdapAccount(config, "(cn=" + cn + ")"); } protected Entry searchLdapAccount(String filter) throws LdapException, IOException, CursorException { @@ -571,10 +513,9 @@ protected Entry searchLdapAccount(UserLdapConnectionConfig config, String filter List entries = ldapSearch(config, connection, filter); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for "+filter+": "+entries, 1, entries.size()); - Entry entry = entries.get(0); + assertEquals("Unexpected number of entries for " + filter + ": " + entries, 1, entries.size()); - return entry; + return entries.get(0); } protected Entry assertLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { @@ -585,13 +526,12 @@ protected Entry assertLdapAccount(String uid, String cn) throws LdapException, I protected Entry getLdapGroupByName(String name) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(&(cn="+name+")(objectClass="+getLdapGroupObjectClass()+"))"); + List entries = ldapSearch(connection, "(&(cn=" + name + ")(objectClass=" + getLdapGroupObjectClass() + "))"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for group cn="+name+": "+entries, 1, entries.size()); - Entry entry = entries.get(0); + assertEquals("Unexpected number of entries for group cn=" + name + ": " + entries, 1, entries.size()); - return entry; + return entries.get(0); } protected Entry assertLdapGroup(String cn) throws LdapException, IOException, CursorException { @@ -602,9 +542,9 @@ protected Entry assertLdapGroup(String cn) throws LdapException, IOException, Cu protected void assertNoLdapGroup(String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(&(cn="+cn+")(objectClass="+getLdapGroupObjectClass()+"))"); + List entries = ldapSearch(connection, "(&(cn=" + cn + ")(objectClass=" + getLdapGroupObjectClass() + "))"); ldapDisconnect(connection); - assertEquals("Unexpected LDAP group "+cn+": "+entries, 0, entries.size()); + assertEquals("Unexpected LDAP group " + cn + ": " + entries, 0, entries.size()); } protected void assertAttribute(Entry entry, String attrName, String expectedValue) throws LdapInvalidAttributeValueException { @@ -614,18 +554,18 @@ protected void assertAttribute(Entry entry, String attrName, String expectedValu if (expectedValue == null) { return; } else { - AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); + AssertJUnit.fail("No attribute " + attrName + " in " + dn + ", expected: " + expectedValue); } } else { - assertEquals("Wrong attribute "+attrName+" in "+dn, expectedValue, ldapAttribute.getString()); + assertEquals("Wrong attribute " + attrName + " in " + dn, expectedValue, ldapAttribute.getString()); } } - protected void assertNoAttribute(Entry entry, String attrName) throws LdapInvalidAttributeValueException { + protected void assertNoAttribute(Entry entry, String attrName) { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); if (ldapAttribute != null) { - AssertJUnit.fail("Unexpected attribute "+attrName+" in "+dn+": "+ldapAttribute); + AssertJUnit.fail("Unexpected attribute " + attrName + " in " + dn + ": " + ldapAttribute); } } @@ -633,14 +573,16 @@ protected void assertAttributeContains(Entry entry, String attrName, String expe assertAttributeContains(entry, attrName, expectedValue, null); } - protected void assertAttributeContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws LdapInvalidAttributeValueException, SchemaException { + protected void assertAttributeContains( + Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) + throws SchemaException { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); if (ldapAttribute == null) { if (expectedValue == null) { return; } else { - AssertJUnit.fail("No attribute "+attrName+" in "+dn+", expected: "+expectedValue); + AssertJUnit.fail("No attribute " + attrName + " in " + dn + ", expected: " + expectedValue); } } else { List vals = new ArrayList<>(); @@ -658,7 +600,7 @@ protected void assertAttributeContains(Entry entry, String attrName, String expe } vals.add(value.getString()); } - AssertJUnit.fail("Wrong attribute "+attrName+" in "+dn+" expected to contain value " + expectedValue + " but it has values " + vals); + AssertJUnit.fail("Wrong attribute " + attrName + " in " + dn + " expected to contain value " + expectedValue + " but it has values " + vals); } } @@ -666,22 +608,18 @@ protected void assertAttributeNotContains(Entry entry, String attrName, String e assertAttributeNotContains(entry, attrName, expectedValue, null); } - protected void assertAttributeNotContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws LdapInvalidAttributeValueException, SchemaException { + protected void assertAttributeNotContains(Entry entry, String attrName, String expectedValue, MatchingRule matchingRule) throws SchemaException { String dn = entry.getDn().toString(); Attribute ldapAttribute = entry.get(attrName); - if (ldapAttribute == null) { - return; - } else { - Iterator> iterator = ldapAttribute.iterator(); - while (iterator.hasNext()) { - Value value = iterator.next(); + if (ldapAttribute != null) { + for (Value value : ldapAttribute) { if (matchingRule == null) { if (expectedValue.equals(value.getString())) { - AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it"); + AssertJUnit.fail("Attribute " + attrName + " in " + dn + " contains value " + expectedValue + ", but it should not have it"); } } else { if (matchingRule.match(expectedValue, value.getString())) { - AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it"); + AssertJUnit.fail("Attribute " + attrName + " in " + dn + " contains value " + expectedValue + ", but it should not have it"); } } } @@ -695,7 +633,7 @@ protected Entry getLdapEntry(String dn) throws LdapException, IOException, Curso return entry; } - protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws LdapException, IOException, CursorException { + protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws LdapException, CursorException { List entries = ldapSearch(connection, dn, "(objectclass=*)", SearchScope.OBJECT, "*"); if (entries.isEmpty()) { return null; @@ -705,15 +643,15 @@ protected Entry getLdapEntry(LdapNetworkConnection connection, String dn) throws protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entries = ldapSearch(connection, "(uid="+uid+")"); + List entries = ldapSearch(connection, "(uid=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for uid="+uid+": "+entries, 0, entries.size()); + assertEquals("Unexpected number of entries for uid=" + uid + ": " + entries, 0, entries.size()); } protected void assertNoEntry(String dn) throws LdapException, IOException, CursorException { Entry entry = getLdapEntry(dn); - assertNull("Expected no entry "+dn+", but found "+entry, entry); + assertNull("Expected no entry " + dn + ", but found " + entry, entry); } protected void assertLdapGroupMember(Entry accountEntry, String groupName) throws LdapException, IOException, CursorException, SchemaException { @@ -748,7 +686,7 @@ protected List ldapSearch(UserLdapConnectionConfig config, LdapNetworkCon protected List ldapSearch(LdapNetworkConnection connection, String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException, CursorException { LOGGER.trace("LDAP search base={}, filter={}, scope={}, attributes={}", - new Object[]{baseDn, filter, scope, attributes}); + baseDn, filter, scope, attributes); SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.setBase(new Dn(baseDn)); @@ -757,21 +695,21 @@ protected List ldapSearch(LdapNetworkConnection connection, String baseDn searchRequest.addAttributes(attributes); searchRequest.ignoreReferrals(); - List entries = new ArrayList(); + List entries = new ArrayList<>(); try { SearchCursor searchCursor = connection.search(searchRequest); while (searchCursor.next()) { Response response = searchCursor.get(); if (response instanceof SearchResultEntry) { - Entry entry = ((SearchResultEntry)response).getEntry(); + Entry entry = ((SearchResultEntry) response).getEntry(); entries.add(entry); } } searchCursor.close(); } catch (IOException e) { - throw new IllegalStateException("IO Error: "+e.getMessage(), e); + throw new IllegalStateException("IO Error: " + e.getMessage(), e); } catch (CursorLdapReferralException e) { - throw new IllegalStateException("Got referral to: "+e.getReferralInfo(), e); + throw new IllegalStateException("Got referral to: " + e.getReferralInfo(), e); } return entries; } @@ -802,11 +740,12 @@ protected void assertLdapPassword(UserLdapConnectionConfig config, Entry entry, LOGGER.debug("Search-after-auth found {} entries", foundEntries); ldapDisconnect(conn); if (foundEntries != 1) { - throw new SecurityException("Cannot read my own entry ("+entry.getDn()+")"); + throw new SecurityException("Cannot read my own entry (" + entry.getDn() + ")"); } } - protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) throws LdapException, IOException, CursorException { + protected Entry addLdapAccount(String uid, String cn, String givenName, String sn) + throws LdapException, IOException { Entry entry = createAccountEntry(uid, cn, givenName, sn); addLdapEntry(entry); return entry; @@ -816,9 +755,9 @@ protected void addLdapEntry(Entry entry) throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); try { connection.add(entry); - display("Added LDAP account:\n"+entry); + display("Added LDAP account:\n" + entry); } catch (Exception e) { - display("Error adding entry:\n"+entry+"\nError: "+e.getMessage()); + display("Error adding entry:\n" + entry + "\nError: " + e.getMessage()); ldapDisconnect(connection); throw e; } @@ -835,17 +774,19 @@ protected Entry createAccountEntry(String uid, String cn, String givenName, Stri return entry; } - protected Entry addLdapGroup(String cn, String description, String... memberDns) throws LdapException, IOException, CursorException { + protected Entry addLdapGroup(String cn, String description, String... memberDns) + throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); Entry entry = createGroupEntry(cn, description, memberDns); LOGGER.trace("Adding LDAP entry:\n{}", entry); connection.add(entry); - display("Added LDAP group:"+entry); + display("Added LDAP group:" + entry); ldapDisconnect(connection); return entry; } - protected Entry createGroupEntry(String cn, String description, String... memberDns) throws LdapException { + protected Entry createGroupEntry(String cn, String description, String... memberDns) + throws LdapException { Entry entry = new DefaultEntry(toGroupDn(cn), "objectclass", getLdapGroupObjectClass(), "cn", cn, @@ -859,7 +800,7 @@ protected Entry createGroupEntry(String cn, String description, String... member protected void deleteLdapEntry(String dn) throws LdapException, IOException { LdapNetworkConnection connection = ldapConnect(); connection.delete(dn); - display("Deleted LDAP entry: "+dn); + display("Deleted LDAP entry: " + dn); ldapDisconnect(connection); } @@ -878,7 +819,7 @@ protected void cleanupDelete(UserLdapConnectionConfig config, String dn) throws Entry entry = getLdapEntry(connection, dn); if (entry != null) { connection.delete(dn); - display("Cleaning up LDAP entry: "+dn); + display("Cleaning up LDAP entry: " + dn); } ldapDisconnect(connection); } @@ -888,19 +829,19 @@ protected String toAccountDn(String username, String fullName) { } protected String toAccountDn(String username) { - return "uid="+username+","+getPeopleLdapSuffix(); + return "uid=" + username + "," + getPeopleLdapSuffix(); } protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("uid", username)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } protected String toGroupDn(String cn) { - return "cn="+cn+","+getGroupsLdapSuffix(); + return "cn=" + cn + "," + getGroupsLdapSuffix(); } protected String getAttributeAsString(Entry entry, String primaryIdentifierAttributeName) throws LdapInvalidAttributeValueException { @@ -951,13 +892,12 @@ protected LdapNetworkConnection ldapConnect(UserLdapConnectionConfig config) thr if (useSsl()) { config.setUseSsl(true); TrustManager trustManager = new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] chain, String authType) - throws CertificateException { - + public void checkClientTrusted(X509Certificate[] chain, String authType) { } - public void checkServerTrusted(X509Certificate[] chain, String authType) - throws CertificateException { + + public void checkServerTrusted(X509Certificate[] chain, String authType) { } + public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } @@ -970,7 +910,7 @@ public X509Certificate[] getAcceptedIssuers() { LdapNetworkConnection connection = new LdapNetworkConnection(config); boolean connected = connection.connect(); if (!connected) { - AssertJUnit.fail("Cannot connect to LDAP server "+config.getLdapHost()+":"+config.getLdapPort()); + AssertJUnit.fail("Cannot connect to LDAP server " + config.getLdapHost() + ":" + config.getLdapPort()); } LOGGER.trace("LDAP connected to {}:{}, executing bind as {}", config.getLdapHost(), config.getLdapPort(), config.getBindDn()); @@ -981,7 +921,7 @@ public X509Certificate[] getAcceptedIssuers() { BindResponse bindResponse = connection.bind(bindRequest); if (bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS) { ldapDisconnect(connection); - throw new SecurityException("Bind as "+config.getBindDn()+" failed: "+bindResponse.getLdapResult().getDiagnosticMessage()+" ("+bindResponse.getLdapResult().getResultCode()+")"); + throw new SecurityException("Bind as " + config.getBindDn() + " failed: " + bindResponse.getLdapResult().getDiagnosticMessage() + " (" + bindResponse.getLdapResult().getResultCode() + ")"); } LOGGER.trace("LDAP connected to {}:{}, bound as {}", config.getLdapHost(), config.getLdapPort(), config.getBindDn()); @@ -997,20 +937,17 @@ protected void assertAccountShadow(PrismObject shadow, String dn) th assertShadowCommon(shadow, null, dn, resourceType, getAccountObjectClass(), ciMatchingRule, false); } - protected void assertAccountRepoShadow(PrismObject shadow, String dn) throws SchemaException { - assertShadowCommon(shadow, null, dnMatchingRule.normalize(dn), resourceType, getAccountObjectClass(), ciMatchingRule, false); - } - protected void assertGroupShadow(PrismObject shadow, String dn) throws SchemaException { assertShadowCommon(shadow, null, dn, resourceType, getGroupObjectClass(), ciMatchingRule, false, true); } protected long roundTsDown(long ts) { - return (((long)(ts/1000))*1000); + return (ts / 1000 * 1000); } + // TODO: for 10000 it produces 10001? I don't understand it (Virgo) protected long roundTsUp(long ts) { - return (((long)(ts/1000))*1000)+1; + return (ts / 1000 * 1000) + 1; } protected void assertStableSystem() throws NumberFormatException, IOException, InterruptedException { @@ -1052,7 +989,7 @@ protected void assertLdapConnectorInstances(int expectedConnectorInstances) thro } private ConnectorOperationalStatus findLdapConnectorStat(List stats) { - for (ConnectorOperationalStatus stat: stats) { + for (ConnectorOperationalStatus stat : stats) { if (stat.getConnectorClassName().equals(getLdapConnectorClassName())) { return stat; } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java index 666633fb6df..2c54dc94ad5 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java index 0f167f9aded..aae8da01a22 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsDnPhobos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java index ecc44d53859..02c1f21a7ca 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java index a88f6404a28..736f9d62c08 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/Test389DsNsUniqueIdPhobos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java index ba2024cc87d..c718c30d625 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirAthena.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java index ead23b75e9d..d940ddf2a74 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestEDirDeimos.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java index 06e067bcee8..523e1dc72d1 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java index 6bd0c8ea72b..52b732d6870 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjDumber.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -55,15 +55,12 @@ protected boolean isUsingGroupShortcutAttribute() { */ @Test @Override - public void test350SeachInvisibleAccount() throws Exception { - final String TEST_NAME = "test350SeachInvisibleAccount"; - displayTestTitle(TEST_NAME); - + public void test350SearchInvisibleAccount() throws Exception { // GIVEN createBilboEntry(); - SearchResultList> shadows = searchBilbo(TEST_NAME); + SearchResultList> shadows = searchBilbo(); - assertEquals("Unexpected search result: "+shadows, 0, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 0, shadows.size()); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java index 27dcf672aaa..bf73f748678 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDjUnsafe.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016-2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,12 +8,6 @@ import java.io.File; -import org.testng.annotations.AfterClass; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * Almost same sa TestOpenDj, but there is unsafeNameHint setting and maybe * some other possibly risky and alternative connector settings. @@ -26,5 +20,4 @@ public class TestOpenDjUnsafe extends TestOpenDj { protected File getResourceFile() { return new File(getBaseDir(), "resource-unsafe.xml"); } - } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java index bfa9e3d0dae..6f920af9c4f 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdap.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014-2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,18 +6,14 @@ */ package com.evolveum.midpoint.testing.conntest; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.text.ParseException; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.util.GeneralizedTime; -import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -42,7 +38,6 @@ /** * @author semancik - * */ public class TestOpenLdap extends AbstractLdapConnTest { @@ -58,12 +53,12 @@ protected File getBaseDir() { @Override public String getStartSystemCommand() { - return "sudo "+getScriptDirectoryName()+"/openldap-start"; + return "sudo " + getScriptDirectoryName() + "/openldap-start"; } @Override public String getStopSystemCommand() { - return "sudo "+getScriptDirectoryName()+"/openldap-stop"; + return "sudo " + getScriptDirectoryName() + "/openldap-stop"; } @Override @@ -98,15 +93,14 @@ protected int getSearchSizeLimit() { @Override protected String getPeopleLdapSuffix() { - return "ou=people,"+getLdapSuffix(); + return "ou=people," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "ou=groups,"+getLdapSuffix(); + return "ou=groups," + getLdapSuffix(); } - @Override protected String getLdapGroupObjectClass() { return "groupOfNames"; @@ -144,38 +138,35 @@ protected void assertActivationCapability(ActivationCapabilityType activationCap @Override protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); result.computeStatus(); TestUtil.assertSuccess(result); PrismProperty syncTokenProperty = task.getExtensionPropertyOrClone(SchemaConstants.SYNC_TOKEN); - assertNotNull("No sync token in "+task, syncTokenProperty); + assertNotNull("No sync token in " + task, syncTokenProperty); String syncToken = syncTokenProperty.getRealValue(); - assertNotNull("No sync token in "+task, syncToken); + assertNotNull("No sync token in " + task, syncToken); IntegrationTestTools.display("Sync token", syncToken); GeneralizedTime syncTokenGt; try { syncTokenGt = new GeneralizedTime(syncToken); } catch (ParseException e) { - throw new RuntimeException(e.getMessage(),e); + throw new RuntimeException(e.getMessage(), e); } - TestUtil.assertBetween("Wrong time in sync token: "+syncToken, roundTsDown(tsStart), roundTsUp(tsEnd), syncTokenGt.getCalendar().getTimeInMillis()); + TestUtil.assertBetween("Wrong time in sync token: " + syncToken, roundTsDown(tsStart), roundTsUp(tsEnd), syncTokenGt.getCalendar().getTimeInMillis()); } @Test public void test700CheckBarbossaLockoutStatus() throws Exception { - final String TEST_NAME = "test700CheckBarbossaLockoutStatus"; - TestUtil.displayTestTitle(this, TEST_NAME); - // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); PrismObject shadow = getShadowModel(accountBarbossaOid); // THEN - TestUtil.displayThen(TEST_NAME); + then(); display("Shadow (model)", shadow); ActivationType activation = shadow.asObjectable().getActivation(); if (activation != null) { @@ -190,18 +181,14 @@ public void test700CheckBarbossaLockoutStatus() throws Exception { @Test public void test702LockOutBarbossa() throws Exception { - final String TEST_NAME = "test702LockOutBarbossa"; - TestUtil.displayTestTitle(this, TEST_NAME); - Entry entry = getLdapAccountByUid(USER_BARBOSSA_USERNAME); display("LDAP Entry before", entry); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); for (int i = 0; i < 10; i++) { - LdapNetworkConnection conn; try { - conn = ldapConnect(null, entry.getDn().toString(), "this password is wrong"); + ldapConnect(null, entry.getDn().toString(), "this password is wrong"); } catch (SecurityException e) { // Good bad attempt continue; @@ -210,7 +197,7 @@ public void test702LockOutBarbossa() throws Exception { } // THEN - TestUtil.displayThen(TEST_NAME); + then(); entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); display("LDAP Entry after", entry); @@ -223,25 +210,21 @@ public void test702LockOutBarbossa() throws Exception { assertEquals("Wrong lockout status", LockoutStatusType.LOCKED, lockoutStatus); } - @Test public void test705UnlockBarbossaAccount() throws Exception { - final String TEST_NAME = "test705UnlockBarbossaAccount"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta accountDelta = createModifyAccountShadowReplaceDelta(accountBarbossaOid, null, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); executeChanges(accountDelta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java index e4760fc774f..8abdd9ed2de 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenLdapDumber.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2017-2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -7,29 +7,10 @@ package com.evolveum.midpoint.testing.conntest; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; import java.io.File; -import java.text.ParseException; - -import org.apache.directory.api.util.GeneralizedTime; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.AbstractIntegrationTest; -import com.evolveum.midpoint.test.IntegrationTestTools; + import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * OpenLDAP, but without permissive modify, shortcut attributes, etc. @@ -56,7 +37,7 @@ protected boolean isUsingGroupShortcutAttribute() { // This is a dumb resource. It cannot count. @Override protected void assertCountAllAccounts(Integer count) { - assertEquals("Wrong account count", (Integer)null, count); + assertEquals("Wrong account count", (Integer) null, count); } } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java index 4ee9a7bc8c4..ab68de5aecb 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/UserLdapConnectionConfig.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -10,7 +10,6 @@ /** * @author semancik - * */ public class UserLdapConnectionConfig extends LdapConnectionConfig { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java index 03097c3e42c..6612eb9a11c 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapCookedTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.conntest.ad; -import static com.evolveum.midpoint.test.IntegrationTestTools.display; import static org.testng.AssertJUnit.assertTrue; import java.util.Collection; @@ -15,7 +14,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -27,17 +25,13 @@ public abstract class AbstractAdLdapCookedTest extends AbstractAdLdapTest { @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); assertTrue("No native activation capability", ResourceTypeUtil.hasResourceNativeActivationCapability(resourceType)); assertTrue("No native activation status capability", ResourceTypeUtil.hasResourceNativeActivationStatusCapability(resourceType)); -// assertTrue("No native lockout capability", ResourceTypeUtil.hasResourceNativeActivationLockoutCapability(resourceType)); - assertTrue("No native credentias capability", ResourceTypeUtil.isCredentialsCapabilityEnabled(resourceType, null)); + assertTrue("No native credentials capability", ResourceTypeUtil.isCredentialsCapabilityEnabled(resourceType, null)); } protected void assertAccountDisabled(PrismObject shadow) { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java index a11ef4aac24..85a4a6635e2 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainRunAsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2018 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -70,8 +70,6 @@ public void test226ModifyUserBarbossaPasswordSelfServicePassword1AgainAgain() th */ @Test public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws Exception { - final String TEST_NAME = "test228ModifyUserBarbossaPasswordSelfServiceDesynchronized"; - displayTestTitle(TEST_NAME); // GIVEN // preconditions @@ -82,7 +80,7 @@ public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -90,11 +88,11 @@ public void test228ModifyUserBarbossaPasswordSelfServiceDesynchronized() throws USER_BARBOSSA_PASSWORD_AD_1, USER_BARBOSSA_PASSWORD_AD_3); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); display(result); assertPartialError(result); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java index 0cad4fe7e1d..8dbd98711f8 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapMultidomainTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,24 +6,18 @@ */ package com.evolveum.midpoint.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; -import static com.evolveum.midpoint.test.IntegrationTestTools.LDAP_CONNECTOR_TYPE; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -41,6 +35,7 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -68,23 +63,14 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ad-ldap-multidomain"); @@ -121,7 +107,7 @@ public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { private static final QName EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME = new QName(NS_EXTENSION, "showInAdvancedViewOnly"); protected static final File USER_SUBMAN_FILE = new File(TEST_DIR, "user-subman.xml"); - private static final String USER_SUBMAN_OID ="910ac45a-8bd6-11e6-9122-ef88d95095f0"; + private static final String USER_SUBMAN_OID = "910ac45a-8bd6-11e6-9122-ef88d95095f0"; private static final String USER_SUBMAN_USERNAME = "subman"; private static final String USER_SUBMAN_GIVEN_NAME = "Sub"; private static final String USER_SUBMAN_FAMILY_NAME = "Man"; @@ -134,7 +120,7 @@ public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { private static final String USER_SUBDOG_FULL_NAME = "Sub Dog"; protected static final File USER_SUBMARINE_FILE = new File(TEST_DIR, "user-submarine.xml"); - private static final String USER_SUBMARINE_OID ="c4377f86-8be9-11e6-8ef5-c3c56ff64b09"; + private static final String USER_SUBMARINE_OID = "c4377f86-8be9-11e6-8ef5-c3c56ff64b09"; private static final String USER_SUBMARINE_USERNAME = "submarine"; private static final String USER_SUBMARINE_GIVEN_NAME = "Sub"; private static final String USER_SUBMARINE_FAMILY_NAME = "Marine"; @@ -222,12 +208,12 @@ public String getPrimaryIdentifierAttributeName() { @Override protected String getPeopleLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } protected String getLdapSubSuffix() { @@ -235,7 +221,7 @@ protected String getLdapSubSuffix() { } protected String getPeopleLdapSubSuffix() { - return "CN=Users,"+getLdapSubSuffix(); + return "CN=Users," + getLdapSubSuffix(); } @Override @@ -268,7 +254,7 @@ protected boolean isGroupMemberMandatory() { } protected String getOrgsLdapSuffix() { - return "OU=Org,"+getLdapSuffix(); + return "OU=Org," + getLdapSuffix(); } private UserLdapConnectionConfig getSubLdapConnectionConfig() { @@ -285,7 +271,9 @@ private UserLdapConnectionConfig getSubLdapConnectionConfig() { protected abstract String getReconciliationTaskOid(); - protected String getLdapConnectorClassName() { return AdUtils.AD_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return AdUtils.AD_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -313,9 +301,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - assertLdapPassword(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME, ACCOUNT_JACK_PASSWORD); cleanupDelete(toAccountDn(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME)); cleanupDelete(toAccountDn(USER_CPTBARBOSSA_USERNAME, USER_CPTBARBOSSA_FULL_NAME)); @@ -335,12 +320,9 @@ public void test000Sanity() throws Exception { @Test @Override public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - -// IntegrationTestTools.displayXml("Resource XML", resource); + // IntegrationTestTools.displayXml("Resource XML", resource); accountObjectClassDefinition = AdUtils.assertAdResourceSchema(resource, getAccountObjectClass(), prismContext); - AdUtils.assertAdRefinedSchema(resource, getAccountObjectClass(), prismContext); + AdUtils.assertAdRefinedSchema(resource, getAccountObjectClass()); AdUtils.assertExchangeSchema(resource, getAccountObjectClass(), prismContext); ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); @@ -351,11 +333,8 @@ public void test020Schema() throws Exception { @Test public void test100SeachJackBySamAccountName() throws Exception { - final String TEST_NAME = "test100SeachJackBySamAccountName"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createSamAccountNameQuery(ACCOUNT_JACK_SAM_ACCOUNT_NAME); @@ -364,14 +343,15 @@ public void test100SeachJackBySamAccountName() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); - SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); + when(); + SearchResultList> shadows = + modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -391,17 +371,13 @@ public void test100SeachJackBySamAccountName() throws Exception { assertLdapConnectorInstances(1); } - /** * MID-3730 */ @Test public void test101SeachJackByDn() throws Exception { - final String TEST_NAME = "test101SeachJackByDn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String jackDn = toAccountDn(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME); @@ -411,14 +387,14 @@ public void test101SeachJackByDn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -440,16 +416,13 @@ public void test101SeachJackByDn() throws Exception { /** * Search for non-existent DN should return no results. It should NOT * throw an error. - * + *

* MID-3730 */ @Test public void test102SeachNotExistByDn() throws Exception { - final String TEST_NAME = "test102SeachNotExistByDn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String dn = toAccountDn("idonoexist", "I am a Fiction"); @@ -459,14 +432,14 @@ public void test102SeachNotExistByDn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 0, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 0, shadows.size()); // assertConnectorOperationIncrement(2); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -476,11 +449,8 @@ public void test102SeachNotExistByDn() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -490,14 +460,14 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -517,11 +487,8 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); @@ -529,11 +496,11 @@ public void test110GetJack() throws Exception { long startOfTestMsTimestamp = AdUtils.getWin32Filetime(System.currentTimeMillis()); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Shadow", shadow); @@ -548,10 +515,10 @@ public void test110GetJack() throws Exception { assertAttribute(shadow, "description", "The best pirate the world has ever seen"); assertAttribute(shadow, "sAMAccountName", ACCOUNT_JACK_SAM_ACCOUNT_NAME); assertObjectCategory(shadow, OBJECT_CATEGORY_PERSON); - List lastLogonValues = ShadowUtil.getAttributeValues(shadow, new QName(getResourceNamespace(),"lastLogon")); - assertEquals("Wrong number of lastLong values: "+lastLogonValues, 1, lastLogonValues.size()); + List lastLogonValues = ShadowUtil.getAttributeValues(shadow, new QName(getResourceNamespace(), "lastLogon")); + assertEquals("Wrong number of lastLong values: " + lastLogonValues, 1, lastLogonValues.size()); if (lastLogonValues.get(0) > startOfTestMsTimestamp) { - fail("Wrong lastLogon, expected it to be less than "+startOfTestMsTimestamp+", but was "+lastLogonValues.get(0)); + fail("Wrong lastLogon, expected it to be less than " + startOfTestMsTimestamp + ", but was " + lastLogonValues.get(0)); } assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); @@ -560,17 +527,13 @@ public void test110GetJack() throws Exception { assertLdapConnectorInstances(1); } - /** * No paging. It should return all accounts. */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -579,7 +542,7 @@ public void test150SeachAllAccounts() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); // TODO: Why 14? Why not 1? @@ -599,11 +562,8 @@ public void test150SeachAllAccounts() throws Exception { */ @Test public void test152SeachFirst2Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst2Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -612,7 +572,7 @@ public void test152SeachFirst2Accounts() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -628,11 +588,8 @@ public void test152SeachFirst2Accounts() throws Exception { @Test public void test154SeachFirst11Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst11Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -641,7 +598,7 @@ public void test154SeachFirst11Accounts() throws Exception { paging.setMaxSize(11); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -657,11 +614,8 @@ public void test154SeachFirst11Accounts() throws Exception { @Test public void test162SeachFirst2AccountsOffset0() throws Exception { - final String TEST_NAME = "test162SeachFirst2AccountsOffset0"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -671,7 +625,7 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -691,11 +645,8 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { */ @Test public void test172Search2AccountsOffset1() throws Exception { - final String TEST_NAME = "test172Search2AccountsOffset1"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -703,7 +654,7 @@ public void test172Search2AccountsOffset1() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); // TODO: Why 2? Why not 1? assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2); @@ -723,11 +674,8 @@ public void test172Search2AccountsOffset1() throws Exception { */ @Test public void test174SeachFirst11AccountsOffset2() throws Exception { - final String TEST_NAME = "test174SeachFirst11AccountsOffset2"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -738,7 +686,7 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { allowDuplicateSearchResults = true; // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // THEN allowDuplicateSearchResults = false; @@ -761,11 +709,8 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { */ @Test public void test182Search2AccountsOffset1SortCn() throws Exception { - final String TEST_NAME = "test182Search2AccountsOffset1SortCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -774,7 +719,7 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { paging.setOrdering(getAttributePath(resource, "cn"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> shadows = doSearch(query, 2, task, result); assertAccountShadow(shadows.get(0), "CN=Adolf Supperior,CN=Users,DC=ad,DC=evolveum,DC=com"); // assertAccountShadow(shadows.get(1), "CN=DiscoverySearchMailbox {D919BA05-46A6-415f-80AD-7E09334BB852},CN=Users,DC=ad,DC=evolveum,DC=com"); @@ -793,20 +738,17 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -821,7 +763,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -834,11 +776,11 @@ public void test200AssignAccountBarbossa() throws Exception { // MID-4624 ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, createTimestampMillis); assertObjectCategory(shadow, OBJECT_CATEGORY_PERSON); @@ -847,11 +789,8 @@ public void test200AssignAccountBarbossa() throws Exception { @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -859,15 +798,15 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { QName attrQName = new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_TITLE_NAME); ResourceAttributeDefinition attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName); PropertyDelta attrDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( - ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "Captain"); + ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "Captain"); delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -885,11 +824,8 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -901,11 +837,11 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -926,14 +862,10 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce */ @Test public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Exception { - final String TEST_NAME = "test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, "showInAdvancedViewOnly"); @@ -943,12 +875,12 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ItemPath.create(UserType.F_EXTENSION, EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME), task, result, Boolean.FALSE); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -972,28 +904,25 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except */ @Test public void test214ModifyAccountBarbossaProxyAddressesSimple() throws Exception { - final String TEST_NAME = "test214ModifyAccountBarbossaProxyAddressesSimple"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_PROXY_ADDRESSES_NAME); ResourceAttributeDefinition attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName); - assertNotNull("No definition for attribute "+attrQName, attrDef); + assertNotNull("No definition for attribute " + attrQName, attrDef); PropertyDelta attrDelta = prismContext.deltaFactory().property().createModificationAddProperty( - ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, PROXY_ADDRES_ADDR_UPCASE); + ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, PROXY_ADDRES_ADDR_UPCASE); delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -1048,15 +977,12 @@ public void test226ModifyUserBarbossaPasswordSelfServicePassword1AgainAgain() th } protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TEST_NAME, String oldPassword, String newPassword) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - - // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, oldPassword); login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -1064,11 +990,11 @@ protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TES oldPassword, newPassword); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertSuccess(result); @@ -1080,12 +1006,10 @@ protected void testModifyUserBarbossaPasswordSelfServiceSuccess(final String TES } protected void testModifyUserBarbossaPasswordSelfServiceFailure(final String TEST_NAME, String oldPassword, String newPassword) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - login(USER_BARBOSSA_USERNAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANNEL_GUI_SELF_SERVICE_URI); OperationResult result = task.getResult(); @@ -1093,44 +1017,40 @@ protected void testModifyUserBarbossaPasswordSelfServiceFailure(final String TES oldPassword, newPassword); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); login(USER_ADMINISTRATOR_USERNAME); assertPartialError(result); assertBarbossaEnabled(newPassword); assertUserAfter(USER_BARBOSSA_OID) - .assertPassword(newPassword); + .assertPassword(newPassword); assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, oldPassword); assertLdapConnectorInstances(2); } - @Test public void test230DisableUserBarbossa() throws Exception { - final String TEST_NAME = "test230DisableUserBarbossa"; - displayTestTitle(TEST_NAME); - // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD_AD_1); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1141,19 +1061,16 @@ public void test230DisableUserBarbossa() throws Exception { */ @Test public void test232ReconcileBarbossa() throws Exception { - final String TEST_NAME = "test232ReconcileBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1164,21 +1081,18 @@ public void test232ReconcileBarbossa() throws Exception { */ @Test public void test236EnableUserBarbossa() throws Exception { - final String TEST_NAME = "test236EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1191,19 +1105,16 @@ public void test236EnableUserBarbossa() throws Exception { */ @Test public void test237ReconcileBarbossa() throws Exception { - final String TEST_NAME = "test237ReconcileBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1216,22 +1127,19 @@ public void test237ReconcileBarbossa() throws Exception { */ @Test public void test238DisableUserBarbossaRawAndReconcile() throws Exception { - final String TEST_NAME = "test238DisableUserBarbossaRawAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ModelExecuteOptions.createRaw(), task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaDisabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1244,22 +1152,19 @@ public void test238DisableUserBarbossaRawAndReconcile() throws Exception { */ @Test public void test239EnableUserBarbossaRawAndReconcile() throws Exception { - final String TEST_NAME = "test239EnableUserBarbossaRawAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_BARBOSSA_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ModelExecuteOptions.createRaw(), task, result, ActivationStatusType.ENABLED); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BARBOSSA_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertBarbossaEnabled(USER_BARBOSSA_PASSWORD_AD_1); @@ -1318,11 +1223,8 @@ private void assertBarbossaDisabled(String password) throws Exception { */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // ProtectedStringType userPasswordPs = new ProtectedStringType(); @@ -1333,11 +1235,11 @@ public void test250AssignGuybrushPirates() throws Exception { task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1366,22 +1268,19 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test255ModifyUserGuybrushPassword() throws Exception { - final String TEST_NAME = "test255ModifyUserGuybrushPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_GUYBRUSH_PASSWORD_123); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1400,21 +1299,18 @@ public void test255ModifyUserGuybrushPassword() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_GUYBRUSH_OID); @@ -1439,11 +1335,8 @@ public void test260EnableGyubrush() throws Exception { */ @Test public void test270AssignAccountToEmptyhead() throws Exception { - final String TEST_NAME = "test270AssignAccountToEmptyhead"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_EMPTYHEAD_NAME, USER_EMPTYHEAD_NAME, true); @@ -1452,11 +1345,11 @@ public void test270AssignAccountToEmptyhead() throws Exception { String userEmptyheadOid = userBefore.getOid(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(userEmptyheadOid, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); assertMessageContains(result.getMessage(), "does not meet the length, complexity, or history requirement"); @@ -1470,19 +1363,15 @@ public void test270AssignAccountToEmptyhead() throws Exception { */ @Test public void test295TestConnection() throws Exception { - final String TEST_NAME = "test295TestConnection"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult testResult = modelService.testResource(getResourceOid(), task); // THEN - displayThen(TEST_NAME); + then(); display("Test connection result", testResult); TestUtil.assertSuccess("Test connection result", testResult); @@ -1493,19 +1382,16 @@ public void test295TestConnection() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1527,11 +1413,8 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, UserType.F_NAME, @@ -1540,13 +1423,12 @@ public void test390ModifyUserBarbossaRename() throws Exception { PrismTestUtil.createPolyString(USER_CPTBARBOSSA_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1569,24 +1451,20 @@ public void test390ModifyUserBarbossaRename() throws Exception { // TODO: create account with a group membership - @Test public void test395UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test395UnAssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1608,19 +1486,16 @@ public void test395UnAssignBarbossaPirates() throws Exception { @Test public void test399UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test399UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1635,11 +1510,8 @@ public void test399UnAssignAccountBarbossa() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = instantiateObject(OrgType.class); @@ -1653,11 +1525,11 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); orgMeleeIslandOid = org.getOid(); @@ -1680,19 +1552,16 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1715,11 +1584,8 @@ public void test510AssignGuybrushMeleeIsland() throws Exception { */ @Test public void test515AddOrgGroupMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test515AddOrgGroupMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = instantiateObject(RoleType.class); @@ -1741,11 +1607,11 @@ public void test515AddOrgGroupMeleeIslandPirates() throws Exception { roleType.getAssignment().add(orgAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1770,19 +1636,16 @@ public void test515AddOrgGroupMeleeIslandPirates() throws Exception { */ @Test public void test520RenameMeleeIsland() throws Exception { - final String TEST_NAME = "test520RenameMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); renameObject(OrgType.class, orgMeleeIslandOid, GROUP_MELEE_ISLAND_ALT_NAME, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1830,21 +1693,18 @@ public void test520RenameMeleeIsland() throws Exception { */ @Test public void test522ModifyMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test522GetMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(ShadowType.class, groupMeleeIslandPiratesOid, ItemPath.create(ShadowType.F_ATTRIBUTES, new QName(MidPointConstants.NS_RI, "description")), task, result, GROUP_MELEE_ISLAND_PIRATES_DESCRIPTION); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1858,19 +1718,16 @@ public void test522ModifyMeleeIslandPirates() throws Exception { @Test public void test524GetMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test524GetMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, groupMeleeIslandPiratesOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Shadow after", shadow); @@ -1883,25 +1740,20 @@ public void test524GetMeleeIslandPirates() throws Exception { Entry entryOrgGroup = assertLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_ALT_NAME); display("Melee org", entryOrgGroup); assertNoLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_NAME); - -// assertLdapConnectorInstances(2); } @Test public void test595DeleteOrgGroupMeleeIslandPirates() throws Exception { - final String TEST_NAME = "test595DeleteOrgGroupMeleeIslandPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(RoleType.class, roleMeleeIslandPiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapOrgGroup(GROUP_MELEE_ISLAND_PIRATES_NAME, GROUP_MELEE_ISLAND_ALT_NAME); @@ -1916,26 +1768,23 @@ public void test595DeleteOrgGroupMeleeIslandPirates() throws Exception { * We create "underMelee" org that gets into the way of the delete. * Melee cannot be deleted in an ordinary way. "tree delete" control must * be used. This is configured in the connector config. - * + *

* MID-5935 */ @Test public void test599DeleteOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test599DeleteOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createUnderMeleeEntry(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapGroup(GROUP_MELEE_ISLAND_NAME); @@ -1960,21 +1809,18 @@ protected void createUnderMeleeEntry() throws LdapException, IOException { @Test public void test600AssignAccountSubman() throws Exception { - final String TEST_NAME = "test600AssignAccountSubman"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_SUBMAN_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1991,7 +1837,7 @@ public void test600AssignAccountSubman() throws Exception { accountSubmanOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -2003,31 +1849,28 @@ public void test600AssignAccountSubman() throws Exception { // MID-4624 ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); long createTimestampMillis = XmlTypeConverter.toMillis(createTimestamp); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, createTimestampMillis); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, createTimestampMillis); // assertLdapConnectorInstances(2); } @Test public void test610ModifyUserSubmanTitle() throws Exception { - final String TEST_NAME = "test610ModifyUserSubmanTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, UserType.F_TITLE, task, result, createPolyString("Underdog")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2044,22 +1887,19 @@ public void test610ModifyUserSubmanTitle() throws Exception { @Test public void test620ModifyUserSubmanPassword() throws Exception { - final String TEST_NAME = "test620ModifyUserSubmanPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue("SuB.321"); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2076,21 +1916,18 @@ public void test620ModifyUserSubmanPassword() throws Exception { @Test public void test630DisableUserSubman() throws Exception { - final String TEST_NAME = "test630DisableUserSubman"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // assertLdapConnectorInstances(2); @@ -2117,21 +1954,18 @@ public void test630DisableUserSubman() throws Exception { @Test public void test639EnableUserSubman() throws Exception { - final String TEST_NAME = "test639EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_SUBMAN_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_SUBMAN_OID); @@ -2149,11 +1983,8 @@ public void test639EnableUserSubman() throws Exception { @Test public void test690ModifyUserSubmanRename() throws Exception { - final String TEST_NAME = "test690ModifyUserSubmanRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_SUBMAN_OID, UserType.F_NAME, @@ -2162,11 +1993,11 @@ public void test690ModifyUserSubmanRename() throws Exception { createPolyString(USER_SUBDOG_FULL_NAME)); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(objectDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapSubAccount(USER_SUBDOG_USERNAME, USER_SUBDOG_FULL_NAME); @@ -2188,19 +2019,16 @@ public void test690ModifyUserSubmanRename() throws Exception { @Test public void test699UnAssignAccountSubdog() throws Exception { - final String TEST_NAME = "test699UnAssignAccountSubdog"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_SUBMAN_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapSubAccount(USER_SUBMAN_USERNAME, USER_SUBMAN_FULL_NAME); @@ -2220,28 +2048,21 @@ public void test699UnAssignAccountSubdog() throws Exception { */ @Test public void test700AssignAccountSubmarineAndModify() throws Exception { - final String TEST_NAME = "test700AssignAccountSubmarineAndModify"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - long tsStart = System.currentTimeMillis(); - // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_SUBMARINE_OID, ROLE_SUBMISSIVE_OID, task, result); modifyUserReplace(USER_SUBMARINE_OID, UserType.F_TITLE, task, result, PrismTestUtil.createPolyString("Underseadog")); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); - long tsEnd = System.currentTimeMillis(); - Entry entry = assertLdapSubAccount(USER_SUBMARINE_USERNAME, USER_SUBMARINE_FULL_NAME); display("Sub entry", entry); assertAttribute(entry, "title", "Underseadog"); @@ -2253,61 +2074,48 @@ public void test700AssignAccountSubmarineAndModify() throws Exception { accountSubmarineOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountIcfUid); + assertNotNull("No identifier in " + shadow, accountIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), accountIcfUid); assertAttribute(entry, AdUtils.ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512"); - -// assertLdapConnectorInstances(2); } @Test public void test809UnAssignAccountSubmarine() throws Exception { - final String TEST_NAME = "test809UnAssignAccountSubmarine"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_SUBMARINE_OID, ROLE_SUBMISSIVE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoLdapSubAccount(USER_SUBMARINE_USERNAME, USER_SUBMARINE_FULL_NAME); PrismObject user = getUser(USER_SUBMARINE_OID); assertNoLinkedAccount(user); - -// assertLdapConnectorInstances(2); } @Test public void test850ReconcileAccounts() throws Exception { - final String TEST_NAME = "test850ReconcileAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); - OperationResult result = task.getResult(); - assertUsers(6); // WHEN - displayWhen(TEST_NAME); + when(); addTask(getReconciliationTaskFile()); waitForTaskFinish(getReconciliationTaskOid(), true); // THEN - displayThen(TEST_NAME); + then(); assertUsers(15); // TODO @@ -2319,46 +2127,46 @@ public void test850ReconcileAccounts() throws Exception { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9\\-]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9\\-]+")); - ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); - assertNotNull("No SID in "+shadow, objectSidAttr); + ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); + assertNotNull("No SID in " + shadow, objectSidAttr); display("SID of " + dn + ": " + objectSidAttr); } protected void assertSid(PrismObject shadow, String expectedSid) throws SchemaException { - ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); - assertNotNull("No SID in "+shadow, objectSidAttr); + ResourceAttribute objectSidAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_SID_NAME)); + assertNotNull("No SID in " + shadow, objectSidAttr); display("SID of " + shadow + ": " + objectSidAttr); - assertEquals("Wrong SID in "+shadow, expectedSid, objectSidAttr.getRealValue()); + assertEquals("Wrong SID in " + shadow, expectedSid, objectSidAttr.getRealValue()); } private void assertObjectCategory(PrismObject shadow, String expectedObjectCategory) { - ResourceAttribute objectCategoryAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI,AdUtils.ATTRIBUTE_OBJECT_CATEGORY_NAME)); - assertNotNull("No objectCategory in "+shadow, objectCategoryAttr); + ResourceAttribute objectCategoryAttr = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, AdUtils.ATTRIBUTE_OBJECT_CATEGORY_NAME)); + assertNotNull("No objectCategory in " + shadow, objectCategoryAttr); display("objectCategory of " + shadow + ": " + objectCategoryAttr); - assertEquals("Wrong objectCategory in "+shadow, expectedObjectCategory, objectCategoryAttr.getRealValue()); + assertEquals("Wrong objectCategory in " + shadow, expectedObjectCategory, objectCategoryAttr.getRealValue()); } @Override protected Entry assertLdapAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount("(cn="+cn+")"); + Entry entry = searchLdapAccount("(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, AdUtils.ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } protected Entry assertLdapSubAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount(getSubLdapConnectionConfig(), "(cn="+cn+")"); + Entry entry = searchLdapAccount(getSubLdapConnectionConfig(), "(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, AdUtils.ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } @Override - protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { + protected void assertNoLdapAccount(String uid) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -2372,12 +2180,12 @@ protected void assertNoLdapSubAccount(String uid, String cn) throws LdapExceptio protected void assertNoLdapAccount(UserLdapConnectionConfig config, String uid, String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(config); - List entriesCn = ldapSearch(config, connection, "(cn="+cn+")"); - List entriesSamAccountName = ldapSearch(config, connection, "(sAMAccountName="+uid+")"); + List entriesCn = ldapSearch(config, connection, "(cn=" + cn + ")"); + List entriesSamAccountName = ldapSearch(config, connection, "(sAMAccountName=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size()); - assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size()); + assertEquals("Unexpected number of entries for cn=" + cn + ": " + entriesCn, 0, entriesCn.size()); + assertEquals("Unexpected number of entries for sAMAccountName=" + uid + ": " + entriesSamAccountName, 0, entriesSamAccountName.size()); } @Override @@ -2387,11 +2195,11 @@ protected String toAccountDn(String username) { @Override protected String toAccountDn(String username, String fullName) { - return ("CN="+fullName+","+getPeopleLdapSuffix()); + return ("CN=" + fullName + "," + getPeopleLdapSuffix()); } protected String toAccountSubDn(String username, String fullName) { - return ("CN="+fullName+","+getPeopleLdapSubSuffix()); + return ("CN=" + fullName + "," + getPeopleLdapSubSuffix()); } @Override @@ -2399,22 +2207,22 @@ protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("CN", fullName)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } protected String toOrgDn(String cn) { - return "ou="+cn+","+getOrgsLdapSuffix(); + return "ou=" + cn + "," + getOrgsLdapSuffix(); } protected String toOrgGroupDn(String groupCn, String orgName) { - return "cn="+groupCn+","+toOrgDn(orgName); + return "cn=" + groupCn + "," + toOrgDn(orgName); } protected Entry assertLdapOrg(String orgName) throws LdapException, IOException, CursorException { String dn = toOrgDn(orgName); Entry entry = getLdapEntry(dn); - assertNotNull("No entry "+dn, entry); + assertNotNull("No entry " + dn, entry); assertAttribute(entry, "ou", orgName); return entry; } @@ -2422,14 +2230,14 @@ protected Entry assertLdapOrg(String orgName) throws LdapException, IOException, protected Entry assertNoLdapOrg(String orgName) throws LdapException, IOException, CursorException { String dn = toOrgDn(orgName); Entry entry = getLdapEntry(dn); - assertNull("Unexpected org entry "+entry, entry); + assertNull("Unexpected org entry " + entry, entry); return entry; } protected Entry assertLdapOrgGroup(String groupCn, String orgName) throws LdapException, IOException, CursorException { String dn = toOrgGroupDn(groupCn, orgName); Entry entry = getLdapEntry(dn); - assertNotNull("No entry "+dn, entry); + assertNotNull("No entry " + dn, entry); assertAttribute(entry, "cn", groupCn); return entry; } @@ -2437,7 +2245,7 @@ protected Entry assertLdapOrgGroup(String groupCn, String orgName) throws LdapEx protected Entry assertNoLdapOrgGroup(String groupCn, String orgName) throws LdapException, IOException, CursorException { String dn = toOrgGroupDn(groupCn, orgName); Entry entry = getLdapEntry(dn); - assertNull("Unexpected org group entry "+entry, entry); + assertNull("Unexpected org group entry " + entry, entry); return entry; } @@ -2450,7 +2258,7 @@ protected void assertLdapPassword(UserLdapConnectionConfig config, String uid, S assertLdapPassword(config, entry, password); } - protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { + protected void assertLdapPassword(String uid, String password) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -2490,7 +2298,7 @@ public void assertAttribute(PrismObject shadow, String attrName, public void assertAttribute(PrismObject shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected abstract void assertAccountDisabled(PrismObject shadow); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java index 7f7e51a8856..82cfcd54ba8 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapRawTest.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016 Evolveum and contributors +/* + * Copyright (c) 2016-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. @@ -18,7 +18,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; /** @@ -29,10 +28,7 @@ public abstract class AbstractAdLdapRawTest extends AbstractAdLdapTest { @Test - public void test050Capabilities() throws Exception { - final String TEST_NAME = "test050Capabilities"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test050Capabilities() { Collection nativeCapabilitiesCollection = ResourceTypeUtil.getNativeCapabilitiesCollection(resourceType); display("Native capabilities", nativeCapabilitiesCollection); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java index 1ca13e9dc9d..7a95d721c5d 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AbstractAdLdapTest.java @@ -1,36 +1,28 @@ -/** +/* * Copyright (c) 2015-2019 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.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS; import static com.evolveum.midpoint.schema.constants.SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE; import static com.evolveum.midpoint.testing.conntest.ad.AdUtils.*; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import java.io.File; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.List; - import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.prism.path.ItemPath; import org.apache.commons.lang.StringUtils; import org.apache.directory.api.ldap.model.cursor.CursorException; -import org.apache.directory.api.ldap.model.entry.DefaultEntry; -import org.apache.directory.api.ldap.model.entry.DefaultModification; -import org.apache.directory.api.ldap.model.entry.Entry; -import org.apache.directory.api.ldap.model.entry.Modification; -import org.apache.directory.api.ldap.model.entry.ModificationOperation; +import org.apache.directory.api.ldap.model.entry.*; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Ava; @@ -44,6 +36,7 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.query.ObjectPaging; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.query.OrderDirection; @@ -70,23 +63,14 @@ import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; /** * @author semancik - * */ -@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest { protected static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ad-ldap"); @@ -97,8 +81,6 @@ public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest protected static final File ROLE_META_ORG_FILE = new File(TEST_DIR, "role-meta-org.xml"); protected static final String ROLE_META_ORG_OID = "f2ad0ace-45d7-11e5-af54-001e8c717e5b"; - - protected static final String ACCOUNT_JACK_SAM_ACCOUNT_NAME = "jack"; protected static final String ACCOUNT_JACK_FULL_NAME = "Jack Sparrow"; protected static final String ACCOUNT_JACK_PASSWORD = "qwe.123"; @@ -118,7 +100,6 @@ public abstract class AbstractAdLdapTest extends AbstractLdapSynchronizationTest protected String jackAccountOid; protected String groupPiratesOid; - protected long jackLockoutTimestamp; protected String accountBarbossaOid; protected String orgMeleeIslandOid; protected String groupMeleeOid; @@ -175,12 +156,12 @@ public String getPrimaryIdentifierAttributeName() { @Override protected String getPeopleLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override protected String getGroupsLdapSuffix() { - return "CN=Users,"+getLdapSuffix(); + return "CN=Users," + getLdapSuffix(); } @Override @@ -217,7 +198,9 @@ protected boolean isGroupMemberMandatory() { return false; } - protected String getLdapConnectorClassName() { return AdUtils.AD_CONNECTOR_TYPE; } + protected String getLdapConnectorClassName() { + return AdUtils.AD_CONNECTOR_TYPE; + } @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { @@ -239,8 +222,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test @Override public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); super.test000Sanity(); assertLdapPassword(ACCOUNT_JACK_SAM_ACCOUNT_NAME, ACCOUNT_JACK_FULL_NAME, ACCOUNT_JACK_PASSWORD); @@ -254,9 +235,6 @@ public void test000Sanity() throws Exception { @Test @Override public void test020Schema() throws Exception { - final String TEST_NAME = "test020Schema"; - displayTestTitle(TEST_NAME); - accountObjectClassDefinition = AdUtils.assertAdResourceSchema(resource, getAccountObjectClass(), prismContext); assertLdapConnectorInstances(1); @@ -266,11 +244,8 @@ public void test020Schema() throws Exception { @Test public void test100SeachJackBySamAccountName() throws Exception { - final String TEST_NAME = "test100SeachJackBySamAccountName"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = createSamAccountNameQuery(ACCOUNT_JACK_SAM_ACCOUNT_NAME); @@ -279,14 +254,14 @@ public void test100SeachJackBySamAccountName() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -306,11 +281,8 @@ public void test100SeachJackBySamAccountName() throws Exception { @Test public void test105SeachPiratesByCn() throws Exception { - final String TEST_NAME = "test105SeachPiratesByCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getGroupObjectClass(), prismContext); @@ -320,14 +292,14 @@ public void test105SeachPiratesByCn() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN result.computeStatus(); TestUtil.assertSuccess(result); - assertEquals("Unexpected search result: "+shadows, 1, shadows.size()); + assertEquals("Unexpected search result: " + shadows, 1, shadows.size()); PrismObject shadow = shadows.get(0); display("Shadow", shadow); @@ -346,18 +318,15 @@ public void test105SeachPiratesByCn() throws Exception { @Test public void test110GetJack() throws Exception { - final String TEST_NAME = "test110GetJack"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT); rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, jackAccountOid, null, task, result); // THEN @@ -382,17 +351,13 @@ public void test110GetJack() throws Exception { assertLdapConnectorInstances(1); } - /** * No paging. It should return all accounts. */ @Test public void test150SeachAllAccounts() throws Exception { - final String TEST_NAME = "test150SeachAllAccounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -401,7 +366,7 @@ public void test150SeachAllAccounts() throws Exception { rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT); // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, + SearchResultList> searchResultList = doSearch(query, NUMBER_OF_ACCOUNTS, task, result); // TODO: why 11? should be 1 @@ -421,11 +386,8 @@ public void test150SeachAllAccounts() throws Exception { */ @Test public void test152SeachFirst2Accounts() throws Exception { - final String TEST_NAME = "test152SeachFirst2Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -434,7 +396,7 @@ public void test152SeachFirst2Accounts() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -452,11 +414,8 @@ public void test152SeachFirst2Accounts() throws Exception { */ @Test public void test154SeachFirst11Accounts() throws Exception { - final String TEST_NAME = "test154SeachFirst11Accounts"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -465,7 +424,7 @@ public void test154SeachFirst11Accounts() throws Exception { paging.setMaxSize(11); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -480,11 +439,8 @@ public void test154SeachFirst11Accounts() throws Exception { @Test public void test162SeachFirst2AccountsOffset0() throws Exception { - final String TEST_NAME = "test162SeachFirst2AccountsOffset0"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -494,7 +450,7 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { paging.setMaxSize(2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -514,11 +470,8 @@ public void test162SeachFirst2AccountsOffset0() throws Exception { */ @Test public void test172Search2AccountsOffset1() throws Exception { - final String TEST_NAME = "test172Search2AccountsOffset1"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -526,7 +479,7 @@ public void test172Search2AccountsOffset1() throws Exception { ObjectPaging paging = prismContext.queryFactory().createPaging(1, 2); query.setPaging(paging); - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> searchResultList = doSearch(query, 2, task, result); assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 1); assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0); @@ -546,11 +499,8 @@ public void test172Search2AccountsOffset1() throws Exception { */ @Test public void test174SeachFirst11AccountsOffset2() throws Exception { - final String TEST_NAME = "test174SeachFirst11AccountsOffset2"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -561,7 +511,7 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { allowDuplicateSearchResults = true; // WHEN - SearchResultList> searchResultList = doSearch(TEST_NAME, query, 11, task, result); + SearchResultList> searchResultList = doSearch(query, 11, task, result); // THEN allowDuplicateSearchResults = false; @@ -584,11 +534,8 @@ public void test174SeachFirst11AccountsOffset2() throws Exception { */ @Test public void test182Search2AccountsOffset1SortCn() throws Exception { - final String TEST_NAME = "test182Search2AccountsOffset1SortCn"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext); @@ -597,7 +544,7 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { paging.setOrdering(getAttributePath(resource, "cn"), OrderDirection.ASCENDING); query.setPaging(paging); - SearchResultList> shadows = doSearch(TEST_NAME, query, 2, task, result); + SearchResultList> shadows = doSearch(query, 2, task, result); assertAccountShadow(shadows.get(0), "CN=Administrator,CN=Users,DC=win,DC=evolveum,DC=com"); assertAccountShadow(shadows.get(1), "CN=Chuck LeChuck,CN=Users,DC=win,DC=evolveum,DC=com"); @@ -615,20 +562,17 @@ public void test182Search2AccountsOffset1SortCn() throws Exception { @Test public void test200AssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test200AssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long tsStart = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long tsEnd = System.currentTimeMillis(); @@ -643,7 +587,7 @@ public void test200AssignAccountBarbossa() throws Exception { accountBarbossaOid = shadow.getOid(); Collection> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); String accountBarbossaIcfUid = (String) identifiers.iterator().next().getRealValue(); - assertNotNull("No identifier in "+shadow, accountBarbossaIcfUid); + assertNotNull("No identifier in " + shadow, accountBarbossaIcfUid); assertEquals("Wrong ICFS UID", AdUtils.formatGuidToDashedNotation(MiscUtil.binaryToHex(entry.get(getPrimaryIdentifierAttributeName()).getBytes())), @@ -654,21 +598,18 @@ public void test200AssignAccountBarbossa() throws Exception { assertAttribute(entry, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512"); ResourceAttribute createTimestampAttribute = ShadowUtil.getAttribute(shadow, new QName(MidPointConstants.NS_RI, "createTimeStamp")); - assertNotNull("No createTimestamp in "+shadow, createTimestampAttribute); + assertNotNull("No createTimestamp in " + shadow, createTimestampAttribute); XMLGregorianCalendar createTimestamp = createTimestampAttribute.getRealValue(); // LDAP server may be on a different host. Allow for some clock offset. - TestUtil.assertBetween("Wrong createTimestamp in "+shadow, roundTsDown(tsStart)-120000, roundTsUp(tsEnd)+120000, XmlTypeConverter.toMillis(createTimestamp)); + TestUtil.assertBetween("Wrong createTimestamp in " + shadow, roundTsDown(tsStart) - 120000, roundTsUp(tsEnd) + 120000, XmlTypeConverter.toMillis(createTimestamp)); assertLdapConnectorInstances(2); } @Test public void test210ModifyAccountBarbossaTitle() throws Exception { - final String TEST_NAME = "test210ModifyAccountBarbossaTitle"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -680,11 +621,11 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -701,11 +642,8 @@ public void test210ModifyAccountBarbossaTitle() throws Exception { @Test public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exception { - final String TEST_NAME = "test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object() @@ -717,11 +655,11 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -741,14 +679,10 @@ public void test212ModifyAccountBarbossaShowInAdvancedViewOnlyTrue() throws Exce */ @Test public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Exception { - final String TEST_NAME = "test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); - ObjectDelta delta = prismContext.deltaFactory().object() .createEmptyModifyDelta(ShadowType.class, accountBarbossaOid); QName attrQName = new QName(MidPointConstants.NS_RI, "showInAdvancedViewOnly"); @@ -758,12 +692,12 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except delta.addModification(attrDelta); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, ItemPath.create(UserType.F_EXTENSION, EXTENSION_SHOW_IN_ADVANCED_VIEW_ONLY_QNAME), task, result, Boolean.FALSE); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -779,22 +713,19 @@ public void test213ModifyUserBarbossaShowInAdvancedViewOnlyFalse() throws Except @Test public void test220ModifyUserBarbossaPassword() throws Exception { - final String TEST_NAME = "test220ModifyUserBarbossaPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_2); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -814,22 +745,19 @@ public void test220ModifyUserBarbossaPassword() throws Exception { */ @Test public void test222ModifyUserBarbossaPasswordNational() throws Exception { - final String TEST_NAME = "test222ModifyUserBarbossaPasswordNational"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue(USER_BARBOSSA_PASSWORD_AD_1); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME); @@ -846,22 +774,19 @@ public void test222ModifyUserBarbossaPasswordNational() throws Exception { @Test public void test230DisableUserBarbossa() throws Exception { - final String TEST_NAME = "test230DisableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // precondition assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD_AD_1); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertLdapConnectorInstances(2); @@ -888,19 +813,16 @@ public void test230DisableUserBarbossa() throws Exception { @Test public void test239EnableUserBarbossa() throws Exception { - final String TEST_NAME = "test239EnableUserBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject user = getUser(USER_BARBOSSA_OID); @@ -921,21 +843,18 @@ public void test239EnableUserBarbossa() throws Exception { */ @Test public void test250AssignGuybrushPirates() throws Exception { - final String TEST_NAME = "test250AssignGuybrushPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -957,22 +876,19 @@ public void test250AssignGuybrushPirates() throws Exception { @Test public void test255ModifyUserGuybrushPassword() throws Exception { - final String TEST_NAME = "test255ModifyUserGuybrushPassword"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ProtectedStringType userPasswordPs = new ProtectedStringType(); userPasswordPs.setClearValue("wanna.be.a.123"); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_CREDENTIALS_PASSWORD_VALUE, task, result, userPasswordPs); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -991,19 +907,16 @@ public void test255ModifyUserGuybrushPassword() throws Exception { @Test public void test260EnableGyubrush() throws Exception { - final String TEST_NAME = "test260EnableGyubrush"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_GUYBRUSH_OID, PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1024,19 +937,16 @@ public void test260EnableGyubrush() throws Exception { @Test public void test300AssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test300AssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1058,11 +968,8 @@ public void test300AssignBarbossaPirates() throws Exception { @Test public void test390ModifyUserBarbossaRename() throws Exception { - final String TEST_NAME = "test390ModifyUserBarbossaRename"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta objectDelta = createModifyUserReplaceDelta(USER_BARBOSSA_OID, UserType.F_NAME, @@ -1071,13 +978,12 @@ public void test390ModifyUserBarbossaRename() throws Exception { PrismTestUtil.createPolyString(USER_CPTBARBOSSA_FULL_NAME)); Collection> deltas = MiscSchemaUtil.createCollection(objectDelta); - // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1100,24 +1006,20 @@ public void test390ModifyUserBarbossaRename() throws Exception { // TODO: create account with a group membership - @Test public void test395UnAssignBarbossaPirates() throws Exception { - final String TEST_NAME = "test395UnAssignBarbossaPirates"; - displayTestTitle(TEST_NAME); - // TODO: do this on another account. There is a bad interference with rename. // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_BARBOSSA_OID, ROLE_PIRATES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1139,19 +1041,16 @@ public void test395UnAssignBarbossaPirates() throws Exception { @Test public void test399UnAssignAccountBarbossa() throws Exception { - final String TEST_NAME = "test399UnAssignAccountBarbossa"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, getResourceOid(), null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1166,11 +1065,8 @@ public void test399UnAssignAccountBarbossa() throws Exception { @Test public void test500AddOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test500AddOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate(); @@ -1184,11 +1080,11 @@ public void test500AddOrgMeleeIsland() throws Exception { orgType.getAssignment().add(metaroleAssignment); // WHEN - displayWhen(TEST_NAME); + when(); addObject(org, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1205,19 +1101,16 @@ public void test500AddOrgMeleeIsland() throws Exception { @Test public void test510AssignGuybrushMeleeIsland() throws Exception { - final String TEST_NAME = "test510AssignGuybrushMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_GUYBRUSH_OID, orgMeleeIslandOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertLdapAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME); @@ -1239,8 +1132,8 @@ protected void doAdditionalRenameModifications(LdapNetworkConnection connection) Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID); connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod); - display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + - " -> "+ACCOUNT_HTM_UID+": "+mod); + display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + + " -> " + ACCOUNT_HTM_UID + ": " + mod); } @Override @@ -1252,32 +1145,32 @@ protected String getAccountHtmCnAfterRename() { protected void assertAccountShadow(PrismObject shadow, String dn) throws SchemaException { super.assertAccountShadow(shadow, dn); ResourceAttribute primaryIdAttr = ShadowUtil.getAttribute(shadow, getPrimaryIdentifierAttributeQName()); - assertNotNull("No primary identifier ("+getPrimaryIdentifierAttributeQName()+" in "+shadow, primaryIdAttr); + assertNotNull("No primary identifier (" + getPrimaryIdentifierAttributeQName() + " in " + shadow, primaryIdAttr); String primaryId = primaryIdAttr.getRealValue(); - assertTrue("Unexpected chars in primary ID: '"+primaryId+"'", primaryId.matches("[a-z0-9\\-]+")); + assertTrue("Unexpected chars in primary ID: '" + primaryId + "'", primaryId.matches("[a-z0-9\\-]+")); } @Override protected Entry assertLdapAccount(String samAccountName, String cn) throws LdapException, IOException, CursorException { - Entry entry = searchLdapAccount("(cn="+cn+")"); + Entry entry = searchLdapAccount("(cn=" + cn + ")"); assertAttribute(entry, "cn", cn); assertAttribute(entry, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, samAccountName); return entry; } @Override - protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException { + protected void assertNoLdapAccount(String uid) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } protected void assertNoLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException { LdapNetworkConnection connection = ldapConnect(); - List entriesCn = ldapSearch(connection, "(cn="+cn+")"); - List entriesSamAccountName = ldapSearch(connection, "(sAMAccountName="+uid+")"); + List entriesCn = ldapSearch(connection, "(cn=" + cn + ")"); + List entriesSamAccountName = ldapSearch(connection, "(sAMAccountName=" + uid + ")"); ldapDisconnect(connection); - assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size()); - assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size()); + assertEquals("Unexpected number of entries for cn=" + cn + ": " + entriesCn, 0, entriesCn.size()); + assertEquals("Unexpected number of entries for sAMAccountName=" + uid + ": " + entriesSamAccountName, 0, entriesSamAccountName.size()); } @Override @@ -1287,7 +1180,7 @@ protected String toAccountDn(String username) { @Override protected String toAccountDn(String username, String fullName) { - return "CN="+fullName+","+getPeopleLdapSuffix(); + return "CN=" + fullName + "," + getPeopleLdapSuffix(); } @Override @@ -1295,7 +1188,7 @@ protected Rdn toAccountRdn(String username, String fullName) { try { return new Rdn(new Ava("CN", fullName)); } catch (LdapInvalidDnException e) { - throw new IllegalStateException(e.getMessage(),e); + throw new IllegalStateException(e.getMessage(), e); } } @@ -1304,7 +1197,7 @@ protected void assertLdapPassword(String uid, String fullName, String password) assertLdapPassword(entry, password); } - protected void assertLdapPassword(String uid, String password) throws LdapException, IOException, CursorException { + protected void assertLdapPassword(String uid, String password) { throw new UnsupportedOperationException("Boom! Cannot do this here. This is bloody AD! We need full name!"); } @@ -1331,17 +1224,13 @@ protected Entry createAccountEntry(String uid, String cn, String givenName, Stri private byte[] encodePassword(String password) { String quotedPassword = "\"" + password + "\""; - try { - return quotedPassword.getBytes("UTF-16LE"); - } catch (UnsupportedEncodingException e) { - throw new SystemException(e.getMessage(), e); - } + return quotedPassword.getBytes(StandardCharsets.UTF_16LE); } @Override protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd) throws ObjectNotFoundException, SchemaException { - OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName()+".assertSyncToken"); + OperationResult result = new OperationResult(AbstractIntegrationTest.class.getName() + ".assertSyncToken"); Task task = taskManager.getTask(syncTaskOid, result); PrismProperty syncTokenProperty = task.getExtensionPropertyOrClone(SchemaConstants.SYNC_TOKEN); assertNotNull("No sync token", syncTokenProperty); @@ -1357,7 +1246,7 @@ public void assertAttribute(PrismObject shadow, String attrName, public void assertAttribute(PrismObject shadow, QName attrQname, T... expectedValues) { List actualValues = ShadowUtil.getAttributeValues(shadow, attrQname); - PrismAsserts.assertSets("attribute "+attrQname+" in " + shadow, actualValues, expectedValues); + PrismAsserts.assertSets("attribute " + attrQname + " in " + shadow, actualValues, expectedValues); } protected abstract void assertAccountDisabled(PrismObject shadow); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java index 643bbbc1573..9f0251af1ac 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/AdUtils.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,11 +6,9 @@ */ package com.evolveum.midpoint.testing.conntest.ad; +import static org.testng.AssertJUnit.*; + import static com.evolveum.midpoint.test.IntegrationTestTools.display; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; import javax.xml.namespace.QName; @@ -25,14 +23,12 @@ import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; /** * @author semancik - * */ public class AdUtils { @@ -54,59 +50,53 @@ public class AdUtils { /** * Returns dashed GUID notation formatted from simple hex-encoded binary. - * + *

* E.g. "2f01c06bb1d0414e9a69dd3841a13506" -> "6bc0012f-d0b1-4e41-9a69-dd3841a13506" */ public static String formatGuidToDashedNotation(String hexValue) { if (hexValue == null) { return null; } - StringBuilder sb = new StringBuilder(); - sb.append(hexValue.substring(6, 8)); - sb.append(hexValue.substring(4, 6)); - sb.append(hexValue.substring(2, 4)); - sb.append(hexValue.substring(0, 2)); - sb.append('-'); - sb.append(hexValue.substring(10, 12)); - sb.append(hexValue.substring(8, 10)); - sb.append('-'); - sb.append(hexValue.substring(14, 16)); - sb.append(hexValue.substring(12, 14)); - sb.append('-'); - sb.append(hexValue.substring(16, 20)); - sb.append('-'); - sb.append(hexValue.substring(20, 32)); - return sb.toString(); + return hexValue.substring(6, 8) + + hexValue.substring(4, 6) + + hexValue.substring(2, 4) + + hexValue.substring(0, 2) + + '-' + + hexValue.substring(10, 12) + + hexValue.substring(8, 10) + + '-' + + hexValue.substring(14, 16) + + hexValue.substring(12, 14) + + '-' + + hexValue.substring(16, 20) + + '-' + + hexValue.substring(20, 32); } public static ObjectClassComplexTypeDefinition assertAdResourceSchema(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); - display("Resource schema", resourceSchema); - ResourceTypeUtil.validateSchema(resourceSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchema(resourceSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; + ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); + display("Resource schema", resourceSchema); + ResourceTypeUtil.validateSchema(resourceSchema, resource); + return assertAdSchema(resource, accountObjectClass); } public static ObjectClassComplexTypeDefinition assertAdResourceSchemaLongTimestamp(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); display("Resource schema", resourceSchema); ResourceTypeUtil.validateSchema(resourceSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchemaLongTimestamp(resourceSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; -} + return assertAdSchemaLongTimestamp(resource, accountObjectClass); + } - public static ObjectClassComplexTypeDefinition assertAdRefinedSchema(PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { + public static ObjectClassComplexTypeDefinition assertAdRefinedSchema(PrismObject resource, QName accountObjectClass) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); RefinedResourceSchemaImpl.validateRefinedSchema(refinedSchema, resource); - ObjectClassComplexTypeDefinition accountObjectClassDef = assertAdSchema(refinedSchema, resource, accountObjectClass, prismContext); - return accountObjectClassDef; + return assertAdSchema(resource, accountObjectClass); } - // Assumes string timestamp - public static ObjectClassComplexTypeDefinition assertAdSchema(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resourceSchema, resource, accountObjectClass, prismContext); + public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject resource, QName accountObjectClass) throws SchemaException { + ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resource, accountObjectClass); ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp"); PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), @@ -126,8 +116,8 @@ public static ObjectClassComplexTypeDefinition assertAdSchema(ResourceSchema res } // Assumes string timestamp - public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { - ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resourceSchema, resource, accountObjectClass, prismContext); + public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(PrismObject resource, QName accountObjectClass) throws SchemaException { + ObjectClassComplexTypeDefinition accountObjectClassDefinition = assertAdSchemaBase(resource, accountObjectClass); ResourceAttributeDefinition createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp"); PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), @@ -139,12 +129,12 @@ public static ObjectClassComplexTypeDefinition assertAdSchemaLongTimestamp(Resou return accountObjectClassDefinition; } - private static ObjectClassComplexTypeDefinition assertAdSchemaBase(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException { + private static ObjectClassComplexTypeDefinition assertAdSchemaBase(PrismObject resource, QName accountObjectClass) throws SchemaException { RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); display("Refined schema", refinedSchema); ObjectClassComplexTypeDefinition accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(accountObjectClass); - assertNotNull("No definition for object class "+accountObjectClass, accountObjectClassDefinition); + assertNotNull("No definition for object class " + accountObjectClass, accountObjectClassDefinition); display("Account object class def", accountObjectClassDefinition); ResourceAttributeDefinition cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); @@ -208,16 +198,16 @@ private static ObjectClassComplexTypeDefinition assertAdSchemaBase(ResourceSchem public static void assertExchangeSchema(PrismObject resource, QName accountObjectClassQName, PrismContext prismContext) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); - assertExchangeSchema(resourceSchema, resource, accountObjectClassQName, prismContext); + assertExchangeSchema(resourceSchema, accountObjectClassQName); RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); - assertExchangeSchema(refinedSchema, resource, accountObjectClassQName, prismContext); + assertExchangeSchema(refinedSchema, accountObjectClassQName); } - public static void assertExchangeSchema(ResourceSchema resourceSchema, PrismObject resource, QName accountObjectClassQName, PrismContext prismContext) throws SchemaException { + public static void assertExchangeSchema(ResourceSchema resourceSchema, QName accountObjectClassQName) { ObjectClassComplexTypeDefinition msExchBaseClassObjectClassDefinition = resourceSchema.findObjectClassDefinition(OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME); - assertNotNull("No definition for object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME, msExchBaseClassObjectClassDefinition); - display("Object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME+" def", msExchBaseClassObjectClassDefinition); + assertNotNull("No definition for object class " + OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME, msExchBaseClassObjectClassDefinition); + display("Object class " + OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME + " def", msExchBaseClassObjectClassDefinition); ResourceAttributeDefinition msExchHideFromAddressListsDef = msExchBaseClassObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME); PrismAsserts.assertDefinition(msExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1); @@ -226,8 +216,8 @@ public static void assertExchangeSchema(ResourceSchema resourceSchema, PrismObje assertTrue("msExchHideFromAddressLists add", msExchHideFromAddressListsDef.canAdd()); ObjectClassComplexTypeDefinition accountObjectClassDef = resourceSchema.findObjectClassDefinition(accountObjectClassQName); - assertNotNull("No definition for object class "+accountObjectClassQName, accountObjectClassDef); - display("Object class "+accountObjectClassQName+" def", accountObjectClassDef); + assertNotNull("No definition for object class " + accountObjectClassQName, accountObjectClassDef); + display("Object class " + accountObjectClassQName + " def", accountObjectClassDef); ResourceAttributeDefinition accountMsExchHideFromAddressListsDef = accountObjectClassDef.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME); PrismAsserts.assertDefinition(accountMsExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java index 44c13031044..037d2df093c 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimera.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java index c2c481182ab..8a773c2d083 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraNativeSchema.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -12,18 +12,13 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; -import org.testng.annotations.Test; - -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; /** * Test for multi-domain AD (chimera-hydra) with native AD schema support and automatic objectCategory management. * * @author semancik */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraNativeSchema extends TestAdLdapChimera { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java index 7f606299409..a825ffd04b5 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraRunAs.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -12,7 +12,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; -import org.testng.annotations.Test; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; @@ -20,9 +19,8 @@ /** * @author semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraRunAs extends AbstractAdLdapMultidomainRunAsTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java index 11cb55ff27d..b61095d2354 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapChimeraStrange.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,24 +6,24 @@ */ package com.evolveum.midpoint.testing.conntest.ad; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import java.io.File; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import java.io.File; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; /** * Test for multi-domain AD (chimera-hydra) with some strange configuration. * * @author semancik */ -@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-conntest-test-main.xml" }) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimeraStrange extends TestAdLdapChimera { @@ -39,18 +39,15 @@ protected File getResourceFile() { */ @Test public void test599DeleteOrgMeleeIsland() throws Exception { - final String TEST_NAME = "test599DeleteOrgMeleeIsland"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); createUnderMeleeEntry(); try { // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, orgMeleeIslandOid, task, result); assertNotReached(); @@ -59,7 +56,7 @@ public void test599DeleteOrgMeleeIsland() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); // assertLdapConnectorInstances(2); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java index b86e58f1e3d..a815eab005a 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapLocalhost extends AbstractAdLdapCookedTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java index 0ad0c35fd26..473bcc9eb49 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapMedusa.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapMedusa extends AbstractAdLdapCookedTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java index a6dcf6d36cf..bdc5b139b5d 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawLocalhost.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapRawLocalhost extends AbstractAdLdapRawTest { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java index 02640240f47..4b5c5b7e0f7 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/ad/TestAdLdapRawMedusa.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015-2016 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -8,16 +8,8 @@ import java.io.File; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Listeners; - -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; - /** * @author semancik - * */ public class TestAdLdapRawMedusa extends AbstractAdLdapRawTest { diff --git a/testing/conntest/testng-unit.xml b/testing/conntest/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/conntest/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/testing/longtest/pom.xml b/testing/longtest/pom.xml index 8855bc6b85f..b8b3fdd882a 100644 --- a/testing/longtest/pom.xml +++ b/testing/longtest/pom.xml @@ -19,6 +19,11 @@ midPoint Testing - Long Tests + + + true + + com.evolveum.midpoint.infra @@ -166,7 +171,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -210,29 +214,23 @@ - - - - - extratest - - - - maven-surefire-plugin - - false - alphabetical - - - - maven-failsafe-plugin - - false - alphabetical - - - - - - + + + + maven-surefire-plugin + + + true + alphabetical + + + + maven-failsafe-plugin + + ${skipLongTests} + alphabetical + + + + diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java index 05c076b59ae..b00c661b64e 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestGenericSynchronization.java @@ -203,10 +203,7 @@ private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFE @Test public void test100TreeImport() throws Exception { - final String TEST_NAME = "test100TreeImport"; - TestUtil.displayTestTitle(this, TEST_NAME); - - Task task = taskManager.createTaskInstance(TestLdap.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -215,14 +212,14 @@ public void test100TreeImport() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + (ldapdUserCount + ldapOrgCount) * 2000); // THEN - TestUtil.displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -230,10 +227,7 @@ public void test100TreeImport() throws Exception { } @Test - public void test200MoveRootChild() throws Exception { - final String TEST_NAME = "test200MoveRootChild"; - TestUtil.displayTestTitle(this, TEST_NAME); - + public void test200MoveRootChild() { //todo move one child of one root to root position } } diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java index c7a7e0027f4..c22cb9645a0 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdap.java @@ -150,7 +150,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertUsers(NUM_INITIAL_USERS); } @@ -162,18 +161,17 @@ public void test000Sanity() throws Exception { @Test public void test200AssignRolePiratesToBarbossa() throws Exception { final String TEST_NAME = "test200AssignRolePiratesToBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_BARBOSSA_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -190,10 +188,9 @@ public void test200AssignRolePiratesToBarbossa() throws Exception { @Test public void test202AssignLdapAccountToGuybrush() throws Exception { final String TEST_NAME = "test202AssignLdapAccountToGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); byte[] photoIn = Files.readAllBytes(Paths.get(DOT_JPG_FILENAME)); @@ -211,11 +208,11 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { assertTrue("Photo bytes do not match (user before)", Arrays.equals(photoIn, userJpegPhotoBefore)); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Entry entry = assertOpenDjAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true); @@ -249,10 +246,9 @@ public void test202AssignLdapAccountToGuybrush() throws Exception { @Test public void test204AssignRolePiratesToGuybrush() throws Exception { final String TEST_NAME = "test204AssignRolePiratesToGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange( "dn: cn=Pirates,ou=groups,dc=example,dc=com\n" + @@ -262,11 +258,11 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { ); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_GUYBRUSH_OID, ROLE_PIRATE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -280,10 +276,9 @@ public void test204AssignRolePiratesToGuybrush() throws Exception { @Test public void test400RenameLeChuckConflicting() throws Exception { final String TEST_NAME = "test400RenameLeChuckConflicting"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userLechuck = createUser(USER_LECHUCK_NAME, "LeChuck", true); @@ -302,12 +297,12 @@ public void test400RenameLeChuckConflicting() throws Exception { assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userLechuckOid, UserType.F_NAME, task, result, PrismTestUtil.createPolyString(ACCOUNT_CHARLES_NAME)); // THEN - displayThen(TEST_NAME); + then(); assertOpenDjAccount(ACCOUNT_CHARLES_NAME, "Charles L. Charles", true); assertOpenDjAccount(ACCOUNT_CHARLES_NAME + "1", "LeChuck", true); assertNoOpenDjAccount(ACCOUNT_LECHUCK_NAME); @@ -318,7 +313,6 @@ public void test400RenameLeChuckConflicting() throws Exception { @Test public void test800BigLdapSearch() throws Exception { final String TEST_NAME = "test800BigLdapSearch"; - displayTestTitle(TEST_NAME); // GIVEN @@ -326,7 +320,7 @@ public void test800BigLdapSearch() throws Exception { loadLdapEntries("a", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); @@ -344,16 +338,16 @@ public boolean handle(PrismObject shadow, OperationResult parentResu }; // WHEN - displayWhen(TEST_NAME); + when(); modelService.searchObjectsIterative(ShadowType.class, query, handler, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); // THEN - displayThen(TEST_NAME); + then(); assertEquals("Unexpected number of search results", NUM_LDAP_ENTRIES + 8, count.getValue()); @@ -363,7 +357,6 @@ public boolean handle(PrismObject shadow, OperationResult parentResu @Test public void test810BigImport() throws Exception { final String TEST_NAME = "test810BigImport"; - displayTestTitle(TEST_NAME); // GIVEN @@ -371,25 +364,25 @@ public void test810BigImport() throws Exception { loadLdapEntries("u", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -399,11 +392,10 @@ public void test810BigImport() throws Exception { @Test public void test820BigReconciliation() throws Exception { final String TEST_NAME = "test820BigReconciliation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // System.out.println("openDJController.isRunning = " + openDJController.isRunning()); @@ -415,19 +407,19 @@ public void test820BigReconciliation() throws Exception { ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); // WHEN - displayWhen(TEST_NAME); + when(); reconciliationTaskHandler.launch(resource, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(); // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -437,27 +429,26 @@ public void test820BigReconciliation() throws Exception { @Test public void test900DeleteShadows() throws Exception { final String TEST_NAME = "test900DeleteShadows"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_OPENDJ_SHADOWS_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_OPENDJ_SHADOWS_OID, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0); @@ -487,25 +478,24 @@ public void test900DeleteShadows() throws Exception { @Test public void test910DeleteAccounts() throws Exception { final String TEST_NAME = "test910DeleteAccounts"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_DELETE_OPENDJ_ACCOUNTS_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_DELETE_OPENDJ_ACCOUNTS_OID, true, 20000 + NUM_LDAP_ENTRIES*3000); // THEN - displayThen(TEST_NAME); + then(); assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, (2*NUM_LDAP_ENTRIES)/100+2); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java index 1bf1bc43103..c5a89119d0f 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapComplex.java @@ -11,12 +11,10 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.io.IOException; import javax.xml.namespace.QName; import org.opends.server.types.Entry; -import org.opends.server.util.LDIFException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -133,30 +131,29 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100BigImport() throws Exception { final String TEST_NAME = "test100BigImport"; - displayTestTitle(TEST_NAME); // GIVEN loadLdapEntries("u", NUM_LDAP_ENTRIES); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); // THEN - displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -175,15 +172,14 @@ private void assertUser(String name, Task task, OperationResult result) throws c @Test(enabled = false) public void test120BigReconciliation() throws Exception { final String TEST_NAME = "test120BigReconciliation"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 2); ResourceType resource = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result).asObjectable(); @@ -191,7 +187,7 @@ public void test120BigReconciliation() throws Exception { new QName(RESOURCE_OPENDJ_NAMESPACE, "AccountObjectClass"), task, result); // THEN - displayThen(TEST_NAME); + then(); // TODO // OperationResult subresult = result.getLastSubresult(); // TestUtil.assertInProgress("reconciliation launch result", subresult); @@ -199,7 +195,7 @@ public void test120BigReconciliation() throws Exception { waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000); // THEN - displayThen(TEST_NAME); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); @@ -214,20 +210,19 @@ public void test120BigReconciliation() throws Exception { @Test public void test500GuybrushAssignSecurity() throws Exception { final String TEST_NAME = "test500GuybrushAssignSecurity"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(USER_GUYBRUSH_FILE); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, INTENT_SECURITY, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); @@ -245,10 +240,9 @@ public void test500GuybrushAssignSecurity() throws Exception { @Test public void test502RuinGuybrushAccountAndReconcile() throws Exception { final String TEST_NAME = "test502RuinGuybrushAccountAndReconcile"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Entry entryOrig = openDJController.searchByUid(USER_GUYBRUSH_USERNAME); @@ -258,11 +252,11 @@ public void test502RuinGuybrushAccountAndReconcile() throws Exception { openDJController.assertHasNoObjectClass(entryBefore, OBJECTCLASS_USER_SECURITY_INFORMATION); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_GUYBRUSH_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_GUYBRUSH_OID); diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java index dd0cddb6f40..b1a65c9d822 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestLdapUniversity.java @@ -6,6 +6,25 @@ */ package com.evolveum.midpoint.testing.longtest; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import javax.xml.namespace.QName; + +import org.apache.commons.io.IOUtils; +import org.opends.server.types.Entry; +import org.opends.server.types.LDIFImportConfig; +import org.opends.server.util.LDIFException; +import org.opends.server.util.LDIFReader; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + import com.evolveum.midpoint.common.LoggingConfigurationManager; import com.evolveum.midpoint.common.ProfilingConfigurationManager; import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; @@ -16,7 +35,6 @@ import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; @@ -24,59 +42,29 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.apache.commons.io.IOUtils; -import org.opends.server.types.Entry; -import org.opends.server.types.LDIFImportConfig; -import org.opends.server.util.LDIFException; -import org.opends.server.util.LDIFReader; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; - -import static org.testng.AssertJUnit.assertEquals; /** - * * @author Pavol Mederly - * */ -@ContextConfiguration(locations = {"classpath:ctx-longtest-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-longtest-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestLdapUniversity extends AbstractModelIntegrationTest { - public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "ldap-university"); - public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml"); - public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value(); protected static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml"); protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002"; - protected static final String USER_ADMINISTRATOR_USERNAME = "administrator"; protected static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml"); - protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004"; protected static final File RESOURCE_OPENDJ_FILE = new File(COMMON_DIR, "resource-opendj-university.xml"); - protected static final String RESOURCE_OPENDJ_NAME = "Localhost OpenDJ"; protected static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; protected static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; // Make it at least 1501 so it will go over the 3000 entries size limit private static final int NUM_LDAP_ENTRIES = 3100; - private static final String LDAP_GROUP_PIRATES_DN = "cn=Pirates,ou=groups,dc=example,dc=com"; - protected ResourceType resourceOpenDjType; protected PrismObject resourceOpenDj; @@ -89,7 +77,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -128,155 +116,113 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100BigImportWithLinking() throws Exception { - final String TEST_NAME = "test100BigImportWithLinking"; - TestUtil.displayTestTitle(this, TEST_NAME); - // GIVEN InternalsConfig.turnOffAllChecks(); - Task task = taskManager.createTaskInstance(TestLdapUniversity.class.getName() + "." + TEST_NAME); + Task task = getTestTask(); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); loadEntries("u"); - createUsers("u", new OperationResult("createUsers")); // we do not want to have all this in the task's result + createUsers(new OperationResult("createUsers")); // we do not want to have all this in the task's result display("e0", findUserByUsername("e0")); - // WHEN - TestUtil.displayWhen(TEST_NAME); - //task.setExtensionPropertyValue(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS, 5); + when(); modelService.importFromResource(RESOURCE_OPENDJ_OID, new QName(RESOURCE_OPENDJ_NAMESPACE, "inetOrgPerson"), task, result); - // THEN - TestUtil.displayThen(TEST_NAME); + then(); OperationResult subresult = result.getLastSubresult(); TestUtil.assertInProgress("importAccountsFromResource result", subresult); - waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES*2000, 10000L); - - // THEN - TestUtil.displayThen(TEST_NAME); + waitForTaskFinish(task, true, 20000 + NUM_LDAP_ENTRIES * 2000, 10000L); + then(); int userCount = modelService.countObjects(UserType.class, null, null, task, result); display("Users", userCount); - assertEquals("Unexpected number of users", NUM_LDAP_ENTRIES+1, userCount); + assertEquals("Unexpected number of users", NUM_LDAP_ENTRIES + 1, userCount); display("e0(u0)", findUserByUsername("e0(u0)")); display("e1(u1)", findUserByUsername("e1(u1)")); - assertUser("e0(u0)", task, result); - assertUser("e1(u1)", task, result); + assertUser("e0(u0)"); + assertUser("e1(u1)"); } - private void createUsers(String prefix, OperationResult result) throws ObjectAlreadyExistsException, SchemaException { - final int TICK=100; + private void createUsers(OperationResult result) throws ObjectAlreadyExistsException, SchemaException { + final int TICK = 100; long start = System.currentTimeMillis(); - for(int i=0; i < NUM_LDAP_ENTRIES; i++) { + for (int i = 0; i < NUM_LDAP_ENTRIES; i++) { UserType userType = (UserType) prismContext.getSchemaRegistry().findObjectDefinitionByType(UserType.COMPLEX_TYPE).instantiate().asObjectable(); - if (i%2 == 0) { + if (i % 2 == 0) { userType.setName(createPolyStringType("e" + i)); } else { userType.setName(createPolyStringType("e" + i + "(u" + i + ")")); } - userType.setEmployeeNumber("e"+i); + userType.setEmployeeNumber("e" + i); repositoryService.addObject(userType.asPrismObject(), null, result); - if ((i+1)%TICK == 0 && (i+1) namesToAdd = new ArrayList<>(BATCH); - for(int i=0; i < NUM_LDAP_ENTRIES; i++) { - String name = "user"+i; - Entry entry = createEntry(prefix+i, "e"+i, name); + for (int i = 0; i < NUM_LDAP_ENTRIES; i++) { + String name = "user" + i; + Entry entry = createEntry(prefix + i, "e" + i, name); openDJController.addEntry(entry); -// namesToAdd.add(entry.getDN().toNormalizedString()); -// if (namesToAdd.size() == BATCH) { -// addToGroups(namesToAdd); -// namesToAdd.clear(); -// } - if ((i+1)%TICK == 0 && (i+1) namesToAdd) throws IOException, LDIFException { - for (int groupIndex = 1; groupIndex <= 10; groupIndex++) { - openDJController.addGroupUniqueMembers(groupDn(groupIndex), namesToAdd); - } + display("Loaded " + NUM_LDAP_ENTRIES + " LDAP entries in " + ((ldapPopEnd - ldapPopStart) / 1000) + " seconds"); } private Entry createEntry(String uid, String empno, String name) throws IOException, LDIFException { StringBuilder sb = new StringBuilder(); - String dn = "uid="+uid+","+openDJController.getSuffixPeople(); + String dn = "uid=" + uid + "," + openDJController.getSuffixPeople(); sb.append("dn: ").append(dn).append("\n"); sb.append("objectClass: inetOrgPerson\n"); sb.append("uid: ").append(uid).append("\n"); @@ -285,19 +231,6 @@ private Entry createEntry(String uid, String empno, String name) throws IOExcept sb.append("sn: ").append(name).append("\n"); LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), StandardCharsets.UTF_8)); LDIFReader ldifReader = new LDIFReader(importConfig); - Entry ldifEntry = ldifReader.readEntry(); - return ldifEntry; - } - - private String toDn(String username) { - return "uid="+username+","+OPENDJ_PEOPLE_SUFFIX; - } - - private String groupDn(int groupIndex) { - return "cn="+groupCn(groupIndex)+","+OPENDJ_GROUPS_SUFFIX; - } - - private String groupCn(int groupIndex) { - return String.format("g%02d", groupIndex); + return ldifReader.readEntry(); } } diff --git a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java index a135632e7ea..edf7c67c3e4 100644 --- a/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java +++ b/testing/longtest/src/test/java/com/evolveum/midpoint/testing/longtest/TestRunAs.java @@ -12,72 +12,27 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Map; -import javax.xml.namespace.QName; - import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.midpoint.model.api.ModelService; -import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; -import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.aspect.ProfilingDataManager; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.mutable.MutableInt; -import org.opends.server.types.Entry; -import org.opends.server.types.LDIFImportConfig; -import org.opends.server.util.LDIFException; -import org.opends.server.util.LDIFReader; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.polystring.PolyString; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.GetOperationOptions; -import com.evolveum.midpoint.schema.ResultHandler; -import com.evolveum.midpoint.schema.RetrieveOption; -import com.evolveum.midpoint.schema.SelectorOptions; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; -import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -148,9 +103,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); - assertUsers(NUM_INITIAL_USERS); } @@ -160,18 +112,17 @@ public void test000Sanity() throws Exception { @Test public void test100AssignAccountDummyToBarbossa() throws Exception { final String TEST_NAME = "test100AssignAccountDummyToBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -192,18 +143,17 @@ public void test100AssignAccountDummyToBarbossa() throws Exception { @Test public void test109UnassignAccountDummyFromBarbossa() throws Exception { final String TEST_NAME = "test109UnassignAccountDummyFromBarbossa"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_BARBOSSA_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -216,19 +166,18 @@ public void test109UnassignAccountDummyFromBarbossa() throws Exception { @Test public void test200CleanupPlain() throws Exception { final String TEST_NAME = "test200CleanupPlain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -256,22 +205,21 @@ public void test205WarmUp() throws Exception { @Test public void test210BarbossaSetOrganizationPlain() throws Exception { final String TEST_NAME = "test210BarbossaSetOrganizationPlain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -289,19 +237,18 @@ public void test210BarbossaSetOrganizationPlain() throws Exception { @Test public void test300CleanupRunAs() throws Exception { final String TEST_NAME = "test300CleanupRunAs"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result /* no value */); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_BARBOSSA_OID); @@ -329,22 +276,21 @@ public void test305WarmUp() throws Exception { @Test public void test310BarbossaSetOrganizationRunAs() throws Exception { final String TEST_NAME = "test310BarbossaSetOrganizationRunAs"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); long starMillis = System.currentTimeMillis(); modifyUserReplace(USER_BARBOSSA_OID, UserType.F_ORGANIZATION, task, result, createPolyString(ORG_PIRATES)); long endMillis = System.currentTimeMillis(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long readCountIncrement = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); @@ -371,16 +317,15 @@ public void test310BarbossaSetOrganizationRunAs() throws Exception { } private void warmUp(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); rememberCounter(InternalCounters.REPOSITORY_READ_COUNT); // WHEN - displayWhen(TEST_NAME); + when(); long firstTime = warmUpRound(0, task, result); long lastTime = 0; long sumTime = firstTime; @@ -390,7 +335,7 @@ private void warmUp(final String TEST_NAME) throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long readCountIncremenet = getCounterIncrement(InternalCounters.REPOSITORY_READ_COUNT); diff --git a/testing/longtest/testng-unit.xml b/testing/longtest/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/longtest/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/testing/pom.xml b/testing/pom.xml index 67f52d58ced..20944cf37cd 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -23,7 +23,20 @@ sanity - + + conntest + longtest + story + rest + samples-test + schrodingertest @@ -32,28 +45,4 @@ true true - - - - extratest - - longtest - story - rest - samples-test - - - - conntest - - conntest - - - - schrodinger - - schrodingertest - - - diff --git a/testing/rest/pom.xml b/testing/rest/pom.xml index 60a906dde26..57402cdcf02 100644 --- a/testing/rest/pom.xml +++ b/testing/rest/pom.xml @@ -19,6 +19,11 @@ midPoint Testing - REST API + + + true + + com.evolveum.midpoint.infra @@ -193,7 +198,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -338,27 +342,21 @@ - - - - - extratest - - - - maven-surefire-plugin - - false - - - - maven-failsafe-plugin - - false - - - - - - + + + + maven-surefire-plugin + + + true + + + + maven-failsafe-plugin + + ${skipRestTests} + + + + diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java index b1b5ba53c00..222f11d87f7 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestAbstractRestService.java @@ -19,16 +19,12 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; -import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; import com.evolveum.midpoint.model.api.ModelExecuteOptions; import com.evolveum.midpoint.task.api.Task; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -143,17 +139,16 @@ public TestAbstractRestService() { @Test public void test001GetUserAdministrator() { final String TEST_NAME = "test001GetUserAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -167,17 +162,16 @@ public void test001GetUserAdministrator() { @Test public void test002GetNonExistingUser() { final String TEST_NAME = "test002GetNonExistingUser"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/12345"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 404); OperationResultType result = response.readEntity(OperationResultType.class); assertNotNull("Error response must contain operation result", result); @@ -192,17 +186,16 @@ public void test002GetNonExistingUser() { @Test public void test003GetNoAuthHeaders() { final String TEST_NAME = "test003GetNoAuthHeaders"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(null, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -213,17 +206,16 @@ public void test003GetNoAuthHeaders() { @Test public void test004GetAuthBadUsernameNullPassword() { final String TEST_NAME = "test004GetAuthBadUsernameNullPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -234,17 +226,16 @@ public void test004GetAuthBadUsernameNullPassword() { @Test public void test005GetAuthBadUsernameEmptyPassword() { final String TEST_NAME = "test005GetAuthBadUsernameEmptyPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", ""); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -255,17 +246,16 @@ public void test005GetAuthBadUsernameEmptyPassword() { @Test public void test006GetAuthBadUsernameBadPassword() { final String TEST_NAME = "test006GetAuthBadUsernameBadPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient("NoSUCHuser", "NoSuchPassword"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -276,17 +266,16 @@ public void test006GetAuthBadUsernameBadPassword() { @Test public void test007GetAuthNoPassword() { final String TEST_NAME = "test007GetAuthNoPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_ADMINISTRATOR_USERNAME, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -297,17 +286,16 @@ public void test007GetAuthNoPassword() { @Test public void test016GetAuthBadPassword() { final String TEST_NAME = "test016GetAuthBadPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_ADMINISTRATOR_USERNAME, "forgot"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -318,17 +306,16 @@ public void test016GetAuthBadPassword() { @Test public void test017GetUnauthorizedUser() { final String TEST_NAME = "test017GetUnauthorizedUser"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOBODY_USERNAME, USER_NOBODY_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); display("Audit", getDummyAuditService()); @@ -339,17 +326,16 @@ public void test017GetUnauthorizedUser() { @Test public void test018GetUserAdministratorByCyclops() { final String TEST_NAME = "test018GetUserAdministratorByCyclops"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_CYCLOPS_USERNAME, USER_CYCLOPS_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 403); display("Audit", getDummyAuditService()); @@ -360,17 +346,16 @@ public void test018GetUserAdministratorByCyclops() { @Test public void test019GetUserAdministratorBySomebody() { final String TEST_NAME = "test019GetUserAdministratorBySomebody"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_SOMEBODY_USERNAME, USER_SOMEBODY_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 200); @@ -386,17 +371,16 @@ public void test019GetUserAdministratorBySomebody() { @Test public void test102AddUserTemplate() throws Exception { final String TEST_NAME = "test102AddUserTemplate"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates/"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -410,17 +394,16 @@ public void test102AddUserTemplate() throws Exception { @Test public void test103AddUserBadTargetCollection() throws Exception { final String TEST_NAME = "test103AddUserBadTargetCollection"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 400); @@ -437,7 +420,6 @@ public void test103AddUserBadTargetCollection() throws Exception { @Test public void test104AddAccountRawResourceDoesNotExist() throws Exception { final String TEST_NAME = "test104AddAccountRaw"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/shadows"); @@ -445,10 +427,10 @@ public void test104AddAccountRawResourceDoesNotExist() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(ACCOUT_CHUCK_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); // expecting hadnled error because resource doesn't exist.. it is OK, but let's say admin about that @@ -478,17 +460,16 @@ public void test104AddAccountRawResourceDoesNotExist() throws Exception { @Test public void test120AddRoleAdder() throws Exception { final String TEST_NAME = "test120AddRoleAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/roles"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(ROLE_ADDER_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -501,17 +482,16 @@ public void test120AddRoleAdder() throws Exception { @Test public void test121AddUserDarthAdder() throws Exception { final String TEST_NAME = "test121AddUserDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_DARTHADDER_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -524,17 +504,16 @@ public void test121AddUserDarthAdder() throws Exception { @Test public void test122AddRoleModifierAsDarthAdder() throws Exception { final String TEST_NAME = "test122AddRoleModifierAsDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/roles"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(ROLE_MODIFIER_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -547,17 +526,16 @@ public void test122AddRoleModifierAsDarthAdder() throws Exception { @Test public void test123DarthAdderAssignModifierHimself() throws Exception { final String TEST_NAME = "test123DarthAdderAssignModifierHimself"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/"+USER_DARTHADDER_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 403); OperationResultType result = response.readEntity(OperationResultType.class); @@ -574,17 +552,16 @@ public void test123DarthAdderAssignModifierHimself() throws Exception { @Test public void test124DarthAdderAssignModifierByAdministrator() throws Exception { final String TEST_NAME = "test124DarthAdderAssignModifierByAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/"+USER_DARTHADDER_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ASSIGN_ROLE_MODIFIER))); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -601,17 +578,16 @@ public void test124DarthAdderAssignModifierByAdministrator() throws Exception { @Test public void test130DarthAdderDisableHimself() throws Exception { final String TEST_NAME = "test130DarthAdderDisableHimself"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/"+USER_DARTHADDER_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_DISABLE))); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -628,17 +604,16 @@ public void test130DarthAdderDisableHimself() throws Exception { @Test public void test131GetUserAdministratorByDarthAdder() { final String TEST_NAME = "test131GetUserAdministratorByDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -650,17 +625,16 @@ public void test131GetUserAdministratorByDarthAdder() { @Test public void test132DarthAdderEnableByAdministrator() throws Exception { final String TEST_NAME = "test132DarthAdderEnableByAdministrator"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/"+USER_DARTHADDER_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(MiscUtil.readFile(getRequestFile(MODIFICATION_ENABLE))); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 204); @@ -677,17 +651,16 @@ public void test132DarthAdderEnableByAdministrator() throws Exception { @Test public void test133GetUserAdministratorByDarthAdder() { final String TEST_NAME = "test133GetUserAdministratorByDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -701,17 +674,16 @@ public void test133GetUserAdministratorByDarthAdder() { @Test public void test135AddUserNopasswordAsDarthAdder() throws Exception { final String TEST_NAME = "test135AddUserNopasswordAsDarthAdder"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD); client.path("/users"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_NOPASSWORD_FILE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 201); @@ -724,17 +696,16 @@ public void test135AddUserNopasswordAsDarthAdder() throws Exception { @Test public void test140GetUserAdministratorByNopassword() { final String TEST_NAME = "test140GetUserAdministratorByNopassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOPASSWORD_USERNAME, null); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -746,17 +717,16 @@ public void test140GetUserAdministratorByNopassword() { @Test public void test141GetUserAdministratorByNopasswordBadPassword() { final String TEST_NAME = "test140GetUserAdministratorByNopassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_NOPASSWORD_USERNAME, "bad"); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 401); // assertNoEmptyResponse(response); @@ -768,17 +738,16 @@ public void test141GetUserAdministratorByNopasswordBadPassword() { @Test public void test200searchAllUsers() { final String TEST_NAME = "test200searchAllUsers"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/search"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(new QueryType()); - displayThen(TEST_NAME); + then(); displayResponse(response); assertStatus(response, 200); @@ -791,7 +760,6 @@ public void test200searchAllUsers() { @Test public void test401AddUserTemplateOverwrite() throws Exception { final String TEST_NAME = "test401AddUserTemplateOverwrite"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/objectTemplates"); @@ -800,11 +768,11 @@ public void test401AddUserTemplateOverwrite() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(USER_TEMPLATE_FILE)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -826,7 +794,6 @@ public void test401AddUserTemplateOverwrite() throws Exception { @Test public void test410AddFunctionLibraryHello() throws Exception { final String TEST_NAME = "test410AddFunctionLibraryHello"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/functionLibraries"); @@ -835,11 +802,11 @@ public void test410AddFunctionLibraryHello() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(FUNCTION_LIBRARY_HELLO_FILE)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 201 but got " + response.getStatus(), 201, response.getStatus()); @@ -858,17 +825,16 @@ public void test410AddFunctionLibraryHello() throws Exception { @Test public void test412GetFunctionLibraryHello() { final String TEST_NAME = "test412GetFunctionLibraryHello"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/functionLibraries/" + FUNCTION_LIBRARY_HELLO_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); assertStatus(response, 200); FunctionLibraryType libType = response.readEntity(FunctionLibraryType.class); assertNotNull("Returned entity in body must not be null.", libType); @@ -888,17 +854,16 @@ public void test412GetFunctionLibraryHello() { @Test public void test501generateValue() throws Exception { final String TEST_NAME = "test501generateValue"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -913,17 +878,16 @@ public void test501generateValue() throws Exception { @Test public void test502generateValueBadPath() throws Exception { final String TEST_NAME = "test502generateValueBadPath"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_BAD_PATH)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -936,17 +900,16 @@ public void test502generateValueBadPath() throws Exception { @Test public void test503generateValueExecute() throws Exception { final String TEST_NAME = "test503generateValueExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXECUTE)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -964,17 +927,16 @@ public void test503generateValueExecute() throws Exception { @Test public void test504checkGeneratedValue() throws Exception { final String TEST_NAME = "test503generateValueExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID ); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.get(); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -986,17 +948,16 @@ public void test504checkGeneratedValue() throws Exception { @Test public void test505generatePasswordExecute() throws Exception { final String TEST_NAME = "test505generatePasswordExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_PASSWORD_EXECUTE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1013,17 +974,16 @@ public void test505generatePasswordExecute() throws Exception { @Test public void test506generateHonorificPrefixNameExecute() throws Exception { final String TEST_NAME = "test506generateHonorificPrefixNameExecute"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_HONORIFIC_PREFIX_EXECUTE)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1080,17 +1040,16 @@ private void assertLocalizableMessage(LocalizableMessageType localizableMessage) @Test public void test510validateValueExplicit() throws Exception { final String TEST_NAME = "test510validateValueExplicit"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1105,17 +1064,16 @@ public void test510validateValueExplicit() throws Exception { @Test public void test511validateValueExplicitConflict() throws Exception { final String TEST_NAME = "test511validateValueExplicitConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_CONFLICT)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response, true); @@ -1130,17 +1088,16 @@ public void test511validateValueExplicitConflict() throws Exception { @Test public void test512validateValueImplicitSingle() throws Exception { final String TEST_NAME = "test512validateValueImplicitSingle"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_SINGLE)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1154,17 +1111,16 @@ public void test512validateValueImplicitSingle() throws Exception { @Test public void test513validateValueImplicitMulti() throws Exception { final String TEST_NAME = "test513validateValueImplicitMulti"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1178,17 +1134,16 @@ public void test513validateValueImplicitMulti() throws Exception { @Test public void test514validateValueImplicitMultiConflict() throws Exception { final String TEST_NAME = "test514validateValueImplicitMultiConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_MULTI_CONFLICT)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1203,17 +1158,16 @@ public void test514validateValueImplicitMultiConflict() throws Exception { @Test public void test515validatePasswordHistoryConflict() throws Exception { final String TEST_NAME = "test515validatePasswordHistoryConflict"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_PASSWORD_PASSWORD_HISTORY_CONFLICT)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response, true); @@ -1228,17 +1182,16 @@ public void test515validatePasswordHistoryConflict() throws Exception { @Test public void test516validateValueExplicitNoValuePolicy() throws Exception { final String TEST_NAME = "test516validateValueExplicitNoValuePolicy"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_EXPLICIT_NO_VALUE_POLICY)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1253,17 +1206,16 @@ public void test516validateValueExplicitNoValuePolicy() throws Exception { @Test public void test517generateValueExplicit() throws Exception { final String TEST_NAME = "test517generateValueExplicit"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/generate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_GENERATE_EXPLICIT)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1278,9 +1230,8 @@ public void test517generateValueExplicit() throws Exception { @Test public void test518validateValueImplicitPassword() throws Exception { final String TEST_NAME = "test518validateValueImplicitPassword"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject secPolicyNoHistory = parseObject(SECURITY_POLICY_NO_HISTORY); addObject(secPolicyNoHistory, ModelExecuteOptions.createOverwrite(), task, result); @@ -1290,10 +1241,10 @@ public void test518validateValueImplicitPassword() throws Exception { getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_IMPLICIT_PASSWORD)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1313,17 +1264,16 @@ public void test518validateValueImplicitPassword() throws Exception { @Test public void test520GeneratePasswordsUsingScripting() throws Exception { final String TEST_NAME = "test520GeneratePasswordsUsingScripting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/executeScript"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(SCRIPT_GENERATE_PASSWORDS)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1368,17 +1318,16 @@ public void test520GeneratePasswordsUsingScripting() throws Exception { @Test public void test530ModifyValidToUsingScripting() throws Exception { final String TEST_NAME = "test530ModifyValidToUsingScripting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/rpc/executeScript"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(SCRIPT_MODIFY_VALID_TO)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1501,7 +1450,6 @@ private List> extractI @Test public void test600ModifySecurityQuestionReplaceAnswerId1Existing() throws Exception { final String TEST_NAME = "test600ModifySecurityQuestionReplaceAnswerId1Existing"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1509,11 +1457,11 @@ public void test600ModifySecurityQuestionReplaceAnswerId1Existing() throws Excep getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER_ID_1_VALUE)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1546,7 +1494,6 @@ private UserType getUserRest(String oid) { @Test public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exception { final String TEST_NAME = "test602ModifySecurityQuestionReplaceTwoAnswersExisting"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1554,11 +1501,11 @@ public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exce getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_TWO_ANSWERS)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1583,7 +1530,6 @@ public void test602ModifySecurityQuestionReplaceTwoAnswersExisting() throws Exce @Test public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { final String TEST_NAME = "test604ModifySecurityQuestionReplaceNoAnswer"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1591,11 +1537,11 @@ public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_NO_ANSWER)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1620,7 +1566,6 @@ public void test604ModifySecurityQuestionReplaceNoAnswer() throws Exception { @Test public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { final String TEST_NAME = "test606ModifySecurityQuestionReplaceAnswer"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); @@ -1628,11 +1573,11 @@ public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { getDummyAuditService().clear(); // WHEN - displayWhen(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER)); // THEN - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1654,17 +1599,16 @@ public void test606ModifySecurityQuestionReplaceAnswer() throws Exception { @Test public void test607validateSecurityAnswerCheckExpressionFail() throws Exception { final String TEST_NAME = "test607validateSecurityAnswerCheckExpressionFail"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION_FAIL)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1679,17 +1623,16 @@ public void test607validateSecurityAnswerCheckExpressionFail() throws Exception @Test public void test608validateSecurityAnswerCheckExpression() throws Exception { final String TEST_NAME = "test607validateSecurityAnswerCheckExpression"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/validate"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRepoFile(POLICY_ITEM_DEFINITION_VALIDATE_SECURITY_ANSWER_CHECK_EXPRESSION)); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1753,17 +1696,16 @@ private void assertSecurityQuestionAnswer(List secQu @Test public void test610ModifyPasswordForceChange() throws Exception { final String TEST_NAME = "test610ModifyPasswordForceChange"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); Response response = client.post(getRequestFile(MODIFICATION_FORCE_PASSWORD_CHANGE)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1775,10 +1717,10 @@ public void test610ModifyPasswordForceChange() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - displayWhen(TEST_NAME); + when(); response = client.get(); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1794,20 +1736,19 @@ public void test610ModifyPasswordForceChange() throws Exception { @Test public void test612ResetPassword() throws Exception { final String TEST_NAME = "test612ResetPassword"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/users/" + USER_DARTHADDER_OID + "/credential"); getDummyAuditService().clear(); - displayWhen(TEST_NAME); + when(); // ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); // executeCredentialResetRequest.setResetMethod("passwordReset"); // executeCredentialResetRequest.setUserEntry("123passwd456"); Response response = client.post(getRequestFile(EXECUTE_CREDENTIAL_RESET)); - displayThen(TEST_NAME); + then(); displayResponse(response); traceResponse(response); @@ -1819,11 +1760,11 @@ public void test612ResetPassword() throws Exception { getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI); getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class); - displayWhen(TEST_NAME); + when(); client = prepareClient(); response = client.path("/users/" + USER_DARTHADDER_OID).get(); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus()); @@ -1842,15 +1783,14 @@ public void test612ResetPassword() throws Exception { @Test // MID-4928 public void test650SuspendNonExistingTask() { final String TEST_NAME = "test650SuspendNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/suspend"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1859,15 +1799,14 @@ public void test650SuspendNonExistingTask() { @Test // MID-4928 public void test652SuspendWrongObject() { final String TEST_NAME = "test652SuspendWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/suspend"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1876,15 +1815,14 @@ public void test652SuspendWrongObject() { @Test // MID-4928 public void test660ResumeNonExistingTask() { final String TEST_NAME = "test660ResumeNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/resume"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1893,15 +1831,14 @@ public void test660ResumeNonExistingTask() { @Test // MID-4928 public void test662ResumeWrongObject() { final String TEST_NAME = "test662ResumeWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/resume"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1910,15 +1847,14 @@ public void test662ResumeWrongObject() { @Test // MID-4928 public void test670ScheduleNonExistingTask() { final String TEST_NAME = "test670ScheduleNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456/run"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1927,15 +1863,14 @@ public void test670ScheduleNonExistingTask() { @Test // MID-4928 public void test672ScheduleWrongObject() { final String TEST_NAME = "test672ScheduleWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002/run"); - displayWhen(TEST_NAME); + when(); Response response = client.post(null); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); @@ -1944,15 +1879,14 @@ public void test672ScheduleWrongObject() { @Test // MID-4928 public void test680DeleteNonExistingTask() { final String TEST_NAME = "test680DeleteNonExistingTask"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/123456"); - displayWhen(TEST_NAME); + when(); Response response = client.delete(); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 404 but got " + response.getStatus(), 404, response.getStatus()); @@ -1961,15 +1895,14 @@ public void test680DeleteNonExistingTask() { @Test // MID-4928 public void test682DeleteWrongObject() { final String TEST_NAME = "test682DeleteWrongObject"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(); client.path("/tasks/00000000-0000-0000-0000-000000000002"); - displayWhen(TEST_NAME); + when(); Response response = client.delete(); - displayThen(TEST_NAME); + then(); displayResponse(response); assertEquals("Expected 400 but got " + response.getStatus(), 400, response.getStatus()); diff --git a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java index 78151460b61..7090cbecf66 100644 --- a/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java +++ b/testing/rest/src/test/java/com/evolveum/midpoint/testing/rest/TestRestServiceProxyAuthentication.java @@ -7,23 +7,17 @@ package com.evolveum.midpoint.testing.rest; import com.evolveum.midpoint.common.rest.MidpointAbstractProvider; -import com.evolveum.midpoint.gui.test.TestMidPointSpringApplication; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; -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.AssertJUnit; import org.testng.annotations.Test; @@ -31,8 +25,6 @@ import javax.ws.rs.core.Response; import java.io.File; -import static com.evolveum.midpoint.test.util.TestUtil.displayTestTitle; - import static org.testng.AssertJUnit.assertNotNull; /** @@ -77,17 +69,16 @@ public void initSystem(Task initTask, OperationResult result) throws Exception { @Test public void test001getUserSelfBySomebody() { final String TEST_NAME = "test001getUserSelfBySomebody"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_SOMEBODY_OID); client.path("/self/"); getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); AssertJUnit.assertNotNull("Returned entity in body must not be null.", userType); @@ -101,17 +92,16 @@ public void test001getUserSelfBySomebody() { @Test public void test002getUserSelfByEgoist() { final String TEST_NAME = "test002getUserSelfByEgoist"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_EGOIST_OID); client.path("/self/"); getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -129,17 +119,16 @@ public void test002getUserSelfByEgoist() { @Test public void test003getUserAdministratorByEgoist() { final String TEST_NAME = "test003getUserAdministratorByEgoist"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_EGOIST_OID); client.path("/users/" + SystemObjectsType.USER_ADMINISTRATOR.value()); getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 403); IntegrationTestTools.display("Audit", getDummyAuditService()); @@ -153,17 +142,16 @@ public void test003getUserAdministratorByEgoist() { @Test public void test004getUserSelfByHead() { final String TEST_NAME = "test004getUserSelfByHead"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(null); client.path("/self"); getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 200); UserType userType = response.readEntity(UserType.class); assertNotNull("Returned entity in body must not be null.", userType); @@ -181,17 +169,16 @@ public void test004getUserSelfByHead() { @Test public void test005getUserSelfByProxyHead() { final String TEST_NAME = "test005getUserSelfByProxyHead"; - displayTestTitle(TEST_NAME); WebClient client = prepareClient(USER_HEAD_OID); client.path("/self"); getDummyAuditService().clear(); - TestUtil.displayWhen(TEST_NAME); + when(); Response response = client.get(); - TestUtil.displayThen(TEST_NAME); + then(); assertStatus(response, 403); IntegrationTestTools.display("Audit", getDummyAuditService()); diff --git a/testing/rest/testng-unit.xml b/testing/rest/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/rest/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/testing/samples-test/pom.xml b/testing/samples-test/pom.xml index e9c130e6c04..45cb5c5df56 100644 --- a/testing/samples-test/pom.xml +++ b/testing/samples-test/pom.xml @@ -19,6 +19,11 @@ midPoint Samples - Test + + + true + + @@ -115,7 +120,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -214,7 +218,7 @@ unpack-samples - compile + pre-integration-test unpack @@ -235,12 +239,15 @@ maven-surefire-plugin + + true alphabetical maven-failsafe-plugin + ${skipSamplesTests} alphabetical diff --git a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java index 649b41cc086..66fcdc403df 100644 --- a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java +++ b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/AbstractSampleTest.java @@ -6,33 +6,19 @@ */ package com.evolveum.midpoint.samples.test; -import com.evolveum.midpoint.model.api.ModelService; import com.evolveum.midpoint.model.test.AbstractModelIntegrationTest; -import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; -import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; -import javax.xml.bind.JAXBException; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.List; import static org.testng.AssertJUnit.assertEquals; diff --git a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java index b6262e49772..4ccb250a4d9 100644 --- a/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java +++ b/testing/samples-test/src/test/java/com/evolveum/midpoint/samples/test/TestSampleImport.java @@ -64,9 +64,10 @@ public void importOpenDJAdvanced() throws FileNotFoundException, SchemaException // } public void importSample(File sampleFile, Class type, String objectName) throws FileNotFoundException, SchemaException { - TestUtil.displayTestTitle(this, "Import sample "+sampleFile.getPath()); + sampleFile.getPath(); // GIVEN - Task task = createTask(sampleFile.getName()); + sampleFile.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); result.addParam("file", sampleFile.getPath()); FileInputStream stream = new FileInputStream(sampleFile); diff --git a/testing/samples-test/testng-unit.xml b/testing/samples-test/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/samples-test/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/testing/sanity/pom.xml b/testing/sanity/pom.xml index c3aeaf33f66..00893a03ad8 100644 --- a/testing/sanity/pom.xml +++ b/testing/sanity/pom.xml @@ -193,7 +193,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -247,7 +246,8 @@ maven-surefire-plugin - alphabetical + + true diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index 38a6ab7b8ce..4883c30a18a 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -21,7 +21,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; @@ -390,11 +389,9 @@ public static void stopResources() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTitle(this, TEST_NAME); assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); - assertTrue(isSystemInitialized()); assertNotNull(taskManager); assertNotNull(prismContext); @@ -433,7 +430,6 @@ public void test000Integrity() throws Exception { @Test public void test001SelfTests() throws Exception { final String TEST_NAME = "test001SelfTests"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestSanity.class.getName()+"."+TEST_NAME); @@ -463,7 +459,6 @@ public void test001SelfTests() throws Exception { @Test public void test001TestConnectionOpenDJ() throws Exception { final String TEST_NAME = "test001TestConnectionOpenDJ"; - displayTestTitle(TEST_NAME); // GIVEN try{ @@ -639,7 +634,6 @@ private void checkOpenResourceConfiguration(PrismObject resource, @Test public void test002AddDerbyResource() throws Exception { final String TEST_NAME = "test002AddDerbyResource"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -747,8 +741,6 @@ private void checkDerbyConfiguration(PrismObject resource, String */ @Test public void test003TestConnectionDerby() throws Exception { - TestUtil.displayTestTitle("test003TestConnectionDerby"); - // GIVEN checkRepoDerbyResource(); @@ -794,10 +786,8 @@ public void test003TestConnectionDerby() throws Exception { } @Test - public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, - FaultMessage { - TestUtil.displayTestTitle("test004Capabilities"); - + public void test004Capabilities() + throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage { // GIVEN checkRepoOpenDjResource(); @@ -855,9 +845,6 @@ public void test004Capabilities() throws ObjectNotFoundException, CommunicationE @Test public void test005resolveConnectorRef() throws Exception{ - - TestUtil.displayTestTitle("test005resolveConnectorRef"); - PrismObject resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME)); ModelExecuteOptionsType options = new ModelExecuteOptionsType(); @@ -877,9 +864,6 @@ public void test005resolveConnectorRef() throws Exception{ @Test public void test006reimportResourceDummy() throws Exception{ - - TestUtil.displayTestTitle("test006reimportResourceDummy"); - //get object from repo (with version set and try to add it - it should be re-added, without error) OperationResult repoResult = new OperationResult("getObject"); @@ -934,7 +918,6 @@ public void test006reimportResourceDummy() throws Exception{ @Test public void test010AddUser() throws Exception { final String TEST_NAME = "test010AddUser"; - displayTestTitle(TEST_NAME); // GIVEN checkRepoOpenDjResource(); @@ -986,7 +969,6 @@ public void test010AddUser() throws Exception { @Test public void test013AddOpenDjAccountToUser() throws Exception { final String TEST_NAME = "test013AddOpenDjAccountToUser"; - displayTestTitle(TEST_NAME); try{ // GIVEN checkRepoOpenDjResource(); @@ -1001,11 +983,11 @@ public void test013AddOpenDjAccountToUser() throws Exception { REQUEST_USER_MODIFY_ADD_ACCOUNT_OPENDJ_FILENAME, ObjectDeltaType.class); // WHEN - displayWhen(TEST_NAME); + when(); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - displayThen(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1123,9 +1105,7 @@ private OperationResultType modifyObjectViaModelWS(ObjectDeltaType objectChange) */ @Test public void test014AddDerbyAccountToUser() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test014AddDerbyAccountToUser"); - + ObjectNotFoundException, SchemaException, SQLException { // GIVEN checkRepoDerbyResource(); @@ -1234,8 +1214,6 @@ public void test014AddDerbyAccountToUser() throws IOException, JAXBException, Fa @Test public void test015AccountOwner() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException { - TestUtil.displayTestTitle("test015AccountOwner"); - // GIVEN checkRepoOpenDjResource(); assertNoRepoCache(); @@ -1260,8 +1238,6 @@ public void test015AccountOwner() throws FaultMessage, ObjectNotFoundException, @Test public void test016ProvisioningSearchAccountsIterative() throws Exception { - TestUtil.displayTestTitle("test016ProvisioningSearchAccountsIterative"); - // GIVEN OperationResult result = new OperationResult(TestSanity.class.getName() + ".test016ProvisioningSearchAccountsIterative"); @@ -1322,7 +1298,6 @@ public boolean handle(PrismObject prismObject, OperationResult paren @Test public void test020ModifyUser() throws Exception { final String TEST_NAME = "test020ModifyUser"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1420,7 +1395,6 @@ private Entry assertOpenDJAccountJack(Entry entry, String uid, String givenName) @Test public void test022ChangeUserPassword() throws Exception { final String TEST_NAME = "test022ChangeUserPassword"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1442,7 +1416,6 @@ public void test022ChangeUserPassword() throws Exception { @Test public void test023ChangeUserPasswordJAXB() throws Exception { final String TEST_NAME = "test023ChangeUserPasswordJAXB"; - displayTestTitle(TEST_NAME); // GIVEN final String NEW_PASSWORD = "abandonSHIP"; @@ -1535,7 +1508,6 @@ public void test028ModifyAccountDjExplicitType() throws Exception { } public void testModifyAccountDjRoomNumber(final String TEST_NAME, File reqFile, String expectedVal) throws Exception { - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1572,7 +1544,6 @@ public void testModifyAccountDjRoomNumber(final String TEST_NAME, File reqFile, @Test public void test029ModifyAccountDjBadPath() throws Exception { final String TEST_NAME = "test029ModifyAccountDjBadPath"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -1621,7 +1592,6 @@ public void test029ModifyAccountDjBadPath() throws Exception { @Test public void test030DisableUser() throws Exception { final String TEST_NAME = "test030DisableUser"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1637,11 +1607,11 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResultType result = modifyObjectViaModelWS(objectChange); // THEN - displayThen(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); @@ -1698,12 +1668,12 @@ public void test030DisableUser() throws Exception { assertNoRepoCache(); // WHEN - displayWhen(TEST_NAME); + when(); modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder); // THEN - displayThen(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("getObject has failed", resultHolder.value); @@ -1734,7 +1704,6 @@ public void test030DisableUser() throws Exception { @Test public void test031EnableUser() throws Exception { final String TEST_NAME = "test031EnableUser"; - displayTestTitle(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1835,10 +1804,8 @@ public void test031EnableUser() throws Exception { * The account will not be deleted, just the association to user will be broken. */ @Test - public void test040UnlinkDerbyAccountFromUser() throws FileNotFoundException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test040UnlinkDerbyAccountFromUser"); - + public void test040UnlinkDerbyAccountFromUser() + throws FaultMessage, ObjectNotFoundException, SchemaException { // GIVEN ObjectDeltaType objectChange = new ObjectDeltaType(); @@ -1886,10 +1853,8 @@ public void test040UnlinkDerbyAccountFromUser() throws FileNotFoundException, JA * The account was unlinked in the previous test, therefore no operation with user is needed. */ @Test - public void test041DeleteDerbyAccount() throws FileNotFoundException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException, SQLException { - TestUtil.displayTestTitle("test041DeleteDerbyAccount"); - + public void test041DeleteDerbyAccount() + throws FaultMessage, SchemaException, SQLException { // GIVEN assertNoRepoCache(); @@ -1938,7 +1903,6 @@ private OperationResultType deleteObjectViaModelWS(QName typeQName, String oid) @Test public void test047RenameUser() throws Exception { final String TEST_NAME = "test047RenameUser"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2003,7 +1967,6 @@ public void test047RenameUser() throws Exception { @Test public void test048ModifyUserRemoveGivenName() throws Exception { final String TEST_NAME = "test048ModifyUserRemoveGivenName"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2063,8 +2026,7 @@ public void test048ModifyUserRemoveGivenName() throws Exception { * @throws JAXBException */ @Test - public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException, JAXBException { - TestUtil.displayTestTitle("test049DeleteUser"); + public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryException { // GIVEN assertNoRepoCache(); @@ -2109,7 +2071,6 @@ public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryE @Test public void test100AssignRolePirate() throws Exception { final String TEST_NAME = "test100AssignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2205,7 +2166,6 @@ public void test100AssignRolePirate() throws Exception { @Test public void test101AccountOwnerAfterRole() throws Exception { final String TEST_NAME = "test101AccountOwnerAfterRole"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2232,7 +2192,6 @@ public void test101AccountOwnerAfterRole() throws Exception { @Test public void test102AssignRoleCaptain() throws Exception { final String TEST_NAME = "test102AssignRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2314,7 +2273,6 @@ public void test102AssignRoleCaptain() throws Exception { @Test public void test103AssignRoleCaptainAgain() throws Exception { final String TEST_NAME = "test103AssignRoleCaptainAgain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2393,7 +2351,6 @@ public void test103AssignRoleCaptainAgain() throws Exception { @Test public void test105ModifyAccount() throws Exception { final String TEST_NAME = "test105ModifyAccount"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2478,7 +2435,6 @@ public void test105ModifyAccount() throws Exception { @Test public void test104AssignRoleJudge() throws Exception { final String TEST_NAME = "test104AssignRoleJudge"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2523,7 +2479,6 @@ public void test104AssignRoleJudge() throws Exception { @Test public void test107UnassignRolePirate() throws Exception { final String TEST_NAME = "test107UnassignRolePirate"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2606,7 +2561,6 @@ public void test107UnassignRolePirate() throws Exception { @Test public void test108UnassignRoleCaptain() throws Exception { final String TEST_NAME = "test108UnassignRoleCaptain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2694,7 +2648,6 @@ public void test108UnassignRoleCaptain() throws Exception { @Test public void test109UnassignRoleCaptainAgain() throws Exception { final String TEST_NAME = "test109UnassignRoleCaptainAgain"; - displayTestTitle(TEST_NAME); // GIVEN @@ -2761,7 +2714,6 @@ public void test109UnassignRoleCaptainAgain() throws Exception { @Test public void test300LiveSyncInit() throws Exception { final String TEST_NAME = "test300LiveSyncInit"; - displayTestTitle(TEST_NAME); // Now it is the right time to add task definition to the repository // We don't want it there any sooner, as it may interfere with the // previous tests @@ -2872,7 +2824,6 @@ public void timeout() { @Test public void test301LiveSyncCreate() throws Exception { final String TEST_NAME = "test301LiveSyncCreate"; - displayTestTitle(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. @@ -2885,7 +2836,7 @@ public void test301LiveSyncCreate() throws Exception { display("Sync token before", tokenBefore.toString()); // WHEN - displayWhen(TEST_NAME); + when(); Entry entry = openDJController.addEntryFromLdifFile(LDIF_WILL_FILENAME); display("Entry from LDIF", entry); @@ -2894,7 +2845,7 @@ public void test301LiveSyncCreate() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 2, result); // THEN - displayThen(TEST_NAME); + then(); // Search for the user that should be created now UserType user = searchUserByName(WILL_NAME); @@ -2912,7 +2863,6 @@ public void test301LiveSyncCreate() throws Exception { @Test public void test302LiveSyncModify() throws Exception { final String TEST_NAME = "test302LiveSyncModify"; - displayTestTitle(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -2945,7 +2895,6 @@ public void test302LiveSyncModify() throws Exception { @Test public void test303LiveSyncLink() throws Exception { final String TEST_NAME = "test303LiveSyncLink"; - displayTestTitle(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2967,7 +2916,7 @@ public void test303LiveSyncLink() throws Exception { // AssertJUnit.assertEquals(userOid, oidHolder.value); //WHEN - displayWhen(TEST_NAME); + when(); //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -2985,7 +2934,7 @@ public void test303LiveSyncLink() throws Exception { basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 1, result); // THEN - displayThen(TEST_NAME); + then(); //check user and account ref userType = searchUserByName("e"); @@ -3011,7 +2960,6 @@ public void test303LiveSyncLink() throws Exception { @Test public void test304LiveSyncCreateNoLocation() throws Exception { final String TEST_NAME = "test304LiveSyncCreateNoLocation"; - displayTestTitle(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. @@ -3085,7 +3033,6 @@ private Object findSyncTokenObject(Task syncCycle) { @Test public void test399LiveSyncCleanup() throws Exception { final String TEST_NAME = "test399LiveSyncCleanup"; - displayTestTitle(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); @@ -3097,7 +3044,6 @@ public void test399LiveSyncCleanup() throws Exception { @Test public void test400ImportFromResource() throws Exception { final String TEST_NAME = "test400ImportFromResource"; - displayTestTitle(TEST_NAME); // GIVEN checkAllShadows(); assertNoRepoCache(); @@ -3114,11 +3060,11 @@ public void test400ImportFromResource() throws Exception { display("Entry from LDIF", addEntry); // WHEN - displayWhen(TEST_NAME); + when(); TaskType taskType = modelWeb.importFromResource(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS); // THEN - displayThen(TEST_NAME); + then(); assertNoRepoCache(); displayJaxb("importFromResource result", taskType.getResult(), SchemaConstants.C_RESULT); AssertJUnit.assertEquals("importFromResource has failed", OperationResultStatusType.IN_PROGRESS, taskType.getResult().getStatus()); @@ -3313,7 +3259,6 @@ private String getUserLocality(UserType user){ @Test public void test420RecomputeUsers() throws Exception { final String TEST_NAME = "test420RecomputeUsers"; - displayTestTitle(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -3456,7 +3401,6 @@ public void timeout() { @Test public void test440ReconcileResourceOpenDj() throws Exception { final String TEST_NAME = "test440ReconcileResourceOpenDj"; - displayTestTitle(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() @@ -3677,7 +3621,6 @@ public void timeout() { @Test public void test480ListResources() throws Exception { final String TEST_NAME = "test480ListResources"; - displayTestTitle(TEST_NAME); // GIVEN OperationResultType result = new OperationResultType(); Holder resultHolder = new Holder<>(result); @@ -3703,11 +3646,9 @@ public void test480ListResources() throws Exception { @Test public void test485ListResourcesWithBrokenResource() throws Exception { - TestUtil.displayTestTitle("test485ListResourcesWithBrokenResource"); - // GIVEN - Task task = taskManager.createTaskInstance(TestSanity.class.getName() + ".test410ListResourcesWithBrokenResource"); - final OperationResult result = task.getResult(); + Task task = getTestTask(); + final OperationResult result = getTestOperationResult(); // WHEN List> resources = modelService.searchObjects(ResourceType.class, null, null, task, result); @@ -3737,9 +3678,6 @@ public void test485ListResourcesWithBrokenResource() throws Exception { @Test public void test500NotifyChangeCreateAccount() throws Exception{ - final String TEST_NAME = "test500NotifyChangeCreateAccount"; - displayTestTitle(TEST_NAME); - Entry ldifEntry = openDJController.addEntryFromLdifFile(LDIF_ANGELIKA_FILENAME); display("Entry from LDIF", ldifEntry); @@ -3805,9 +3743,8 @@ public void test500NotifyChangeCreateAccount() throws Exception{ @Test public void test501NotifyChangeModifyAccount() throws Exception{ final String TEST_NAME = "test501NotifyChangeModifyAccount"; - displayTestTitle(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); @@ -3862,7 +3799,6 @@ public void test501NotifyChangeModifyAccount() throws Exception{ @Test public void test502NotifyChangeModifyAccountPassword() throws Exception{ final String TEST_NAME = "test502NotifyChangeModifyAccountPassword"; - displayTestTitle(TEST_NAME); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); @@ -3919,7 +3855,6 @@ public void test502NotifyChangeModifyAccountPassword() throws Exception{ @Test public void test503NotifyChangeDeleteAccount() throws Exception{ final String TEST_NAME = "test503NotifyChangeDeleteAccount"; - displayTestTitle(TEST_NAME); PrismObject userAngelika = findUserByUsername(ANGELIKA_NAME); assertNotNull("User with the name angelika must exist.", userAngelika); diff --git a/testing/sanity/testng-unit.xml b/testing/sanity/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/sanity/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/testing/schrodingertest/pom.xml b/testing/schrodingertest/pom.xml index b0d292002fc..46185745a09 100644 --- a/testing/schrodingertest/pom.xml +++ b/testing/schrodingertest/pom.xml @@ -19,10 +19,17 @@ schrodingertest + midPoint Testing - Schrodinger + + ../../gui/admin-gui com.evolveum.midpoint.web.boot.MidPointSpringApplication - false + + true 8180 0.0.0.0 @@ -111,23 +118,25 @@ - - + maven-surefire-plugin + + + true + + + maven-failsafe-plugin - - - - - - - - - - - + + ${skipSchrodingerTests} + + + + + integration-test + verify + + + maven-antrun-plugin @@ -136,7 +145,7 @@ pre-integration-test - ${skipTests} + ${skipSchrodingerTests} @@ -167,7 +176,7 @@ Attempt to execute the Shut-down-process post-integration-test - ${skipTests} + ${skipSchrodingerTests} @@ -200,7 +209,7 @@ Shut-down-process and attempt to execute clean up post-integration-test - ${skipTests} + ${skipSchrodingerTests} diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java index b38963315e7..8a81e129941 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestBase.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.lang.reflect.Method; import java.util.Properties; -import javax.naming.ConfigurationException; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.testng.BrowserPerClass; @@ -96,7 +95,7 @@ public void beforeClass() throws IOException { basicPage = login.loginWithReloadLoginPage(username, password); } - private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) throws IOException { + private EnvironmentConfiguration buildEnvironmentConfiguration(Properties props) { EnvironmentConfiguration config = new EnvironmentConfiguration(); config.driver(WebDriver.valueOf(props.getProperty("webdriver"))); config.driverLocation(props.getProperty("webdriverLocation")); @@ -157,7 +156,7 @@ protected void importObject(File source) { importObject(source, false); } - protected String fetchMidpointHome() throws ConfigurationException { + protected String fetchMidpointHome() { AboutPage aboutPage = basicPage.aboutPage(); String mpHomeDir = aboutPage.getJVMproperty(PROPERTY_NAME_MIDPOINT_HOME); @@ -166,8 +165,9 @@ protected String fetchMidpointHome() throws ConfigurationException { return mpHomeDir; } else { - mpHomeDir = new StringBuilder(aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME)) - .append(aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR)).append("midpoint").toString(); + mpHomeDir = aboutPage.getSystemProperty(PROPERTY_NAME_USER_HOME) + + aboutPage.getSystemProperty(PROPERTY_NAME_FILE_SEPARATOR) + + "midpoint"; LOG.info("Midpoint home parameter is empty! Using defaults: " + mpHomeDir); @@ -175,7 +175,7 @@ protected String fetchMidpointHome() throws ConfigurationException { return mpHomeDir; } - protected File initTestDirectory(String dir) throws ConfigurationException, IOException { + protected File initTestDirectory(String dir) throws IOException { String home = fetchMidpointHome(); File parentDir = new File(home, "schrodinger"); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java deleted file mode 100644 index 310b851b07c..00000000000 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/TestSuiteConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2010-2019 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.testing.schrodinger; - -import com.evolveum.midpoint.schrodinger.EnvironmentConfiguration; -import com.evolveum.midpoint.schrodinger.MidPoint; - -import com.evolveum.midpoint.schrodinger.page.BasicPage; -import com.evolveum.midpoint.schrodinger.page.configuration.AboutPage; -import org.apache.commons.lang3.ArrayUtils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; - -import java.io.IOException; - - -/** - * Created by matus on 7/10/2018. - */ -public class TestSuiteConfig extends TestBase { - - private static final Logger LOG = LoggerFactory.getLogger(TestSuiteConfig.class); - - @BeforeSuite - public void init() throws IOException { - - EnvironmentConfiguration config = new EnvironmentConfiguration(); - midPoint = new MidPoint(config); - } - - @AfterSuite - public void cleanUp() { - - } -} diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java index 1c699c69d54..b28d9788e8b 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/labs/BasicProvisioningTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,14 @@ */ package com.evolveum.midpoint.testing.schrodinger.labs; +import static com.codeborne.selenide.Selenide.$; + +import javax.xml.namespace.QName; + import com.codeborne.selenide.Condition; +import org.testng.Assert; +import org.testng.annotations.Test; + import com.evolveum.midpoint.schema.SchemaConstantsGenerated; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import com.evolveum.midpoint.schrodinger.page.user.UserPage; @@ -14,18 +21,12 @@ import com.evolveum.midpoint.testing.schrodinger.TestBase; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.testng.Assert; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; - -import static com.codeborne.selenide.Selenide.$; /** * Created by honchar * covers LAB 4-1 */ -public class BasicProvisioningTest extends TestBase { +public class BasicProvisioningTest extends TestBase { private static final String USER_NAME_ATTRIBUTE = "Name"; private static final String USER_GIVEN_NAME_ATTRIBUTE = "Given name"; @@ -42,31 +43,31 @@ public class BasicProvisioningTest extends TestBase { private static final String USER_ADMINISTRATIVE_STATUS = "Enabled"; //todo dependsOnGroup - @Test(groups={"lab_4_1"}) - public void test001createUserKirk(){ + @Test(groups = { "lab_4_1" }) + public void test001createUserKirk() { //we use New user link in this test UserPage userPage = basicPage.newUser(); userPage .selectTabBasic() - .form() - .addAttributeValue(UserType.F_NAME, USER_NAME) - .addAttributeValue(UserType.F_FAMILY_NAME, USER_FAMILY_NAME) - .addAttributeValue(UserType.F_GIVEN_NAME, USER_GIVEN_NAME) - .setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS) - .setPasswordFieldsValues(PASSWORD_FIELD_LABEL, USER_PASSWORD) - .and() - .and() + .form() + .addAttributeValue(UserType.F_NAME, USER_NAME) + .addAttributeValue(UserType.F_FAMILY_NAME, USER_FAMILY_NAME) + .addAttributeValue(UserType.F_GIVEN_NAME, USER_GIVEN_NAME) + .setDropDownAttributeValue(ActivationType.F_ADMINISTRATIVE_STATUS, USER_ADMINISTRATIVE_STATUS) + .setPasswordFieldsValues(PASSWORD_FIELD_LABEL, USER_PASSWORD) + .and() + .and() .clickSave(); ListUsersPage usersList = new ListUsersPage(); usersList .table() - .search() - .byName() - .inputValue(USER_NAME) - .updateSearch() - .and() + .search() + .byName() + .inputValue(USER_NAME) + .updateSearch() + .and() .clickByName(USER_NAME); //check name attribute value @@ -100,26 +101,26 @@ public void test001createUserKirk(){ } - @Test(groups={"lab_4_1"}) + @Test(groups = { "lab_4_1" }) public void test002addProjectionToUserKirk() { ListUsersPage users = basicPage.listUsers(); users .table() - .search() - .byName() - .inputValue(USER_NAME) - .updateSearch() + .search() + .byName() + .inputValue(USER_NAME) + .updateSearch() + .and() + .clickByName(USER_NAME) + .selectTabProjections() + .clickHeaderActionDropDown() + .addProjection() + .table() + .selectCheckboxByName(ImportResourceTest.RESOURCE_NAME) + .and() + .clickAdd() .and() - .clickByName(USER_NAME) - .selectTabProjections() - .clickHeaderActionDropDown() - .addProjection() - .table() - .selectCheckboxByName(ImportResourceTest.RESOURCE_NAME) - .and() - .clickAdd() - .and() - .clickSave() + .clickSave() .feedback() .isSuccess(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java index fc33b506b4b..5a5797ba233 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AboutPageTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -39,18 +39,14 @@ public void checkMidpointVersion() { @Test public void checkGitDescribeValue() { - Assert.assertTrue(!aboutPage - .gitDescribe() - .isEmpty() - ); + Assert.assertFalse( + aboutPage.gitDescribe().isEmpty()); } @Test public void checkBuildAt() { - Assert.assertTrue(!aboutPage - .buildAt() - .isEmpty() - ); + Assert.assertFalse( + aboutPage.buildAt().isEmpty()); } @Test // TODO fix select the right element @@ -96,6 +92,7 @@ public void checkReindexRepositoryObjectsCategory() { @Test public void checkReindexRepositoryObjectsDisplayName() { + // @formatter:off Assert.assertEquals(aboutPage .reindexRepositoryObjects() .feedback() @@ -104,29 +101,23 @@ public void checkReindexRepositoryObjectsDisplayName() { .summary() .fetchDisplayName() , REINDEX_REPO_TASK_DISPLAY_NAME_EXPECTED); + // @formatter:on } @Test public void checkJVMPropertiesMidpointHome(){ - - Assert.assertTrue( - !aboutPage.getJVMproperty(TestBase.PROPERTY_NAME_MIDPOINT_HOME).isEmpty() - ); - + Assert.assertFalse( + aboutPage.getJVMproperty(TestBase.PROPERTY_NAME_MIDPOINT_HOME).isEmpty()); } @Test public void checkJVMPropertiesXmx(){ - - Assert.assertTrue( - !aboutPage.getJVMproperty(PROPERTY_JVM_NAME_XMX).isEmpty() - ); - + Assert.assertFalse( + aboutPage.getJVMproperty(PROPERTY_JVM_NAME_XMX).isEmpty()); } @Test public void checkSystemProperty(){ - Assert.assertTrue( - !aboutPage.getSystemProperty(TestBase.PROPERTY_NAME_USER_HOME).isEmpty() - ); + Assert.assertFalse( + aboutPage.getSystemProperty(TestBase.PROPERTY_NAME_USER_HOME).isEmpty()); } } diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java index 669d5ad08ea..333bcb8bd02 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/AbstractLoginPageTest.java @@ -43,7 +43,7 @@ public void beforeClass() throws IOException { } @Test - public void loginLockoutUser() { + public void test001loginLockoutUser() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/login"); for (int i = 0; i < 4; i++) { @@ -53,13 +53,13 @@ public void loginLockoutUser() { } @Test - public void loginDisabledUser() { + public void test002loginDisabledUser() { basicPage.loggedUser().logoutIfUserIsLogin(); unsuccessfulLogin("disabled_user", "5ecr3t"); } @Test - public void loginEnabledUserWithoutAuthorizationsUser() { + public void test003loginEnabledUserWithoutAuthorizationsUser() { basicPage.loggedUser().logoutIfUserIsLogin(); unsuccessfulLogin("enabled_user_without_authorizations", "5ecr3t"); } @@ -73,7 +73,7 @@ protected void unsuccessfulLogin(String username, String password){ } @Test - public void auditingSuccessfulLogin() { + public void test010auditingSuccessfulLogin() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("administrator", "5ecr3t"); @@ -89,7 +89,7 @@ protected void auditingSuccesfulLogin(String username) { } @Test - public void auditingFailLogin() { + public void test011auditingFailLogin() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("bad_administrator", "5ecr3t"); @@ -103,7 +103,7 @@ public void auditingFailLogin() { } @Test - public void auditingSuccessfulLogout() { + public void test012auditingSuccessfulLogout() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); login.login("administrator", "5ecr3t"); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java index 3faf0fd767a..bd427f04a86 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/BulkActionsTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java index 35ed1a1be85..77af0f02a89 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/InternalsConfigurationPageTest.java @@ -34,7 +34,7 @@ private void cleanup() { } @Test - public void changeTime() { + public void test001changeTime() { ClockTab clockTab = configPage.clockTab(); clockTab.changeTime("5/15/2099", "10", "30", ClockTab.AmOrPmChoice.PM); @@ -51,7 +51,7 @@ public void changeTime() { } @Test - public void resetTime() { + public void test010resetTime() { ClockTab clockTab = configPage.clockTab(); clockTab.resetTime(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java index 1c0dafa4af7..e2e3917b0a5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageTest.java @@ -28,7 +28,7 @@ public class LoginPageTest extends AbstractLoginPageTest { @Test - public void changeLanguageFormPage() { + public void test020changeLanguageFormPage() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); @@ -38,7 +38,7 @@ public void changeLanguageFormPage() { } @Test - public void changeLanguageSamlSelectPage() { + public void test021changeLanguageSamlSelectPage() { basicPage.loggedUser().logoutIfUserIsLogin(); SamlSelectPage login = midPoint.samlSelect(); login.goToUrl(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java index a400fff05bd..f373e73343c 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/page/LoginPageWithAuthenticationConfigTest.java @@ -61,7 +61,7 @@ public void beforeClass() throws IOException { SystemPage systemPage = new SystemPage(); PrismForm infrastructureForm = systemPage.infrastructureTab().form(); infrastructureForm.showEmptyAttributes("Infrastructure"); - infrastructureForm.addAttributeValue("defaultHostname", getConfiguration().getBaseUrl()); + infrastructureForm.addAttributeValue("publicHttpUrlPattern", getConfiguration().getBaseUrl()); File notificationFile = NOTIFICATION_FILE; notificationFile.createNewFile(); NotificationsTab notificationTab = systemPage.notificationsTab(); @@ -88,7 +88,7 @@ public void failWholeAuthenticationFlow() { } @Test - public void loginAndLogoutForAdministrators() { + public void test020loginAndLogoutForAdministrators() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/auth/emergency/internalLoginForm"); FormLoginPage login = midPoint.formLogin(); @@ -98,14 +98,14 @@ public void loginAndLogoutForAdministrators() { } @Test - public void negativeLoginForAdministrators() { + public void test021negativeLoginForAdministrators() { basicPage.loggedUser().logoutIfUserIsLogin(); open("/auth/emergency/internalLoginForm"); unsuccessfulLogin("user_without_superuser", "5ecr3t"); } @Test - public void changePassowordMailNonce() throws IOException, InterruptedException { + public void test030changePassowordMailNonce() throws IOException, InterruptedException { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); MailNoncePage mailNonce = (MailNoncePage) login.forgotPassword(); @@ -120,7 +120,7 @@ public void changePassowordMailNonce() throws IOException, InterruptedException } @Test - public void changePassowordSecurityQuestion() { + public void test031changePassowordSecurityQuestion() { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); open("/login"); @@ -137,9 +137,12 @@ public void changePassowordSecurityQuestion() { } @Test - public void selfRegistration() throws IOException, InterruptedException { + public void test040selfRegistration() throws IOException, InterruptedException { basicPage.loggedUser().logoutIfUserIsLogin(); FormLoginPage login = midPoint.formLogin(); + open("/login"); + open("/"); + TimeUnit.SECONDS.sleep(2); SelfRegistrationPage registrationPage = login.register(); registrationPage.setGivenName("Test").setFamilyName("User").setEmail("test.user@evolveum.com").setPassword("5ecr3t").submit(); TimeUnit.SECONDS.sleep(4); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java index f2fc4b012ac..155683cee9a 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -16,7 +16,6 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -53,7 +52,7 @@ public class AccountTests extends TestBase { @Test(priority = 1, groups = TEST_GROUP_BEFORE_USER_DELETION) - public void createMidpointUser() throws IOException, ConfigurationException { + public void createMidpointUser() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java index 42d1878e767..625608686e5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AdvancedAccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -11,7 +11,6 @@ import org.apache.commons.io.FileUtils; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -25,7 +24,7 @@ public class AdvancedAccountTests extends TestBase { private static final String DIRECTORY_CURRENT_TEST = "advancedAccountTests"; @Test - public void initializeTestConfiguration() throws IOException, ConfigurationException { + public void initializeTestConfiguration() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java index 312fc24ca67..e2a8d08533a 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/AssignmentArchetypeTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java index 46b5c5a7138..90d0f0cb6eb 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/CaseTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,26 +6,22 @@ */ package com.evolveum.midpoint.testing.schrodinger.scenarios; +import java.io.File; + import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + import com.evolveum.midpoint.schrodinger.MidPoint; -import com.evolveum.midpoint.schrodinger.component.modal.ConfirmationModal; import com.evolveum.midpoint.schrodinger.component.modal.ForwardWorkitemModal; -import com.evolveum.midpoint.schrodinger.component.modal.ObjectBrowserModal; import com.evolveum.midpoint.schrodinger.page.cases.*; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import com.evolveum.midpoint.schrodinger.page.user.UserPage; import com.evolveum.midpoint.schrodinger.util.ConstantsUtil; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import org.openqa.selenium.By; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.io.File; - -import static com.codeborne.selenide.Selenide.$; /** * Created by honchar. diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java index c40b325edc7..b382b71bf16 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ObjectListArchetypeTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -19,9 +19,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; -import java.io.IOException; import static com.codeborne.selenide.Selenide.$; @@ -46,7 +44,7 @@ public class ObjectListArchetypeTests extends TestBase { public static final String OBJECT_LIST_ARCHETYPE_TESTS_GROUP = "bjectListArchetypeTests"; @Test(priority = 0, groups = OBJECT_LIST_ARCHETYPE_TESTS_GROUP) - public void importEmployeeArchetype() throws IOException, ConfigurationException { + public void importEmployeeArchetype() { importObject(EMPLOYEE_ARCHETYPE_FILE, true); } diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java index f2d1e32ddcd..9a5ceda73c0 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrgMembersTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -13,7 +13,6 @@ import com.evolveum.midpoint.schrodinger.page.user.UserPage; import com.evolveum.midpoint.schrodinger.util.Schrodinger; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import org.openqa.selenium.By; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java index f027237e7be..572dd8c0dd5 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/OrganizationStructureTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.schrodinger.scenarios; -import com.codeborne.selenide.Selenide; import com.evolveum.midpoint.schrodinger.page.configuration.ImportObjectPage; import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; @@ -17,7 +16,6 @@ import org.testng.Assert; import org.testng.annotations.Test; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; @@ -50,7 +48,7 @@ public class OrganizationStructureTests extends TestBase { private static final String FILE_RESOUCE_NAME = "midpoint-advanced-sync.csv"; @Test - public void importOrgStructure() throws IOException, ConfigurationException { + public void importOrgStructure() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); @@ -72,7 +70,7 @@ public void importOrgStructure() throws IOException, ConfigurationException { @Test (dependsOnMethods ={IMPORT_ORG_STRUCT_DEPENDENCY}) public void assignOrgUnit(){ ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() @@ -103,7 +101,7 @@ public void assignOrgUnit(){ @Test (dependsOnMethods ={ORG_UNIT_ACCOUNT_INDUCEMENT_DEPENDENCY}) public void unassignOrgUnit(){ ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() @@ -133,7 +131,7 @@ public void orgUnitAccountInducement(){ refreshResourceSchema(NAME_CSV_RESOURCE_ADVANCED_SYNC); ListUsersPage users = basicPage.listUsers(); - UserPage userPage = (UserPage) users + UserPage userPage = users .table() .search() .byName() diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java index 69230455451..9c54b39cd9c 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PolyStringTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java index 9b6358d9868..28197674c31 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/PostAuthenticationTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java index 74b57bb3e86..dcd241dbff9 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/ScenariosCommons.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java index b0fbaf1a184..f26d54d1bd3 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/SynchronizationTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -10,7 +10,6 @@ import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.user.UserProjectionsTab; import com.evolveum.midpoint.schrodinger.page.resource.ListResourcesPage; -import com.evolveum.midpoint.schrodinger.page.task.EditTaskPage; import com.evolveum.midpoint.schrodinger.page.task.ListTasksPage; import com.evolveum.midpoint.schrodinger.page.user.ListUsersPage; import org.apache.commons.io.FileUtils; @@ -20,11 +19,9 @@ import org.testng.annotations.Test; import com.evolveum.midpoint.testing.schrodinger.TestBase; -import javax.naming.ConfigurationException; import java.io.File; import java.io.IOException; - /** * Created by matus on 5/21/2018. */ @@ -48,7 +45,7 @@ public class SynchronizationTests extends TestBase { private static final String DIRECTORY_CURRENT_TEST = "synchronizationTests"; @Test(priority = 0) - public void setUpResourceAndSynchronizationTask() throws ConfigurationException, IOException { + public void setUpResourceAndSynchronizationTask() throws IOException { initTestDirectory(DIRECTORY_CURRENT_TEST); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java index 7c174553719..461f95553c0 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserAccountTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -20,8 +20,6 @@ public class UserAccountTests extends AccountTests { private static final String ENABLE_MP_USER_DEPENDENCY = "enableUser"; private static final String BULK_DISABLE_MP_USER_DEPENDENCY = "bulkDisableUsers"; - - @Test (dependsOnMethods = {CREATE_MP_USER_DEPENDENCY}, groups = TEST_GROUP_BEFORE_USER_DELETION) public void modifyUserAttribute(){ ListUsersPage usersPage = basicPage.listUsers(); diff --git a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java index f48f37e0cb3..3a210a5ee98 100644 --- a/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java +++ b/testing/schrodingertest/src/test/java/com/evolveum/midpoint/testing/schrodinger/scenarios/UserPhotoTests.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 diff --git a/testing/schrodingertest/testng-integration.xml b/testing/schrodingertest/testng-integration.xml index e4598aa01d4..8924df0dda8 100644 --- a/testing/schrodingertest/testng-integration.xml +++ b/testing/schrodingertest/testng-integration.xml @@ -57,4 +57,19 @@ + + + + + + + + + + + + + + + diff --git a/testing/schrodingertest/testng-unit.xml b/testing/schrodingertest/testng-unit.xml deleted file mode 100644 index f8c96cd687d..00000000000 --- a/testing/schrodingertest/testng-unit.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/testing/story/pom.xml b/testing/story/pom.xml index 5bdb0fa3d7e..e3d2f618b6a 100644 --- a/testing/story/pom.xml +++ b/testing/story/pom.xml @@ -19,6 +19,11 @@ midPoint Testing - Story Tests + + + true + + com.evolveum.midpoint.infra @@ -235,7 +240,6 @@ com.evolveum.midpoint.infra test-util - 4.1-SNAPSHOT test @@ -295,29 +299,22 @@ - - - - - extratest - - - - maven-surefire-plugin - - false - alphabetical - - - - maven-failsafe-plugin - - false - alphabetical - - - - - - + + + + maven-surefire-plugin + + + true + + + + maven-failsafe-plugin + + ${skipStoryTests} + alphabetical + + + + diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java index 490d4910c7e..f089512377a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/CountingInspector.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -14,25 +14,21 @@ import org.testng.AssertJUnit; -import java.util.Set; - import com.evolveum.midpoint.schema.internals.InternalInspector; import com.evolveum.midpoint.util.DebugDumpable; 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.FocusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; /** * @author semancik - * */ public class CountingInspector implements InternalInspector, DebugDumpable { @SuppressWarnings("rawtypes") - private Map readMap = new HashMap<>(); + private Map readMap = new HashMap<>(); - private Map roleEvaluationMap = new HashMap<>(); + private Map roleEvaluationMap = new HashMap<>(); @Override public void inspectRepositoryRead(Class type, String oid) { @@ -45,7 +41,7 @@ public void inspectRepositoryRead(Class type, String o } public void assertRead(Class type, int expectedCount) { - assertEquals("Unexpected number of reads of "+type.getSimpleName(), (Integer)expectedCount, readMap.get(type)); + assertEquals("Unexpected number of reads of " + type.getSimpleName(), (Integer) expectedCount, readMap.get(type)); } @Override @@ -59,15 +55,16 @@ public void inspectRoleEvaluation(F target, boo roleEvaluationMap.put(key, i); } - public void assertRoleEvaluations(String roleOid, int expectedCount) { - for(Entry entry: roleEvaluationMap.entrySet()) { + public void assertRoleEvaluations(String roleOid, int expectedCount) { + for (Entry entry : roleEvaluationMap.entrySet()) { if (roleOid.equals(entry.getKey().oid)) { - assertEquals("Wrong role evaluation count for role "+roleOid, (Integer)expectedCount, entry.getValue()); + assertEquals("Wrong role evaluation count for role " + roleOid, + (Integer) expectedCount, entry.getValue()); return; } } if (expectedCount != 0) { - AssertJUnit.fail("No evaluation count found for role "+roleOid); + AssertJUnit.fail("No evaluation count found for role " + roleOid); } } @@ -144,7 +141,5 @@ private CountingInspector getOuterType() { public String toString() { return "(" + oid + ":" + name + ")"; } - - } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java index 22bcd60a1b5..65a2d3a6cd0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConfiguredCapabilitiesActivation.java @@ -7,12 +7,10 @@ package com.evolveum.midpoint.testing.story; import com.evolveum.icf.dummy.resource.DummyAccount; -import com.evolveum.icf.dummy.resource.DummyResource; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.UserAsserter; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; @@ -83,18 +81,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportAccount() throws Exception { final String TEST_NAME = "test100ImportAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.importFromResource(SHADOW_SAMPLE_ACTIVATION_SIMULATED_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); /* List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -108,9 +105,8 @@ public void test100ImportAccount() throws Exception { @Test public void test110AssignJackPirate() throws Exception { String TEST_NAME = "test110AssignJackPirate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN @@ -126,7 +122,7 @@ public void test110AssignJackPirate() throws Exception { //THEN - displayThen(TEST_NAME); + then(); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter .activation() @@ -169,9 +165,8 @@ public void test110AssignJackPirate() throws Exception { @Test public void test112ModifyActivationJack() throws Exception { String TEST_NAME = "test112ModifyActivationJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userJack = getUser(USER_JACK_OID); @@ -181,7 +176,7 @@ public void test112ModifyActivationJack() throws Exception { modifyUserReplace(USER_JACK_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, task, result, ActivationStatusType.DISABLED); //THEN - displayThen(TEST_NAME); + then(); UserAsserter userAfterAsserter = assertUserAfter(USER_JACK_OID); userAfterAsserter diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java index 43eb8517f16..fb2e5e990c5 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestConsistencyMechanism.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.IOException; -import java.time.Duration; import java.util.*; import javax.xml.bind.JAXBElement; @@ -30,10 +29,8 @@ import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.*; -import com.evolveum.midpoint.prism.impl.PrismPropertyValueImpl; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions; import com.evolveum.midpoint.schema.*; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.ObjectTypes; @@ -77,12 +74,10 @@ import com.evolveum.midpoint.schema.util.SchemaTestConstants; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.Checker; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointAsserts; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DOMUtil; -import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; @@ -317,11 +312,9 @@ public static void stopResources() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - displayTestTitle(TEST_NAME); assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); - assertTrue(isSystemInitialized()); assertNotNull(taskManager); assertNotNull(prismContext); @@ -358,7 +351,6 @@ public void test000Integrity() throws Exception { @Test public void test001TestConnectionOpenDJ() throws Exception { final String TEST_NAME = "test001TestConnectionOpenDJ"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); // GIVEN @@ -425,11 +417,11 @@ public void test100AddUser() throws Exception { OperationResult repoResult = new OperationResult("getObject"); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(repoResult); assertUser(uObject,"repo") @@ -445,9 +437,8 @@ public void test100AddUser() throws Exception { @Test public void test110PrepareOpenDjWithJackieAccounts() throws Exception { final String TEST_NAME = "test110PrepareOpenDjWithJackieAccounts"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); // adding jackie shadow directly and then, linking this shadow to the user jack. we need to do linking on repository level, to skip clockwork execution @@ -501,9 +492,8 @@ public void test110PrepareOpenDjWithJackieAccounts() throws Exception { @Test public void test111prepareOpenDjWithDenielsAccounts() throws Exception { final String TEST_NAME = "test111prepareOpenDjWithDenielsAccounts"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); addObject(ACCOUNT_DENIELS_FILE, task, parentResult); @@ -547,7 +537,6 @@ public void test111prepareOpenDjWithDenielsAccounts() throws Exception { @Test public void test120AddAccountAlreadyExistLinked() throws Exception { final String TEST_NAME = "test120AddAccountAlreadyExistLinked"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); OperationResult parentResult = new OperationResult("Add account already exist linked"); @@ -605,7 +594,6 @@ public void test120AddAccountAlreadyExistLinked() throws Exception { @Test public void test122AddAccountAlreadyExistUnlinked() throws Exception { final String TEST_NAME = "test122AddAccountAlreadyExistUnlinked"; - displayTestTitle(TEST_NAME); // GIVEN OperationResult parentResult = new OperationResult("Add account already exist unlinked."); @@ -628,11 +616,11 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_WILL_OID, RESOURCE_OPENDJ_OID, null, task, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); String accountOid = checkUser(USER_WILL_OID, task, parentResult); // MidPointAsserts.assertAssignments(user, 1); @@ -654,8 +642,7 @@ public void test122AddAccountAlreadyExistUnlinked() throws Exception { @Test(enabled = false) public void test124AddAccountDirectAlreadyExists() throws Exception { final String TEST_NAME = "test124AddAccountDirectAlreadyExists"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult parentResult = task.getResult(); @@ -745,8 +732,7 @@ public void test124AddAccountDirectAlreadyExists() throws Exception { @Test public void test130DeleteObjectNotFound() throws Exception { final String TEST_NAME = "test130DeleteObjectNotFound"; - displayTestTitle(TEST_NAME); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_FILENAME, parentResult); @@ -768,7 +754,7 @@ public void test130DeleteObjectNotFound() throws Exception { clockForward("PT20M"); - displayThen(TEST_NAME); + then(); provisioningService.refreshShadow(shadowRepo, null, task, parentResult); try { @@ -798,8 +784,7 @@ public void test130DeleteObjectNotFound() throws Exception { @Test public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { final String TEST_NAME = "test140ModifyObjectNotFoundLinkedAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_FILE, result); @@ -828,7 +813,7 @@ public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { // requestToExecuteChanges(REQUEST_ACCOUNT_MODIFY_NOT_FOUND_DELETE_ACCOUNT_FILE, ACCOUNT_GUYBRUSH_OID, ShadowType.class, task, null, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject shadowAfter = getShadowRepo(ACCOUNT_GUYBRUSH_OID); ShadowAsserter.forShadow(shadowAfter) .assertTombstone() @@ -865,10 +850,9 @@ public void test140ModifyObjectNotFoundLinkedAccount() throws Exception { @Test public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test142ModifyObjectNotFoundAssignedAccountq"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_GUYBRUSH_MODIFY_DELETE_FILE, parentResult); repoAddObjectFromFile(USER_GUYBRUSH_NOT_FOUND_FILENAME, parentResult); @@ -882,7 +866,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFor(ShadowType.class) .property(ItemPath.create(ShadowType.F_ATTRIBUTES, new ItemName(MidPointConstants.NS_RI, "roomNumber"))) .replace("cabin") @@ -900,7 +884,7 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { // requestToExecuteChanges(REQUEST_ACCOUNT_MODIFY_NOT_FOUND_DELETE_ACCOUNT_FILE, ACCOUNT_GUYBRUSH_MODIFY_DELETE_OID, ShadowType.class, task, null, parentResult); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_GUYBRUSH_NOT_FOUND_OID); UserAsserter.forUser(userAfter) .assertLinks(1); @@ -928,10 +912,9 @@ public void test142ModifyObjectNotFoundAssignedAccount() throws Exception { @Test public void test144GetObjectNotFoundAssignedAccount() throws Exception { final String TEST_NAME = "test144GetObjectNotFoundAssignedAccount"; - displayTestTitle(TEST_NAME); // GIVEN - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddShadowFromFile(ACCOUNT_HECTOR_FILE, parentResult); repoAddObjectFromFile(USER_HECTOR_NOT_FOUND_FILENAME, parentResult); @@ -969,7 +952,6 @@ public void test144GetObjectNotFoundAssignedAccount() throws Exception { @Test public void test150RecomputeUserAccountNotFound() throws Exception { final String TEST_NAME = "test150RecomputeUserAccountNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -994,11 +976,11 @@ public void test150RecomputeUserAccountNotFound() throws Exception { assertTrue("Oh my! Shadow is dead!", repoShadowBefore.asObjectable().isDead() != Boolean.TRUE); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); recomputeUser(USER_GUYBRUSH_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1025,7 +1007,6 @@ public void test150RecomputeUserAccountNotFound() throws Exception { @Test public void test152RecomputeUserAccountAndShadowNotFound() throws Exception { final String TEST_NAME = "test152RecomputeUserAccountAndShadowNotFound"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -1074,7 +1055,6 @@ public void test152RecomputeUserAccountAndShadowNotFound() throws Exception { @Test public void test159DeleteUSerGuybrush() throws Exception { final String TEST_NAME = "test159DeleteUSerGuybrush"; - displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -1105,7 +1085,6 @@ public void test159DeleteUSerGuybrush() throws Exception { @Test public void test200StopOpenDj() throws Exception { final String TEST_NAME = "test200StopOpenDj"; - displayTestTitle(TEST_NAME); openDJController.stop(); assertEquals("Resource is running", false, EmbeddedUtils.isRunning()); @@ -1114,7 +1093,6 @@ public void test200StopOpenDj() throws Exception { @Test public void test210AddObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test210AddObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1171,7 +1149,6 @@ public void test210AddObjectCommunicationProblem() throws Exception { @Test public void test212AddModifyObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test212AddModifyObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1188,13 +1165,13 @@ public void test212AddModifyObjectCommunicationProblem() throws Exception { .createModificationAddProperty(ShadowType.class, accountOid, createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_NUMBER), "emp4321"); delta.addModificationReplaceProperty(createAttributePath(LDAP_ATTRIBUTE_GIVENNAME), "eeeee"); - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); executeChanges(delta, null, task, parentResult); XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); //THEN - TestUtil.displayThen(TEST_NAME); + then(); assertRepoShadow(accountOid) .display(TEST_NAME + "Shadow after") .assertKind(ShadowKindType.ACCOUNT) @@ -1245,18 +1222,17 @@ private ItemPath createAttributePath(QName itemName) { @Test public void test214ModifyObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test214ModifyObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); String accountOid = assertUserOneAccountRef(USER_JACK_OID); Task task = taskManager.createTaskInstance(); //WHEN - TestUtil.displayWhen(TEST_NAME); + when(); ObjectDelta delta = prismContext.deltaFactory() .object() .createModificationAddProperty(ShadowType.class, accountOid, createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_NUMBER), "emp4321"); @@ -1268,7 +1244,7 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); //THEN - TestUtil.displayThen(TEST_NAME); + then(); assertModelShadowNoFetch(ACCOUNT_JACKIE_OID) .display(TEST_NAME + "Shadow after") .assertKind(ShadowKindType.ACCOUNT) @@ -1309,7 +1285,6 @@ public void test214ModifyObjectCommunicationProblem() throws Exception { @Test public void test220DeleteObjectCommunicationProblem() throws Exception { final String TEST_NAME = "test220DeleteObjectCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1361,11 +1336,10 @@ public void test220DeleteObjectCommunicationProblem() throws Exception { @Test public void test230GetAccountCommunicationProblem() throws Exception { final String TEST_NAME = "test230GetAccountCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); ShadowType account = modelService.getObject(ShadowType.class, ACCOUNT_DENIELS_OID, null, null, result).asObjectable(); @@ -1397,11 +1371,10 @@ public void test230GetAccountCommunicationProblem() throws Exception { @Test public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception{ final String TEST_NAME = "test240AddObjectCommunicationProblemAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); Entry entry = openDJController.addEntryFromLdifFile(LDIF_ELAINE_FILE); Entry searchResult = openDJController.searchByUid("elaine"); @@ -1471,11 +1444,10 @@ public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception @Test public void test250ModifyFocusCommunicationProblem() throws Exception { final String TEST_NAME = "test250ModifyFocusCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); assertUser(USER_JACK_OID, "User before") .assertLinks(1); @@ -1555,11 +1527,10 @@ public void test250ModifyFocusCommunicationProblem() throws Exception { @Test public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception { final String TEST_NAME = "test251ModifyFocusCommunicationProblemSecondTime"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); assertUser(USER_JACKIE_OID, "User before") .assertLinks(1) @@ -1671,12 +1642,11 @@ public void test251ModifyFocusCommunicationProblemSecondTime() throws Exception @Test public void test260GetDiscoveryAddCommunicationProblem() throws Exception { final String TEST_NAME = "test260GetDiscoveryAddCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); display("OpenDJ stopped"); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_ANGELIKA_FILENAME, parentResult); @@ -1686,14 +1656,14 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { Task task = taskManager.createTaskInstance(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); assignAccount(UserType.class, USER_ANGELIKA_OID, RESOURCE_OPENDJ_OID, "internal", task, parentResult); XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); parentResult.computeStatus(); assertInProgress(parentResult); @@ -1738,7 +1708,6 @@ public void test260GetDiscoveryAddCommunicationProblem() throws Exception { @Test public void test262GetDiscoveryModifyCommunicationProblem() throws Exception { final String TEST_NAME = "test262GetDiscoveryModifyCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1831,7 +1800,6 @@ public void test262GetDiscoveryModifyCommunicationProblem() throws Exception { @Test public void test264GetDiscoveryModifyUserPasswordCommunicationProblem() throws Exception { final String TEST_NAME = "test264GetDiscoveryModifyUserPasswordCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1922,7 +1890,6 @@ public void test264GetDiscoveryModifyUserPasswordCommunicationProblem() throws E @Test public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exception { final String TEST_NAME = "test265ModifyUserPasswordCommunicationProblemRecon"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1934,13 +1901,13 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio String shadowOid = getLinkRefOid(USER_ALICE_OID, RESOURCE_OPENDJ_OID); // WHEN (down) - TestUtil.displayWhen(TEST_NAME); + when(); XMLGregorianCalendar lastRequestStartTs = clock.currentTimeXMLGregorianCalendar(); modifyUserChangePassword(USER_ALICE_OID, "UNDEADmenTELLscaryTALES", task, result); XMLGregorianCalendar lastRequestEndTs = clock.currentTimeXMLGregorianCalendar(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); //check the state after execution assertModelShadowNoFetch(shadowOid) .display(TEST_NAME + "Shadow after") @@ -1978,11 +1945,11 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio modifyResourceAvailabilityStatus(AvailabilityStatusType.UP, result); // WHEN (restore) - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(USER_ALICE_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); openDJController.assertPassword(aliceAccountDn, "UNDEADmenTELLscaryTALES"); assertUser(USER_ALICE_OID, "User after") @@ -1998,11 +1965,10 @@ public void test265ModifyUserPasswordCommunicationProblemRecon() throws Exceptio @Test public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { final String TEST_NAME = "test270ModifyDiscoveryAddCommunicationProblem"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); // WHEN repoAddObjectFromFile(USER_BOB_NO_GIVEN_NAME_FILENAME, parentResult); @@ -2054,11 +2020,10 @@ public void test270ModifyDiscoveryAddCommunicationProblem() throws Exception { @Test public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exception{ final String TEST_NAME = "test280ModifyObjectCommunicationProblemWeakMapping"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_JOHN_WEAK_FILENAME, parentResult); assertUser(USER_JOHN_WEAK_OID, "User before") @@ -2104,11 +2069,10 @@ public void test280ModifyObjectCommunicationProblemWeakMapping() throws Exceptio @Test public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws Exception { final String TEST_NAME = "test282ModifyObjectCommunicationProblemWeakAndStrongMapping"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_DONALD_FILENAME, parentResult); @@ -2172,11 +2136,10 @@ public void test282ModifyObjectCommunicationProblemWeakAndStrongMapping() throws @Test public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { final String TEST_NAME = "test283GetObjectNoFetchShadowAndRecompute"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); assertUser(USER_DONALD_OID, "User before") .assertLinks(1); @@ -2197,11 +2160,11 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { .assertNoModification(createAttributePath(LDAP_ATTRIBUTE_EMPLOYEE_TYPE)); //WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_DONALD_OID, ModelExecuteOptions.createReconcile(), task, parentResult); //THEN - displayThen(TEST_NAME); + then(); assertModelShadow(shadowOid) .attributes() .assertValue(LDAP_ATTRIBUTE_GIVENNAME, "don") @@ -2212,9 +2175,8 @@ public void test283GetObjectNoFetchShadowAndRecompute() throws Exception { @Test public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Exception { final String TEST_NAME = "test284ModifyObjectAssignToGroupCommunicationProblem"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); // GIVEN openDJController.addEntriesFromLdifFile(LDIF_CREATE_ADMINS_GROUP_FILE); @@ -2234,7 +2196,7 @@ public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Except String shadowOid = getLinkRefOid(USER_DONALD_OID, RESOURCE_OPENDJ_OID); // WHEN - displayWhen(TEST_NAME); + when(); AssignmentType adminRoleAssignment = new AssignmentType(prismContext); adminRoleAssignment.setTargetRef(ObjectTypeUtil.createObjectRef(ROLE_LDAP_ADMINS_OID, ObjectTypes.ROLE)); @@ -2286,11 +2248,10 @@ public void test284ModifyObjectAssignToGroupCommunicationProblem() throws Except @Test(enabled = false) public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exception{ final String TEST_NAME = "test400GetDiscoveryAddCommunicationProblemAlreadyExists"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeStopped(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); repoAddObjectFromFile(USER_DISCOVERY_FILENAME, parentResult); @@ -2332,7 +2293,6 @@ public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exc @Test public void test500AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test500AddUserMorganWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2345,11 +2305,11 @@ public void test500AddUserMorganWithAssignment() throws Exception { // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_MORGAN_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); PrismObject userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result); display("User morgan after", userMorgan); @@ -2379,7 +2339,6 @@ public void test500AddUserMorganWithAssignment() throws Exception { @Test public void test501AddUserChuckWithAssignment() throws Exception { final String TEST_NAME = "test501AddUserChuckWithAssignment"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2395,11 +2354,11 @@ public void test501AddUserChuckWithAssignment() throws Exception { // // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); addObject(USER_CHUCK_FILE); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2437,7 +2396,6 @@ public void test501AddUserChuckWithAssignment() throws Exception { @Test public void test502AssignAccountToHerman() throws Exception { final String TEST_NAME = "test502AssignAccountToHerman"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2458,11 +2416,11 @@ public void test502AssignAccountToHerman() throws Exception { //REQUEST_USER_MODIFY_ADD_ACCOUNT_COMMUNICATION_PROBLEM //WHEN - displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_HERMAN_OID, RESOURCE_OPENDJ_OID, "internal", task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2498,7 +2456,6 @@ public void test502AssignAccountToHerman() throws Exception { @Test public void test510UnlinkAndUnassignAccountMorgan() throws Exception { final String TEST_NAME = "test510UnlinkAndUnassignAccountMorgan"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2516,7 +2473,7 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); ///----user's link is removed, now, remove assignment @@ -2525,13 +2482,13 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { user.findContainer(UserType.F_ASSIGNMENT).getValue().clone()); deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); repositoryService.deleteObject(ShadowType.class, linkRef.getOid(), result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2569,7 +2526,6 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { @Test public void test511AssignAccountMorgan() throws Exception { final String TEST_NAME = "test511AssignAccountMorgan"; - displayTestTitle(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2611,12 +2567,12 @@ public void test511AssignAccountMorgan() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); @@ -2644,7 +2600,6 @@ public void test511AssignAccountMorgan() throws Exception { @Test public void test600DeleteUserAlice() throws Exception { String TEST_NAME = "test600DeleteUserAlice"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); Task task = taskManager.createTaskInstance(TEST_NAME); @@ -2668,10 +2623,9 @@ public void test600DeleteUserAlice() throws Exception { @Test public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws Exception { String TEST_NAME = "test601GetDiscoveryModifyCommunicationProblemDirectAccount"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); - OperationResult parentResult = new OperationResult(TEST_NAME); + OperationResult parentResult = createOperationalResult(); //prepare user repoAddObjectFromFile(USER_ALICE_FILENAME, parentResult); @@ -2724,7 +2678,6 @@ public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws @Test//(enabled = false) public void test800Reconciliation() throws Exception { final String TEST_NAME = "test800Reconciliation"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); @@ -2822,10 +2775,9 @@ public void test800Reconciliation() throws Exception { @Test//(enabled = false) public void test801TestReconciliationRename() throws Exception { final String TEST_NAME = "test801TestReconciliationRename"; - displayTestTitle(TEST_NAME); openDJController.assumeRunning(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); final OperationResult result = task.getResult(); LOGGER.info("starting rename"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java index 67794beef45..298f1898120 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelayedEnable.java @@ -110,20 +110,19 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AddUserMancomb() throws Exception { final String TEST_NAME = "test100AddUserMancomb"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_MANCOMB_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -141,16 +140,15 @@ public void test100AddUserMancomb() throws Exception { @Test public void test102UserMancombTriggerScannerAgain() throws Exception { final String TEST_NAME = "test102UserMancombTriggerScannerAgain"; - displayTestTitle(TEST_NAME); displayCurrentTime(); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertMancombCreated(); @@ -164,19 +162,18 @@ public void test102UserMancombTriggerScannerAgain() throws Exception { @Test public void test104UserMancombRecompute() throws Exception { final String TEST_NAME = "test104UserMancombRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); displayCurrentTime(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombCreated(); @@ -209,17 +206,16 @@ private void assertMancombCreated() throws Exception { @Test public void test110UserMancombRunTriggerScannerDay1() throws Exception { final String TEST_NAME = "test110UserMancombRunTriggerScannerDay1"; - displayTestTitle(TEST_NAME); clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertMancombEnabled(); @@ -233,20 +229,19 @@ public void test110UserMancombRunTriggerScannerDay1() throws Exception { @Test public void test112UserMancombRecomputeDay1() throws Exception { final String TEST_NAME = "test112UserMancombRecomputeDay1"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombEnabled(); @@ -273,15 +268,14 @@ private void assertMancombEnabled() throws Exception { @Test public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { final String TEST_NAME = "test114UserMancombRunTriggerScannerDay1Again"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertMancombEnabled(); @@ -294,18 +288,17 @@ public void test114UserMancombRunTriggerScannerDay1Again() throws Exception { @Test public void test116UserMancombRecomputeDay1Again() throws Exception { final String TEST_NAME = "test116UserMancombRecomputeDay1Again"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombEnabled(); @@ -320,20 +313,19 @@ public void test116UserMancombRecomputeDay1Again() throws Exception { @Test public void test120UserMancombHrDisable() throws Exception { final String TEST_NAME = "test120UserMancombHrDisable"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_MANCOMB_OID, getExtensionPath(EXT_HR_STATUS_QNAME), task, result, EXT_HR_STATUS_DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -362,18 +354,17 @@ private void assertMancombHalfDisabled() throws Exception { @Test public void test122UserMancombRecompute() throws Exception { final String TEST_NAME = "test122UserMancombRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombHalfDisabled(); @@ -384,18 +375,17 @@ public void test122UserMancombRecompute() throws Exception { @Test public void test124UserMancombDay1TriggerScanner() throws Exception { final String TEST_NAME = "test124UserMancombDay1TriggerScanner"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombHalfDisabled(); @@ -410,20 +400,19 @@ public void test124UserMancombDay1TriggerScanner() throws Exception { @Test public void test130UserMancombTriggerScannerDay2() throws Exception { final String TEST_NAME = "test130UserMancombTriggerScannerDay2"; - displayTestTitle(TEST_NAME); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -451,18 +440,17 @@ private void assertMancombDisabled() throws Exception { @Test public void test132UserMancombRecomputeDay2() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -473,18 +461,17 @@ public void test132UserMancombRecomputeDay2() throws Exception { @Test public void test132UserMancombRecomputeDay2Again() throws Exception { final String TEST_NAME = "test132UserMancombRecomputeDay2Again"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -499,20 +486,19 @@ public void test132UserMancombRecomputeDay2Again() throws Exception { @Test public void test140UserMancombRecomputeDay3() throws Exception { final String TEST_NAME = "test140UserMancombRecomputeDay3"; - displayTestTitle(TEST_NAME); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_MANCOMB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertMancombDisabled(); @@ -526,16 +512,16 @@ public void test140UserMancombRecomputeDay3() throws Exception { public void test200HrLivesyncTask() throws Exception { final String TEST_NAME = "test200HrLivesyncTask"; - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(TASK_DUMMY_HR_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); waitForTaskStart(TASK_DUMMY_HR_OID, true); @@ -546,9 +532,8 @@ public void test200HrLivesyncTask() throws Exception { @Test public void test210HrAddUserGuybrush() throws Exception { final String TEST_NAME = "test210HrAddUserGuybrush"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); DummyAccount accountGuybrushBefore = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME); @@ -561,12 +546,12 @@ public void test210HrAddUserGuybrush() throws Exception { hrCreateTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); hrCreateTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -580,20 +565,19 @@ public void test210HrAddUserGuybrush() throws Exception { @Test public void test212HrUserGuybrushSyncAgain() throws Exception { final String TEST_NAME = "test212HrUserGuybrushSyncAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -604,20 +588,19 @@ public void test212HrUserGuybrushSyncAgain() throws Exception { @Test public void test214HrUserGuybrushRunTriggers() throws Exception { final String TEST_NAME = "test214HrUserGuybrushRunTriggers"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -628,20 +611,19 @@ public void test214HrUserGuybrushRunTriggers() throws Exception { @Test public void test216HrUserGuybrushRecompute() throws Exception { final String TEST_NAME = "test216HrUserGuybrushRecompute"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -652,20 +634,19 @@ public void test216HrUserGuybrushRecompute() throws Exception { @Test public void test218HrUserGuybrushReconcile() throws Exception { final String TEST_NAME = "test218HrUserGuybrushReconcile"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushCreated(assertUserAfter(userGuybrushOid)); @@ -695,17 +676,16 @@ private UserAsserter assertGuybrushCreated(UserAsserter userAsserter @Test public void test220HrUserGuybrushDay1() throws Exception { final String TEST_NAME = "test220HrUserGuybrushDay1"; - displayTestTitle(TEST_NAME); clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertGuybrushEnabled(); @@ -715,18 +695,17 @@ public void test220HrUserGuybrushDay1() throws Exception { @Test public void test222HrUserGuybrushDay1SyncAgain() throws Exception { final String TEST_NAME = "test222HrUserGuybrushDay1SyncAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -737,20 +716,19 @@ public void test222HrUserGuybrushDay1SyncAgain() throws Exception { @Test public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { final String TEST_NAME = "test224HrUserGuybrushDay1TriggerScanAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -761,18 +739,17 @@ public void test224HrUserGuybrushDay1TriggerScanAgain() throws Exception { @Test public void test226HrUserGuybrushDay1Recompute() throws Exception { final String TEST_NAME = "test226HrUserGuybrushDay1Recompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -783,18 +760,17 @@ public void test226HrUserGuybrushDay1Recompute() throws Exception { @Test public void test228HrUserGuybrushDay1Reconcile() throws Exception { final String TEST_NAME = "test228HrUserGuybrushDay1Reconcile"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushEnabled(); @@ -820,7 +796,6 @@ private void assertGuybrushEnabled() throws Exception { @Test public void test230HrDisableGuybrush() throws Exception { final String TEST_NAME = "test230HrDisableGuybrush"; - displayTestTitle(TEST_NAME); getDummyResourceHr() .getAccountByUsername(ACCOUNT_GUYBRUSH_USERNAME) @@ -829,12 +804,12 @@ public void test230HrDisableGuybrush() throws Exception { hrModifyTsStart = clock.currentTimeXMLGregorianCalendar(); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); hrModifyTsEnd = clock.currentTimeXMLGregorianCalendar(); @@ -846,15 +821,14 @@ public void test230HrDisableGuybrush() throws Exception { @Test public void test232GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); assertGuybrushHalfDisabled(); @@ -864,18 +838,17 @@ public void test232GuybrushHrSyncAgain() throws Exception { @Test public void test234GuybrushRecompute() throws Exception { final String TEST_NAME = "test232GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -886,18 +859,17 @@ public void test234GuybrushRecompute() throws Exception { @Test public void test236GuybrushReconcile() throws Exception { final String TEST_NAME = "test236GuybrushReconcile"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushHalfDisabled(); @@ -908,17 +880,16 @@ public void test236GuybrushReconcile() throws Exception { @Test public void test238GuybrushrunTriggersAgain() throws Exception { final String TEST_NAME = "test238GuybrushrunTriggersAgain"; - displayTestTitle(TEST_NAME); clockForward("PT1H"); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertGuybrushHalfDisabled(); @@ -945,17 +916,16 @@ private void assertGuybrushHalfDisabled() throws Exception { @Test public void test240HrUserGuybrushDay2() throws Exception { final String TEST_NAME = "test240HrUserGuybrushDay2"; - displayTestTitle(TEST_NAME); clockForward("P1D"); // WHEN - displayWhen(TEST_NAME); + when(); runTriggerScanner(); // THEN - displayThen(TEST_NAME); + then(); assertGuybrushDisabled(); @@ -965,18 +935,17 @@ public void test240HrUserGuybrushDay2() throws Exception { @Test public void test242GuybrushRecompute() throws Exception { final String TEST_NAME = "test242GuybrushRecompute"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushDisabled(); @@ -987,15 +956,14 @@ public void test242GuybrushRecompute() throws Exception { @Test public void test244GuybrushHrSyncAgain() throws Exception { final String TEST_NAME = "test244GuybrushHrSyncAgain"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); syncWithHr(); // THEN - displayThen(TEST_NAME); + then(); assertGuybrushDisabled(); @@ -1005,18 +973,17 @@ public void test244GuybrushHrSyncAgain() throws Exception { @Test public void test246GuybrushReconcile() throws Exception { final String TEST_NAME = "test246GuybrushReconcile"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userGuybrushOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertGuybrushDisabled(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java index 968c57764b2..7e11f84bc55 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDelivery.java @@ -160,12 +160,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti // setGlobalTracingOverride(createModelAndWorkflowLoggingTracingProfile()); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - -// @Override + // @Override // protected TracingProfileType getTestMethodTracingProfile() { // return createModelAndWorkflowLoggingTracingProfile() // .fileNamePattern(TEST_METHOD_TRACING_FILENAME_PATTERN); @@ -178,8 +173,8 @@ protected PrismObject getDefaultActor() { @Test public void test100Assign_IT_2_failure() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); try { assignRole(userBobOid, roleIt2Oid, task, result); // hard constraint @@ -191,20 +186,20 @@ public void test100Assign_IT_2_failure() throws Exception { @Test public void test110Assign_IT_2_success() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt2Oid, task, result); // hard constraint result.computeStatus(); assertSuccess(result); - assertAssignedRole(userBarkeeperOid, roleIt2Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt2Oid, result); } @Test public void test120Assign_IT_1() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userBobOid, roleIt1Oid, task, result); // approval constraint @@ -221,7 +216,7 @@ public void test120Assign_IT_1() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBobOid, roleIt1Oid, task, result); + assertAssignedRole(userBobOid, roleIt1Oid, result); } /** @@ -229,8 +224,8 @@ public void test120Assign_IT_1() throws Exception { */ @Test public void test130Assign_IT_3() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userCarlaOid, roleIt3Oid, task, result); // two approval constraints @@ -256,7 +251,7 @@ public void test130Assign_IT_3() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userCarlaOid, roleIt3Oid, task, result); + assertAssignedRole(userCarlaOid, roleIt3Oid, result); } /** @@ -264,8 +259,8 @@ public void test130Assign_IT_3() throws Exception { */ @Test public void test140Assign_IT_4() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt4Oid, task, result); // approval constraint @@ -282,7 +277,7 @@ public void test140Assign_IT_4() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBarkeeperOid, roleIt4Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt4Oid, result); } /** @@ -290,8 +285,8 @@ public void test140Assign_IT_4() throws Exception { */ @Test public void test150Assign_IT_5() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); assignRole(userBarkeeperOid, roleIt5Oid, task, result); // approval constraint @@ -308,7 +303,7 @@ public void test150Assign_IT_5() throws Exception { task, result); waitForCaseClose(rootCase, 60000); - assertAssignedRole(userBarkeeperOid, roleIt5Oid, task, result); + assertAssignedRole(userBarkeeperOid, roleIt5Oid, result); } @NotNull diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java index 16244825c7c..cf89687ba03 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestDependencyRename.java @@ -103,7 +103,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_PHONEBOOK_OID, task); @@ -118,7 +117,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddUserHerman() throws Exception { final String TEST_NAME = "test100AddUserHerman"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -149,7 +147,6 @@ public void test100AddUserHerman() throws Exception { @Test public void test110HermanAssignRoleBasic() throws Exception { final String TEST_NAME = "test110HermanAssignRoleBasic"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -184,7 +181,6 @@ public void test110HermanAssignRoleBasic() throws Exception { @Test public void test112HermanRename() throws Exception { final String TEST_NAME = "test112HermanRename"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -219,7 +215,6 @@ public void test112HermanRename() throws Exception { @Test public void test120AddUserCapsizeWithBasicRole() throws Exception { final String TEST_NAME = "test120AddUserCapsizeWithBasicRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestDependencyRename.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java index eec90b77070..ce008f700cc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestEntertainment.java @@ -88,7 +88,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -110,7 +109,6 @@ public void test000Sanity() throws Exception { @Test public void test001AddParentOrg() throws Exception { final String TEST_NAME = "test001AddParentOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -142,7 +140,6 @@ public void test001AddParentOrg() throws Exception { @Test public void test002AddChildOrg() throws Exception { final String TEST_NAME = "test002AddChildOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestEntertainment.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java index ce10d295b7c..da29dec8b14 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestExistentialIssues.java @@ -60,17 +60,16 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100DisableUserDescartes() throws Exception { final String TEST_NAME = "test100DisableUserDescartes"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -89,17 +88,16 @@ public void test100DisableUserDescartes() throws Exception { @Test public void test110DescartesAssignLazyAccount() throws Exception { final String TEST_NAME = "test110DescartesAssignLazyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -118,17 +116,16 @@ public void test110DescartesAssignLazyAccount() throws Exception { @Test public void test112EnableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -147,17 +144,16 @@ public void test112EnableDescartes() throws Exception { @Test public void test114DisableDescartes() throws Exception { final String TEST_NAME = "test112EnableDescartes"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -176,17 +172,16 @@ public void test114DisableDescartes() throws Exception { @Test public void test116ReenableDescartes() throws Exception { final String TEST_NAME = "test116ReenableDescartes"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_DESCARTES_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.ENABLED); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -205,17 +200,16 @@ public void test116ReenableDescartes() throws Exception { @Test public void test120DescartesUnassignLazyAccount() throws Exception { final String TEST_NAME = "test120DescartesUnassignLazyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_DESCARTES_OID, RESOURCE_DUMMY_LAZY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_DESCARTES_OID); @@ -234,17 +228,16 @@ public void test120DescartesUnassignLazyAccount() throws Exception { @Test public void test129DeleteDescartes() throws Exception { final String TEST_NAME = "test129DeleteDescartes"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(UserType.class, USER_DESCARTES_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoObject(UserType.class, USER_DESCARTES_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java index 942a8b397c4..d9a4fe10b6f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestImportGroups.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,16 +6,13 @@ */ package com.evolveum.midpoint.testing.story; -import com.evolveum.icf.dummy.resource.DummySyncStyle; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.AfterClass; @@ -49,7 +46,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -73,14 +70,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001importGroups() throws Exception { - String TEST_NAME = "test001importGroups"; - displayTestTitle(TEST_NAME); - addObject(TASK_IMPORT_GROUPS); waitForTaskFinish(TASK_IMPORT_GROUPS_OID, true); assertObjects(OrgType.class, DEFAULT_GROUPS + GROUPS); - } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java index dacd8aa2bf1..caee18d43ec 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInboundOutboundAssociation.java @@ -7,7 +7,6 @@ package com.evolveum.midpoint.testing.story; import java.io.File; -import java.util.Collection; import java.util.function.Consumer; import javax.xml.namespace.QName; @@ -24,7 +23,6 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.asserter.RoleAsserter; @@ -32,7 +30,6 @@ import com.evolveum.midpoint.util.exception.CommonException; import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -101,18 +98,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100ImportGroupPirates() throws Exception { final String TEST_NAME = "test100ImportGroupPirates"; - displayTestTitle(TEST_NAME); DummyGroup group = new DummyGroup(GROUP_PIRATES_NAME); getDummyResourceDir().addGroup(group); // WHEN - displayWhen(TEST_NAME); + when(); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -136,17 +132,16 @@ public void test100ImportGroupPirates() throws Exception { @Test public void test110AssignJackDirAccount() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -168,14 +163,13 @@ public void test110AssignJackDirAccount() throws Exception { @Test public void test115Stability() throws Exception { final String TEST_NAME = "test110AssignJackDirAccount"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -193,7 +187,6 @@ public void test115Stability() throws Exception { @Test public void test120AddJackToGroupPirates() throws Exception { final String TEST_NAME = "test120AddJackToGroupPirates"; - displayTestTitle(TEST_NAME); getDummyResourceDir().getGroupByName(GROUP_PIRATES_NAME) .addMember(USER_JACK_USERNAME); @@ -203,12 +196,12 @@ public void test120AddJackToGroupPirates() throws Exception { .replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "rum"); // WHEN - displayWhen(TEST_NAME); + when(); liveSyncDir(); // THEN - displayThen(TEST_NAME); + then(); display("dir after", getDummyResourceDir()); @@ -230,17 +223,16 @@ public void test120AddJackToGroupPirates() throws Exception { @Test public void test130JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test120AddJackToGroupPirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -260,17 +252,16 @@ public void test130JackUnassignRolePirates() throws Exception { @Test public void test140JackAssignRolePirates() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -298,17 +289,16 @@ public void test140JackAssignRolePirates() throws Exception { @Test public void test142JackUnAssignDirAccount() throws Exception { final String TEST_NAME = "test140JackAssignRolePirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -334,17 +324,16 @@ public void test142JackUnAssignDirAccount() throws Exception { @Test public void test149JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test149JackUnassignRolePirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -362,17 +351,16 @@ public void test149JackUnassignRolePirates() throws Exception { @Test public void test150AssignJackDirAccount() throws Exception { final String TEST_NAME = "test150AssignJackDirAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -391,17 +379,16 @@ public void test150AssignJackDirAccount() throws Exception { @Test public void test152JackAssignRolePirates() throws Exception { final String TEST_NAME = "test152JackAssignRolePirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -427,9 +414,8 @@ public void test152JackAssignRolePirates() throws Exception { @Test public void test153JackUnassignRolePiratesPreview() throws Exception { final String TEST_NAME = "test153JackUnassignRolePiratesPreview"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta focusDelta = createAssignmentFocusDelta( @@ -439,11 +425,11 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { null, (Consumer)null, false); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext previewContext = previewChanges(focusDelta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertPreviewContext(previewContext) @@ -476,17 +462,16 @@ public void test153JackUnassignRolePiratesPreview() throws Exception { @Test public void test154JackUnassignRolePirates() throws Exception { final String TEST_NAME = "test154JackUnassignRolePirates"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, rolePiratesOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -509,17 +494,16 @@ public void test154JackUnassignRolePirates() throws Exception { @Test public void test159JackUnassignDirAccount() throws Exception { final String TEST_NAME = "test159JackUnassignDirAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccount(UserType.class, USER_JACK_OID, RESOURCE_DUMMY_DIR_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); @@ -540,17 +524,16 @@ public void test159JackUnassignDirAccount() throws Exception { @Test public void test200MancombAssignAccount() throws Exception { final String TEST_NAME = "test200MancombAssignAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_MANCOMB_OID, RESOURCE_DUMMY_DIR_OID, "default", task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("dir after", getDummyResourceDir()); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java index 1a306e296c1..bc7a26d397a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestInducement.java @@ -73,7 +73,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); //no resource, no extension definition //anything to check? @@ -86,10 +85,9 @@ public void test000Sanity() throws Exception { @Test public void test010InducementConditionsTrue() throws Exception { final String TEST_NAME = "test010InducementConditionsTrue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -117,10 +115,9 @@ public void test010InducementConditionsTrue() throws Exception { @Test public void test020InducementRole2ConditionFalse() throws Exception { final String TEST_NAME = "test020InducementRole2ConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -149,10 +146,9 @@ public void test020InducementRole2ConditionFalse() throws Exception { @Test public void test030InducementRole3ConditionFalse() throws Exception { final String TEST_NAME = "test030InducementRole3ConditionFalse"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -180,10 +176,9 @@ public void test030InducementRole3ConditionFalse() throws Exception { @Test public void test040Recomputed() throws Exception { final String TEST_NAME = "test040Recomputed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -210,10 +205,9 @@ public void test040Recomputed() throws Exception { @Test public void test050InducementRole3ConditionTrue() throws Exception { final String TEST_NAME = "test050InducementRole3ConditionTrue"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -240,10 +234,9 @@ public void test050InducementRole3ConditionTrue() throws Exception { @Test public void test060Recomputed() throws Exception { final String TEST_NAME = "test060Recomputed"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -267,10 +260,9 @@ public void test060Recomputed() throws Exception { @Test public void test070DeleteUser() throws Exception { final String TEST_NAME = "test070DeleteUser"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java index accac1ece2f..774dd834959 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLargeGroups.java @@ -46,7 +46,6 @@ /** * An attempt to test performance of various operations on large groups. * E.g. MID-5836 but others as well (in the future). - * */ @ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @@ -77,11 +76,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti dummyResource.setSyncStyle(DummySyncStyle.SMART); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected TracingProfileType getTestMethodTracingProfile() { return createModelLoggingTracingProfile() @@ -89,8 +83,8 @@ protected TracingProfileType getTestMethodTracingProfile() { } @Test - public void test000Sanity(ITestContext ctx) throws Exception { - Task task = getTask(ctx); + public void test000Sanity() throws Exception { + Task task = getTestTask(); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); TestUtil.assertSuccess(testResult); @@ -101,8 +95,8 @@ public void test000Sanity(ITestContext ctx) throws Exception { */ @Test public void test100GetLargeGroup(ITestContext ctx) throws Exception { - Task task = getTask(ctx); - OperationResult result = getResult(ctx); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); final int MEMBERS = 20000; @@ -124,9 +118,12 @@ public void test100GetLargeGroup(ITestContext ctx) throws Exception { assert100LargeGroupSearch(ctx, badOptions, MEMBERS); } - private void assert100LargeGroupSearch(ITestContext ctx, Collection> options, final int MEMBERS) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { - Task task = getTask(ctx); - OperationResult result = getResult(ctx); + private void assert100LargeGroupSearch( + ITestContext ctx, Collection> options, final int MEMBERS) + throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { + + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); ResourceAttributeDefinition nameDefinition = libraryMidpointFunctions .getAttributeDefinition(resourceDummy, dummyResourceCtl.getGroupObjectClass(), SchemaConstants.ICFS_NAME); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java index a7db1ed7aed..c03a84eec7f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLimitedResources.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType; /** @@ -69,18 +68,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject resourceNoAAD = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); List configuredCapabilities = resourceNoAAD.asObjectable().getCapabilities().getConfigured().getAny(); @@ -93,17 +91,16 @@ public void test000Sanity() throws Exception { @Test public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test100AssignJackAccountNoAttributeAddDelete"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -116,18 +113,17 @@ public void test100AssignJackAccountNoAttributeAddDelete() throws Exception { @Test public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { final String TEST_NAME = "test102AddJackOrganizationalUnitTreasureHunt"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -140,18 +136,17 @@ public void test102AddJackOrganizationalUnitTreasureHunt() throws Exception { @Test public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { final String TEST_NAME = "test104AddJackOrganizationalUnitLootingSailing"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserAdd(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING), createPolyString(OU_SAILING)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -164,18 +159,17 @@ public void test104AddJackOrganizationalUnitLootingSailing() throws Exception { @Test public void test106DeleteJackOrganizationalUnitLooting() throws Exception { final String TEST_NAME = "test106DeleteJackOrganizationalUnitLooting"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_LOOTING)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -191,18 +185,17 @@ public void test106DeleteJackOrganizationalUnitLooting() throws Exception { @Test public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exception { final String TEST_NAME = "test108DeleteJackOrganizationalUnitTreasureHuntSailing"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserDelete(USER_JACK_OID, UserType.F_ORGANIZATIONAL_UNIT, task, result, createPolyString(OU_TREASURE_HUNT), createPolyString(OU_SAILING)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_JACK_OID); @@ -215,17 +208,16 @@ public void test108DeleteJackOrganizationalUnitTreasureHuntSailing() throws Exce @Test public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { final String TEST_NAME = "test109UnassignJackAccountNoAttributeAddDelete"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_ATTRIBUTE_ADD_DELETE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -242,17 +234,16 @@ public void test109UnassignJackAccountNoAttributeAddDelete() throws Exception { @Test public void test110AssignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test110AssignJackAccountNoCreate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); display("Result", result); assertSuccess(result, 2); @@ -266,17 +257,16 @@ public void test110AssignJackAccountNoCreate() throws Exception { @Test public void test119UnassignJackAccountNoCreate() throws Exception { final String TEST_NAME = "test119UnassignJackAccountNoCreate"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NO_CREATE_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java index f78e64521d4..d00dec1ef17 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestLiveSyncMadness.java @@ -7,15 +7,13 @@ package com.evolveum.midpoint.testing.story; import com.evolveum.icf.dummy.resource.*; -import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -99,8 +97,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); TestUtil.assertSuccess(testResultHr); @@ -116,7 +113,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddHrAccountHerman() throws Exception { final String TEST_NAME = "test100AddHrAccountHerman"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); @@ -126,12 +122,12 @@ public void test100AddHrAccountHerman() throws Exception { dummyResourceHr.addAccount(newAccount); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HERMAN_FIST_NAME + " " + ACCOUNT_HERMAN_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HERMAN_LAST_NAME) @@ -156,7 +152,6 @@ public void test100AddHrAccountHerman() throws Exception { @Test public void test110RenameHrAccountHerman() throws Exception { final String TEST_NAME = "test110RenameHrAccountHerman"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); @@ -165,12 +160,12 @@ public void test110RenameHrAccountHerman() throws Exception { account.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_HT_LAST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) @@ -199,18 +194,17 @@ public void test110RenameHrAccountHerman() throws Exception { @Test public void test112HrAccountHermanEmptyDelta() throws Exception { final String TEST_NAME = "test112HrAccountHermanEmptyDelta"; - displayTestTitle(TEST_NAME); dummyAuditService.clear(); dummyResourceHr.recordEmptyDeltaForAccountByUsername(ACCOUNT_HERMAN_USERNAME, DummyDeltaType.MODIFY); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_LIVE_SYNC_DUMMY_HR_OID); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertUserAfterByUsername(ACCOUNT_HERMAN_USERNAME) .assertFullName(ACCOUNT_HT_FIST_NAME + " " + ACCOUNT_HT_LAST_NAME) .assertTitle("Mr. " + ACCOUNT_HT_LAST_NAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java index 1351841a61a..97e1a8bb4ce 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMachineIntelligence.java @@ -105,8 +105,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); Object[] newRealValue = { sourceFilePath }; @@ -139,7 +138,6 @@ SchemaConstants.ICF_CONFIGURATION_PROPERTIES, new QName(NS_RESOURCE_CSV, "filePa @Test public void test010importActiveUserRUR() throws Exception { final String TEST_NAME = "test010importActiveUserRUR"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -172,7 +170,6 @@ public void test010importActiveUserRUR() throws Exception { @Test public void test011importInactiveUserChappie() throws Exception { final String TEST_NAME = "test011importInactiveUserChappie"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestMachineIntelligence.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java index 33d92d9b792..f8d69387c9b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestManyThreads.java @@ -61,21 +61,19 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti resourceDummy = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY.file, RESOURCE_DUMMY.oid, initTask, initResult); dummyResourceCtl = DummyResourceContoller.create(null, resourceDummy); dummyResource = dummyResourceCtl.getDummyResource(); - - setAutoTaskManagementEnabled(true); } @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_DUMMY.oid, task)); } @Test public void test100SearchResourceObjects() throws Exception { - Task globalTask = getTask(); - OperationResult globalResult = getResult(); + Task globalTask = getTestTask(); + OperationResult globalResult = getTestOperationResult(); dummyResource.addAccount(new DummyAccount("jack")); @@ -93,7 +91,7 @@ public void test100SearchResourceObjects() throws Exception { ThreadTestExecutor executor = new ThreadTestExecutor(20, 60000L); executor.execute(() -> { login(userAdministrator.clone()); - Task localTask = createTask("execute"); + Task localTask = getTestTask(); OperationResult localResult = localTask.getResult(); ObjectQuery query = prismContext.queryFor(ShadowType.class) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java index d67f2119eca..2282610f438 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMapleLeaf.java @@ -135,7 +135,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestMapleLeaf.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -157,15 +156,13 @@ public void test000Sanity() throws Exception { @Test public void test001addUser() throws Exception { final String TEST_NAME = "test001addUser"; - displayTestTitle(TEST_NAME); - //when - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, "default"); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -190,15 +187,13 @@ public void test001addUser() throws Exception { @Test public void test002assignRoleSquirrel() throws Exception { final String TEST_NAME = "test002assignRoleSquirrel"; - displayTestTitle(TEST_NAME); - //when - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -223,14 +218,13 @@ public void test002assignRoleSquirrel() throws Exception { @Test public void test003unassignRoleSquirrel() throws Exception { final String TEST_NAME = "test003unassignRoleSquirrel"; - displayTestTitle(TEST_NAME); //when - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_SQUIRREL_OID); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -256,14 +250,13 @@ public void test003unassignRoleSquirrel() throws Exception { @Test public void test004assignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test004assignRoleMapleLeafFaculty"; - displayTestTitle(TEST_NAME); //when - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -297,14 +290,13 @@ private boolean containRoleMemebrShip(List roleMemberships, @Test public void test005assignRoleMapleLeafGraduate() throws Exception { final String TEST_NAME = "test005assignRoleMapleLeafGraduate"; - displayTestTitle(TEST_NAME); //when - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_GRADUATE_OID); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -330,14 +322,13 @@ public void test005assignRoleMapleLeafGraduate() throws Exception { @Test public void test006unassignRoleMapleLeafFaculty() throws Exception { final String TEST_NAME = "test006unassignRoleMapleLeafFaculty"; - displayTestTitle(TEST_NAME); //when - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID); //then - displayThen(TEST_NAME); + then(); PrismObject user = getUser(USER_JACK_OID); assertNotNull("User is null", user); @@ -363,7 +354,6 @@ public void test006unassignRoleMapleLeafFaculty() throws Exception { @Test public void test100changePasswordForceChange() throws Exception { final String TEST_NAME = "test100changePasswordForceChange"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -384,7 +374,7 @@ public void test100changePasswordForceChange() throws Exception { AssertJUnit.assertNotNull("Unexpected value in car license: " + carLicenseBefore.getRealValue(), carLicenseBefore.getRealValue()); //when - displayWhen(TEST_NAME); + when(); passwd = new ProtectedStringType(); passwd.setClearValue("somenewValue"); userDelta = createModifyUserReplaceDelta(USER_JACK_OID, SchemaConstants.PATH_PASSWORD_VALUE, passwd); @@ -394,7 +384,7 @@ public void test100changePasswordForceChange() throws Exception { //THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -419,7 +409,6 @@ public void test100changePasswordForceChange() throws Exception { @Test public void test101resetPassword() throws Exception { final String TEST_NAME = "test101resetPassword"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -427,7 +416,7 @@ public void test101resetPassword() throws Exception { openDJController.assertPassword("uid=jack,ou=People,dc=example,dc=com", "oldValue"); //when - displayWhen(TEST_NAME); + when(); PrismObject user = getUser(USER_JACK_OID); ExecuteCredentialResetRequestType executeCredentialResetRequest = new ExecuteCredentialResetRequestType(); executeCredentialResetRequest.setResetMethod("passwordReset"); @@ -435,7 +424,7 @@ public void test101resetPassword() throws Exception { modelInteractionService.executeCredentialsReset(user, executeCredentialResetRequest, task, result); //THEN - displayThen(TEST_NAME); + then(); PrismObject userAfter = getUser(USER_JACK_OID); UserType userTypeAfter = userAfter.asObjectable(); @@ -454,7 +443,6 @@ public void test101resetPassword() throws Exception { @Test public void test200setArchivedAdministrativeStatus() throws Exception { final String TEST_NAME = "test200setArchivedAdministrativeStatus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -474,7 +462,6 @@ public void test200setArchivedAdministrativeStatus() throws Exception { @Test public void test201SetUndefinedAdministrativeStatus() throws Exception { final String TEST_NAME = "test201SetUndefinedAdministrativeStatus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -489,7 +476,7 @@ public void test201SetUndefinedAdministrativeStatus() throws Exception { assertNotLinked(USER_JACK_OID, accountOid); //THEN - displayThen(TEST_NAME); + then(); modelService.importFromResource(accountOid, task, result); PrismObject userAfter = getUser(USER_JACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java index 6a8a6f7f480..3498d4e043d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMappingMadness.java @@ -83,13 +83,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AssignJackDummyAccounts() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccounts"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -97,7 +96,7 @@ public void test100AssignJackDummyAccounts() throws Exception { assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackPirateAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -113,20 +112,19 @@ public void test100AssignJackDummyAccounts() throws Exception { @Test public void test105ModifyJackTitleCaptain() throws Exception { final String TEST_NAME = "test105ModifyJackTitleCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); setAccountQuotes(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -186,18 +184,17 @@ public void test105ModifyJackTitleCaptain() throws Exception { @Test public void test110ModifyJackTitleWhatever() throws Exception { final String TEST_NAME = "test110ModifyJackTitleWhatever"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_UPPER)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); // Mappings return null, which means no value. @@ -260,18 +257,17 @@ private void assertNoAttributes(DummyAccountAsserter asserter) { @Test public void test112ReconcileJackWhatever() throws Exception { final String TEST_NAME = "test112ReconcileJackWhatever"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME) @@ -316,9 +312,8 @@ public void test112ReconcileJackWhatever() throws Exception { @Test public void test120MadJack() throws Exception { final String TEST_NAME = "test120MadJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Make sure that quotes are re-set. Especially in the nontolerant resource. @@ -329,12 +324,12 @@ public void test120MadJack() throws Exception { setAccountMad(getDummyAccount(RESOURCE_DUMMY_SMART_RANGE_NAME, USER_JACK_USERNAME)); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -355,18 +350,17 @@ public void test120MadJack() throws Exception { @Test public void test130ModifyJackTitleWhateverLower() throws Exception { final String TEST_NAME = "test130ModifyJackTitleWhateverLower"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result, createPolyString(JACK_TITLE_WHATEVER_LOWER)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -386,18 +380,17 @@ public void test130ModifyJackTitleWhateverLower() throws Exception { @Test public void test140ModifyJackTitleEmpty() throws Exception { final String TEST_NAME = "test140ModifyJackTitleEmpty"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_TITLE, task, result /* no value */); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertJackMadAccount(RESOURCE_DUMMY_TOLERANT_NAME); @@ -422,13 +415,12 @@ public void test140ModifyJackTitleEmpty() throws Exception { @Test public void test199UnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test199UnassignJackDummyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_OID, null, task, result); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_TOLERANT_RANGE_OID, null, task, result); @@ -436,7 +428,7 @@ public void test199UnassignJackDummyAccount() throws Exception { unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_NONTOLERANT_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(RESOURCE_DUMMY_TOLERANT_NAME, USER_JACK_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java index c53e0f4a457..ebc1092b601 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestMisbehavingResources.java @@ -53,18 +53,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010SanityAssignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -74,18 +73,17 @@ public void test010SanityAssignJackDummyAccount() throws Exception { @Test public void test019SanityUnassignJackDummyAccount() throws Exception { final String TEST_NAME = "test010SanityAssignJackDummyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -97,20 +95,19 @@ public void test019SanityUnassignJackDummyAccount() throws Exception { @Test public void test100AssignJackDummyAccountTimeout() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccountTimeout"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(3000); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); assertNoDummyAccount(USER_JACK_USERNAME); @@ -119,21 +116,20 @@ public void test100AssignJackDummyAccountTimeout() throws Exception { @Test public void test102AssignJackDummyAccounRetry() throws Exception { final String TEST_NAME = "test102AssignJackDummyAccounRetry"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -146,20 +142,19 @@ public void test102AssignJackDummyAccounRetry() throws Exception { @Test public void test110ModifyJackDummyAccountTimeout() throws Exception { final String TEST_NAME = "test110ModifyJackDummyAccountTimeout"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(3000); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(); assertInProgress(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) @@ -170,21 +165,20 @@ public void test110ModifyJackDummyAccountTimeout() throws Exception { @Test public void test112ModifyJackDummyAccounRetry() throws Exception { final String TEST_NAME = "test112ModifyJackDummyAccounRetry"; - displayTestTitle(TEST_NAME); getDummyResource().setOperationDelayOffset(0); clockForward("P1D"); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(null, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java index 401bfe3ab76..1b2ffc68d07 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNormalizers.java @@ -78,7 +78,6 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); PolyStringNormalizer prismNormalizer = prismContext.getDefaultPolyStringNormalizer(); assertTrue("Wrong normalizer class, expected Ascii7PolyStringNormalizer, but was "+prismNormalizer.getClass(), @@ -88,17 +87,16 @@ public void test000Sanity() throws Exception { @Test public void test100AddUserJack() throws Exception { final String TEST_NAME = "test100AddUserJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(AbstractStoryTest.USER_JACK_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(AbstractStoryTest.USER_JACK_OID); @@ -109,17 +107,16 @@ public void test100AddUserJack() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(USER_TELEKE_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUserFromRepo(USER_TELEKE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java index efc6d3e0740..3dc48c61c9f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestNullAttribute.java @@ -124,7 +124,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestNullAttribute.class.getName() + "." + TEST_NAME); OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_OID, task); @@ -146,10 +145,9 @@ public void test000Sanity() throws Exception { @Test public void test010UserSmackAssignAccountOnlyRole() throws Exception { final String TEST_NAME = "test010UserSmackAssignAccountOnlyRole"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -190,10 +188,9 @@ public void test010UserSmackAssignAccountOnlyRole() throws Exception { @Test public void test020UserSmackSetAttribute() throws Exception { final String TEST_NAME = "test020UserSmackSetAttribute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -244,10 +241,9 @@ public void test020UserSmackSetAttribute() throws Exception { @Test // MID-3325 public void test030UserSmackRemoveAttribute() throws Exception { final String TEST_NAME = "test030UserSmackRemoveAttribute"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -267,12 +263,12 @@ public void test030UserSmackRemoveAttribute() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getUser(USER_SMACK_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java index 9c07a80fc72..e6311798ce6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationCounts.java @@ -112,7 +112,6 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOperationCounts.class.getName() + "." + TEST_NAME); OperationResult testResultOne = modelService.testResource(RESOURCE_DUMMY_ONE_OID, task); @@ -126,20 +125,19 @@ public void test000Sanity() throws Exception { @Test public void test100AddAlice() throws Exception { final String TEST_NAME = "test100AddAlice"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); // GIVEN // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); addObject(USER_ALICE_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -174,20 +172,19 @@ public void test100AddAlice() throws Exception { @Test public void test110AddBob() throws Exception { final String TEST_NAME = "test110AddBob"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); // GIVEN // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); addObject(USER_BOB_FILE, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -219,7 +216,6 @@ public void test110AddBob() throws Exception { @Test public void test120ModifyBob() throws Exception { final String TEST_NAME = "test120ModifyBob"; - displayTestTitle(TEST_NAME); Task task = createTracedTask(TEST_NAME); OperationResult result = task.getResult(); @@ -230,13 +226,13 @@ public void test120ModifyBob() throws Exception { .asObjectDeltaCast(USER_BOB_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); resetThreadLocalPerformanceData(); executeChanges(delta, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java index 795c70c1363..47276fc6d25 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOperationPerf.java @@ -89,7 +89,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_ORDINARY_ROLES); @@ -110,9 +109,8 @@ public void test110AddBob() throws Exception { } public void testAddUser(final String TEST_NAME, File userFile, String userOid, int roles) throws Exception { - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = parseObject(userFile); @@ -129,12 +127,12 @@ public void testAddUser(final String TEST_NAME, File userFile, String userOid, i long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java index 532dee425f8..4c6145ede8f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestOrgSync.java @@ -13,7 +13,6 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -21,7 +20,6 @@ import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; -import org.opends.server.types.SearchResultEntry; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -41,7 +39,6 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.DummyResourceContoller; import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; @@ -290,8 +287,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); TestUtil.assertSuccess(testResultHr); @@ -312,7 +308,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddHrAccountHerman() throws Exception { final String TEST_NAME = "test100AddHrAccountHerman"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); @@ -352,7 +347,6 @@ public void test100AddHrAccountHerman() throws Exception { @Test public void test105AddHrAccountLemonhead() throws Exception { final String TEST_NAME = "test105AddHrAccountLemonhead"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); @@ -397,7 +391,6 @@ public void test105AddHrAccountLemonhead() throws Exception { @Test public void test106AddHrAccountSharptooth() throws Exception { final String TEST_NAME = "test106AddHrAccountSharptooth"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_SHARPTOOTH_USERNAME); @@ -441,7 +434,6 @@ public void test106AddHrAccountSharptooth() throws Exception { @Test public void test107AddHrAccountRedskull() throws Exception { final String TEST_NAME = "test107AddHrAccountRedskull"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_REDSKULL_USERNAME); @@ -484,18 +476,17 @@ public void test107AddHrAccountRedskull() throws Exception { @Test public void test108RedskullGoesVegetarian() throws Exception { final String TEST_NAME = "test108RedskullGoesVegetarian"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceHr.getAccountByUsername(ACCOUNT_REDSKULL_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); account.removeAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_RESPONSIBILITIES, RESP_CANIBALISM); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); assertNotNull("No redskull user", user); display("User", user); @@ -525,16 +516,15 @@ public void test108RedskullGoesVegetarian() throws Exception { @Test public void test109HrDeleteRedskull() throws Exception { final String TEST_NAME = "test109HrDeleteRedskull"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); dummyResourceHr.deleteAccountByName(ACCOUNT_REDSKULL_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true); // THEN - displayThen(TEST_NAME); + then(); PrismObject user = findUserByUsername(ACCOUNT_REDSKULL_USERNAME); display("User", user); assertNull("Redskull user not gone", user); @@ -555,7 +545,6 @@ public void test109HrDeleteRedskull() throws Exception { @Test public void test110AddHrAccountGuybrush() throws Exception { final String TEST_NAME = "test110AddHrAccountGuybrush"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME); @@ -601,7 +590,6 @@ public void test110AddHrAccountGuybrush() throws Exception { @Test public void test115AddHrAccountMancomb() throws Exception { final String TEST_NAME = "test115AddHrAccountMancomb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); @@ -648,7 +636,6 @@ public void test115AddHrAccountMancomb() throws Exception { @Test public void test117AddHrAccountCobb() throws Exception { final String TEST_NAME = "test117AddHrAccountCobb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_COBB_USERNAME); @@ -695,7 +682,6 @@ public void test117AddHrAccountCobb() throws Exception { @Test public void test130AddHrAccountLargo() throws Exception { final String TEST_NAME = "test130AddHrAccountLargo"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LARGO_USERNAME); @@ -748,7 +734,6 @@ public void test130AddHrAccountLargo() throws Exception { @Test public void test140AddHrAccountWally() throws Exception { final String TEST_NAME = "test140AddHrAccountWally"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); @@ -792,7 +777,6 @@ public void test140AddHrAccountWally() throws Exception { @Test public void test142AddHrAccountAugustus() throws Exception { final String TEST_NAME = "test142AddHrAccountAugustus"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_AUGUSTUS_USERNAME); @@ -836,7 +820,6 @@ public void test142AddHrAccountAugustus() throws Exception { @Test public void test185AddHrAccountStan() throws Exception { final String TEST_NAME = "test185AddHrAccountStan"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_STAN_USERNAME); @@ -882,7 +865,6 @@ public void test185AddHrAccountStan() throws Exception { @Test public void test186AddHrAccountCapsize() throws Exception { final String TEST_NAME = "test186AddHrAccountCapsize"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_CAPSIZE_USERNAME); @@ -928,7 +910,6 @@ public void test186AddHrAccountCapsize() throws Exception { @Test public void test187AddHrAccountRogersSr() throws Exception { final String TEST_NAME = "test187AddHrAccountRogersSr"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_ROGERSSR_USERNAME); @@ -975,7 +956,6 @@ public void test187AddHrAccountRogersSr() throws Exception { @Test public void test190AddHrAccountTeleke() throws Exception { final String TEST_NAME = "test190AddHrAccountTeleke"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestOrgSync.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_TELEKE_USERNAME); @@ -1018,10 +998,9 @@ public void test190AddHrAccountTeleke() throws Exception { @Test public void test500ReconcileOpenDJDefault() throws Exception { final String TEST_NAME = "test500ReconcileOpenDJDefault"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1033,17 +1012,17 @@ public void test500ReconcileOpenDJDefault() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1063,10 +1042,9 @@ public void test500ReconcileOpenDJDefault() throws Exception { @Test public void test502ReconcileOpenDJDefaultAgain() throws Exception { final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1074,17 +1052,17 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); @@ -1100,10 +1078,9 @@ public void test502ReconcileOpenDJDefaultAgain() throws Exception { @Test public void test510ReconcileOpenDJLdapGroup() throws Exception { final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; - displayTestTitle(TEST_NAME); // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1115,17 +1092,17 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { reconciliationTaskResultListener.clear(); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0); @@ -1144,13 +1121,12 @@ public void test510ReconcileOpenDJLdapGroup() throws Exception { @Test public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange"; - displayTestTitle(TEST_NAME); // We manually remove Lemonhead from R_canibalism group // And check whether reconciliation re-adds him again // GIVEN - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE); @@ -1167,17 +1143,17 @@ public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false, TASK_WAIT_TIMEOUT); waitForTaskCloseOrSuspend(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); // THEN - displayThen(TEST_NAME); + then(); // Task result PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java index 12b46427d0e..2ee3377e80c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPhotoAssignment.java @@ -59,10 +59,8 @@ protected PrismObject getDefaultActor() { @Test public void test100AssignJoeCard() throws Exception { - final String TEST_NAME = "test100AssignJoeCard"; - TestUtil.displayTestTitle(TEST_NAME); - - Task task = createTask(TestPhotoAssignment.class.getName() + "." + TEST_NAME); + TestPhotoAssignment.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); assignService(USER_JOE.oid, SERVICE_CARD_10001.oid, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java index 433e4582bc0..cdc4d95ee19 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestPlentyOfAssignments.java @@ -34,7 +34,6 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.internals.InternalCounters; import com.evolveum.midpoint.schema.internals.InternalMonitor; -import com.evolveum.midpoint.schema.internals.InternalOperationClasses; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; @@ -163,7 +162,6 @@ private String formatGroupName(int num) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); assertObjects(RoleType.class, NUMBER_OF_GENERATED_EMPTY_ROLES + NUMBER_OF_GENERATED_DUMMY_ROLES + NUMBER_OF_ORDINARY_ROLES); @@ -174,9 +172,8 @@ public void test000Sanity() throws Exception { @Test public void test100AddCheese() throws Exception { final String TEST_NAME = "test100AddCheese"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -188,12 +185,12 @@ public void test100AddCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(cheeseBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -218,9 +215,8 @@ public void test100AddCheese() throws Exception { @Test public void test110RecomputeCheese() throws Exception { final String TEST_NAME = "test110RecomputeCheese"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -232,12 +228,12 @@ public void test110RecomputeCheese() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_CHEESE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -260,9 +256,8 @@ public void test110RecomputeCheese() throws Exception { @Test public void test120CheesePreviewChanges() throws Exception { final String TEST_NAME = "test120CheesePreviewChanges"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject cheeseBefore = prepareCheese(); @@ -277,12 +272,12 @@ public void test120CheesePreviewChanges() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -329,13 +324,12 @@ private void assertCheeseRoleMembershipRef(PrismObject cheese) { @Test public void test200DummyGroups() throws Exception { final String TEST_NAME = "test200DummyGroups"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObjectDefinition shadowDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class); PrismObjectDefinition roleDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(RoleType.class); @@ -388,7 +382,7 @@ public void test200DummyGroups() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); Collection dummyGroups = getDummyResource().listGroups(); @@ -404,9 +398,8 @@ public void test200DummyGroups() throws Exception { @Test public void test210AddBob() throws Exception { final String TEST_NAME = "test210AddBob"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_BOB_FILE); @@ -419,12 +412,12 @@ public void test210AddBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -453,9 +446,8 @@ public void test210AddBob() throws Exception { @Test public void test212RecomputeBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -464,12 +456,12 @@ public void test212RecomputeBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_BOB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -498,9 +490,8 @@ public void test212RecomputeBob() throws Exception { @Test public void test2124ReconcileBob() throws Exception { final String TEST_NAME = "test212RecomputeBob"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -509,12 +500,12 @@ public void test2124ReconcileBob() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_BOB_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -561,9 +552,8 @@ private void assertBobDummy(int expectedBottlesOfRum) throws Exception { @Test public void test220AddAlice() throws Exception { final String TEST_NAME = "test220AddAlice"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = PrismTestUtil.parseObject(USER_ALICE_FILE); @@ -577,12 +567,12 @@ public void test220AddAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(userBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -612,9 +602,8 @@ public void test220AddAlice() throws Exception { @Test public void test222RecomputeAlice() throws Exception { final String TEST_NAME = "test222RecomputeAlice"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -623,12 +612,12 @@ public void test222RecomputeAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_ALICE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -657,9 +646,8 @@ public void test222RecomputeAlice() throws Exception { @Test public void test224ReconcileAlice() throws Exception { final String TEST_NAME = "test224ReconcileAlice"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); inspector.reset(); @@ -668,12 +656,12 @@ public void test224ReconcileAlice() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(USER_ALICE_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java index 05ec44dc24a..f8b782b990d 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestReconNullValue.java @@ -130,7 +130,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -146,7 +145,6 @@ public void test000Sanity() throws Exception { @Test public void test100CreateUsers() throws Exception { final String TEST_NAME = "test200CreateUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestReconNullValue.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -154,12 +152,12 @@ public void test100CreateUsers() throws Exception { // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user0", user0Before); addObject(user0Before, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -182,10 +180,9 @@ public void test100CreateUsers() throws Exception { @Test public void test130AddHonorificPrefix() throws Exception { final String TEST_NAME = "test140AddHonorificPrefix"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -204,12 +201,12 @@ public void test130AddHonorificPrefix() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -239,10 +236,9 @@ public void test130AddHonorificPrefix() throws Exception { @Test public void test140dDeleteHonorificPrefixGivenName() throws Exception { final String TEST_NAME = "test140dDeleteHonorificPrefixGivenName"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -262,12 +258,12 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(delta); // WHEN - displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -299,10 +295,9 @@ public void test140dDeleteHonorificPrefixGivenName() throws Exception { @Test public void test150RemoveTitleRA() throws Exception { final String TEST_NAME = "test150RemoveTitleRA"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -321,14 +316,14 @@ public void test150RemoveTitleRA() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -359,10 +354,9 @@ public void test150RemoveTitleRA() throws Exception { @Test //MID-4567 public void test160SetGivenNameAttributeAndReconcile() throws Exception { final String TEST_NAME = "test160SetGivenNameAttributeAndReconcile"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -381,14 +375,14 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(); modelService.recompute(UserType.class, userBefore.getOid(), null, task, result); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); @@ -415,10 +409,9 @@ public void test160SetGivenNameAttributeAndReconcile() throws Exception { @Test //MID-4567 public void test170ReplaceGivenNameEmpty() throws Exception { final String TEST_NAME = "test170ReplaceGivenNameEmpty"; - displayTestTitle(TEST_NAME); - // GIVEN - Task task = createTask(TEST_NAME); + // GIVEN + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -434,14 +427,14 @@ public void test170ReplaceGivenNameEmpty() throws Exception { dumpLdap(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_GIVEN_NAME, task, result /* no value */); display("LDAP after reconcile"); dumpLdap(); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = getObjectByName(UserType.class, USER_0_NAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java index 86472ee6681..16995a607a3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestRetirement.java @@ -154,7 +154,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -167,19 +166,18 @@ public void test000Sanity() throws Exception { @Test public void test050AddOrgRetired() throws Exception { final String TEST_NAME = "test050AddOrgRetired"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject orgBefore = PrismTestUtil.parseObject(ORG_RETIRED_FILE); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -206,19 +204,18 @@ public void test050AddOrgRetired() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -235,7 +232,6 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { final String TEST_NAME = "test110AddUserTeleke"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -243,12 +239,12 @@ public void test110AddUserTeleke() throws Exception { USER_TELEKE_GIVEN_NAME, USER_TELEKE_FAMILY_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -266,19 +262,18 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { final String TEST_NAME = "test200AddOrgCortuvHrad"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -296,7 +291,6 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { final String TEST_NAME = "test210AddUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -304,12 +298,12 @@ public void test210AddUserGorc() throws Exception { USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -323,19 +317,18 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -353,7 +346,6 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { final String TEST_NAME = "test230AddUserViljaDezi"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -361,12 +353,12 @@ public void test230AddUserViljaDezi() throws Exception { USER_DEZI_GIVEN_NAME, USER_DEZI_FAMILY_NAME, orgVysneVlkodlakyOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,7 +371,6 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RetireUserGorc() throws Exception { final String TEST_NAME = "test300RetireUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -391,11 +382,11 @@ public void test300RetireUserGorc() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -409,16 +400,15 @@ public void test300RetireUserGorc() throws Exception { @Test public void test302ReconcileUserGorc() throws Exception { final String TEST_NAME = "test302ReconcileUserGorc"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(userGorcOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -432,16 +422,15 @@ public void test302ReconcileUserGorc() throws Exception { @Test public void test303ReconcileUserGorcAgain() throws Exception { final String TEST_NAME = "test303ReconcileUserGorcAgain"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); reconcileUser(userGorcOid, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -568,7 +557,7 @@ private void assertNoGroupMembers(PrismObject org) throws Exception { } private void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllUsers"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override @@ -589,7 +578,7 @@ public boolean handle(PrismObject object, OperationResult parentResult } private void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllOrgs"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java index 036e6fb305d..f2a5018b26a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestScience.java @@ -153,8 +153,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultStats = modelService.testResource(RESOURCE_DUMMY_STATS_OID, task); TestUtil.assertSuccess(testResultStats); @@ -172,19 +171,18 @@ public void test000Sanity() throws Exception { @Test public void test100JackAssignRoleStatistics() throws Exception { final String TEST_NAME = "test100JackAssignRoleStatistics"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); display("User before", userBefore); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_STATISTICS_OID, task, result); // WHEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result); @@ -221,8 +219,7 @@ public void test100JackAssignRoleStatistics() throws Exception { @Test public void test101UnassignRoleStats() throws Exception{ final String TEST_NAME = "test101UnassignRoleStats"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -273,8 +270,7 @@ public void test101UnassignRoleStats() throws Exception{ @Test public void test102AssignRoleStats() throws Exception{ final String TEST_NAME = "test102AssignRoleStats"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); @@ -321,8 +317,7 @@ public void test102AssignRoleStats() throws Exception{ @Test public void test200DelteUserJack() throws Exception { final String TEST_NAME = "test200DelteUserJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java index 592e1d0dfeb..faadfa0a273 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccounts.java @@ -84,18 +84,17 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100StartSyncTask() throws Exception { final String TEST_NAME = "test100StartSyncTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_LIVE_SYNC_DUMMY_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskStart(TASK_LIVE_SYNC_DUMMY_OID, true); @@ -106,7 +105,6 @@ public void test100StartSyncTask() throws Exception { @Test public void test101AddServiceAccountSync() throws Exception { final String TEST_NAME = "test101AddServiceAccountSync"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); @@ -117,14 +115,14 @@ public void test101AddServiceAccountSync() throws Exception { ACCOUNT_RUM_STORAGE_DUMMY_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertServices(1); @@ -150,9 +148,8 @@ public void test101AddServiceAccountSync() throws Exception { @Test public void test102ModifyServiceAccount() throws Exception { final String TEST_NAME = "test102ModifyServiceAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, @@ -161,7 +158,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() try { // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -169,7 +166,7 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -199,9 +196,8 @@ serviceAccountShadowOid, getDummyResourceController().getAttributeFullnamePath() @Test public void test104DeleteServiceAccount() throws Exception { final String TEST_NAME = "test104DeleteServiceAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta delta = prismContext.deltaFactory().object().createDeleteDelta(ShadowType.class, @@ -209,7 +205,7 @@ public void test104DeleteServiceAccount() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -217,7 +213,7 @@ public void test104DeleteServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(); display("expected exception", e); } @@ -247,20 +243,19 @@ public void test104DeleteServiceAccount() throws Exception { @Test public void test108DeleteServiceAccountSync() throws Exception { final String TEST_NAME = "test108DeleteServiceAccountSync"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertNoServiceByName(ACCOUNT_RUM_STORAGE_DUMMY_USERNAME); assertServices(0); @@ -269,36 +264,34 @@ public void test108DeleteServiceAccountSync() throws Exception { @Test public void test109StopLivesyncTask() throws Exception { final String TEST_NAME = "test109StopLivesyncTask"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(); suspendTask(TASK_LIVE_SYNC_DUMMY_OID); // THEN - displayThen(TEST_NAME); + then(); assertTaskExecutionStatus(TASK_LIVE_SYNC_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @Test public void test120StartReconTask() throws Exception { final String TEST_NAME = "test120StartReconTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(0); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskStart(TASK_RECONCILE_DUMMY_OID, true); @@ -309,7 +302,6 @@ public void test120StartReconTask() throws Exception { @Test public void test121AddServiceAccountRecon() throws Exception { final String TEST_NAME = "test121AddServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(0); @@ -320,14 +312,14 @@ public void test121AddServiceAccountRecon() throws Exception { ACCOUNT_MAGAZINE_DUMMY_FULLNAME); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertServices(1); @@ -341,20 +333,19 @@ public void test121AddServiceAccountRecon() throws Exception { @Test public void test128DeleteServiceAccountRecon() throws Exception { final String TEST_NAME = "test128DeleteServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().deleteAccountByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertNoServiceByName(ACCOUNT_MAGAZINE_DUMMY_USERNAME); assertServices(0); @@ -362,18 +353,17 @@ public void test128DeleteServiceAccountRecon() throws Exception { public void test129StopReconTask() throws Exception { final String TEST_NAME = "test129StopReconTask"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(); suspendTask(TASK_RECONCILE_DUMMY_OID); // THEN - displayThen(TEST_NAME); + then(); assertTaskExecutionStatus(TASK_RECONCILE_DUMMY_OID, TaskExecutionStatus.SUSPENDED); } @@ -385,9 +375,8 @@ public void test129StopReconTask() throws Exception { @Test public void test140CreateServiceAccount() throws Exception { final String TEST_NAME = "test140CreateServiceAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); addObject(SERVICE_BARELLIUM_FILE); @@ -404,7 +393,7 @@ public void test140CreateServiceAccount() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); @@ -412,7 +401,7 @@ public void test140CreateServiceAccount() throws Exception { } catch (UnsupportedOperationException e) { // THEN - displayThen(TEST_NAME); + then(); display("expected exception", e); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java index d2fb657fe0d..ed369f339ef 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestServiceAccountsClassifier.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2019 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -79,10 +79,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001assigneJackEmployeeRole() throws Exception { final String TEST_NAME = "test001assigneJackEmployeeRole"; - displayTestTitle(TEST_NAME); //WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, ROLE_EMPLOYEE_OID); //THEN @@ -95,13 +94,12 @@ public void test001assigneJackEmployeeRole() throws Exception { @Test public void test100createServiceJira() throws Exception { final String TEST_NAME = "test100createServiceJira"; - displayTestTitle(TEST_NAME); //WHEN addObject(SERVICE_JIRA_FILE); //THEN - displayThen(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -112,18 +110,17 @@ public void test100createServiceJira() throws Exception { @Test public void test101jiraAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN //WHEN - displayWhen(TEST_NAME); + when(); assignAccount(ServiceType.class, SERVICE_JIRA_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - displayThen(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_JIRA_OID); display("Service magazine after", service); assertNotNull("No magazine service", service); @@ -135,18 +132,17 @@ public void test101jiraAssignResourceNoneEnforcement() throws Exception { @Test public void test150StartReconTask() throws Exception { final String TEST_NAME = "test150StartReconTask"; - displayTestTitle(TEST_NAME); assertUsers(getNumberOfUsers()); assertServices(1); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_RECONCILE_DUMMY_CLASSIFIER_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskStart(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); @@ -157,7 +153,6 @@ public void test150StartReconTask() throws Exception { @Test public void test151LinkServiceAccountRecon() throws Exception { final String TEST_NAME = "test151LinkServiceAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -166,14 +161,14 @@ public void test151LinkServiceAccountRecon() throws Exception { account.setEnabled(true); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertServices(1); PrismObject serviceJirafter = getObject(ServiceType.class, SERVICE_JIRA_OID); @@ -187,7 +182,6 @@ public void test151LinkServiceAccountRecon() throws Exception { @Test public void test152InactivateUnmatchedAccountRecon() throws Exception { final String TEST_NAME = "test152InactivateUnmatchedAccountRecon"; - displayTestTitle(TEST_NAME); // Preconditions assertServices(1); @@ -196,14 +190,14 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { account.setEnabled(true); // WHEN - displayWhen(TEST_NAME); + when(); getDummyResource().addAccount(account); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertServices(1); @@ -214,13 +208,12 @@ public void test152InactivateUnmatchedAccountRecon() throws Exception { @Test public void test200createServiceGithub() throws Exception { final String TEST_NAME = "test200createServiceGithub"; - displayTestTitle(TEST_NAME); //WHEN addObject(SERVICE_GITHUB_FILE); //THEN - displayThen(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -231,14 +224,13 @@ public void test200createServiceGithub() throws Exception { @Test public void test210createAccountGithub() throws Exception { final String TEST_NAME = "test210createAccountGithub"; - displayTestTitle(TEST_NAME); //WHEN - displayWhen(TEST_NAME); + when(); addObject(SHADOW_GITHUB_FILE); // THEN - displayThen(TEST_NAME); + then(); PrismObject shadowGithub = getShadowModel(SHADOW_GITHUB_OID); display("Shadow github after", shadowGithub); @@ -251,18 +243,17 @@ public void test210createAccountGithub() throws Exception { @Test public void test215githubAssignResourceNoneEnforcement() throws Exception { final String TEST_NAME = "test101jiraAssignResourceNoneEnforcement"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); //GIVEN //WHEN - displayWhen(TEST_NAME); + when(); assignAccount(ServiceType.class, SERVICE_GITHUB_OID, RESOURCE_DUMMY_CLASSIFIER_OID, "service"); //THEN - displayThen(TEST_NAME); + then(); PrismObject service = getObject(ServiceType.class, SERVICE_GITHUB_OID); display("Service github after", service); assertNotNull("No github service", service); @@ -274,8 +265,7 @@ public void test215githubAssignResourceNoneEnforcement() throws Exception { @Test public void test220linkAccountGithubAndFixIntent() throws Exception { final String TEST_NAME = "test220linkAccountGithubAndFixIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -285,11 +275,11 @@ public void test220linkAccountGithubAndFixIntent() throws Exception { assertNoLinkedAccount(serviceGithubBefore); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_RECONCILE_DUMMY_CLASSIFIER_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertServices(2); PrismObject serviceGithubAfter = getObject(ServiceType.class, SERVICE_GITHUB_OID); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java index abcfadeeb85..c4d16a6485b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestShadowsPerformance.java @@ -98,16 +98,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult result = modelService.testResource(RESOURCE_DUMMY_OID, task); // THEN - displayThen(TEST_NAME); + then(); result.computeStatusIfUnknown(); assertSuccess(result); } @@ -115,9 +114,8 @@ public void test010Sanity() throws Exception { @Test public void test100ImportAccounts() throws Exception { final String TEST_NAME = "test100ImportAccounts"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (int i = 0; i < NUMBER_OF_GENERATED_USERS; i++) { @@ -127,11 +125,11 @@ public void test100ImportAccounts() throws Exception { } // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_IMPORT_FILE); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_IMPORT_OID, true, SYNC_TASK_WAIT_TIMEOUT); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -147,9 +145,8 @@ public void test100ImportAccounts() throws Exception { @Test(enabled = false) public void test200DeleteAccountsAndReconcile() throws Exception { final String TEST_NAME = "test200DeleteAccountsAndReconcile"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (DummyAccount account : new ArrayList<>(dummyResourceCtl.getDummyResource().listAccounts())) { @@ -158,11 +155,11 @@ public void test200DeleteAccountsAndReconcile() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_RECONCILIATION_FILE); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_RECONCILIATION_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -178,9 +175,8 @@ public void test200DeleteAccountsAndReconcile() throws Exception { @Test public void test210DeleteShadows() throws Exception { final String TEST_NAME = "test210DeleteShadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); for (DummyAccount account : new ArrayList<>(dummyResourceCtl.getDummyResource().listAccounts())) { @@ -189,11 +185,11 @@ public void test210DeleteShadows() throws Exception { assertEquals("Wrong # of remaining accounts", 0, dummyResourceCtl.getDummyResource().listAccounts().size()); // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_BULK_DELETE_FILE); // THEN - displayThen(TEST_NAME); + then(); Task taskAfter = waitForTaskFinish(TASK_BULK_DELETE_OID, true, 0L, SYNC_TASK_WAIT_TIMEOUT, false, 100, null); display("task after", prismContext.xmlSerializer().serialize(taskAfter.getUpdatedTaskObject())); @@ -209,9 +205,8 @@ public void test210DeleteShadows() throws Exception { @Test public void test900Summarize() { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); @@ -221,7 +216,7 @@ public void test900Summarize() { display("Summary (" + NUMBER_OF_GENERATED_USERS + " users)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java index 1591059f9c6..ae36a4e2de8 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestStrings.java @@ -197,8 +197,7 @@ protected PrismObject getDefaultActor() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // TODO } @@ -207,19 +206,18 @@ public void test000Sanity() throws Exception { @Test public void test100SimpleAssignmentStart() throws Exception { final String TEST_NAME = "test100SimpleAssignmentStart"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); dummyTransport.clearMessages(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBobOid, roleATest1Oid, task, task.getResult()); // THEN - displayThen(TEST_NAME); + then(); assertNotAssignedRole(getUser(userBobOid), roleATest1Oid); CaseWorkItemType workItem = getWorkItem(task, result); @@ -273,8 +271,7 @@ public void test100SimpleAssignmentStart() throws Exception { @Test public void test102SimpleAssignmentApproveByLechuck() throws Exception { final String TEST_NAME = "test102SimpleAssignmentApproveByLechuck"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -285,7 +282,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { CaseWorkItemType workItem = getWorkItem(task, result); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject lechuck = getUserFromRepo(userLechuckOid); login(lechuck); workflowService.completeWorkItem(WorkItemId.of(workItem), @@ -293,7 +290,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { task, result); // THEN - displayThen(TEST_NAME); + then(); login(userAdministrator); List workItems = getWorkItems(task, result); @@ -362,8 +359,7 @@ public void test102SimpleAssignmentApproveByLechuck() throws Exception { @Test public void test104SimpleAssignmentApproveByAdministrator() throws Exception { final String TEST_NAME = "test104SimpleAssignmentApproveByAdministrator"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -443,8 +439,7 @@ public void test104SimpleAssignmentApproveByAdministrator() throws Exception { @Test public void test106SimpleAssignmentApproveByCheese() throws Exception { final String TEST_NAME = "test106SimpleAssignmentApproveByCheese"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -502,8 +497,7 @@ public void test106SimpleAssignmentApproveByCheese() throws Exception { @Test public void test108SimpleAssignmentApproveByChef() throws Exception { final String TEST_NAME = "test108SimpleAssignmentApproveByChef"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // GIVEN @@ -580,8 +574,7 @@ public void test108SimpleAssignmentApproveByChef() throws Exception { @Test public void test200EscalatedApprovalStart() throws Exception { final String TEST_NAME = "test200EscalatedApprovalStart"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -628,8 +621,7 @@ public void test200EscalatedApprovalStart() throws Exception { @Test public void test202FourDaysLater() throws Exception { final String TEST_NAME = "test202FourDaysLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -661,8 +653,7 @@ public void test202FourDaysLater() throws Exception { @Test public void test204SixDaysLater() throws Exception { final String TEST_NAME = "test204SixDaysLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -729,8 +720,7 @@ public void test204SixDaysLater() throws Exception { @Test public void test205EightDaysLater() throws Exception { final String TEST_NAME = "test205EightDaysLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -781,8 +771,7 @@ public void test205EightDaysLater() throws Exception { @Test public void test206ApproveByCheese() throws Exception { final String TEST_NAME = "test206ApproveByCheese"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -875,8 +864,7 @@ public void test206ApproveByCheese() throws Exception { @Test public void test208SixDaysLater() throws Exception { final String TEST_NAME = "test208SixDaysLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -917,8 +905,7 @@ public void test208SixDaysLater() throws Exception { @Test public void test209EightDaysLater() throws Exception { final String TEST_NAME = "test209EightDaysLater"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -974,11 +961,10 @@ private void checkTwoCompleted(List lifecycleMessages) { @Test public void test220FormRoleAssignmentStart() throws Exception { final String TEST_NAME = "test220FormRoleAssignmentStart"; - displayTestTitle(TEST_NAME); PrismObject bob = getUserFromRepo(userBobOid); login(bob); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); task.setOwner(bob); OperationResult result = task.getResult(); @@ -1019,8 +1005,7 @@ public void test220FormRoleAssignmentStart() throws Exception { @Test public void test221FormApproveByLechuck() throws Exception { final String TEST_NAME = "test221FormApproveByLechuck"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1065,8 +1050,7 @@ public void test221FormApproveByLechuck() throws Exception { @Test public void test222FormApproveByCheese() throws Exception { final String TEST_NAME = "test222FormApproveByCheese"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); @@ -1136,8 +1120,7 @@ public void test222FormApproveByCheese() throws Exception { @Test public void test250ApproverAssignment() throws Exception { final String TEST_NAME = "test250ApproverAssignment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); dummyAuditService.clear(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index 7d10f5ddcae..de55f4dc2c1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -102,8 +102,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test001testImportBaseUsers() throws Exception { final String TEST_NAME = "test001testImportBaseUsers"; - displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); importObjectFromFile(TASK_IMPORT_BASE_USERS_FILE); @@ -143,7 +142,6 @@ protected int getNumberOfUsers() { @Test public void test100assignPolicyRuleCreateToTask() throws Exception { final String TEST_NAME = "test100assignPolicyRuleCreateToTask"; - displayTestTitle(TEST_NAME); // WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -162,7 +160,6 @@ public void test100assignPolicyRuleCreateToTask() throws Exception { @Test public void test110importAccounts() throws Exception { final String TEST_NAME = "test110importAccountsSimulate"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -173,7 +170,7 @@ public void test110importAccounts() throws Exception { assertUsers(getNumberOfUsers()); //WHEN - displayWhen(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -188,7 +185,6 @@ public void test110importAccounts() throws Exception { @Test public void test111importAccountsAgain() throws Exception { final String TEST_NAME = "test111importAccountsAgain"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TEST_NAME); OperationResult result = task.getResult(); @@ -199,7 +195,7 @@ public void test111importAccountsAgain() throws Exception { assertUsers(getNumberOfUsers()+getProcessedUsers()); //WHEN - displayWhen(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); @@ -215,7 +211,6 @@ public void test111importAccountsAgain() throws Exception { @Test public void test500chageTaskPolicyRule() throws Exception { final String TEST_NAME = "test500chageTaskPolicyRule"; - displayTestTitle(TEST_NAME); //WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -235,14 +230,13 @@ public void test500chageTaskPolicyRule() throws Exception { @Test public void test520changeActivationThreeAccounts() throws Exception { final String TEST_NAME = "test520changeActivationThreeAccounts"; - displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); //GIVEN openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); //WHEN - displayWhen(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(getTaskOid(), false, 20000); assertFailure(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 91559396d76..05cbf895eb6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -69,7 +69,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test600chageTaskPolicyRule() throws Exception { final String TEST_NAME = "test600chageTaskPolicyRule"; - displayTestTitle(TEST_NAME); //WHEN Task task = taskManager.createTaskInstance(TEST_NAME); @@ -88,11 +87,10 @@ public void test600chageTaskPolicyRule() throws Exception { @Test public void test610testFullRecon() throws Exception { final String TEST_NAME = "test610testFullRecon"; - displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); //WHEN - displayWhen(TEST_NAME); + when(); OperationResult reconResult = waitForTaskResume(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000); assertSuccess(reconResult); @@ -109,8 +107,7 @@ public void test610testFullRecon() throws Exception { @Test public void test611testFullRecon() throws Exception { final String TEST_NAME = "test611testFullRecon"; - displayTestTitle(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + OperationResult result = createOperationalResult(); openDJController.delete("uid=user10,ou=People,dc=example,dc=com"); openDJController.delete("uid=user11,ou=People,dc=example,dc=com"); @@ -120,7 +117,7 @@ public void test611testFullRecon() throws Exception { openDJController.delete("uid=user15,ou=People,dc=example,dc=com"); //WHEN - displayWhen(TEST_NAME); + when(); OperationResult reconResult = waitForTaskNextRun(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000, false); assertSuccess(reconResult); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java index 98c323e630b..1b7f34b5261 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUniversity.java @@ -116,7 +116,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -163,7 +163,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_HR_OID, task); @@ -180,8 +179,6 @@ public void test000Sanity() throws Exception { @Test public void test100AddComeniusUniversity() throws Exception { final String TEST_NAME = "test100AddComeniusUniversity"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege comenius = new DummyPrivilege("UK"); @@ -205,8 +202,6 @@ public void test100AddComeniusUniversity() throws Exception { @Test public void test110AddComeniusStructure() throws Exception { final String TEST_NAME = "test110AddComeniusStructure"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege srcFmfi = new DummyPrivilege("FMFI"); srcFmfi.addAttributeValue(DUMMY_PRIVILEGE_ATTRIBUTE_HR_ORGPATH, "UK"); @@ -280,8 +275,6 @@ private void assertNoGroupMembers(PrismObject org) throws Exception { @Test public void test120MoveComputingCentre() throws Exception { final String TEST_NAME = "test120MoveComputingCentre"; - TestUtil.displayTestTitle(this, TEST_NAME); - Task task = taskManager.createTaskInstance(TestUniversity.class.getName() + "." + TEST_NAME); DummyPrivilege srcVc = dummyResourceHr.getPrivilegeByName("VC"); @@ -330,172 +323,6 @@ public void test120MoveComputingCentre() throws Exception { assertNoGroupMembers(vc); } -// @Test -// public void test500ReconcileOpenDJDefault() throws Exception { -// final String TEST_NAME = "test500ReconcileOpenDJDefault"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// List> users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users before recon", users); -// assertUsers(15); -// -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// importObjectFromFile(TASK_RECON_OPENDJ_DEFAULT_SINGLE_FILE); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); -// -// users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users after recon", users); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test502ReconcileOpenDJDefaultAgain() throws Exception { -// final String TEST_NAME = "test502ReconcileOpenDJDefaultAgain"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// assertUsers(18); -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 17, 0, 0); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test510ReconcileOpenDJLdapGroup() throws Exception { -// final String TEST_NAME = "test510ReconcileOpenDJLdapGroup"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// List> users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users before recon", users); -// assertUsers(18); -// -// reconciliationTaskResultListener.clear(); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// importObjectFromFile(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_FILE); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// reconciliationTaskResultListener.assertResult(RESOURCE_OPENDJ_OID, 0, 2, 0, 0); -// -// users = modelService.searchObjects(UserType.class, null, null, task, result); -// display("Users after recon", users); -// -// assertUsers(18); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_LDAPGROUP_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// } -// -// @Test -// public void test550ReconcileOpenDJAfterMembershipChange() throws Exception { -// final String TEST_NAME = "test550ReconcileOpenDJAfterMembershipChange"; -// TestUtil.displayTestTile(this, TEST_NAME); -// -// // We manually remove Lemonhead from R_canibalism group -// // And check whether reconciliation re-adds him again -// -// // GIVEN -// Task task = createTask(TestInsurance.class.getName() + "." + TEST_NAME); -// OperationResult result = task.getResult(); -// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); -// -// Collection membersBeforeTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN); -// System.out.println("group members before test = " + membersBeforeTest); -// assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersBeforeTest.contains(ACCOUNT_LEMONHEAD_DN)); -// -// openDJController.removeGroupUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); -// -// System.out.println("group members after removal = " + openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN)); -// -// openDJController.assertNoUniqueMember(RESP_CANIBALISM_DN, ACCOUNT_LEMONHEAD_DN); -// -// // WHEN -// TestUtil.displayWhen(TEST_NAME); -// restartTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// waitForTaskFinish(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID, false); -// -// // THEN -// TestUtil.displayThen(TEST_NAME); -// -// // Task result -// PrismObject reconTaskAfter = getTask(TASK_RECON_OPENDJ_DEFAULT_SINGLE_OID); -// OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult(); -// display("Recon task result", reconTaskResult); -// TestUtil.assertSuccess(reconTaskResult); -// -// Collection membersAfterTest = openDJController.getGroupUniqueMembers(RESP_CANIBALISM_DN); -// System.out.println("group members after test = " + membersAfterTest); -// assertTrue(RESP_CANIBALISM_DN + " does not contain " + ACCOUNT_LEMONHEAD_DN, membersAfterTest.contains(ACCOUNT_LEMONHEAD_DN.toLowerCase())); // ...it seems to get lowercased during the reconciliation -// } - private PrismObject getAndAssertFunctionalOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException { PrismObject org = getOrg(orgName); PrismAsserts.assertPropertyValue(org, OrgType.F_ORG_TYPE, "functional"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index df9e68910fe..142f64003b6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -29,7 +29,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.common.Utils; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler; @@ -295,8 +294,7 @@ protected String getResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(getResourceOid(), task); TestUtil.assertSuccess(testResultOpenDj); @@ -308,7 +306,6 @@ public void test000Sanity() throws Exception { @Test public void test010Schema() throws Exception { final String TEST_NAME = "test010Schema"; - displayTestTitle(TEST_NAME); resourceOpenDj = getObject(ResourceType.class, getResourceOid()); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -342,18 +339,17 @@ public void test010Schema() throws Exception { @Test public void test100AddUserHermanBasic() throws Exception { final String TEST_NAME = "test100AddUserHermanBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_HERMAN_USERNAME, USER_HERMAN_FIST_NAME, USER_HERMAN_LAST_NAME, ROLE_BASIC_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -370,18 +366,17 @@ public void test100AddUserHermanBasic() throws Exception { @Test public void test110AddUserMancombUnix() throws Exception { final String TEST_NAME = "test110AddUserMancombUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_MANCOMB_USERNAME, USER_MANCOMB_FIST_NAME, USER_MANCOMB_LAST_NAME, ROLE_UNIX_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -398,19 +393,18 @@ public void test110AddUserMancombUnix() throws Exception { @Test public void test111AccountMancombEditObjectClassDefinition() throws Exception { final String TEST_NAME = "test111AccountMancombEditObjectClassDefinition"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject shadow = getShadowModel(accountMancombOid); display("shadow", shadow); // WHEN - displayWhen(TEST_NAME); + when(); RefinedObjectClassDefinition editObjectClassDefinition = modelInteractionService.getEditObjectClassDefinition(shadow, resourceOpenDj, AuthorizationPhaseType.REQUEST, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); display("OC def", editObjectClassDefinition); @@ -428,18 +422,17 @@ public void test111AccountMancombEditObjectClassDefinition() throws Exception { @Test public void test119DeleteUserMancombUnix() throws Exception { final String TEST_NAME = "test119DeleteUserMancombUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_MANCOMB_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_MANCOMB_USERNAME); @@ -454,18 +447,17 @@ public void test119DeleteUserMancombUnix() throws Exception { @Test public void test120AddUserLargo() throws Exception { final String TEST_NAME = "test120AddUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, (String)null); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -478,18 +470,17 @@ public void test120AddUserLargo() throws Exception { @Test public void test122AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test122AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -507,8 +498,7 @@ public void test122AssignUserLargoBasic() throws Exception { @Test public void test124AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test124AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -516,11 +506,11 @@ public void test124AssignUserLargoUnix() throws Exception { long startTs = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); long endTs = System.currentTimeMillis(); @@ -542,18 +532,17 @@ public void test124AssignUserLargoUnix() throws Exception { @Test public void test125RecomputeUserLargo() throws Exception { final String TEST_NAME = "test125RecomputeUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -571,18 +560,17 @@ public void test125RecomputeUserLargo() throws Exception { @Test public void test126UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test126UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -600,18 +588,17 @@ public void test126UnAssignUserLargoUnix() throws Exception { @Test public void test127RecomputeUserLargo() throws Exception { final String TEST_NAME = "test127RecomputeUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -629,18 +616,17 @@ public void test127RecomputeUserLargo() throws Exception { @Test public void test128UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test128UnAssignUserLargoBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -657,18 +643,17 @@ public void test128UnAssignUserLargoBasic() throws Exception { @Test public void test129RecomputeUserLargo() throws Exception { final String TEST_NAME = "test129RecomputeUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -685,18 +670,17 @@ public void test129RecomputeUserLargo() throws Exception { @Test public void test130AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test130AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -714,8 +698,7 @@ public void test130AssignUserLargoUnix() throws Exception { @Test public void test131ReconcileUserLargo() throws Exception { final String TEST_NAME = "test131ReconcileUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -723,11 +706,11 @@ public void test131ReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -754,8 +737,7 @@ public void test131ReconcileUserLargo() throws Exception { @Test public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test132MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -782,11 +764,11 @@ public void test132MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -822,8 +804,7 @@ protected void assertTest132Audit() { @Test public void test133ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test133ReconcileUserLargoAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -834,11 +815,11 @@ public void test133ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -861,8 +842,7 @@ public void test133ReconcileUserLargoAgain() throws Exception { @Test public void test134AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test134AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -870,11 +850,11 @@ public void test134AssignUserLargoBasic() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -898,8 +878,7 @@ public void test134AssignUserLargoBasic() throws Exception { @Test public void test135UnAssignUserLargoUnix() throws Exception { final String TEST_NAME = "test135UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -907,11 +886,11 @@ public void test135UnAssignUserLargoUnix() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -944,8 +923,7 @@ protected void assertTest135Audit() { @Test // MID-2883 public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test136MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -972,11 +950,11 @@ public void test136MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1004,8 +982,7 @@ protected void assertAccountTest136(PrismObject shadow) throws Excep @Test public void test137ReconcileUserLargoAgain() throws Exception { final String TEST_NAME = "test137ReconcileUserLargoAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -1016,11 +993,11 @@ public void test137ReconcileUserLargoAgain() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1051,18 +1028,17 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test138UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test138UnAssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1081,18 +1057,17 @@ public void test138UnAssignUserLargoBasic() throws Exception { @Test public void test200AddLdapGroupMonkeyIsland() throws Exception { final String TEST_NAME = "test200AddLdapGroupMonkeyIsland"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createLdapGroupRole(ROLE_MONKEY_ISLAND_NAME); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1110,18 +1085,17 @@ public void test200AddLdapGroupMonkeyIsland() throws Exception { @Test public void test202AssignUserHermanMonkeyIsland() throws Exception { final String TEST_NAME = "test202AssignUserHermanMonkeyIsland"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_HERMAN_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), roleMonkeyIslandOid); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_HERMAN_USERNAME); @@ -1139,18 +1113,17 @@ public void test202AssignUserHermanMonkeyIsland() throws Exception { @Test public void test210AddUnixGroupVillains() throws Exception { final String TEST_NAME = "test210AddUnixGroupVillains"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_VILLAINS_NAME, ROLE_META_UNIXGROUP_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1168,18 +1141,17 @@ public void test210AddUnixGroupVillains() throws Exception { @Test public void test211AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test211AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1197,18 +1169,17 @@ public void test211AssignUserLargoUnix() throws Exception { @Test public void test212AssignUserLargoVillains() throws Exception { final String TEST_NAME = "test212AssignUserLargoVillains"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), roleVillainsOid); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -1228,18 +1199,17 @@ public void test212AssignUserLargoVillains() throws Exception { @Test public void test250AddUserRangerBasic() throws Exception { final String TEST_NAME = "test250AddUserRangerBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME, ROLE_BASIC_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1256,18 +1226,17 @@ public void test250AddUserRangerBasic() throws Exception { @Test public void test251AssignUserRangerBasic() throws Exception { final String TEST_NAME = "test251AssignUserRangerBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1285,18 +1254,17 @@ public void test251AssignUserRangerBasic() throws Exception { @Test public void test252AddUnixGroupRangers() throws Exception { final String TEST_NAME = "test252AddUnixGroupRangers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_RANGERS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1314,18 +1282,17 @@ public void test252AddUnixGroupRangers() throws Exception { @Test public void test253AddUnixGroupSeals() throws Exception { final String TEST_NAME = "test253AddUnixGroupSeals"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject role = createUnixGroupRole(ROLE_SEALS_NAME, ROLE_META_UNIXGROUP2_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(role, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, role.getOid()); @@ -1345,18 +1312,17 @@ public void test253AddUnixGroupSeals() throws Exception { @Test public void test254AssignUserRangerRangers() throws Exception { final String TEST_NAME = "test254AssignUserRangerRangers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), roleRangersOid); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1365,7 +1331,7 @@ public void test254AssignUserRangerRangers() throws Exception { assertUser(userAfter, USER_RANGER_USERNAME, USER_RANGER_FIST_NAME, USER_RANGER_LAST_NAME); String accountOid = getSingleLinkOid(userAfter); - displayThen(TEST_NAME); + then(); PrismObject shadow = getShadowModel(accountOid); display("Shadow (model)", shadow); String accountRangerDn = assertPosixAccount(shadow, USER_RANGER_UID_NUMBER); @@ -1387,18 +1353,17 @@ public void test254AssignUserRangerRangers() throws Exception { @Test public void test255AssignUserRangerSeals() throws Exception { final String TEST_NAME = "test255AssignUserRangerSeals"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(user.getOid(), roleSealsOid); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1421,18 +1386,17 @@ public void test255AssignUserRangerSeals() throws Exception { @Test public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { final String TEST_NAME = "test256UnAssignUserRangerSealsKeepRangers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), roleSealsOid); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME); @@ -1460,18 +1424,17 @@ public void test256UnAssignUserRangerSealsKeepRangers() throws Exception { @Test public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception { final String TEST_NAME = "test257RenameUserAndAccountsCheckGroupmembership"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(userBefore.getOid(), UserType.F_NAME, task, result, new PolyString("usranger", "usranger")); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1500,18 +1463,17 @@ public void test257RenameUserAndAccountsCheckGroupmembership() throws Exception @Test public void test260DeleteUserUsrangerUnix() throws Exception { final String TEST_NAME = "test260DeleteUserUsrangerUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_RANGER_USERNAME_RENAMED); // WHEN - displayWhen(TEST_NAME); + when(); deleteObject(UserType.class, userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_RANGER_USERNAME_RENAMED); @@ -1529,16 +1491,15 @@ public void test260DeleteUserUsrangerUnix() throws Exception { @Test public void test270RenameUnixGroupSeals() throws Exception { final String TEST_NAME = "test270RenameUnixGroupSeals"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); renameObject(RoleType.class, roleSealsOid, ROLE_WALRUSES_NAME, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject roleAfter = getObject(RoleType.class, roleSealsOid); @@ -1558,8 +1519,7 @@ public void test270RenameUnixGroupSeals() throws Exception { @Test public void test300AddUserCapsizeUnixFail() throws Exception { final String TEST_NAME = "test300AddUserCapsizeUnixFail"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject sequenceBefore = getObject(SequenceType.class, SEQUENCE_UIDNUMBER_OID); @@ -1572,7 +1532,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); AssertJUnit.fail("Unexpected success"); @@ -1582,7 +1542,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertFailure(result); @@ -1603,8 +1563,7 @@ public void test300AddUserCapsizeUnixFail() throws Exception { @Test public void test310AddUserWallyUnix() throws Exception { final String TEST_NAME = "test310AddUserWallyUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject sequenceBefore = getObject(SequenceType.class, SEQUENCE_UIDNUMBER_OID); @@ -1615,11 +1574,11 @@ public void test310AddUserWallyUnix() throws Exception { PrismObject user = createUser(USER_WALLY_USERNAME, USER_WALLY_FIST_NAME, USER_WALLY_LAST_NAME, ROLE_UNIX_OID); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_WALLY_USERNAME); @@ -1644,8 +1603,7 @@ public void test310AddUserWallyUnix() throws Exception { @Test public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { final String TEST_NAME = "test312AccountWallyRemovePosixObjectclassNative"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ @@ -1666,11 +1624,11 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1695,8 +1653,7 @@ public void test312AccountWallyRemovePosixObjectclassNative() throws Exception { @Test public void test314AccountWallyAddPosixObjectclassNative() throws Exception { final String TEST_NAME = "test314AccountWallyAddPosixObjectclassNative"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); openDJController.executeLdifChange("dn: "+accountWallyDn+"\n"+ @@ -1717,11 +1674,11 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { display("Wally LDAP account before", entryWallyBefore); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1742,19 +1699,18 @@ public void test314AccountWallyAddPosixObjectclassNative() throws Exception { @Test public void test400ListAllAccountsObjectClass() throws Exception { final String TEST_NAME = "test400ListAllAccountsObjectClass"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1765,8 +1721,7 @@ public void test400ListAllAccountsObjectClass() throws Exception { @Test public void test401ListAllAccountsKindIntent() throws Exception { final String TEST_NAME = "test401ListAllAccountsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1774,11 +1729,11 @@ public void test401ListAllAccountsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1789,8 +1744,7 @@ public void test401ListAllAccountsKindIntent() throws Exception { @Test public void test402ListLdapGroupsKindIntent() throws Exception { final String TEST_NAME = "test402ListLdapGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1798,11 +1752,11 @@ public void test402ListLdapGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -1813,8 +1767,7 @@ public void test402ListLdapGroupsKindIntent() throws Exception { @Test public void test403ListUnixGroupsKindIntent() throws Exception { final String TEST_NAME = "test403ListUnixGroupsKindIntent"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(getResourceOid(), @@ -1822,11 +1775,11 @@ public void test403ListUnixGroupsKindIntent() throws Exception { display("query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("found objects", objects); @@ -1836,19 +1789,18 @@ public void test403ListUnixGroupsKindIntent() throws Exception { @Test public void test500AddUserStan() throws Exception { final String TEST_NAME = "test500AddUserStan"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_STAN_USERNAME, USER_STAN_FIST_NAME, USER_STAN_LAST_NAME, roleRangersOid); addRoleAssignment(user, roleMonkeyIslandOid); // WHEN - displayWhen(TEST_NAME); + when(); addObject(user, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); @@ -1870,8 +1822,7 @@ public void test500AddUserStan() throws Exception { @Test public void test510StanDisablePosixAssocAndReconcile() throws Exception { final String TEST_NAME = "test510StanDisablePosixAssocAndReconcile"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userStan = findUserByUsername(USER_STAN_USERNAME); @@ -1890,11 +1841,11 @@ public void test510StanDisablePosixAssocAndReconcile() throws Exception { repositoryService.modifyObject(UserType.class, userStan.getOid(), itemDeltas, result); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userStan.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_STAN_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index f9daa719c26..97170f9dcd2 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -112,18 +112,17 @@ protected void assertTest137Account(PrismObject shadow) throws Excep @Test public void test140AssignUserLargoBasic() throws Exception { final String TEST_NAME = "test140AssignUserLargoBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -146,8 +145,7 @@ public void test140AssignUserLargoBasic() throws Exception { @Test public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { final String TEST_NAME = "test142MeddleWithAccountAndReconcileUserLargo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); @@ -168,11 +166,11 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { dummyAuditService.clear(); // WHEN - displayWhen(TEST_NAME); + when(); reconcileUser(userBefore.getOid(), task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -194,18 +192,17 @@ public void test142MeddleWithAccountAndReconcileUserLargo() throws Exception { @Test public void test144AssignUserLargoUnix() throws Exception { final String TEST_NAME = "test144AssignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -225,18 +222,17 @@ public void test144AssignUserLargoUnix() throws Exception { @Test public void test146UnassignUserLargoUnix() throws Exception { final String TEST_NAME = "test146UnassignUserLargoUnix"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); @@ -256,18 +252,17 @@ public void test146UnassignUserLargoUnix() throws Exception { @Test public void test149UnAssignUserLargoBasic() throws Exception { final String TEST_NAME = "test149UnAssignUserLargoBasic"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(userBefore.getOid(), ROLE_BASIC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java index dbe870d7fec..23cc864a102 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestVillage.java @@ -264,7 +264,6 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_DUMMY_SOURCE_OID, task); @@ -288,7 +287,6 @@ public void test000Sanity() throws Exception { @Test public void test020ResourceOpenDjGet() throws Exception { final String TEST_NAME = "test020ResourceOpenDjGet"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -301,11 +299,11 @@ public void test020ResourceOpenDjGet() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -326,7 +324,6 @@ public void test020ResourceOpenDjGet() throws Exception { @Test public void test022ResourceOpenDjRefinedSchema() throws Exception { final String TEST_NAME = "test022ResourceOpenDjRefinedSchema"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -343,13 +340,13 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); long t0 = System.currentTimeMillis(); PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); long t1 = System.currentTimeMillis(); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -379,7 +376,6 @@ public void test022ResourceOpenDjRefinedSchema() throws Exception { @Test public void test100AddSrcAccountHerman() throws Exception { final String TEST_NAME = "test100AddSrcAccountHerman"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_HERMAN_USERNAME); @@ -401,7 +397,6 @@ public void test100AddSrcAccountHerman() throws Exception { @Test public void test101HermanAssignBasicRole() throws Exception { final String TEST_NAME = "test101HermanAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -419,7 +414,6 @@ public void test101HermanAssignBasicRole() throws Exception { @Test public void test102HermanUnAssignBasicRole() throws Exception { final String TEST_NAME = "test102HermanUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -437,7 +431,6 @@ public void test102HermanUnAssignBasicRole() throws Exception { @Test public void test103HermanAssignBasicAndSimpleRole() throws Exception { final String TEST_NAME = "test103HermanAssignBasicAndSimpleRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -457,7 +450,6 @@ public void test103HermanAssignBasicAndSimpleRole() throws Exception { @Test public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { final String TEST_NAME = "test104HermanUnAssignSimpleRoleThenBasic"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -486,7 +478,6 @@ public void test104HermanUnAssignSimpleRoleThenBasic() throws Exception { @Test public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { final String TEST_NAME = "test105ModifySrcAccountHermanRemoveLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -504,7 +495,6 @@ public void test105ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test106HermanAssignBasicRole() throws Exception { final String TEST_NAME = "test106HermanAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -522,7 +512,6 @@ public void test106HermanAssignBasicRole() throws Exception { @Test public void test107ModifySrcAccountHermanAddLoc() throws Exception { final String TEST_NAME = "test107ModifySrcAccountHermanAddLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -541,7 +530,6 @@ public void test107ModifySrcAccountHermanAddLoc() throws Exception { @Test public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { final String TEST_NAME = "test108ModifySrcAccountHermanRemoveLoc"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -560,7 +548,6 @@ public void test108ModifySrcAccountHermanRemoveLoc() throws Exception { @Test public void test109HermanUnAssignBasicRole() throws Exception { final String TEST_NAME = "test109HermanUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_HERMAN_NAME); @@ -578,7 +565,6 @@ public void test109HermanUnAssignBasicRole() throws Exception { @Test public void test110AddSrcAccountLemonhead() throws Exception { final String TEST_NAME = "test110AddSrcAccountLemonhead"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME); @@ -605,7 +591,6 @@ public void test110AddSrcAccountLemonhead() throws Exception { @Test public void test120AddSrcAccountWally() throws Exception { final String TEST_NAME = "test120AddSrcAccountWally"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_WALLY_USERNAME); @@ -625,7 +610,6 @@ public void test120AddSrcAccountWally() throws Exception { @Test public void test121WallyAssignBasicRole() throws Exception { final String TEST_NAME = "test121WallyAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_WALLY_NAME); @@ -642,7 +626,6 @@ public void test121WallyAssignBasicRole() throws Exception { @Test public void test122WallyUnAssignBasicRole() throws Exception { final String TEST_NAME = "test122WallyUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_WALLY_NAME); @@ -662,7 +645,6 @@ public void test122WallyUnAssignBasicRole() throws Exception { @Test public void test130AddSrcAccountMancomb() throws Exception { final String TEST_NAME = "test130AddSrcAccountMancomb"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME); @@ -684,7 +666,6 @@ public void test130AddSrcAccountMancomb() throws Exception { @Test public void test131MancombAssignBasicRole() throws Exception { final String TEST_NAME = "test131WallyAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_MANCOMB_NAME); @@ -701,7 +682,6 @@ public void test131MancombAssignBasicRole() throws Exception { @Test public void test132MancombUnAssignBasicRole() throws Exception { final String TEST_NAME = "test132MancombUnAssignBasicRole"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); PrismObject user = findUserByUsername(USER_MANCOMB_NAME); @@ -722,7 +702,6 @@ public void test132MancombUnAssignBasicRole() throws Exception { @Test public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { final String TEST_NAME = "test150ModifySrcAccountHermanReplaceOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); @@ -746,18 +725,17 @@ public void test150ModifySrcAccountHermanReplaceOrg() throws Exception { @Test public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { final String TEST_NAME = "test152ModifySrcAccountHermanDeleteOrg"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); account.replaceAttributeValues(DUMMY_ACCOUNT_ATTRIBUTE_SRC_ORG); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true); // THEN - TestUtil.displayThen(TEST_NAME); + then(); PrismObject user = findUserByUsername(getUsername(ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, null)); assertUserNoRole(user, ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, null); assertLocGov(user, null, null); @@ -771,9 +749,8 @@ public void test152ModifySrcAccountHermanDeleteOrg() throws Exception { @Test public void test200CreateUserAssignOrgPwdPolicy() throws Exception { final String TEST_NAME = "test200CreateUserAssignOrgPwdPolicy"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); - OperationResult result = new OperationResult(TEST_NAME); + Task task = getTestTask(); + OperationResult result = createOperationalResult(); //prepare password policies addObject(GLOBAL_PASSWORD_POLICY_FILE); @@ -796,12 +773,12 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { ObjectDelta addUserMikeDelta = DeltaFactory.Object.createAddDelta(userMikeBefore); // WHEN - displayWhen(TEST_NAME); + when(); //The user's password has length 4..if the policy is not chosen correctly, it fails modelService.executeChanges(MiscUtil.createCollection(addUserMikeDelta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(result); //TODO: assert added user @@ -814,7 +791,6 @@ public void test200CreateUserAssignOrgPwdPolicy() throws Exception { @Test public void test201unassignRole() throws Exception{ final String TEST_NAME = "test201unassignRole"; - displayTestTitle(TEST_NAME); unassignRole(USER_MIKE_OID, ROLE_BASIC_OID); //TODO: assertions } @@ -822,10 +798,9 @@ public void test201unassignRole() throws Exception{ @Test public void test202assignRoleOrgPwdPolicy() throws Exception{ final String TEST_NAME = "test202assignRoleOrgPwdPolicy"; - displayTestTitle(TEST_NAME); //this will throw exception, if incorrect pwd policy is selected...but some assertion will be nice :) - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); assignRole(USER_MIKE_OID, ROLE_BASIC_OID, task, result); assertPartialError(result); @@ -836,16 +811,15 @@ public void test202assignRoleOrgPwdPolicy() throws Exception{ @Test public void test300AddProjectJollyRoger() throws Exception { final String TEST_NAME = "test300AddProjectJollyRoger"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ORG_PROJECT_JOLLY_ROGER_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PrismObject org = getObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID); @@ -863,7 +837,6 @@ public void test300AddProjectJollyRoger() throws Exception { @Test public void test310ProjectJollyRogerNestedGroup() throws Exception { final String TEST_NAME = "test310ProjectJollyRogerNestedGroup"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -881,12 +854,12 @@ ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn")).eq("admins" .build(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); // TODO: search for cn=admins,ou=Jolly Roger,dc=example,dc=com SearchResultList> groupShadows = modelService.searchObjects(ShadowType.class, query, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -901,16 +874,15 @@ ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NAMESPACE, "cn")).eq("admins" @Test public void test319DeleteProjectJollyRoger() throws Exception { final String TEST_NAME = "test319DeleteProjectJollyRoger"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); deleteObject(OrgType.class, ORG_PROJECT_JOLLY_ROGER_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -926,7 +898,6 @@ public void test319DeleteProjectJollyRoger() throws Exception { @Test public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { final String TEST_NAME = "test350AddRepoUserNoEmployeeNumberRecompute"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestVillage.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -934,11 +905,11 @@ public void test350AddRepoUserNoEmployeeNumberRecompute() throws Exception { repositoryService.addObject(user, null, result); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); recomputeUser(USER_MURRAY_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java index 6363fb895b7..b8b915efe06 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestWriter.java @@ -61,8 +61,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultWriter = modelService.testResource(RESOURCE_WRITER_OID, task); TestUtil.assertSuccess(testResultWriter); @@ -71,20 +70,19 @@ public void test000Sanity() throws Exception { @Test public void test100AssignJackDummyAccount() throws Exception { final String TEST_NAME = "test100AssignJackDummyAccount"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, createPolyString(USER_JACK_LOCALITY)); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_WRITER_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) @@ -97,18 +95,17 @@ public void test100AssignJackDummyAccount() throws Exception { @Test public void test110ModifyCaptainJack() throws Exception { final String TEST_NAME = "test110ModifyCaptainJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, createPolyString(USER_JACK_FULL_NAME_CAPTAIN)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertDummyAccountByUsername(RESOURCE_WRITER_DUMMY_NAME, USER_JACK_USERNAME) diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java index 53493c1fb24..a7de7802c53 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/AbstractGrouperTest.java @@ -136,11 +136,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti addObject(TASK_GROUP_SCAVENGER, initTask, initResult); } - @Override - protected boolean isAutoTaskManagementEnabled() { - return true; - } - @Override protected File getSystemConfigurationFile() { return SYSTEM_CONFIGURATION_FILE; diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java index 33469878fe1..f20113af21c 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperAsyncUpdate.java @@ -69,7 +69,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -77,8 +77,8 @@ public void test000Sanity() throws Exception { @Test public void test010CreateUsers() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); addObject(USER_BANDERSON, task, result); addObject(USER_JLEWIS685, task, result); @@ -94,9 +94,9 @@ public void test010CreateUsers() throws Exception { */ @Test public void test110AddAlumni() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -146,9 +146,9 @@ public void test110AddAlumni() throws Exception { */ @Test public void test115AddStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -197,9 +197,9 @@ public void test115AddStaff() throws Exception { */ @Test public void test200AddAlumniForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -234,8 +234,8 @@ public void test200AddAlumniForAnderson() throws Exception { */ @Test public void test202RecomputeAnderson() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN @@ -263,9 +263,9 @@ public void test202RecomputeAnderson() throws Exception { */ @Test public void test210AddStaffForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -295,8 +295,8 @@ public void test210AddStaffForAnderson() throws Exception { */ @Test public void test212RecomputeAnderson() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN @@ -327,9 +327,9 @@ public void test212RecomputeAnderson() throws Exception { */ @Test public void test220AddAlumniForLewis() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -358,9 +358,9 @@ public void test220AddAlumniForLewis() throws Exception { */ @Test public void test221AddStaffForLewis() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -390,8 +390,8 @@ public void test221AddStaffForLewis() throws Exception { */ @Test public void test222RecomputeLewis() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN @@ -421,9 +421,9 @@ public void test222RecomputeLewis() throws Exception { */ @Test public void test230AddAlumniForNobody() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -448,9 +448,9 @@ public void test230AddAlumniForNobody() throws Exception { */ @Test public void test250DeleteAlumniForAnderson() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -479,8 +479,8 @@ public void test250DeleteAlumniForAnderson() throws Exception { */ @Test public void test252RecomputeAnderson() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // WHEN @@ -508,9 +508,9 @@ public void test252RecomputeAnderson() throws Exception { */ @Test public void test305RenameStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -566,9 +566,9 @@ public void test305RenameStaff() throws Exception { */ @Test public void test310DeleteStaff() throws Exception { - Task task = getTask(); + Task task = getTestTask(); task.setChannel(SchemaConstants.CHANGE_CHANNEL_ASYNC_UPDATE_URI); - OperationResult result = getResult(); + OperationResult result = getTestOperationResult(); // GIVEN @@ -617,8 +617,8 @@ public void test310DeleteStaff() throws Exception { */ @Test public void test312ScavengeGroups() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); // GIVEN diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java index 4ca614ab583..51688f94489 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupImport.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.story.grouper; -import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -46,7 +45,7 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -54,8 +53,8 @@ public void test000Sanity() throws Exception { @Test public void test100ImportGroups() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); addObject(TASK_IMPORT_GROUPS, task, result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java index 4c609363f41..f2b93f7c357 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/grouper/TestGrouperLargeGroupReconciliation.java @@ -6,7 +6,6 @@ */ package com.evolveum.midpoint.testing.story.grouper; -import com.evolveum.icf.dummy.resource.DummyGroup; import com.evolveum.midpoint.schema.internals.InternalsConfig; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; @@ -46,7 +45,7 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { - Task task = getTask(); + Task task = getTestTask(); assertSuccess(modelService.testResource(RESOURCE_LDAP.oid, task)); assertSuccess(modelService.testResource(RESOURCE_GROUPER.oid, task)); @@ -54,8 +53,8 @@ public void test000Sanity() throws Exception { @Test public void test100ReconcileGroups() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); addObject(TASK_RECONCILE_GROUPS, task, result); @@ -68,8 +67,8 @@ public void test100ReconcileGroups() throws Exception { @Test public void test110ReconcileGroupsAgain() throws Exception { - Task task = getTask(); - OperationResult result = getResult(); + Task task = getTestTask(); + OperationResult result = getTestOperationResult(); task.setOwner(userAdministrator); deleteGroupMember(ALUMNI_NAME, 3); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java index a7153141701..427c2c02e65 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/AbstractLdapTest.java @@ -25,8 +25,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; import com.evolveum.midpoint.util.exception.PolicyViolationException; import com.evolveum.midpoint.prism.PrismContainer; @@ -35,14 +33,12 @@ import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.path.ItemName; import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -57,11 +53,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Testing dependencies: @@ -123,7 +115,7 @@ protected ObjectDelta createAssignmentOrgDelta(String orgOid, String ro protected void assignRoleToOrg(String orgOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - assignRoleToOrg(orgOid, roleOid, (ActivationType) null, task, result); + assignRoleToOrg(orgOid, roleOid, null, task, result); } protected void assignRoleToOrg(String orgOid, String roleOid, ActivationType activationType, Task task, @@ -136,7 +128,7 @@ protected void assignRoleToOrg(String orgOid, String roleOid, ActivationType act protected void unassignRoleFromOrg(String orgOid, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { - unassignRoleFromOrg(orgOid, roleOid, (ActivationType) null, task, result); + unassignRoleFromOrg(orgOid, roleOid, null, task, result); } protected void unassignRoleFromOrg(String orgOid, String roleOid, ActivationType activationType, Task task, @@ -146,11 +138,6 @@ protected void unassignRoleFromOrg(String orgOid, String roleOid, ActivationType modifyOrgAssignment(orgOid, roleOid, RoleType.COMPLEX_TYPE, null, task, null, activationType, false, result); } - protected void assertOrgNotAssignedRole(PrismObject focus, String roleOid) { - assertNotAssigned(focus, roleOid, RoleType.COMPLEX_TYPE); - // assertNotAssigned(user, roleOid, RoleType.COMPLEX_TYPE); - } - // TODO: maybe a replacement for MidpointAsserts.assertNotAssigned() // it can be used not only for user protected void assertNotAssigned(PrismObject focus, String targetOid, QName refType) { @@ -173,7 +160,8 @@ protected void assertLdapConnectorInstances(int expectedConnectorInstances) thro } protected void assertLdapConnectorInstances(int expectedConnectorInstancesMin, int expectedConnectorInstancesMax) throws NumberFormatException, IOException, InterruptedException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { - Task task = createTask(TestLdapSyncMassive.class.getName() + ".assertLdapConnectorInstances"); + TestLdapSyncMassive.class.getName(); + Task task = getTestTask(); OperationResult result = task.getResult(); List stats = provisioningService.getConnectorOperationalStatus(getLdapResourceOid(), task, result); display("Resource connector stats", stats); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java index 4f89c712928..5040f9f9ec4 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapAssociationPerformance.java @@ -147,9 +147,8 @@ protected String getLdapResourceOid() { @Test public void test000ClonePerformance() throws SchemaException { final String TEST_NAME = "test000ClonePerformance"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject systemConfiguration = systemObjectCache.getSystemConfiguration(result); @@ -166,19 +165,18 @@ public void test000ClonePerformance() throws SchemaException { @Test public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addObject(ROLE_TEST_FILE, task, result); addObject(USER_TEST_FILE, task, result); // THEN - displayThen(TEST_NAME); + then(); dumpLdap(); openDJController.assertUniqueMember("cn=role-test,ou=groups,dc=example,dc=com", "uid=user-test,ou=people,dc=example,dc=com"); @@ -191,13 +189,12 @@ public void test010Sanity() throws Exception { @Test public void test020GenerateRoles() throws Exception { final String TEST_NAME = "test020GenerateRoles"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); resetPerformanceCollectors(); @@ -213,7 +210,7 @@ public void test020GenerateRoles() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -240,13 +237,12 @@ private void resetPerformanceCollectors() { @Test public void test100AddUsers() throws Exception { final String TEST_NAME = "test100AddUsers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); resetPerformanceCollectors(); @@ -275,7 +271,7 @@ public void test100AddUsers() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -310,15 +306,14 @@ private void dumpRepoSnapshot(String label, PerformanceInformation performanceIn @Test public void test110RecomputeUsers() throws Exception { final String TEST_NAME = "test110RecomputeUsers"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -328,7 +323,7 @@ public void test110RecomputeUsers() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_1_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_1_OID)); @@ -355,15 +350,14 @@ public void test110RecomputeUsers() throws Exception { @Test public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { final String TEST_NAME = "test120RecomputeUsersNoRoleAndShadowCache"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -373,7 +367,7 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_NO_CACHE_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_NO_CACHE_OID)); @@ -400,15 +394,14 @@ public void test120RecomputeUsersNoRoleAndShadowCache() throws Exception { @Test public void test130RecomputeUsersMultinode() throws Exception { final String TEST_NAME = "test130RecomputeUsersMultinode"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -420,7 +413,7 @@ public void test130RecomputeUsersMultinode() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_OID)); @@ -449,15 +442,14 @@ public void test130RecomputeUsersMultinode() throws Exception { @Test public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { final String TEST_NAME = "test140RecomputeUsersMultinodeMultithreaded"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); getRepoPerformanceMonitor().clearGlobalPerformanceInformation(); resetGlobalCachePerformanceCollector(); @@ -469,7 +461,7 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { IntegrationTestTools.setSilentConsole(false); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME, getTreeRunDurationMillis(TASK_RECOMPUTE_MULTINODE_MULTITHREADED_OID)); @@ -499,15 +491,14 @@ public void test140RecomputeUsersMultinodeMultithreaded() throws Exception { @Test public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { final String TEST_NAME = "test200RecomputeUsersNoDefaultRoleCache"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject newConfiguration = parseObject(SYSTEM_CONFIGURATION_NO_ROLE_CACHE_FILE); repositoryService.addObject(newConfiguration, RepoAddOptions.createOverwrite(), result); @@ -519,7 +510,7 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { waitForTaskFinish(TASK_RECOMPUTE_4_OID, true, RECOMPUTE_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECOMPUTE_4_OID)); @@ -547,9 +538,8 @@ public void test200RecomputeUsersNoDefaultRoleCache() throws Exception { @Test public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); @@ -559,7 +549,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users, "+NUMBER_OF_GENERATED_ROLES+" roles)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(); // TODO: more thresholds diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java index 1f0be677313..da122427ed7 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapComplex.java @@ -182,8 +182,7 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -199,18 +198,17 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -223,16 +221,15 @@ public void test010Shadows() throws Exception { @Test public void test050AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test050AssignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -257,19 +254,18 @@ public void test050AssignAccountOpenDjSimple() throws Exception { @Test public void test055Shadows() throws Exception { final String TEST_NAME = "test055Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); display("Query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -279,16 +275,15 @@ public void test055Shadows() throws Exception { @Test public void test059UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test059UnassignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -310,19 +305,18 @@ public void test059UnassignAccountOpenDjSimple() throws Exception { @Test public void test100ModifyJackFullNameLang() throws Exception { final String TEST_NAME = "test100ModifyJackFullNameLang"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK)); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -344,16 +338,15 @@ public void test100ModifyJackFullNameLang() throws Exception { @Test public void test110AssignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test110AssignAccountOpenDjLang"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -380,19 +373,18 @@ public void test110AssignAccountOpenDjLang() throws Exception { @Test public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { final String TEST_NAME = "test112ModifyJackFullNameLangEnSkRuHr"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_EN_SK_RU_HR)); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -418,19 +410,18 @@ public void test112ModifyJackFullNameLangEnSkRuHr() throws Exception { @Test public void test114ModifyJackFullNameLangCzHr() throws Exception { final String TEST_NAME = "test114ModifyJackFullNameLangCzHr"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME); newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CZ_HR)); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -456,19 +447,18 @@ public void test114ModifyJackFullNameLangCzHr() throws Exception { @Test public void test116ModifyJackFullNameLangCaptain() throws Exception { final String TEST_NAME = "test116ModifyJackFullNameLangCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); newFullName.setLang(MiscUtil.paramsToMap(JACK_FULL_NAME_LANG_CAPTAIN_EN_CZ_SK)); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -493,18 +483,17 @@ public void test116ModifyJackFullNameLangCaptain() throws Exception { @Test public void test118ModifyJackFullNameCaptain() throws Exception { final String TEST_NAME = "test118ModifyJackFullNameCaptain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PolyString newFullName = new PolyString(USER_JACK_FULL_NAME_CAPTAIN); // WHEN - displayWhen(TEST_NAME); + when(); modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, newFullName); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -526,16 +515,15 @@ public void test118ModifyJackFullNameCaptain() throws Exception { @Test public void test119UnassignAccountOpenDjLang() throws Exception { final String TEST_NAME = "test119UnassignAccountOpenDjLang"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -557,8 +545,7 @@ public void test119UnassignAccountOpenDjLang() throws Exception { @Test public void test120ModifyJackTitleMap() throws Exception { final String TEST_NAME = "test120ModifyJackTitleMap"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_EN_SK_RU); @@ -569,11 +556,11 @@ public void test120ModifyJackTitleMap() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -595,16 +582,15 @@ public void test120ModifyJackTitleMap() throws Exception { @Test public void test130AssignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test130AssignAccountOpenDjTitleMap"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -636,8 +622,7 @@ public void test130AssignAccountOpenDjTitleMap() throws Exception { @Test public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { final String TEST_NAME = "test132AssignAccountOpenDjTitleMapAdd"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_HR); @@ -648,11 +633,11 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -684,8 +669,7 @@ public void test132AssignAccountOpenDjTitleMapAdd() throws Exception { @Test public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { final String TEST_NAME = "test134AssignAccountOpenDjTitleMapDelete"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_RU); @@ -696,11 +680,11 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -732,8 +716,7 @@ public void test134AssignAccountOpenDjTitleMapDelete() throws Exception { @Test public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { final String TEST_NAME = "test138AssignAccountOpenDjTitleMapReplace"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); List> cvals = createTitleMapValues(TITLE_EN_SK_RU); @@ -744,11 +727,11 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { .asObjectDelta(USER_JACK_OID); // WHEN - displayWhen(TEST_NAME); + when(); executeChanges(delta, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -776,16 +759,15 @@ public void test138AssignAccountOpenDjTitleMapReplace() throws Exception { @Test public void test139UnassignAccountOpenDjTitleMap() throws Exception { final String TEST_NAME = "test139UnassignAccountOpenDjTitleMap"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -806,16 +788,15 @@ public void test139UnassignAccountOpenDjTitleMap() throws Exception { @Test public void test150AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test150AssignAccountOpenDj"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -851,8 +832,7 @@ public void test150AssignAccountOpenDj() throws Exception { @Test public void test152JackMultivalueDescriptionGet() throws Exception { final String TEST_NAME = "test152JackMultivalueDescriptionGet"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // Let's ruing Jack's description in LDAP. @@ -873,11 +853,11 @@ public void test152JackMultivalueDescriptionGet() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject shadow = modelService.getObject(ShadowType.class, accountJackOid, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); PolyString descriptionShadowAttribute = (PolyString) assertShadow(shadow, "Jack's shadow after read") @@ -906,18 +886,17 @@ public void test152JackMultivalueDescriptionGet() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -931,12 +910,11 @@ public void test300Shadows() throws Exception { @Test public void test310SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -948,18 +926,17 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -986,7 +963,6 @@ public void test312Shadows() throws Exception { @Test public void test320SearchLdapAccountsBelow() throws Exception { final String TEST_NAME = "test320SearchLdapAccountsBelow"; - displayTestTitle(TEST_NAME); openDJController.addEntry("dn: ou=below,ou=People,dc=example,dc=com\n" + "ou: below\n" + @@ -1006,7 +982,7 @@ public void test320SearchLdapAccountsBelow() throws Exception { ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 4); } @@ -1018,12 +994,11 @@ public void test320SearchLdapAccountsBelow() throws Exception { @Test public void test400SearchLdapProjectGroups() throws Exception { final String TEST_NAME = "test400SearchLdapProjectGroups"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_PROJECT_GROUP, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); // Group "pirates" already exists searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); @@ -1036,12 +1011,11 @@ public void test400SearchLdapProjectGroups() throws Exception { @Test public void test401SearchLdapOrgGroups() throws Exception { final String TEST_NAME = "test401SearchLdapOrgGroups"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, INTENT_LDAP_ORG_GROUP, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -1052,7 +1026,6 @@ public void test401SearchLdapOrgGroups() throws Exception { @Test public void test410CreateProjectKeelhaul() throws Exception { final String TEST_NAME = "test410CreateProjectKeelhaul"; - displayTestTitle(TEST_NAME); PrismObject projectKeelhaul = createObject(OrgType.class, PROJECT_KEELHAUL_NAME); projectKeelhaul.asObjectable() @@ -1060,11 +1033,11 @@ public void test410CreateProjectKeelhaul() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(); addObject(projectKeelhaul); // THEN - displayThen(TEST_NAME); + then(); PrismObject orgKeelhaul = findObjectByName(OrgType.class, PROJECT_KEELHAUL_NAME); projectKeelhaulOid = orgKeelhaul.getOid(); groupKeelhaulOid = assertOrg(orgKeelhaul, "after") @@ -1082,7 +1055,6 @@ public void test410CreateProjectKeelhaul() throws Exception { @Test public void test412CreateProjectWalkThePlank() throws Exception { final String TEST_NAME = "test412CreateProjectWalkThePlank"; - displayTestTitle(TEST_NAME); PrismObject projectKeelhaul = createObject(OrgType.class, PROJECT_WALK_THE_PLANK_NAME); projectKeelhaul.asObjectable() @@ -1090,11 +1062,11 @@ public void test412CreateProjectWalkThePlank() throws Exception { .targetRef(ORG_PROJECT_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(); addObject(projectKeelhaul); // THEN - displayThen(TEST_NAME); + then(); PrismObject orgWalkThePlank = findObjectByName(OrgType.class, PROJECT_WALK_THE_PLANK_NAME); projectWalkThePlankOid = orgWalkThePlank.getOid(); groupWalkThePlankOid = assertOrg(orgWalkThePlank, "after") @@ -1115,7 +1087,6 @@ public void test412CreateProjectWalkThePlank() throws Exception { @Test public void test415CreateOrgRumDepartment() throws Exception { final String TEST_NAME = "test415CreateOrgRumDepartment"; - displayTestTitle(TEST_NAME); PrismObject orgBefore = createObject(OrgType.class, ORG_RUM_DEPARTMENT_NAME); orgBefore.asObjectable() @@ -1123,11 +1094,11 @@ public void test415CreateOrgRumDepartment() throws Exception { .targetRef(ORG_FUNCTIONAL_TOP_OID, OrgType.COMPLEX_TYPE); // WHEN - displayWhen(TEST_NAME); + when(); addObject(orgBefore); // THEN - displayThen(TEST_NAME); + then(); PrismObject orgAfter = findObjectByName(OrgType.class, ORG_RUM_DEPARTMENT_NAME); orgRumDepartmentOid = orgAfter.getOid(); assertNotNull("Null org oid", orgRumDepartmentOid); @@ -1150,9 +1121,8 @@ public void test415CreateOrgRumDepartment() throws Exception { @Test public void test420AssignJackToKeelhaul() throws Exception { final String TEST_NAME = "test412AssignJackToKeelhaul"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) @@ -1163,11 +1133,11 @@ public void test420AssignJackToKeelhaul() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_JACK_OID, projectKeelhaulOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1191,9 +1161,8 @@ public void test420AssignJackToKeelhaul() throws Exception { @Test public void test422AssignJackToWalkThePlank() throws Exception { final String TEST_NAME = "test414AssignJackToWalkThePlank"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) @@ -1204,11 +1173,11 @@ public void test422AssignJackToWalkThePlank() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_JACK_OID, projectWalkThePlankOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); @@ -1232,9 +1201,8 @@ public void test422AssignJackToWalkThePlank() throws Exception { @Test public void test424AssignJackToRumDepartment() throws Exception { final String TEST_NAME = "test424AssignJackToRumDepartment"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); String accountJackOid = assertUserBefore(USER_JACK_OID) @@ -1245,11 +1213,11 @@ public void test424AssignJackToRumDepartment() throws Exception { .getOid(); // WHEN - displayWhen(TEST_NAME); + when(); assignOrg(USER_JACK_OID, orgRumDepartmentOid, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); openDJController.assertUniqueMembers("cn="+PROJECT_KEELHAUL_NAME+",ou=groups,dc=example,dc=com", "uid="+USER_JACK_USERNAME+",ou=people,dc=example,dc=com"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java index 89dd36a3357..d9f3d2ad58f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapDependency.java @@ -139,7 +139,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapDependency.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -152,19 +151,18 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgIT() throws Exception { final String TEST_NAME = "test100AddOrgIT"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_IT_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -180,19 +178,18 @@ public void test100AddOrgIT() throws Exception { @Test public void test150AssignFunctionalRoleToITOrg() throws Exception { final String TEST_NAME = "test150AssignFunctionalRoleToITOrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - displayWhen(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -210,19 +207,18 @@ public void test150AssignFunctionalRoleToITOrg() throws Exception { @Test public void test170UnassignFunctionalRoleFromITOrg() throws Exception { final String TEST_NAME = "test170UnassignFunctionalRoleFromITOrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_IT_NAME); // WHEN - displayWhen(TEST_NAME); + when(); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgItOid, ROLE_META_ORG_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -241,19 +237,18 @@ public void test170UnassignFunctionalRoleFromITOrg() throws Exception { @Test public void test200AddOrgHR() throws Exception { final String TEST_NAME = "test200AddOrgHR"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_HR_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -269,20 +264,19 @@ public void test200AddOrgHR() throws Exception { @Test public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { final String TEST_NAME = "test250AssignFunctionalAndVipRoleToHROrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -302,19 +296,18 @@ public void test250AssignFunctionalAndVipRoleToHROrg() throws Exception { @Test public void test270UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test270UnassignVipRoleFromHROrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(); display("unassigning vip role org", orgBefore); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -335,20 +328,19 @@ public void test270UnassignVipRoleFromHROrg() throws Exception { @Test public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { final String TEST_NAME = "test280AssignVipAndSuperVipRoleToHROrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); // WHEN - displayWhen(TEST_NAME); + when(); display("orgBefore: ", orgBefore); assignRoleToOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assignRoleToOrg(orgHrOid, ROLE_META_ORG_SUPERVIP_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -369,8 +361,7 @@ public void test280AssignVipAndSuperVipRoleToHROrg() throws Exception { @Test public void test290UnassignVipRoleFromHROrg() throws Exception { final String TEST_NAME = "test290UnassignVipRoleFromHROrg"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_HR_NAME); @@ -379,7 +370,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { try { // WHEN - displayWhen(TEST_NAME); + when(); unassignRoleFromOrg(orgHrOid, ROLE_META_ORG_VIP_OID, task, result); assertNotReached(); @@ -389,7 +380,7 @@ public void test290UnassignVipRoleFromHROrg() throws Exception { } // THEN - displayThen(TEST_NAME); + then(); assertFailure(result); dumpOrgTree(); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java index 9acf388802c..11b4c1649aa 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapMutilated.java @@ -14,13 +14,10 @@ import static org.testng.AssertJUnit.assertEquals; import java.io.File; -import java.util.ArrayList; -import java.util.List; import javax.xml.namespace.QName; import org.apache.commons.lang3.StringUtils; -import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -28,13 +25,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.Test; -import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismProperty; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.path.ItemName; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.MidPointConstants; @@ -42,16 +33,11 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.ldap.OpenDJController; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.MiscUtil; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * LDAP Tests with LDAP content that is completely mutilated. It is all wrong. @@ -110,8 +96,7 @@ protected String getLdapResourceOid() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -127,18 +112,17 @@ public void test000Sanity() throws Exception { @Test public void test010Shadows() throws Exception { final String TEST_NAME = "test010Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -151,16 +135,15 @@ public void test010Shadows() throws Exception { @Test public void test100AssignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test100AssignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -183,19 +166,18 @@ public void test100AssignAccountOpenDjSimple() throws Exception { @Test public void test105Shadows() throws Exception { final String TEST_NAME = "test105Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); display("Query", query); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -205,16 +187,15 @@ public void test105Shadows() throws Exception { @Test public void test109UnassignAccountOpenDjSimple() throws Exception { final String TEST_NAME = "test109UnassignAccountOpenDjSimple"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); unassignAccountFromUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); assertUserAfter(USER_JACK_OID) @@ -237,18 +218,17 @@ public void test109UnassignAccountOpenDjSimple() throws Exception { @Test public void test300Shadows() throws Exception { final String TEST_NAME = "test300Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -262,12 +242,11 @@ public void test300Shadows() throws Exception { @Test public void test310SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 0); } @@ -278,18 +257,17 @@ public void test310SearchLdapAccounts() throws Exception { @Test public void test312Shadows() throws Exception { final String TEST_NAME = "test312Shadows"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectQuery query = ObjectQueryUtil.createResourceQuery(RESOURCE_OPENDJ_OID, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); SearchResultList> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); display("Found shadows", shadows); @@ -314,16 +292,15 @@ public void test312Shadows() throws Exception { @Test public void test320AssignAccountOpenDj() throws Exception { final String TEST_NAME = "test320AssignAccountOpenDj"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); accountJackOid = assertUserAfter(USER_JACK_OID) @@ -345,12 +322,11 @@ public void test320AssignAccountOpenDj() throws Exception { @Test public void test322SearchLdapAccounts() throws Exception { final String TEST_NAME = "test310SearchLdapAccounts"; - displayTestTitle(TEST_NAME); ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT, prismContext); // WHEN - displayWhen(TEST_NAME); + when(); searchObjectsIterative(ShadowType.class, query, o -> display("Found object", o), 1); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java index 498c51b1df7..2cd7a79ce71 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapReconPerformance.java @@ -105,15 +105,14 @@ protected String getLdapResourceOid() { @Test public void test010GenerateUsers() throws Exception { final String TEST_NAME = "test010GenerateUsers"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); // Add objects using model, we also want to create LDAP accounts generateObjects(UserType.class, NUMBER_OF_GENERATED_USERS, GENERATED_USER_NAME_FORMAT, GENERATED_USER_OID_FORMAT, (user,i) -> { @@ -129,7 +128,7 @@ public void test010GenerateUsers() throws Exception { result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); recordDuration(TEST_NAME, (endMillis - startMillis)); @@ -148,21 +147,20 @@ public void test010GenerateUsers() throws Exception { @Test public void test100Reconcile1ThreadLdap0() throws Exception { final String TEST_NAME = "test100Reconcile1ThreadLdap0"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_RECON_1_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_1_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_1_OPENDJ_OID)); @@ -192,21 +190,20 @@ public void test120Reconcile1ThreadLdap2() throws Exception { @Test public void test200ReconcileLdap0() throws Exception { final String TEST_NAME = "test200ReconcileLdap0"; - displayTestTitle(TEST_NAME); rememberConnectorResourceCounters(); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN - displayWhen(TEST_NAME); + when(); addTask(TASK_RECON_4_OPENDJ_FILE); waitForTaskFinish(TASK_RECON_4_OPENDJ_OID, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); recordDuration(TEST_NAME,getRunDurationMillis(TASK_RECON_4_OPENDJ_OID)); @@ -236,7 +233,6 @@ public void test230ReconcileLdap3() throws Exception { @Test public void test310ReconcileLdapX1() throws Exception { final String TEST_NAME = "test310ReconcileLdapX1"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapReconPerformance.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -257,7 +253,6 @@ public void test330ReconcileLdapX3() throws Exception { } private long testReconcileLdapRestart1Thread(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); long duration = testReconcileLdapRestartWhen(TEST_NAME, TASK_RECON_1_OPENDJ_OID); @@ -267,7 +262,6 @@ private long testReconcileLdapRestart1Thread(final String TEST_NAME) throws Exce } private long testReconcileLdapRestart(final String TEST_NAME) throws Exception { - displayTestTitle(TEST_NAME); long duration = testReconcileLdapRestartWhen(TEST_NAME, TASK_RECON_4_OPENDJ_OID); @@ -277,20 +271,20 @@ private long testReconcileLdapRestart(final String TEST_NAME) throws Exception { } private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid) throws Exception { - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ruinLdapAccounts(); rememberConnectorResourceCounters(); // WHEN - displayWhen(TEST_NAME); + when(); restartTask(taskOid); waitForTaskFinish(taskOid, true, RECON_TASK_WAIT_TIMEOUT); // THEN - displayThen(TEST_NAME); + then(); long duration = recordDuration(TEST_NAME, getRunDurationMillis(taskOid)); @@ -307,9 +301,8 @@ private long testReconcileLdapRestartWhen(final String TEST_NAME, String taskOid @Test public void test900Summarize() throws Exception { final String TEST_NAME = "test900Summarize"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); StringBuilder sb = new StringBuilder(); @@ -319,7 +312,7 @@ public void test900Summarize() throws Exception { display("Summary ("+NUMBER_OF_GENERATED_USERS+" users)", sb.toString()); // THEN - displayThen(TEST_NAME); + then(); if (reconDuration1ThreadBaseline < reconDuration4ThreadBaseline) { fail("Multi-thread recon SLOWER than single-thread! singlethread="+reconDuration1ThreadBaseline+"ms, multithread="+reconDuration4ThreadBaseline+"ms"); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java index 83ad1220697..c76ac333cad 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapSyncMassive.java @@ -21,7 +21,6 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.schema.SearchResultList; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; @@ -39,16 +38,14 @@ * management related to sync (e.g. MID-5099) * * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) -public class TestLdapSyncMassive extends AbstractLdapTest { +public class TestLdapSyncMassive extends AbstractLdapTest { public static final File TEST_DIR = new File(LDAP_TEST_DIR, "sync-massive"); private static final String RESOURCE_OPENDJ_OID = "10000000-0000-0000-0000-000000000003"; - private static final String RESOURCE_OPENDJ_NAMESPACE = MidPointConstants.NS_RI; private static final File RESOURCE_OPENDJ_FILE_BAD = new File(TEST_DIR, "resource-opendj-bad.xml"); @@ -60,8 +57,6 @@ public class TestLdapSyncMassive extends AbstractLdapTest { private static final String ACCOUNT_WILL_LDAP_CN = "Will Turner"; private static final File ACCOUNT_KRAKEN_LDIF_FILE = new File(TEST_DIR, "kraken.ldif"); - private static final String ACCOUNT_KRAKEN_LDAP_UID = "kraken"; - private static final String ACCOUNT_KRAKEN_LDAP_CN = "Kraken Krakenoff"; private static final int THREAD_COUNT_TOLERANCE = 10; private static final int THREAD_COUNT_TOLERANCE_BIG = 20; @@ -81,7 +76,6 @@ public class TestLdapSyncMassive extends AbstractLdapTest { */ private static final int INSTANCES_MAX = 3; - private PrismObject resourceOpenDj; private Integer lastSyncToken; private int threadCountBaseline; @@ -104,7 +98,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -113,15 +107,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti super.initSystem(initTask, initResult); // Resources - resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); + PrismObject resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); openDJController.setResource(resourceOpenDj); } @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); @@ -134,15 +126,14 @@ public void test000Sanity() throws Exception { @Test public void test080ImportSyncTask() throws Exception { final String TEST_NAME = "test080ImportSyncTask"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_LIVE_SYNC_FILE); // THEN - displayThen(TEST_NAME); + then(); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); @@ -165,25 +156,24 @@ public void test080ImportSyncTask() throws Exception { @Test public void test110SyncAddWill() throws Exception { final String TEST_NAME = "test110SyncAddWill"; - displayTestTitle(TEST_NAME); Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_WILL_LDIF_FILE); display("Entry from LDIF", entry); // WHEN - displayWhen(TEST_NAME); + when(); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); // THEN - displayThen(TEST_NAME); + then(); assertSyncTokenIncrement(1); assertLdapConnectorInstances(1); assertUserAfterByUsername(ACCOUNT_WILL_LDAP_UID) - .assertFullName(ACCOUNT_WILL_LDAP_CN); + .assertFullName(ACCOUNT_WILL_LDAP_CN); assertThreadCount(); @@ -207,23 +197,21 @@ public void test110SyncAddWill() throws Exception { @Test public void test112SyncAddGoods() throws Exception { final String TEST_NAME = "test112SyncAddGoods"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptGood("good", i); } // THEN - displayThen(TEST_NAME); + then(); dumpLdap(); } - /** * Add "goblin" users, each with an LDAP account. * We do not really needs them now. But these will make @@ -236,23 +224,22 @@ public void test112SyncAddGoods() throws Exception { @Test public void test150AddGoblins() throws Exception { final String TEST_NAME = "test150AddGoblins"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); for (int i = 0; i < NUMBER_OF_GOBLINS; i++) { String username = goblinUsername(i); PrismObject goblin = createUser(username, "Goblin", Integer.toString(i), true); goblin.asObjectable(). - beginAssignment() + beginAssignment() .beginConstruction() - .resourceRef(RESOURCE_OPENDJ_OID, ResourceType.COMPLEX_TYPE); + .resourceRef(RESOURCE_OPENDJ_OID, ResourceType.COMPLEX_TYPE); addObject(goblin); } // THEN - displayThen(TEST_NAME); + then(); dumpLdap(); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -271,8 +258,6 @@ public void test150AddGoblins() throws Exception { } - - private String goblinUsername(int i) { return String.format("goblin%05d", i); } @@ -283,14 +268,11 @@ private String goblinUsername(int i) { */ @Test public void test200SyncAddKraken() throws Exception { - final String TEST_NAME = "test200SyncAddKraken"; - displayTestTitle(TEST_NAME); - - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); ImportOptionsType options = new ImportOptionsType() - .overwrite(true); + .overwrite(true); importObjectFromFile(RESOURCE_OPENDJ_FILE_BAD, options, task, result); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -299,7 +281,7 @@ public void test200SyncAddKraken() throws Exception { PrismObject resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result); assertResource(resourceAfter, "after") - .assertHasSchema(); + .assertHasSchema(); assertLdapConnectorInstances(1, INSTANCES_MAX); } @@ -311,18 +293,17 @@ public void test200SyncAddKraken() throws Exception { @Test public void test210SyncAddKraken() throws Exception { final String TEST_NAME = "test210SyncAddKraken"; - displayTestTitle(TEST_NAME); Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_KRAKEN_LDIF_FILE); display("Entry from LDIF", entry); // WHEN - displayWhen(TEST_NAME); + when(); OperationResult taskResult = waitForTaskNextRun(TASK_LIVE_SYNC_OID); // THEN - displayThen(TEST_NAME); + then(); assertPartialError(taskResult); assertSyncTokenIncrement(0); @@ -350,17 +331,16 @@ public void test210SyncAddKraken() throws Exception { @Test public void test212SyncAddBads() throws Exception { final String TEST_NAME = "test212SyncAddBads"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); for (int i = 0; i < SYNC_ADD_ATTEMPTS; i++) { syncAddAttemptBad("bad", i); } // THEN - displayThen(TEST_NAME); + then(); dumpLdap(); @@ -373,15 +353,14 @@ public void test212SyncAddBads() throws Exception { @Test public void test219StopSyncTask() throws Exception { final String TEST_NAME = "test219StopSyncTask"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); suspendTask(TASK_LIVE_SYNC_OID); // THEN - displayThen(TEST_NAME); + then(); assertSyncTokenIncrement(0); assertLdapConnectorInstances(1, INSTANCES_MAX); @@ -392,22 +371,21 @@ public void test219StopSyncTask() throws Exception { @Test public void test230UserRecomputeSequential() throws Exception { final String TEST_NAME = "test230UserRecomputeSequential"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - displayWhen(TEST_NAME); + when(); for (PrismObject user : users) { - reconcile(TEST_NAME, user); + reconcile(user); } // THEN - displayThen(TEST_NAME); + then(); assertLdapConnectorInstances(1, INSTANCES_MAX); assertThreadCount(); @@ -416,28 +394,27 @@ public void test230UserRecomputeSequential() throws Exception { @Test public void test232UserRecomputeParallel() throws Exception { final String TEST_NAME = "test232UserRecomputeParallel"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); SearchResultList> users = modelService.searchObjects(UserType.class, null, null, task, result); // WHEN - displayWhen(TEST_NAME); + when(); int segmentSize = users.size() / NUMBER_OF_TEST_THREADS; - ParallelTestThread[] threads = multithread(TEST_NAME, + ParallelTestThread[] threads = multithread( (threadIndex) -> { for (int i = segmentSize * threadIndex; i < segmentSize * threadIndex + segmentSize; i++) { PrismObject user = users.get(i); - reconcile(TEST_NAME, user); + reconcile(user); } }, NUMBER_OF_TEST_THREADS, TEST_THREADS_RANDOM_START_RANGE); // THEN - displayThen(TEST_NAME); + then(); waitForThreads(threads, PARALLEL_TEST_TIMEOUT); // When system is put under load, this means more threads. But not huge number of threads. @@ -445,8 +422,12 @@ public void test232UserRecomputeParallel() throws Exception { assertLdapConnectorInstances(1, NUMBER_OF_TEST_THREADS); } - private void reconcile(final String TEST_NAME, PrismObject user) throws CommunicationException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException, SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { - Task task = createTask(TEST_NAME+".user."+user.getName()); + private void reconcile(PrismObject user) + throws SchemaException, ObjectAlreadyExistsException, ExpressionEvaluationException, + PolicyViolationException, CommunicationException, SecurityViolationException, + ConfigurationException, ObjectNotFoundException { + user.getName(); + Task task = createTask("user." + user.getName()); OperationResult result = task.getResult(); reconcileUser(user.getOid(), task, result); @@ -459,7 +440,7 @@ private void reconcile(final String TEST_NAME, PrismObject user) throw private void syncAddAttemptGood(String prefix, int index) throws Exception { String uid = String.format("%s%05d", prefix, index); - String cn = prefix+" "+index; + String cn = prefix + " " + index; addAttemptEntry(uid, cn, Integer.toString(index)); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_OID, true); @@ -467,7 +448,7 @@ private void syncAddAttemptGood(String prefix, int index) throws Exception { assertSyncTokenIncrement(1); assertUserAfterByUsername(uid) - .assertFullName(cn); + .assertFullName(cn); assertThreadCount(); } @@ -475,7 +456,7 @@ private void syncAddAttemptGood(String prefix, int index) throws Exception { private void syncAddAttemptBad(String prefix, int index) throws Exception { String uid = String.format("%s%05d", prefix, index); - String cn = prefix+" "+index; + String cn = prefix + " " + index; addAttemptEntry(uid, cn, Integer.toString(index)); OperationResult taskResult = waitForTaskNextRun(TASK_LIVE_SYNC_OID); @@ -488,16 +469,16 @@ private void syncAddAttemptBad(String prefix, int index) throws Exception { private void addAttemptEntry(String uid, String cn, String sn) throws Exception { Entry entry = openDJController.addEntry( - "dn: uid="+uid+",ou=People,dc=example,dc=com\n" + - "uid: "+uid+"\n" + - "cn: "+cn+"\n" + - "sn: "+sn+"\n" + - "givenname: "+uid+"\n" + - "objectclass: top\n" + - "objectclass: person\n" + - "objectclass: organizationalPerson\n" + - "objectclass: inetOrgPerson" - ); + "dn: uid=" + uid + ",ou=People,dc=example,dc=com\n" + + "uid: " + uid + "\n" + + "cn: " + cn + "\n" + + "sn: " + sn + "\n" + + "givenname: " + uid + "\n" + + "objectclass: top\n" + + "objectclass: person\n" + + "objectclass: organizationalPerson\n" + + "objectclass: inetOrgPerson" + ); display("Added generated entry", entry); } @@ -508,26 +489,21 @@ private void assertThreadCount() { private void assertThreadCount(int tolerance) { int currentThreadCount = Thread.activeCount(); if (!isWithinTolerance(threadCountBaseline, currentThreadCount, tolerance)) { - fail("Thread count out of tolerance: "+currentThreadCount+" ("+(currentThreadCount-threadCountBaseline)+")"); + fail("Thread count out of tolerance: " + currentThreadCount + " (" + (currentThreadCount - threadCountBaseline) + ")"); } } private boolean isWithinTolerance(int baseline, int currentCount, int tolerance) { - if (currentCount > baseline + tolerance) { - return false; - } - if (currentCount < baseline - tolerance) { - return false; - } - return true; + return currentCount <= baseline + tolerance + && currentCount >= baseline - tolerance; } private void assertSyncTokenIncrement(int expectedIncrement) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject syncTask = getTask(TASK_LIVE_SYNC_OID); Integer currentSyncToken = ObjectTypeUtil.getExtensionItemRealValue(syncTask, SchemaConstants.SYNC_TOKEN); - display("Sync token, last="+lastSyncToken+", current="+currentSyncToken+", expectedIncrement="+expectedIncrement); + display("Sync token, last=" + lastSyncToken + ", current=" + currentSyncToken + ", expectedIncrement=" + expectedIncrement); if (currentSyncToken != lastSyncToken + expectedIncrement) { - fail("Expected sync token increment "+expectedIncrement+", but it was "+(currentSyncToken-lastSyncToken)); + fail("Expected sync token increment " + expectedIncrement + ", but it was " + (currentSyncToken - lastSyncToken)); } lastSyncToken = currentSyncToken; } @@ -537,5 +513,4 @@ protected void dumpLdap() throws DirectoryException { display("LDAP server tree", openDJController.dumpTree()); } - } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java index 4dbbb05433f..63c7327a3f1 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/TestLdapVirtualGroup.java @@ -192,7 +192,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -207,18 +206,17 @@ public void test000Sanity() throws Exception { @Test public void test090AddItRoleHR() throws Exception { final String TEST_NAME = "test090AddItRoleHR"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("recompute role "+ROLE_IT_HR_NAME); modelService.recompute(RoleType.class, ROLE_IT_HR_OID, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -236,19 +234,18 @@ public void test090AddItRoleHR() throws Exception { @Test public void test100AddItDevRole() throws Exception { final String TEST_NAME = "test100AddItDevRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject roleBefore = createLdapRole(ROLE_IT_DEV_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding role", roleBefore); addObject(roleBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -265,19 +262,18 @@ public void test100AddItDevRole() throws Exception { @Test public void test110AddItOpRole() throws Exception { final String TEST_NAME = "test100AddItOpRole"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject roleBefore = createLdapRole(ROLE_IT_OP_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding role", roleBefore); addObject(roleBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -294,7 +290,6 @@ public void test110AddItOpRole() throws Exception { @Test public void test200CreateUsers() throws Exception { final String TEST_NAME = "test200CreateUsers"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -304,7 +299,7 @@ public void test200CreateUsers() throws Exception { PrismObject user3Before = createUser(USER_3_NAME, "givenName3", "familyName3", true); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user0", user0Before); addObject(user0Before, task, result); display("Adding user1", user1Before); @@ -315,7 +310,7 @@ public void test200CreateUsers() throws Exception { addObject(user3Before, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -339,19 +334,18 @@ public void test200CreateUsers() throws Exception { public void test210AssignItHrRoleToUser0() throws Exception { final String TEST_NAME = "test210AssignItHrRoleToUser0"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject user0Before = getObjectByName(UserType.class, USER_0_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user0Before: ", user0Before); assignRole(user0Before.getOid(), ROLE_IT_HR_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -371,19 +365,18 @@ public void test210AssignItHrRoleToUser0() throws Exception { public void test220AssignItDevRoleToUser1() throws Exception { final String TEST_NAME = "test220AssignItDevRoleToUser1"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); PrismObject user1Before = getObjectByName(UserType.class, USER_1_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user1Before: ", user1Before); assignRole(user1Before.getOid(), roleItDevOid); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -403,7 +396,6 @@ public void test220AssignItDevRoleToUser1() throws Exception { public void test230AssignJobRoleToUser2() throws Exception { final String TEST_NAME = "test230AssignJobRoleToUser2"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -412,12 +404,12 @@ public void test230AssignJobRoleToUser2() throws Exception { PrismObject user2Before = getObjectByName(UserType.class, USER_2_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user2Before: ", user2Before); assignRole(user2Before.getOid(), ROLE_JOB_DEVOPS_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -439,7 +431,6 @@ public void test230AssignJobRoleToUser2() throws Exception { public void test240AssignJobRoleMultiJobToUser3() throws Exception { final String TEST_NAME = "test230AssignJobRoleMultiJobToUser3"; - TestUtil.displayTestTitle(this, TEST_NAME); Task task = taskManager.createTaskInstance(TestLdapVirtualGroup.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); @@ -448,12 +439,12 @@ public void test240AssignJobRoleMultiJobToUser3() throws Exception { PrismObject user3Before = getObjectByName(UserType.class, USER_3_NAME); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("user3Before: ", user3Before); assignRole(user3Before.getOid(), ROLE_JOB_MULTIJOBS_OID); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java index b37859774be..7cc6a954121 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/ldap/hierarchy/AbstractLdapHierarchyTest.java @@ -7,12 +7,10 @@ package com.evolveum.midpoint.testing.story.ldap.hierarchy; - import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import java.io.File; - import javax.xml.namespace.QName; import org.opends.server.types.DirectoryException; @@ -37,33 +35,16 @@ import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.ldap.AbstractLdapTest; -import com.evolveum.midpoint.util.exception.CommonException; -import com.evolveum.midpoint.util.exception.CommunicationException; -import com.evolveum.midpoint.util.exception.ConfigurationException; -import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; -import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.PolicyViolationException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SecurityViolationException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.util.exception.*; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; /** * Common superclass for LDAP hierarchy tests TestLdapFlat, TestLdapNested * * @author Radovan Semancik - * */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractLdapHierarchyTest extends AbstractLdapTest { @@ -134,7 +115,7 @@ protected void startResources() throws Exception { } @AfterClass - public static void stopResources() throws Exception { + public static void stopResources() { openDJController.stop(); } @@ -142,7 +123,6 @@ public static void stopResources() throws Exception { public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); - // Resources resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, getResourceOpenDjFile(), RESOURCE_OPENDJ_OID, initTask, initResult); resourceOpenDjType = resourceOpenDj.asObjectable(); @@ -158,7 +138,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(AbstractLdapHierarchyTest.class.getName() + "." + TEST_NAME); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); @@ -170,20 +149,18 @@ public void test000Sanity() throws Exception { @Test public void test100AddOrgRoyulaCarpathia() throws Exception { - final String TEST_NAME = "test100AddOrgRoyulaCarpathia"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -199,21 +176,19 @@ public void test100AddOrgRoyulaCarpathia() throws Exception { @Test public void test110AddUserTeleke() throws Exception { - final String TEST_NAME = "test110AddUserTeleke"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_TELEKE_USERNAME, USER_TELEKE_GIVEN_NAME, USER_TELEKE_FAMILY_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -230,20 +205,18 @@ public void test110AddUserTeleke() throws Exception { @Test public void test200AddOrgCortuvHrad() throws Exception { - final String TEST_NAME = "test200AddOrgCortuvHrad"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -260,21 +233,19 @@ public void test200AddOrgCortuvHrad() throws Exception { @Test public void test210AddUserGorc() throws Exception { - final String TEST_NAME = "test210AddUserGorc"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_GORC_USERNAME, USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -287,20 +258,18 @@ public void test210AddUserGorc() throws Exception { @Test public void test220AddOrgVysneVlkodlaky() throws Exception { - final String TEST_NAME = "test220AddOrgVysneVlkodlaky"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_VYSNE_VLKODLAKY_NAME, orgCortuvHradOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -317,21 +286,19 @@ public void test220AddOrgVysneVlkodlaky() throws Exception { @Test public void test230AddUserViljaDezi() throws Exception { - final String TEST_NAME = "test230AddUserViljaDezi"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_DEZI_USERNAME, USER_DEZI_GIVEN_NAME, USER_DEZI_FAMILY_NAME, orgVysneVlkodlakyOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding user", userBefore); addObject(userBefore, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -343,20 +310,18 @@ public void test230AddUserViljaDezi() throws Exception { @Test public void test300RenameOrgCortuvHrad() throws Exception { - final String TEST_NAME = "test300RenameOrgCortuvHrad"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_CORTUV_HRAD_NAME, orgRolyulaCarpathiaOid); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); modifyObjectReplaceProperty(OrgType.class, orgCortuvHradOid, OrgType.F_NAME, task, result, new PolyString(ORG_CORTUV_HRAD_NAME2)); // THEN - TestUtil.displayThen(TEST_NAME); + then(); result.computeStatus(); TestUtil.assertSuccess(result); @@ -377,19 +342,18 @@ public void test300RenameOrgCortuvHrad() throws Exception { @Test public void test310RenameUserGorc() throws Exception { final String TEST_NAME = "test310RenameUserGorc"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = createUser(USER_GORC_USERNAME, USER_GORC_GIVEN_NAME, USER_GORC_FAMILY_NAME, orgCortuvHradOid); // WHEN - displayWhen(TEST_NAME); + when(); modifyObjectReplaceProperty(UserType.class, userGorcOid, UserType.F_NAME, task, result, new PolyString(USER_GORC_USERNAME2)); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -401,19 +365,18 @@ public void test310RenameUserGorc() throws Exception { @Test public void test320AddOrgRoyulaDiabolica() throws Exception { final String TEST_NAME = "test320AddOrgRoyulaDiabolica"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = createOrg(ORG_ROYULA_DIABOLICA_NAME, ORG_TOP_OID); // WHEN - displayWhen(TEST_NAME); + when(); display("Adding org", orgBefore); addObject(orgBefore, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -431,16 +394,15 @@ public void test320AddOrgRoyulaDiabolica() throws Exception { @Test public void test322MoveOrgZblo() throws Exception { final String TEST_NAME = "test322MoveOrgZblo"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject orgBefore = getOrg(ORG_CORTUV_HRAD_NAME2); ObjectDelta delta = orgBefore.createModifyDelta(); PrismContainerValue oldAssignment = null; - for (PrismContainerValue aval: orgBefore.findContainer(OrgType.F_ASSIGNMENT).getValues()) { - oldAssignment = (PrismContainerValue)aval; + for (PrismContainerValue aval : orgBefore.findContainer(OrgType.F_ASSIGNMENT).getValues()) { + oldAssignment = (PrismContainerValue) aval; if (OrgType.COMPLEX_TYPE.equals(oldAssignment.asContainerable().getTargetRef().getType())) { break; } @@ -452,13 +414,13 @@ public void test322MoveOrgZblo() throws Exception { delta.addModificationAddContainer(OrgType.F_ASSIGNMENT, newAssignmentType); // WHEN - displayWhen(TEST_NAME); + when(); - display("Modifying "+orgBefore+"with delta", delta); + display("Modifying " + orgBefore + "with delta", delta); modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); assertSuccess(result); dumpOrgTree(); @@ -482,7 +444,7 @@ public void test322MoveOrgZblo() throws Exception { assertSubOrgs(orgVysneVlkodlakyOid, 0); } - protected void recomputeIfNeeded(String changedOrgOid) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { + protected void recomputeIfNeeded(String changedOrgOid) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { // nothing to do by default } @@ -527,17 +489,19 @@ private PrismObject createOrg(String name, String parentOrgOid) throws return org; } - protected PrismObject getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException { + protected PrismObject getAndAssertUser( + String username, String directOrgGroupname, String... indirectGroupNames) + throws CommonException, DirectoryException { PrismObject user = findUserByUsername(username); display("user", user); String shadowOid = getLinkRefOid(user, RESOURCE_OPENDJ_OID, ShadowKindType.ACCOUNT, SchemaConstants.INTENT_DEFAULT); PrismObject accountShadow = getShadowModel(shadowOid); - display("Account "+username+" shadow", accountShadow); + display("Account " + username + " shadow", accountShadow); // TODO assert shadow content - Entry accountEntry = openDJController.searchSingle("uid="+username); - assertNotNull("No account LDAP entry for "+username, accountEntry); + Entry accountEntry = openDJController.searchSingle("uid=" + username); + assertNotNull("No account LDAP entry for " + username, accountEntry); display("account entry", openDJController.toHumanReadableLdifoid(accountEntry)); openDJController.assertObjectClass(accountEntry, "inetOrgPerson"); @@ -552,11 +516,11 @@ protected PrismObject getAndAssertFunctionalOrg(String orgName, String String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, LDAP_GROUP_INTENT); PrismObject groupShadow = getShadowModel(groupOid); - display("Org "+orgName+" group shadow", groupShadow); + display("Org " + orgName + " group shadow", groupShadow); // TODO assert shadow content - Entry groupEntry = openDJController.searchSingle("cn="+orgName); - assertNotNull("No group LDAP entry for "+orgName, groupEntry); + Entry groupEntry = openDJController.searchSingle("cn=" + orgName); + assertNotNull("No group LDAP entry for " + orgName, groupEntry); display("OU GROUP entry", openDJController.toHumanReadableLdifoid(groupEntry)); openDJController.assertObjectClass(groupEntry, "groupOfUniqueNames"); @@ -568,8 +532,8 @@ protected PrismObject getAndAssertFunctionalOrg(String orgName, String protected PrismObject getOrg(String orgName) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject org = findObjectByName(OrgType.class, orgName); - assertNotNull("The org "+orgName+" is missing!", org); - display("Org "+orgName, org); + assertNotNull("The org " + orgName + " is missing!", org); + display("Org " + orgName, org); PrismAsserts.assertPropertyValue(org, OrgType.F_NAME, PrismTestUtil.createPolyString(orgName)); return org; } @@ -583,7 +547,6 @@ protected void dumpLdap() throws DirectoryException { display("LDAP server content", openDJController.dumpEntries()); } - protected void assertGroupMembers(PrismObject org, String... members) throws Exception { String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group"); PrismObject groupShadow = getShadowModel(groupOid); @@ -597,13 +560,13 @@ protected void assertNoGroupMembers(PrismObject org) throws Exception { } protected void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllUsers"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { try { - display("reconciling "+object); + display("reconciling " + object); reconcileUser(object.getOid(), task, parentResult); } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException @@ -618,13 +581,13 @@ public boolean handle(PrismObject object, OperationResult parentResult } protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { - final Task task = createTask("reconcileAllOrgs"); + final Task task = getTestTask(); OperationResult result = task.getResult(); ResultHandler handler = new ResultHandler() { @Override public boolean handle(PrismObject object, OperationResult parentResult) { try { - display("reconciling "+object); + display("reconciling " + object); reconcileOrg(object.getOid(), task, parentResult); } catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java index 88c9c170ccf..12072fbb84f 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/AbstractNotoriousTest.java @@ -35,8 +35,6 @@ import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.testing.story.CountingInspector; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; @@ -90,8 +88,6 @@ public abstract class AbstractNotoriousTest extends AbstractStoryTest { protected static final String ROLE_LEVEL_B_ROLETYPE = "levelB"; protected static final String ROLE_LEVEL_B_OID_FORMAT = "00000000-0000-ffff-2b00-000000%06d"; - private static final Trace LOGGER = TraceManager.getTrace(AbstractNotoriousTest.class); - protected CountingInspector inspector; protected abstract String getNotoriousOid(); @@ -138,7 +134,7 @@ protected void fillLevelBRole(RoleType roleType, int i) { .roleType(ROLE_LEVEL_B_ROLETYPE); } - protected void fillNotorious(AbstractRoleType roleType) throws Exception { + protected void fillNotorious(AbstractRoleType roleType) { for(int i=0; i < NUMBER_OF_LEVEL_B_ROLES; i++) { roleType.beginInducement() .targetRef(generateRoleBOid(i), RoleType.COMPLEX_TYPE) @@ -161,9 +157,6 @@ private String generateRoleBOid(int num) { @Test public void test000Sanity() throws Exception { - final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - assertObjects(RoleType.class, NUMBER_OF_LEVEL_A_ROLES + NUMBER_OF_LEVEL_B_ROLES + NUMBER_OF_ORDINARY_ROLES + getNumberOfExtraRoles()); assertObjects(OrgType.class, getNumberOfExtraOrgs()); @@ -174,9 +167,8 @@ public void test000Sanity() throws Exception { @Test public void test100AssignRa0ToJack() throws Exception { final String TEST_NAME = "test100AssignRa0ToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -184,11 +176,11 @@ public void test100AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -211,20 +203,19 @@ public void test100AssignRa0ToJack() throws Exception { @Test public void test102RecomputeJack() throws Exception { final String TEST_NAME = "test102RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -244,9 +235,8 @@ public void test102RecomputeJack() throws Exception { @Test public void test104PreviewChangesJack() throws Exception { final String TEST_NAME = "test104PreviewChangesJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -259,11 +249,11 @@ public void test104PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -284,20 +274,19 @@ public void test104PreviewChangesJack() throws Exception { @Test public void test109UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test109UnassignRa0FromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -318,20 +307,19 @@ public void test109UnassignRa0FromJack() throws Exception { @Test public void test110Assign5ARolesToJack() throws Exception { final String TEST_NAME = "test110AssignAllARolesToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignJackARoles(5, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -351,20 +339,19 @@ public void test110Assign5ARolesToJack() throws Exception { @Test public void test112RecomputeJack() throws Exception { final String TEST_NAME = "test112RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -384,20 +371,19 @@ public void test112RecomputeJack() throws Exception { @Test public void test119Unassign5ARolesFromJack() throws Exception { final String TEST_NAME = "test119Unassign5ARolesFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignJackARoles(5, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -418,20 +404,19 @@ public void test119Unassign5ARolesFromJack() throws Exception { @Test public void test120AssignAllARolesToJack() throws Exception { final String TEST_NAME = "test120AssignAllARolesToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -451,20 +436,19 @@ public void test120AssignAllARolesToJack() throws Exception { @Test public void test122RecomputeJack() throws Exception { final String TEST_NAME = "test122RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -484,9 +468,8 @@ public void test122RecomputeJack() throws Exception { @Test public void test124PreviewChangesJack() throws Exception { final String TEST_NAME = "test124PreviewChangesJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject userBefore = getUser(USER_JACK_OID); @@ -499,11 +482,11 @@ public void test124PreviewChangesJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); ModelContext modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -524,20 +507,19 @@ public void test124PreviewChangesJack() throws Exception { @Test public void test129UnassignAllARolesFromJack() throws Exception { final String TEST_NAME = "test129UnassignAllARolesFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignJackARoles(NUMBER_OF_LEVEL_A_ROLES, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -558,9 +540,8 @@ public void test129UnassignAllARolesFromJack() throws Exception { @Test public void test130AssignRb0ToJack() throws Exception { final String TEST_NAME = "test130AssignRb0ToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -568,11 +549,11 @@ public void test130AssignRb0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -601,9 +582,8 @@ public void test130AssignRb0ToJack() throws Exception { @Test public void test132AssignRa0ToJack() throws Exception { final String TEST_NAME = "test132AssignRa0ToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -611,11 +591,11 @@ public void test132AssignRa0ToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -638,20 +618,19 @@ public void test132AssignRa0ToJack() throws Exception { @Test public void test134RecomputeJack() throws Exception { final String TEST_NAME = "test134RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -673,9 +652,8 @@ public void test134RecomputeJack() throws Exception { @Test public void test136UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test136UnassignRb0FromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -683,11 +661,11 @@ public void test136UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -710,9 +688,8 @@ public void test136UnassignRb0FromJack() throws Exception { @Test public void test138AssignRb0ToJackAgain() throws Exception { final String TEST_NAME = "test138AssignRb0ToJackAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -720,11 +697,11 @@ public void test138AssignRb0ToJackAgain() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); assignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -747,20 +724,19 @@ public void test138AssignRb0ToJackAgain() throws Exception { @Test public void test140RecomputeJackAgain() throws Exception { final String TEST_NAME = "test140RecomputeJackAgain"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -782,9 +758,8 @@ public void test140RecomputeJackAgain() throws Exception { @Test public void test142RecomputeJackAlt() throws Exception { final String TEST_NAME = "test142RecomputeJackAlt"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -792,11 +767,11 @@ public void test142RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -818,9 +793,8 @@ public void test142RecomputeJackAlt() throws Exception { @Test public void test144UnassignRa0FromJack() throws Exception { final String TEST_NAME = "test144UnassignRa0FromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -828,11 +802,11 @@ public void test144UnassignRa0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleAOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -855,9 +829,8 @@ public void test144UnassignRa0FromJack() throws Exception { @Test public void test149UnassignRb0FromJack() throws Exception { final String TEST_NAME = "test149UnassignRb0FromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -865,11 +838,11 @@ public void test149UnassignRb0FromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); unassignRole(USER_JACK_OID, generateRoleBOid(0), task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -897,9 +870,8 @@ public void test149UnassignRb0FromJack() throws Exception { @Test public void test150AssignNotoriousDefaultToJack() throws Exception { final String TEST_NAME = "test150AssignNotoriousDefaultToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -907,12 +879,12 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, true, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -940,9 +912,8 @@ public void test150AssignNotoriousDefaultToJack() throws Exception { @Test public void test152AssignNotoriousAltRelationToJack() throws Exception { final String TEST_NAME = "test152AssignNotoriousAltRelationToJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -950,12 +921,12 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, true, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -984,9 +955,8 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception { @Test public void test154RecomputeJack() throws Exception { final String TEST_NAME = "test154RecomputeJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -994,11 +964,11 @@ public void test154RecomputeJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1031,9 +1001,8 @@ protected int getTest15xRoleEvaluationIncrement() { @Test public void test156RecomputeJackAlt() throws Exception { final String TEST_NAME = "test156RecomputeJackAlt"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1041,11 +1010,11 @@ public void test156RecomputeJackAlt() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); recomputeUser(USER_JACK_OID, task, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1074,9 +1043,8 @@ public void test156RecomputeJackAlt() throws Exception { @Test public void test158UnassignNotoriousDefaultFromJack() throws Exception { final String TEST_NAME = "test156UnassignNotoriousDefaultFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1084,12 +1052,12 @@ public void test158UnassignNotoriousDefaultFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), null, task, null, null, false, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); @@ -1116,9 +1084,8 @@ protected void assertTest158RoleMembershipRef(PrismObject userAfter) { @Test public void test159UnassignNotoriousAltRelationFromJack() throws Exception { final String TEST_NAME = "test159UnassignNotoriousAltRelationFromJack"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); prepareTest(); @@ -1126,12 +1093,12 @@ public void test159UnassignNotoriousAltRelationFromJack() throws Exception { long startMillis = System.currentTimeMillis(); // WHEN - displayWhen(TEST_NAME); + when(); modifyAssignmentHolderAssignment(UserType.class, USER_JACK_OID, getNotoriousOid(), getNotoriousType(), getAltRelation(), task, null, null, false, result); // THEN - displayThen(TEST_NAME); + then(); long endMillis = System.currentTimeMillis(); assertSuccess(result); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java index 772760669e3..45bb548d52e 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestNotoriousOrg.java @@ -6,71 +6,42 @@ */ package com.evolveum.midpoint.testing.story.notorious; -import static org.testng.AssertJUnit.assertEquals; - import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - import javax.xml.namespace.QName; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; -import com.evolveum.midpoint.model.api.context.ModelContext; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.delta.ItemDelta; -import com.evolveum.midpoint.prism.delta.ObjectDelta; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.SchemaConstants; -import com.evolveum.midpoint.schema.internals.InternalInspector; -import com.evolveum.midpoint.schema.internals.InternalMonitor; import com.evolveum.midpoint.schema.result.OperationResult; -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.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.DebugDumpable; -import com.evolveum.midpoint.util.DebugUtil; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** * Testing bushy roles hierarchy. Especially reuse of the same role * in the rich role hierarchy. It looks like this: - * - * user - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Ra1 Ra2 Ra3 Ra4 Ra5 - * | | | | | - * +------+------+-----+-----+ - * | - * v - * notorious org - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Rb1 Rb2 Rb3 Rb4 Rb5 - * + *

+ * user + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Ra1 Ra2 Ra3 Ra4 Ra5 + * | | | | | + * +------+------+-----+-----+ + * | + * v + * notorious org + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Rb1 Rb2 Rb3 Rb4 Rb5 + *

* Naive mode of evaluation would imply cartesian product of all Rax and Rbx * combinations. That's painfully inefficient. Therefore make sure that the * notorious roles is evaluated only once and the results of the evaluation @@ -78,7 +49,7 @@ * * @author Radovan Semancik */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestNotoriousOrg extends AbstractNotoriousTest { @@ -128,7 +99,7 @@ protected void addNotoriousRole(OperationResult result) throws Exception { @Override protected void assertNotoriousParentOrgRefRelations(PrismObject userAfter, QName... relations) { - for (QName relation: relations) { + for (QName relation : relations) { assertHasOrg(userAfter, getNotoriousOid(), relation); } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java index 2b56951f7bf..7f2b7bb278a 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/notorious/TestSupernotoriousOrg.java @@ -6,37 +6,38 @@ */ package com.evolveum.midpoint.testing.story.notorious; -import com.evolveum.midpoint.prism.query.ObjectQuery; -import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; +import java.io.File; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; import org.testng.annotations.Test; -import java.io.File; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; /** * Testing bushy roles hierarchy. Especially reuse of the same role * in the rich role hierarchy. It looks like this: - * - * user - * | - * +------+------+-----+-----+-.... - * | | | | | - * v v v v v - * Ra1 Ra2 Ra3 Ra4 Ra5 - * | | | | | - * +------+------+-----+-----+ - * | - * v - * +--assignment--> supernotorious org - * | | - * | +------+------+-----+-----+-.... - * | | | | | | - * | v v v v v - * +-- Rb1 Rb2 Rb3 Rb4 Rb5 ---.. - * + *

+ * user + * | + * +------+------+-----+-----+-.... + * | | | | | + * v v v v v + * Ra1 Ra2 Ra3 Ra4 Ra5 + * | | | | | + * +------+------+-----+-----+ + * | + * v + * +--assignment--> supernotorious org + * | | + * | +------+------+-----+-----+-.... + * | | | | | | + * | v v v v v + * +-- Rb1 Rb2 Rb3 Rb4 Rb5 ---.. + *

* Naive mode of evaluation would imply cartesian product of all Rax and Rbx * combinations. That's painfully inefficient. Therefore make sure that the * notorious roles is evaluated only once and the results of the evaluation @@ -44,7 +45,7 @@ * * @author Radovan Semancik */ -@ContextConfiguration(locations = {"classpath:ctx-story-test-main.xml"}) +@ContextConfiguration(locations = { "classpath:ctx-story-test-main.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_CLASS) @Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) public class TestSupernotoriousOrg extends TestNotoriousOrg { @@ -65,23 +66,18 @@ protected File getNotoriousFile() { @Override protected void fillLevelBRole(RoleType roleType, int i) { super.fillLevelBRole(roleType, i); - roleType - .beginAssignment() + roleType.beginAssignment() .targetRef(getNotoriousOid(), getNotoriousType()) -// .focusType(RoleType.COMPLEX_TYPE) - .end(); + .end(); } @Test public void test010LevelBRolesSanity() throws Exception { - final String TEST_NAME = "test010LevelBRolesSanity"; - displayTestTitle(TEST_NAME); - - ObjectQuery query = queryFor(RoleType.class).item(RoleType.F_ROLE_TYPE).eq(ROLE_LEVEL_B_ROLETYPE).build(); + ObjectQuery query = queryFor(RoleType.class) + .item(RoleType.F_ROLE_TYPE).eq(ROLE_LEVEL_B_ROLETYPE) + .build(); searchObjectsIterative(RoleType.class, query, - role -> { - assertRoleMembershipRef(role, getNotoriousOid()); - }, NUMBER_OF_LEVEL_B_ROLES); + role -> assertRoleMembershipRef(role, getNotoriousOid()), NUMBER_OF_LEVEL_B_ROLES); } @Override diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java index bdc63bb74b4..de0a4585da6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/perf/TestImport.java @@ -110,7 +110,6 @@ protected void importSystemTasks(OperationResult initResult) { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestImport.class.getName() + "." + TEST_NAME); OperationResult testResultHr = modelService.testResource(RESOURCE_SOURCE_OID, task); @@ -124,16 +123,15 @@ public void test000Sanity() throws Exception { @Test public void test100RunImport() throws Exception { final String TEST_NAME = "test100RunImport"; - displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestImport.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // WHEN - TestUtil.displayWhen(TEST_NAME); + when(); importObjectFromFile(TASK_IMPORT_FILE, result); // THEN - TestUtil.displayThen(TEST_NAME); + then(); long lastProfilingStarted = 0; long start = System.currentTimeMillis(); for (;;) { diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java index 4a28155092a..1d32777e2bd 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestPrivacy.java @@ -73,14 +73,13 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test100AutzJackReadSearch() throws Exception { final String TEST_NAME = "test100AutzJackReadSearch"; - displayTestTitle(TEST_NAME); assignRole(USER_JACK_OID, ROLE_PRIVACY_END_USER_OID); login(USER_JACK_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); assertGetAllow(UserType.class, USER_GUYBRUSH_OID); assertGetAllow(UserType.class, USER_ELAINE_OID); @@ -90,7 +89,7 @@ public void test100AutzJackReadSearch() throws Exception { USER_ADMINISTRATOR_OID, USER_GUYBRUSH_OID, USER_ELAINE_OID, USER_JACK_OID); // THEN - displayThen(TEST_NAME); + then(); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java index b47140cf67f..2667cb20ab3 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/security/TestRoleMembers.java @@ -40,7 +40,6 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; /** @@ -87,10 +86,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); // WHEN - displayWhen(TEST_NAME); + when(); assertUserBefore(USER_GUYBRUSH_OID) .assertName(USER_GUYBRUSH_USERNAME) @@ -126,7 +124,7 @@ public void test000Sanity() throws Exception { assertFalse("Preview evaluated assignment triple is empty", evaluatedAssignmentTriple.isEmpty()); // THEN - displayThen(TEST_NAME); + then(); } @@ -136,12 +134,11 @@ public void test000Sanity() throws Exception { @Test public void test100AutzGuybrushNoMembers() throws Exception { final String TEST_NAME = "test100AutzGuybrushNoMembers"; - displayTestTitle(TEST_NAME); login(USER_GUYBRUSH_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -173,12 +170,12 @@ public void test100AutzGuybrushNoMembers() throws Exception { assertNull("Preview evaluated assignment triple sneaked in", evaluatedAssignmentTriple); // THEN - displayThen(TEST_NAME); + then(); } private ModelContext previewUser(String userOid) throws SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectNotFoundException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException { - Task task = createTask("previewUser"); + Task task = getTestTask(); OperationResult result = task.getResult(); ObjectDelta emptyMancombDelta = deltaFor(UserType.class).asObjectDelta(userOid); ModelContext previewContext = modelInteractionService.previewChanges(Collections.singleton(emptyMancombDelta), null, task, result); @@ -197,12 +194,11 @@ private ModelContext previewUser(String userOid) throws SchemaExceptio @Test public void test105AutzElaineMembers() throws Exception { final String TEST_NAME = "test105AutzElaineMembers"; - displayTestTitle(TEST_NAME); login(USER_ELAINE_USERNAME); // WHEN - displayWhen(TEST_NAME); + when(); PrismObject userMancomb = assertGetAllow(UserType.class, USER_MANCOMB_OID); assertUser(userMancomb, "mancomb") @@ -222,7 +218,7 @@ public void test105AutzElaineMembers() throws Exception { .assertRoleMemberhipRefs(1); // THEN - displayThen(TEST_NAME); + then(); } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java index 3e4441c70bc..a8d9e8a11b6 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/AbstractUuidTest.java @@ -7,23 +7,17 @@ */ import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; -import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; import com.evolveum.midpoint.testing.story.AbstractStoryTest; -import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.opends.server.types.DirectoryException; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -93,8 +87,7 @@ protected File getSystemConfigurationFile() { @Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task); TestUtil.assertSuccess(testResultOpenDj); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java index 91c5f683226..802a7e30ca0 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidClient.java @@ -9,13 +9,10 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -24,7 +21,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -102,8 +98,7 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createNoNameUser(USER_RAPP_GIVEN_NAME, USER_RAPP_FAMILY_NAME, true); @@ -123,8 +118,7 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleClient() throws Exception { final String TEST_NAME = "test101RappAssignRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -144,8 +138,7 @@ public void test101RappAssignRoleClient() throws Exception { @Test public void test107RappUnAssignRoleClient() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN unassignRole(userRappOid, ROLE_CLIENT_OID); @@ -159,8 +152,7 @@ public void test107RappUnAssignRoleClient() throws Exception { @Test public void test110AddMancombWithRoleClient() throws Exception { final String TEST_NAME = "test110AddMancombWithRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(null, null, USER_MANCOMB_GIVEN_NAME, USER_MANCOMB_FAMILY_NAME, true); @@ -184,8 +176,7 @@ public void test110AddMancombWithRoleClient() throws Exception { @Test public void test112RenameMancomb() throws Exception { final String TEST_NAME = "test112RenameMancomb"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); try { @@ -207,8 +198,7 @@ public void test112RenameMancomb() throws Exception { @Test public void test119MancombDelete() throws Exception { final String TEST_NAME = "test119MancombDelete"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -227,8 +217,7 @@ public void test119MancombDelete() throws Exception { @Test public void test120AddKateWithRoleClient() throws Exception { final String TEST_NAME = "test120AddKateWithRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(null, USER_KATE_NAME, USER_KATE_GIVEN_NAME, USER_KATE_FAMILY_NAME, true); @@ -250,8 +239,7 @@ public void test120AddKateWithRoleClient() throws Exception { @Test public void test122AddWallyWithRoleClient() throws Exception { final String TEST_NAME = "test122AddWallyWithRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_WALLY_OID, null, USER_WALLY_GIVEN_NAME, USER_WALLY_FAMILY_NAME, true); @@ -273,8 +261,7 @@ public void test122AddWallyWithRoleClient() throws Exception { @Test public void test124AddRogersWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_ROGERS_OID, USER_ROGERS_OID, USER_ROGERS_GIVEN_NAME, USER_ROGERS_FAMILY_NAME, true); @@ -296,8 +283,7 @@ public void test124AddRogersWithRoleClient() throws Exception { @Test public void test126AddMartyWithRoleClient() throws Exception { final String TEST_NAME = "test124AddMartyWithRoleClient"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createClientUser(USER_MARTY_OID, USER_MARTY_NAME, USER_MARTY_GIVEN_NAME, USER_MARTY_FAMILY_NAME, true); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java index 52026c6e59e..cd333743932 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/uuid/TestUuidExtension.java @@ -8,15 +8,9 @@ import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismReferenceValue; -import com.evolveum.midpoint.prism.path.ItemPath; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.IntegrationTestTools; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.test.util.TestUtil; -import com.evolveum.midpoint.testing.story.AbstractStoryTest; import com.evolveum.midpoint.util.exception.*; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -24,8 +18,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterClass; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -82,8 +74,7 @@ protected File getSystemConfigurationFile() { @Test public void test100AddUserRapp() throws Exception { final String TEST_NAME = "test100AddUserRapp"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createUser(USER_RAPP_NAME, USER_RAPP_GIVEN_NAME, USER_RAPP_FAMILY_NAME, true); @@ -103,8 +94,7 @@ public void test100AddUserRapp() throws Exception { @Test public void test101RappAssignRoleEmployee() throws Exception { final String TEST_NAME = "test101RappAssignRoleEmployee"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); // WHEN @@ -123,8 +113,7 @@ public void test101RappAssignRoleEmployee() throws Exception { @Test public void test107RappUnAssignRoleEmployee() throws Exception { final String TEST_NAME = "test107RappUnAssignRoleEmployee"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); // WHEN unassignRole(userRappOid, ROLE_EMPLOYEE_OID); @@ -141,8 +130,7 @@ public void test107RappUnAssignRoleEmployee() throws Exception { @Test public void test110AddKateWithRoleEmployee() throws Exception { final String TEST_NAME = "test110AddKateWithRoleEmployee"; - displayTestTitle(TEST_NAME); - Task task = createTask(TEST_NAME); + Task task = getTestTask(); OperationResult result = task.getResult(); PrismObject user = createEmployeeUser(USER_KATE_NAME, USER_KATE_GIVEN_NAME, USER_KATE_FAMILY_NAME, true); diff --git a/testing/story/testng-unit.xml b/testing/story/testng-unit.xml deleted file mode 100644 index 136f8aa1e9b..00000000000 --- a/testing/story/testng-unit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/tools/midpoint-war-layout/pom.xml b/tools/midpoint-war-layout/pom.xml index 0e9be1cd833..bb37d0b6f23 100644 --- a/tools/midpoint-war-layout/pom.xml +++ b/tools/midpoint-war-layout/pom.xml @@ -19,6 +19,8 @@ midpoint-war-layout + midPoint Tools - WAR layout + true diff --git a/tools/ninja/pom.xml b/tools/ninja/pom.xml index 4c42688624c..f638b9e12dc 100644 --- a/tools/ninja/pom.xml +++ b/tools/ninja/pom.xml @@ -20,7 +20,7 @@ ninja jar - ninja + midPoint Tools - Ninja ${project.version} diff --git a/tools/schrodinger/pom.xml b/tools/schrodinger/pom.xml index e2b5d976daf..52531f29beb 100644 --- a/tools/schrodinger/pom.xml +++ b/tools/schrodinger/pom.xml @@ -21,7 +21,7 @@ 4.1-SNAPSHOT jar - schrodinger + midPoint Tools - Schrodinger true diff --git a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java index 5c1858a662a..edf76f714ac 100644 --- a/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java +++ b/tools/schrodinger/src/main/java/com/evolveum/midpoint/schrodinger/component/configuration/ClockTab.java @@ -7,6 +7,7 @@ package com.evolveum.midpoint.schrodinger.component.configuration; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.Component; @@ -36,10 +37,12 @@ public void changeTime(String date, String hours, String minutes, AmOrPmChoice a SelenideElement hoursEle = findHours(); hoursEle.doubleClick(); + hoursEle.doubleClick(); hoursEle.sendKeys(hours); SelenideElement minutesEle = findMinutes(); minutesEle.doubleClick(); + minutesEle.doubleClick(); minutesEle.sendKeys(minutes); SelenideElement amOrPmChoiceEle = findAmOrPmChoice(); diff --git a/tools/test-ng/pom.xml b/tools/test-ng/pom.xml index d156cee451f..e3a842e2bae 100644 --- a/tools/test-ng/pom.xml +++ b/tools/test-ng/pom.xml @@ -18,7 +18,7 @@ test-ng jar - midPoint Infrastructure - testing support tools + midPoint Tools - testing utils (lvl 1) true @@ -29,5 +29,13 @@ org.testng testng + + org.slf4j + slf4j-api + + + org.jetbrains + annotations + diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java new file mode 100644 index 00000000000..1437c01a8a1 --- /dev/null +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/AbstractUnitTest.java @@ -0,0 +1,47 @@ +/* + * 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.tools.testng; + +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +/** + * Base test class providing basic {@link MidpointTestMixin} implementation. + * Can be extended by any unit test class that otherwise doesn't extend anything. + */ +public abstract class AbstractUnitTest implements MidpointTestMixin { + + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + @BeforeMethod + public void startTestContext(ITestResult testResult) { + SimpleMidpointTestContext context = SimpleMidpointTestContext.create(testResult); + displayTestTitle(context.getTestName()); + } + + @AfterMethod + public void finishTestContext(ITestResult testResult) { + SimpleMidpointTestContext context = SimpleMidpointTestContext.get(); + SimpleMidpointTestContext.destroy(); + displayDefaultTestFooter(context.getTestName(), testResult); + } + + @Override + @Nullable + public MidpointTestContext getTestContext() { + return SimpleMidpointTestContext.get(); + } + + @Override + public Logger logger() { + return logger; + } +} diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestContext.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestContext.java new file mode 100644 index 00000000000..47b9e00d3fd --- /dev/null +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestContext.java @@ -0,0 +1,38 @@ +package com.evolveum.midpoint.tools.testng; + +/** + * Basic contract for test-method context (typically available through thread-local variable). + */ +public interface MidpointTestContext { + + /** + * Returns the actual instantiated test class. + */ + Class getTestClass(); + + /** + * Returns the name of the test method. + */ + String getTestMethodName(); + + /** + * Returns test name in form of "class-simple-name.method". + */ + default String getTestName() { + return getTestClass().getSimpleName() + "." + getTestMethodName(); + } + + /** + * Returns short test name - currently the same like {@link #getTestMethodName()}. + */ + default String getTestNameShort() { + return getTestMethodName(); + } + + /** + * Returns long test name in form of "fully.qualified.class-name.method". + */ + default String getTestNameLong() { + return getTestClass().getName() + "." + getTestMethodName(); + } +} diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestMixin.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestMixin.java new file mode 100644 index 00000000000..b61ead2766a --- /dev/null +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/MidpointTestMixin.java @@ -0,0 +1,182 @@ +/* + * 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.tools.testng; + +import java.util.Objects; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.testng.ITestResult; + +/** + * Mixin with various utility methods, mostly related to test header/footer/section output/logging. + */ +public interface MidpointTestMixin { + + String TEST_LOG_PREFIX = "=====[ "; + String TEST_LOG_SUFFIX = " ]======================================"; + String TEST_OUT_PREFIX = "\n\n=====[ "; + String TEST_OUT_SUFFIX = " ]======================================\n"; + String TEST_OUT_FOOTER_PREFIX = "====== "; + String TEST_OUT_FOOTER_SUFFIX = "\n"; + String TEST_OUT_SECTION_PREFIX = "\n\n----- "; + String TEST_OUT_SECTION_SUFFIX = " --------------------------------------\n"; + String TEST_LOG_SECTION_PREFIX = "----- "; + String TEST_LOG_SECTION_SUFFIX = " --------------------------------------"; + + /** + * Context name is {@link #getTestName()} if test method context is available, + * otherwise it is just a simple name of the test class. + *

+ * This is particularly useful for code that may run outside of test method scope + * or in another thread where context is not available. + */ + @NotNull + default String contextName() { + MidpointTestContext context = getTestContext(); + return context != null + ? context.getTestName() + : getClass().getSimpleName(); + } + + /** + * Returns {@link MidpointTestContext#getTestName()}. + * This fails if test-method context is not available. + */ + default String getTestName() { + return testContext().getTestName(); + } + + /** + * Returns {@link MidpointTestContext#getTestNameShort()}. + * This fails if test-method context is not available. + */ + default String getTestNameShort() { + return testContext().getTestNameShort(); + } + + /** + * Returns {@link MidpointTestContext#getTestNameLong()}. + * This fails if test-method context is not available. + */ + default String getTestNameLong() { + return testContext().getTestNameLong(); + } + + /** + * Returns test class logger. + */ + Logger logger(); + + /** + * Returns {@link MidpointTestContext} from current test-method context + * or {@code null} if context is not available - it should not fail. + *

+ * This method should be implemented by supporting classes, but not used in tests in general. + * It is used for default implementations of various testName*() methods. + */ + @Nullable MidpointTestContext getTestContext(); + + @Deprecated + @NotNull + // TODO switch to private after ditching JDK 8, DON'T USE/DON'T OVERRIDE! + /*private*/ default MidpointTestContext testContext() { + return Objects.requireNonNull(getTestContext(), + "Current test-method context MUST NOT be null"); + } + + default void displayTestTitle(String testTitle) { + System.out.println(TEST_OUT_PREFIX + testTitle + TEST_OUT_SUFFIX); + logger().info(TEST_LOG_PREFIX + testTitle + TEST_LOG_SUFFIX); + } + + default void displayDefaultTestFooter(String testTitle, ITestResult testResult) { + long testMsDuration = testResult.getEndMillis() - testResult.getStartMillis(); + System.out.println(TEST_OUT_FOOTER_PREFIX + testTitle + " FINISHED in " + testMsDuration + " ms" + TEST_OUT_FOOTER_SUFFIX); + logger().info(TEST_LOG_PREFIX + testTitle + " FINISHED in " + testMsDuration + " ms" + TEST_LOG_SUFFIX); + } + + /** + * Displays "given" subsection header with test name. + * Even better, use {@link #given(String)} and provide human readable description. + */ + default void given() { + given(null); + } + + /** + * Displays "given" subsection header with test name and provided description (nullable). + */ + default void given(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": GIVEN " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": GIVEN " + description + TEST_LOG_SECTION_SUFFIX); + } + + /** + * Displays "when" subsection header with test name. + * Even better, use {@link #when(String)} and provide human readable description. + */ + default void when() { + when(null); + } + + /** + * Displays "when" subsection header with test name and provided description (nullable). + */ + default void when(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": WHEN " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": WHEN " + description + TEST_LOG_SECTION_SUFFIX); + } + + /** + * Displays "then" subsection header with test name. + * Even better, use {@link #then(String)} and provide human readable description. + */ + default void then() { + then(null); + } + + /** + * Displays "then" subsection header with test name and provided description (nullable). + */ + default void then(String description) { + String testName = getTestNameShort(); + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": THEN " + description); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": THEN " + description); + } + + /** + * Displays "expect" subsection header with test name. + * Even better, use {@link #expect(String)} and provide human readable description. + */ + default void expect() { + expect(null); + } + + /** + * Displays "expect" subsection header with test name and provided description (nullable). + * This is for tests with simpler given-expect structure. + * In other words, if "when" and "then" can't be clearly separated, we want "expect". + */ + default void expect(String description) { + String testName = getTestNameShort(); + if (description == null) { + description = ""; + } + System.out.println(TEST_OUT_SECTION_PREFIX + testName + ": EXPECT " + description + TEST_OUT_SECTION_SUFFIX); + logger().info(TEST_LOG_SECTION_PREFIX + testName + ": EXPECT " + description + TEST_LOG_SECTION_SUFFIX); + } +} diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/SimpleMidpointTestContext.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/SimpleMidpointTestContext.java new file mode 100644 index 00000000000..3f234a14d69 --- /dev/null +++ b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/SimpleMidpointTestContext.java @@ -0,0 +1,39 @@ +package com.evolveum.midpoint.tools.testng; + +import org.testng.ITestResult; + +public class SimpleMidpointTestContext implements MidpointTestContext { + + private static final ThreadLocal TEST_CONTEXT_THREAD_LOCAL = + new ThreadLocal<>(); + + private final ITestResult testResult; + + public SimpleMidpointTestContext(ITestResult testResult) { + this.testResult = testResult; + } + + @Override + public Class getTestClass() { + return testResult.getMethod().getTestClass().getRealClass(); + } + + @Override + public String getTestMethodName() { + return testResult.getMethod().getMethodName(); + } + + public static SimpleMidpointTestContext create(ITestResult testResult) { + SimpleMidpointTestContext ctx = new SimpleMidpointTestContext(testResult); + TEST_CONTEXT_THREAD_LOCAL.set(ctx); + return ctx; + } + + public static SimpleMidpointTestContext get() { + return TEST_CONTEXT_THREAD_LOCAL.get(); + } + + public static void destroy() { + TEST_CONTEXT_THREAD_LOCAL.remove(); + } +} diff --git a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java b/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java deleted file mode 100644 index 7ca441f8508..00000000000 --- a/tools/test-ng/src/main/java/com/evolveum/midpoint/tools/testng/TestMethodLoggerListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2010-2014 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.tools.testng; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.testng.IConfigurationListener; -import org.testng.IInvokedMethod; -import org.testng.IInvokedMethodListener; -import org.testng.ITestResult; - -/** - * Created by IntelliJ IDEA. - * User: mamut - * Date: 22.11.2011 - * Time: 16:13 - * To change this template use File | Settings | File Templates. - */ -public class TestMethodLoggerListener implements IInvokedMethodListener, IConfigurationListener { - - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - - @Override - public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { - System.out.println(DATE_FORMAT.format(new Date())); - System.out.println("----[ TestNG running method: " + method.getTestMethod().toString() + " ("+testResult+") ]----"); - } - - @Override - public void afterInvocation(IInvokedMethod method, ITestResult testResult) { - System.out.println(DATE_FORMAT.format(new Date())); - System.out.println("----[ TestNG finished method : " + method.getTestMethod().toString() + " Result: " + (testResult.isSuccess() ? "PASS" : "FAIL")+" ]----"); - } - - @Override - public void onConfigurationFailure(ITestResult res) { - System.out.println("--- TestNG configuration failure : " + res.getTestName()); - } - - @Override - public void onConfigurationSkip(ITestResult res) { - System.out.println("--- TestNG configuration skip : " + res.getTestName()); - } - - @Override - public void onConfigurationSuccess(ITestResult res) { - System.out.println("--- TestNG configuration success : " + res.getTestName()); - } -} diff --git a/tools/xjc-plugin/pom.xml b/tools/xjc-plugin/pom.xml index 650ab3003bb..f1a126aabf5 100644 --- a/tools/xjc-plugin/pom.xml +++ b/tools/xjc-plugin/pom.xml @@ -18,7 +18,7 @@ xjc-plugin jar - midPoint Infrastructure - xjc plugin + midPoint Tools - xjc plugin true