Skip to content

Commit

Permalink
More test fixes after schema cleanup (MID-5052)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Aug 30, 2019
1 parent c1088e0 commit 78bd4dd
Show file tree
Hide file tree
Showing 28 changed files with 98 additions and 1,293 deletions.
Expand Up @@ -52,7 +52,7 @@ public void assertResult(String resourceOid, long expectedUnOpsCount, long expec
long expectedShadowReconCount) {
ReconciliationTaskResult result = findResult(resourceOid);
assert result != null : "No recon result for resource "+resourceOid;
PrismAsserts.assertEquals("Wrong upOpsCount in recon result for resource "+resourceOid,
PrismAsserts.assertEquals("Wrong unOpsCount in recon result for resource "+resourceOid,
expectedUnOpsCount, result.getUnOpsCount());
PrismAsserts.assertEquals("Wrong resourceReconCount in recon result for resource "+resourceOid,
expectedResourceReconCount, result.getResourceReconCount());
Expand Down
Expand Up @@ -112,7 +112,6 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
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_DEPRECATED_FILE = new File(COMMON_DIR, "resource-dummy-deprecated.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";
Expand All @@ -129,7 +128,6 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra

// 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_DEPRECATED_FILE = new File(COMMON_DIR, "resource-dummy-blue-deprecated.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";
Expand All @@ -156,15 +154,13 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra

// 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_DEPRECATED_FILE = new File(COMMON_DIR, "resource-dummy-green-deprecated.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 File RESOURCE_DUMMY_EMERALD_DEPRECATED_FILE = new File(COMMON_DIR, "resource-dummy-emerald-deprecated.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;
Expand Down Expand Up @@ -245,9 +241,6 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
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_JUDGE_DEPRECATED_FILE = new File(COMMON_DIR, "role-judge-deprecated.xml");
protected static final String ROLE_JUDGE_DEPRECATED_OID = "12345111-1111-2222-1111-d21212111111";

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";

Expand Down
Expand Up @@ -71,7 +71,7 @@ public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredM
protected static final Trace LOGGER = TraceManager.getTrace(AbstractInitializedModelIntegrationTest.class);

private static final int NUMBER_OF_IMPORTED_USERS = 5;
private static final int NUMBER_OF_IMPORTED_ROLES = 16;
private static final int NUMBER_OF_IMPORTED_ROLES = 15;

@Autowired protected MappingFactory mappingFactory;
@Autowired protected Clockwork clockwork;
Expand Down Expand Up @@ -245,7 +245,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
repoAddObjectFromFile(ROLE_NICE_PIRATE_FILENAME, initResult);
repoAddObjectFromFile(ROLE_CAPTAIN_FILENAME, initResult);
repoAddObjectFromFile(ROLE_JUDGE_FILE, initResult);
repoAddObjectFromFile(ROLE_JUDGE_DEPRECATED_FILE, initResult);
repoAddObjectFromFile(ROLE_THIEF_FILE, initResult);
repoAddObjectFromFile(ROLE_EMPTY_FILE, initResult);
repoAddObjectFromFile(ROLE_USELESS_FILE, initResult);
Expand Down
Expand Up @@ -1172,8 +1172,7 @@ public void test213ModifiedUserJack() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertSuccess(result);

assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, (propDef, name) -> {
assertNotNull("No definition for additionalName in user", propDef);
Expand Down Expand Up @@ -1259,8 +1258,7 @@ public void test260EditShadowSchemaKindIntent() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertSuccess(result);

PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
Expand Down Expand Up @@ -1303,8 +1301,7 @@ public void test261EditShadowSchemaObjectclass() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertSuccess(result);

PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
Expand Down Expand Up @@ -1337,8 +1334,7 @@ public void test263EditShadowSchemaEmpty() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertSuccess(result);

PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
Expand Down Expand Up @@ -1366,8 +1362,7 @@ public void test265EditShadowSchemaNull() throws Exception {

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertSuccess(result);

PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(ShadowType.F_NAME);
assertNotNull("No definition for name in shadow", nameDef);
Expand Down
Expand Up @@ -1180,7 +1180,7 @@ public void test200AddRoleSwashbuckler() throws Exception {
OperationResult result = task.getResult();
prepareTest(AssignmentPolicyEnforcementType.RELATIVE);

PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_SWASHBUCKLER_FILE);
PrismObject<RoleType> role = parseObject(ROLE_SWASHBUCKLER_FILE);
ObjectDelta<RoleType> roleDelta = DeltaFactory.Object.createAddDelta(role);

XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
Expand All @@ -1199,9 +1199,9 @@ public void test200AddRoleSwashbuckler() throws Exception {
role = getRole(ROLE_SWASHBUCKLER_OID);
display("Role after", role);
// Set by object template
PrismAsserts.assertPropertyValue(role,RoleType.F_DESCRIPTION, ROLE_SWASHBUCKLER_DESCRIPTION);
PrismAsserts.assertPropertyValue(role, RoleType.F_DESCRIPTION, ROLE_SWASHBUCKLER_DESCRIPTION);
// reflected by inbound
PrismAsserts.assertPropertyValue(role,ROLE_EXTENSION_COST_CENTER_PATH, "META0000");
PrismAsserts.assertPropertyValue(role, ROLE_EXTENSION_COST_CENTER_PATH, "META0000");
assertLinks(role, 1);
groupOid = getSingleLinkOid(role);

Expand Down

This file was deleted.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -223,31 +223,6 @@ public void test110SimpleExclusion1() throws Exception {
assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test112SimpleExclusion1Deprecated() throws Exception {
final String TEST_NAME = "test112SimpleExclusion1Deprecated";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// This should go well
assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);

try {
// This should die
assignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);

AssertJUnit.fail("Expected policy violation after adding judge role, but it went well");
} catch (PolicyViolationException e) {
System.out.println("Got expected exception: " + e.getMessage());
}

unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);

assertAssignedNoRole(USER_JACK_OID, task, result);
}

/**
* Same thing as before but other way around
*/
Expand Down Expand Up @@ -276,33 +251,6 @@ public void test120SimpleExclusion2() throws Exception {
assertAssignedNoRole(USER_JACK_OID, task, result);
}

/**
* Same thing as before but other way around
*/
@Test
public void test122SimpleExclusion2Deprecated() throws Exception {
final String TEST_NAME = "test122SimpleExclusion2Deprecated";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// This should go well
assignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);

try {
// This should die
assignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);

AssertJUnit.fail("Expected policy violation after adding pirate role, but it went well");
} catch (PolicyViolationException e) {
System.out.println("Got expected exception: " + e.getMessage());
}

unassignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);
assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test130SimpleExclusionBoth1() throws Exception {
final String TEST_NAME = "test130SimpleExclusionBoth1";
Expand All @@ -328,31 +276,6 @@ public void test130SimpleExclusionBoth1() throws Exception {
assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test132SimpleExclusionBoth1Deprecated() throws Exception {
final String TEST_NAME = "test132SimpleExclusionBoth1Deprecated";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ItemDelta<?,?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_JUDGE_DEPRECATED_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);

try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);

AssertJUnit.fail("Expected policy violation, but it went well");
} catch (PolicyViolationException e) {
System.out.println("Got expected exception: " + e.getMessage());
}

assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test140SimpleExclusionBoth2() throws Exception {
final String TEST_NAME = "test140SimpleExclusionBoth2";
Expand All @@ -378,31 +301,6 @@ public void test140SimpleExclusionBoth2() throws Exception {
assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test142SimpleExclusionBoth2Deprecated() throws Exception {
final String TEST_NAME = "test142SimpleExclusionBoth2Deprecated";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ItemDelta<?,?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ROLE_JUDGE_DEPRECATED_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);

try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);

AssertJUnit.fail("Expected policy violation, but it went well");
} catch (PolicyViolationException e) {
System.out.println("Got expected exception: " + e.getMessage());
}

assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test150SimpleExclusionBothBidirectional1() throws Exception {
final String TEST_NAME = "test150SimpleExclusionBothBidirectional1";
Expand Down Expand Up @@ -610,54 +508,6 @@ public void test190DifferentRelations() throws Exception {
assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test191DifferentRelationsDeprecatedCase1() throws Exception {
final String TEST_NAME = "test191DifferentRelationsCase1";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ItemDelta<?,?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_JUDGE_DEPRECATED_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER, null, null, true)));
modifications.add((createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);

try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);
} finally {
unassignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, SchemaConstants.ORG_APPROVER, task, result);
unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);
}

assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test192DifferentRelationsDeprecatedCase2() throws Exception {
final String TEST_NAME = "test191DifferentRelationsCase1";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ItemDelta<?,?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_JUDGE_DEPRECATED_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, SchemaConstants.ORG_APPROVER, null, null, true)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);

try {
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);
} finally {
unassignRole(USER_JACK_OID, ROLE_JUDGE_DEPRECATED_OID, task, result);
unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, SchemaConstants.ORG_APPROVER, task, result);
}

assertAssignedNoRole(USER_JACK_OID, task, result);
}

@Test
public void test193BothRelationsApprover() throws Exception {
final String TEST_NAME = "test193BothRelationsApprover";
Expand Down

0 comments on commit 78bd4dd

Please sign in to comment.