Skip to content

Commit

Permalink
Test for weak object template mapping afterAssignments with role that…
Browse files Browse the repository at this point in the history
… has focusMappings (MID-3028)
  • Loading branch information
semancik committed May 12, 2016
1 parent de9d364 commit e520ea0
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 4 deletions.
Expand Up @@ -916,10 +916,11 @@ private void assertOnDemandOrgAssigned(String orgName, PrismObject<UserType> use

@Test
public void test200AddUserRapp() throws Exception {
TestUtil.displayTestTile(this, "test100ModifyUserGivenName");
final String TEST_NAME = "test200AddUserRapp";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + ".test200AddUserRapp");
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> user = PrismTestUtil.parseObject(USER_RAPP_FILE);
Expand All @@ -940,13 +941,14 @@ public void test200AddUserRapp() throws Exception {
assertAssignments(userAfter, 1);

UserType userAfterType = userAfter.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userAfterType.getLinkRef().size());
assertLinks(userAfter, 1);

result.computeStatus();
TestUtil.assertSuccess(result);

assertEquals("Unexpected value of employeeNumber, maybe it was generated and should not be?",
"D3ADB33F", userAfterType.getEmployeeNumber());
assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter());
}

@Test
Expand Down Expand Up @@ -1033,6 +1035,73 @@ public void test202AddUserMonkey() throws Exception {
GenerateExpressionEvaluator.DEFAULT_LENGTH, userAfterType.getEmployeeNumber().length());
}

@Test
public void test220AssignRoleSailorToUserRapp() throws Exception {
final String TEST_NAME = "test220AssignRoleSailorToUserRapp";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// WHEN
assignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result);

// THEN
PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result);
assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion");
PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION);

assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID);
assertAssignedRole(userAfter, ROLE_SAILOR_OID);
assertAssignments(userAfter, 2);

UserType userAfterType = userAfter.asObjectable();
assertLinks(userAfter, 2);

result.computeStatus();
TestUtil.assertSuccess(result);

assertEquals("Unexpected value of employeeNumber",
"D3ADB33F", userAfterType.getEmployeeNumber());
assertEquals("Wrong costCenter", "CC-TITANIC", userAfterType.getCostCenter());
}

/**
* MID-3028
*/
@Test
public void test229UnassignRoleSailorFromUserRapp() throws Exception {
final String TEST_NAME = "test220AssignRoleSailorToUserRapp";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// WHEN
unassignRole(USER_RAPP_OID, ROLE_SAILOR_OID, task, result);

// THEN
PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_RAPP_OID, null, task, result);
assertUser(userAfter, USER_RAPP_OID, "rapp", "Rapp Scallion", "Rapp", "Scallion");
PrismAsserts.assertNoItem(userAfter, UserType.F_DESCRIPTION);

assertAssignedAccount(userAfter, RESOURCE_DUMMY_BLUE_OID);
assertAssignedNoRole(userAfter);
assertAssignments(userAfter, 1);

UserType userAfterType = userAfter.asObjectable();
assertLinks(userAfter, 1);

result.computeStatus();
TestUtil.assertSuccess(result);

assertEquals("Unexpected value of employeeNumber",
"D3ADB33F", userAfterType.getEmployeeNumber());
assertEquals("Wrong costCenter", "G001", userAfterType.getCostCenter());
}

/**
* Move the time to the future. See if the time-based mapping in user template is properly recomputed.
*/
Expand Down
15 changes: 14 additions & 1 deletion model/model-intest/src/test/resources/common/role-sailor.xml
@@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2010-2015 Evolveum
~ Copyright (c) 2010-2016 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 @@ -32,4 +32,17 @@
</attribute>
</construction>
</inducement>

<inducement>
<focusMappings>
<mapping>
<expression>
<value>CC-TITANIC</value>
</expression>
<target>
<path>costCenter</path>
</target>
</mapping>
</focusMappings>
</inducement>
</role>

0 comments on commit e520ea0

Please sign in to comment.