Skip to content

Commit

Permalink
fixes of test initialization with new repo (OID/UUID mostly)
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Sep 22, 2021
1 parent 58e248b commit fb36c83
Show file tree
Hide file tree
Showing 23 changed files with 408 additions and 405 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -52,10 +52,10 @@ public abstract class AbstractTestObjectLifecycleApproval extends AbstractWfTest
static final File TEST_RESOURCE_DIR = new File("src/test/resources/objects");

private static final File USER_PIRATE_OWNER_FILE = new File(TEST_RESOURCE_DIR, "user-pirate-owner.xml");
private static final String USER_PIRATE_OWNER_OID = "00000001-d34d-b33f-f00d-POWNER000001";
private static final String USER_PIRATE_OWNER_OID = "00000001-d34d-b33f-f00d-504f574e4552";

private static final File USER_JUDGE_OWNER_FILE = new File(TEST_RESOURCE_DIR, "user-judge-owner.xml");
static final String USER_JUDGE_OWNER_OID = "00000001-d34d-b33f-f00d-JOWNER000001";
static final String USER_JUDGE_OWNER_OID = "00000001-d34d-b33f-f00d-4a4f574e4552";

private static final File USER_JUPITER_FILE = new File(TEST_RESOURCE_DIR, "user-jupiter.xml");
static final String USER_JUPITER_OID = "9ab1cabd-2455-490e-9844-79dfa3efa849";
Expand Down Expand Up @@ -167,7 +167,8 @@ private void createObject(
ObjectType object, boolean immediate, boolean approve, String assigneeOid)
throws Exception {
//noinspection unchecked
ObjectDelta<RoleType> addObjectDelta = DeltaFactory.Object.createAddDelta((PrismObject) object.asPrismObject());
ObjectDelta<RoleType> addObjectDelta =
DeltaFactory.Object.createAddDelta((PrismObject<RoleType>) object.asPrismObject());

executeTest(new TestDetails() {
@Override
Expand Down Expand Up @@ -243,11 +244,8 @@ protected LensContext createModelContext(OperationResult result) throws Exceptio
protected void afterFirstClockworkRun(CaseType rootCase,
CaseType case0, List<CaseType> subcases,
List<CaseWorkItemType> workItems,
Task opTask, OperationResult result) throws Exception {
Task opTask, OperationResult result) {
if (!immediate) {
// ModelContext taskModelContext = temporaryHelper.getModelContext(rootCase, opTask, result);
// ObjectDelta realDelta0 = taskModelContext.getFocusContext().getPrimaryDelta();
// assertDeltasEqual("Wrong delta left as primary focus delta.", expectedDelta0, realDelta0);
assertDelta1NotExecuted.run();
assertWfContextAfterClockworkRun(rootCase, subcases, workItems,
objectDelta.getOid(), expectedTasks, expectedWorkItems);
Expand Down Expand Up @@ -301,11 +299,8 @@ protected LensContext createModelContext(OperationResult result) throws Exceptio
protected void afterFirstClockworkRun(CaseType rootCase,
CaseType case0, List<CaseType> subcases,
List<CaseWorkItemType> workItems,
Task opTask, OperationResult result) throws Exception {
Task opTask, OperationResult result) {
if (!immediate) {
// ModelContext taskModelContext = temporaryHelper.getModelContext(rootCase, opTask, result);
// ObjectDelta realDelta0 = taskModelContext.getFocusContext().getPrimaryDelta();
// assertTrue("Delta0 is not empty: " + realDelta0.debugDump(), realDelta0.isEmpty());
assertWfContextAfterClockworkRun(rootCase, subcases, workItems,
objectOid, expectedTasks, expectedWorkItems);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 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.wf.impl.objects;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import static org.testng.AssertJUnit.assertEquals;

import static com.evolveum.midpoint.prism.util.CloneUtil.cloneCollectionMembers;
import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createAssignmentTo;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.testng.annotations.Test;

import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
Expand All @@ -24,17 +36,6 @@
import com.evolveum.midpoint.wf.impl.ExpectedTask;
import com.evolveum.midpoint.wf.impl.ExpectedWorkItem;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static com.evolveum.midpoint.prism.util.CloneUtil.cloneCollectionMembers;
import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createAssignmentTo;
import static org.testng.AssertJUnit.assertEquals;

/**
* Tests role lifecycle with global policy rules.
Expand Down Expand Up @@ -170,10 +171,10 @@ public void test510AddInducementsToJudge() throws Exception {

ObjectDelta<RoleType> judgeDelta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT)
.add(createAssignmentTo("oid1", ObjectTypes.ROLE, prismContext),
createAssignmentTo("oid2", ObjectTypes.ROLE, prismContext))
.add(createAssignmentTo("oid1", ObjectTypes.ROLE, prismContext),
createAssignmentTo("oid2", ObjectTypes.ROLE, prismContext))
.item(RoleType.F_DESCRIPTION)
.replace("hi")
.replace("hi")
.asObjectDeltaCast(roleJudgeOid);

executeTest(new TestDetails() {
Expand Down Expand Up @@ -429,7 +430,7 @@ public void test610DeleteInducementsFromCaptain() throws Exception {

ObjectDelta<RoleType> captainDelta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT)
.delete(cloneCollectionMembers(captainBefore.findContainer(RoleType.F_INDUCEMENT).getValues()))
.delete(cloneCollectionMembers(captainBefore.findContainer(RoleType.F_INDUCEMENT).getValues()))
.asObjectDeltaCast(roleCaptainOid);

executeTest(new TestDetails() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class TestApprovalTaskOwner extends AbstractWfTestPolicy {

private static final File FILE_USER_MANAGER = new File(TEST_RESOURCE_DIR, "user-manager.xml");
private static final String USER_MANAGER_NAME = "manager";
private static final String USER_MANAGER_OID = "00000000-0000-0000-mng0-000000000002";
private static final String USER_MANAGER_OID = "00000000-0000-0000-6d6e-000000000002";

private static final File FILE_ROLE_META_APPROVE_MANAGER = new File(TEST_RESOURCE_DIR, "metarole-approve-manager.xml");
private static final File FILE_ROLE_DUELLING_CLASSROOM_TEACHER = new File(TEST_RESOURCE_DIR, "role-duelling-classroom-teacher.xml");
private static final String ROLE_DUELLING_CLASSROOM_TEACHER_OID = "00000000-role-0000-0000-111111111777";
private static final String ROLE_DUELLING_CLASSROOM_TEACHER_OID = "00000000-726c-0000-0000-111111111777";

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
Expand Down Expand Up @@ -98,7 +98,7 @@ public void test110approveRoleJack() throws Exception {
.display()
.assertArchetypeRef(SystemObjectsType.ARCHETYPE_APPROVAL_TASK.value())
.owner()
.assertOid(USER_MANAGER_OID);
.assertOid(USER_MANAGER_OID);

//assert assigned role
assertUserAfter(USER_JACK_OID).assignments().assertRole(ROLE_DUELLING_CLASSROOM_TEACHER_OID);
Expand Down Expand Up @@ -164,7 +164,7 @@ public void test310approveRoleAdministrator() throws Exception {
.display()
.assertArchetypeRef(SystemObjectsType.ARCHETYPE_APPROVAL_TASK.value())
.owner()
.assertOid(USER_ADMINISTRATOR_OID);
.assertOid(USER_ADMINISTRATOR_OID);

assertUserAfter(USER_JACK_OID).assignments().assertRole(ROLE_DUELLING_CLASSROOM_TEACHER_OID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="2dadd243-687d-4b4c-80cd-09ddfe4cbf59" version="3">

<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
oid="2dadd243-687d-4b4c-80cd-09ddfe4cbf59">

<name>metarole-approval-role-approvers-all</name>
<description>Requests to assign role holding this metarole will be approved by the role approver(s) using "all must approve" method</description>
<displayName>Metarole: approval by the role approver(s) - all must approve</displayName>
Expand All @@ -24,7 +27,7 @@
<approvalSchema>
<stage>
<name>User's manager</name>
<approverRef oid="00000000-0000-0000-0000-000000000002" type="UserType" />
<approverRef oid="00000000-0000-0000-0000-000000000002" type="UserType"/>
</stage>
</approvalSchema>
</approval>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="00000000-0000-0000-0000-00000000000a" version="9">
<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
oid="00000000-0000-0000-0000-00000000000a" version="9">

<name>Approver</name>
<description>Role authorizing users to make approval decisions on work items.</description>
<authorization id="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" oid="00000000-role-0000-0000-111111111777" version="3">

<role xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
oid="00000000-726c-0000-0000-111111111777" version="3">

<name>Duelling classroom access</name>
<assignment>
<targetRef oid="2dadd243-687d-4b4c-80cd-09ddfe4cbf59" relation="org:default" type="c:RoleType">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2021 Evolveum and contributors
~ Copyright (C) 2021 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<user oid="00000000-0000-0000-mng0-000000000002"
<user oid="00000000-0000-0000-6d6e-000000000002"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:piracy='http://midpoint.evolveum.com/xml/ns/samples/piracy'>
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>

<name>manager</name>
<assignment>
<targetRef oid="00000000-0000-0000-0000-000000000004" type="c:RoleType"/> <!-- give him the full access so we don't need to configure complex authorizations -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum and contributors
~ Copyright (C) 2010-2021 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<user oid="00000001-d34d-b33f-f00d-JOWNER000001"

<user oid="00000001-d34d-b33f-f00d-4a4f574e4552"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>
<name>judge-owner</name>
<fullName>Judge owner</fullName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum and contributors
~ Copyright (C) 2010-2021 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<user oid="00000001-d34d-b33f-f00d-POWNER000001"

<user oid="00000001-d34d-b33f-f00d-504f574e4552"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>
<name>pirate-owner</name>
<fullName>Pirate owner</fullName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.sql.SqlRepositoryServiceImpl;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
Expand All @@ -22,8 +23,8 @@ public class TestAsyncUpdateCachingIndexOnly extends TestAsyncUpdateCaching {
new File(TEST_DIR, "resource-async-caching-index-only.xml");

@Autowired
@Qualifier("repositoryService") // we're downcasting here to known subtype
private SqlRepositoryServiceImpl sqlRepositoryService;
@Qualifier("repositoryService") // we want repo implementation, not cache
private RepositoryService repositoryService;

@Override
protected File getResourceFile() {
Expand All @@ -32,11 +33,16 @@ protected File getResourceFile() {

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
// These are experimental features, so they need to be explicitly enabled. This will be eliminated later,
// when we make them enabled by default.
sqlRepositoryService.sqlConfiguration().setEnableIndexOnlyItems(true);
sqlRepositoryService.sqlConfiguration().setEnableNoFetchExtensionValuesInsertion(true);
sqlRepositoryService.sqlConfiguration().setEnableNoFetchExtensionValuesDeletion(true);
if (repositoryService instanceof SqlRepositoryServiceImpl) {
// These are experimental features, so they need to be explicitly enabled.
// This will be eliminated later, when we make them enabled by default.
SqlRepositoryServiceImpl sqlRepositoryService = (SqlRepositoryServiceImpl) repositoryService;
sqlRepositoryService.sqlConfiguration().setEnableIndexOnlyItems(true);
sqlRepositoryService.sqlConfiguration().setEnableNoFetchExtensionValuesInsertion(true);
sqlRepositoryService.sqlConfiguration().setEnableNoFetchExtensionValuesDeletion(true);
} else {
// It's Sqale repo and it has no explicit switch for index only.
}

super.initSystem(initTask, initResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ public void test004Configuration() throws Exception {
assertNotNull("No configuration container", configurationContainer);
PrismContainerDefinition confContDef = configurationContainer.getDefinition();
assertNotNull("No configuration container definition", confContDef);
PrismContainer confingurationPropertiesContainer =
PrismContainer configurationPropertiesContainer =
configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
assertNotNull("No configuration properties container", confingurationPropertiesContainer);
PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition();
assertNotNull("No configuration properties container", configurationPropertiesContainer);
PrismContainerDefinition confPropDef = configurationPropertiesContainer.getDefinition();
assertNotNull("No configuration properties container definition", confPropDef);

}
Expand Down

0 comments on commit fb36c83

Please sign in to comment.