Skip to content

Commit

Permalink
Adapt tests in workflow-impl to schema cleanup
Browse files Browse the repository at this point in the history
Contains a major cleanup of workflow tests: obsolete ones were removed
and remaining were refactored; main idea was to remove the maze of
dependencies of resource objects used in these tests.

Removes redundant "resource" parameter in assertAttribute methods.
  • Loading branch information
mederly committed Sep 3, 2019
1 parent 1449b99 commit 29ac16c
Show file tree
Hide file tree
Showing 178 changed files with 1,771 additions and 6,176 deletions.
Expand Up @@ -2320,11 +2320,11 @@ protected void assertUnassignedFuture(ShadowAsserter<?> shadowModelAsserterFutur


protected <T> void assertAttribute(PrismObject<ShadowType> shadow, QName attrName, T... expectedValues) {
assertAttribute(resource, shadow.asObjectable(), attrName, expectedValues);
assertAttribute(shadow.asObjectable(), attrName, expectedValues);
}

protected <T> void assertNoAttribute(PrismObject<ShadowType> shadow, QName attrName) {
assertNoAttribute(resource, shadow.asObjectable(), attrName);
assertNoAttribute(shadow.asObjectable(), attrName);
}

protected void assertAttributeFromCache(ShadowAsserter<?> shadowAsserter, QName attrQName,
Expand Down
Expand Up @@ -387,8 +387,8 @@ public void test502GetAccountJackResourceScripty() throws Exception {
displayThen(TEST_NAME);
assertSuccess(result);

assertAttribute(getDummyResourceObject(RESOURCE_DUMMY_SCRIPTY_NAME), accountShadow.asObjectable(),
getDummyResourceController(RESOURCE_DUMMY_SCRIPTY_NAME).getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME),
assertAttribute(accountShadow.asObjectable(),
getDummyResourceController(RESOURCE_DUMMY_SCRIPTY_NAME).getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME),
"Dummy Resource: Scripty");
lastDummyConnectorNumber = ShadowUtil.getAttributeValue(accountShadow,
getDummyResourceController(RESOURCE_DUMMY_SCRIPTY_NAME).getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEALTH_NAME));
Expand Down Expand Up @@ -420,7 +420,7 @@ public void test504GetAccountJackResourceScriptyAgain() throws Exception {
displayThen(TEST_NAME);
assertSuccess(result);

assertAttribute(getDummyResourceObject(RESOURCE_DUMMY_SCRIPTY_NAME), accountShadow.asObjectable(),
assertAttribute(accountShadow.asObjectable(),
getDummyResourceController(RESOURCE_DUMMY_SCRIPTY_NAME).getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME),
"Dummy Resource: Scripty");
Integer dummyConnectorNumber = ShadowUtil.getAttributeValue(accountShadow,
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
Expand Down Expand Up @@ -122,8 +123,8 @@ public void test050AddMetaMeta() throws Exception {
assertSuccess(result);
PrismObject<RoleType> role = getObject(RoleType.class, ROLE_META_META_WORLD_OID);
display("Metametarole after", role);
assertObjectSanity(role);

new PrismObjectAsserter<>(role).assertSanity();
RoleType roleType = role.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", ROLE_META_META_WORLD_NAME, roleType.getName());
Expand Down Expand Up @@ -380,8 +381,8 @@ public void test900LegacyAddMetaMeta() throws Exception {
assertSuccess(result);
PrismObject<RoleType> role = getObject(RoleType.class, ROLE_META_META_LEGACY_OID);
display("Metametarole after", role);
assertObjectSanity(role);

new PrismObjectAsserter<>(role).assertSanity();
RoleType roleType = role.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", ROLE_META_META_LEGACY_NAME, roleType.getName());
Expand Down Expand Up @@ -416,8 +417,8 @@ public void test910LegacyAddMetaLegacyOne() throws Exception {
assertSuccess(result);
PrismObject<RoleType> role = getObject(RoleType.class, ROLE_META_LEGACY_ONE_OID);
display("Metarole after", role);
assertObjectSanity(role);

new PrismObjectAsserter<>(role).assertSanity();
RoleType roleType = role.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", ROLE_META_LEGACY_ONE_NAME, roleType.getName());
Expand Down Expand Up @@ -460,7 +461,7 @@ public void test920LegacyCreateGroupOne() throws Exception {

PrismObject<RoleType> roleAfter = getObject(RoleType.class, groupOneRoleOid);
display("Role after", roleAfter);
assertObjectSanity(roleAfter);
new PrismObjectAsserter<>(roleAfter).assertSanity();
RoleType roleTypeAfter = roleAfter.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+roleAfter+" name", GROUP_ONE_NAME, roleTypeAfter.getName());
Expand Down Expand Up @@ -560,7 +561,7 @@ private PrismObject<RoleType> readAndAssertLatinGroupRole(String roleOid, String
private PrismObject<RoleType> readAndAssertGroupRole(String roleOid, String metaroleOid, String groupName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException, SchemaViolationException, ConflictException, InterruptedException {
PrismObject<RoleType> role = getObject(RoleType.class, roleOid);
display("Role after", role);
assertObjectSanity(role);
new PrismObjectAsserter<>(role).assertSanity();
RoleType roleType = role.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", groupName, roleType.getName());
Expand All @@ -583,8 +584,8 @@ private PrismObject<RoleType> readAndAssertGroupRole(String roleOid, String meta
private PrismObject<RoleType> assertMetaRole(String metaroleOid, String metaroleName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException, SchemaViolationException, ConflictException, InterruptedException {
PrismObject<RoleType> role = getObject(RoleType.class, metaroleOid);
display("Metarole after", role);
assertObjectSanity(role);

new PrismObjectAsserter<>(role).assertSanity();
RoleType roleType = role.asObjectable();

PrismAsserts.assertEqualsPolyString("Wrong "+role+" name", metaroleName, roleType.getName());
Expand Down
Expand Up @@ -2370,6 +2370,13 @@ protected <R extends AbstractRoleType> void assertInducements(PrismObject<R> rol
MidPointAsserts.assertInducements(role, expectedNumber);
}

protected <R extends AbstractRoleType> void assertInducedRoles(PrismObject<R> role, String... roleOids) {
assertInducements(role, roleOids.length);
for (String roleOid : roleOids) {
assertInducedRole(role, roleOid);
}
}

protected <F extends AssignmentHolderType> void assertAssignments(PrismObject<F> user, Class expectedType, int expectedNumber) {
MidPointAsserts.assertAssignments(user, expectedType, expectedNumber);
}
Expand Down
Expand Up @@ -44,7 +44,6 @@
import com.evolveum.midpoint.wf.api.WorkflowManager;
import com.evolveum.midpoint.wf.impl.access.WorkItemManager;
import com.evolveum.midpoint.wf.impl.engine.WorkflowEngine;
import com.evolveum.midpoint.wf.impl.policy.ExpectedWorkItem;
import com.evolveum.midpoint.wf.impl.processors.general.GeneralChangeProcessor;
import com.evolveum.midpoint.wf.impl.processors.primary.PrimaryChangeProcessor;
import com.evolveum.midpoint.wf.impl.util.MiscHelper;
Expand Down Expand Up @@ -77,6 +76,8 @@ public abstract class AbstractWfTest extends AbstractModelImplementationIntegrat
public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml");

protected static final File USER_JACK_FILE = new File(COMMON_DIR, "user-jack.xml");
protected static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111";
protected static final String USER_JACK_USERNAME = "jack";

protected static final File ROLE_APPROVER_FILE = new File(COMMON_DIR, "041-role-approver.xml");
protected static final File ARCHETYPE_MANUAL_PROVISIONING_CASE_FILE = new File(COMMON_DIR, "023-archetype-manual-provisioning-case.xml");
Expand Down

0 comments on commit 29ac16c

Please sign in to comment.