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 d3402e92af8..269732987d5 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 @@ -97,8 +97,10 @@ public class TestMultiAccount extends AbstractInitializedModelIntegrationTest { protected static final String ACCOUNT_ODRADE_FIRST_NAME = "Darwi"; protected static final String ACCOUNT_ODRADE_LAST_NAME = "Odrade"; protected static final String ACCOUNT_ODRADE_PERSONAL_NUMBER = "54321"; - protected static final String ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR = "MS007"; + protected static final String ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE = "A007"; protected static final String ACCOUNT_ODRADE_CONTRACT_NUMBER_GUARDIAN = "G007"; + protected static final String ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR = "MS007"; + protected static final String OU_MOTHER_SCHOOL = "Mother School"; protected static final String OU_MOTHER_SUPERIOR_OFFICE = "Mother Superior Office"; protected static final String OU_SECURITY = "Security"; @@ -109,6 +111,7 @@ public class TestMultiAccount extends AbstractInitializedModelIntegrationTest { private static final String PLANET_KAITAIN = "Kaitain"; private static final String PLANET_IX = "Ix"; private static final String PLANET_GINAZ = "Ginaz"; + private static final String PLANET_WALLACH_IX = "Wallach IX"; private static final String PLANET_CHAPTERHOUSE = "Chapterhouse"; private static final String PLANET_ARRAKIS = "Arrakis"; @@ -660,19 +663,19 @@ public void test400ImportAccountsFromCleverHr() throws Exception { * Import the first account. Nothing special here yet. */ @Test - public void test410ImportOdrade() throws Exception { + public void test410ImportOdradeApprentice() throws Exception { // GIVEN Task task = getTestTask(); OperationResult result = task.getResult(); - DummyAccount account = new DummyAccount(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR); + DummyAccount account = new DummyAccount(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE); account.setEnabled(true); account.addAttributeValues(CLEVER_HR_ATTRIBUTE_FIRST_NAME, ACCOUNT_ODRADE_FIRST_NAME); account.addAttributeValues(CLEVER_HR_ATTRIBUTE_LAST_NAME, ACCOUNT_ODRADE_LAST_NAME); account.addAttributeValues(CLEVER_HR_ATTRIBUTE_PERSONAL_NUMBER, ACCOUNT_ODRADE_PERSONAL_NUMBER); - account.addAttributeValues(CLEVER_HR_ATTRIBUTE_LOCATION, PLANET_CHAPTERHOUSE); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_LOCATION, PLANET_WALLACH_IX); account.addAttributeValues(CLEVER_HR_ATTRIBUTE_PRIMARY, Collections.singleton(Boolean.TRUE)); - account.addAttributeValues(CLEVER_HR_ATTRIBUTE_OU, OU_MOTHER_SUPERIOR_OFFICE); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_OU, OU_MOTHER_SCHOOL); getDummyResource(RESOURCE_DUMMY_CLEVER_HR_NAME).addAccount(account); // Preconditions @@ -689,14 +692,14 @@ public void test410ImportOdrade() throws Exception { .displayWithProjections() .assertGivenName(ACCOUNT_ODRADE_FIRST_NAME) .assertFamilyName(ACCOUNT_ODRADE_LAST_NAME) - .assertEmployeeNumber(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR) - .assertLocality(PLANET_CHAPTERHOUSE) - .assertOrganizationalUnits(OU_MOTHER_SUPERIOR_OFFICE) + .assertEmployeeNumber(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE) + .assertLocality(PLANET_WALLACH_IX) + .assertOrganizationalUnits(OU_MOTHER_SCHOOL) .singleLink() .resolveTarget() .assertKind(ShadowKindType.ACCOUNT) .assertIntent(SchemaConstants.INTENT_DEFAULT) - .assertTag(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR); + .assertTag(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE); assertUsers(getNumberOfUsers() + 3); @@ -737,14 +740,13 @@ public void test420ImportOdradeGuardian() throws Exception { .displayWithProjections() .assertGivenName(ACCOUNT_ODRADE_FIRST_NAME) .assertFamilyName(ACCOUNT_ODRADE_LAST_NAME) - // TODO - .assertLocality(PLANET_CHAPTERHOUSE) -// .assertEmployeeNumber(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR) - .assertOrganizationalUnits(OU_MOTHER_SUPERIOR_OFFICE, OU_SECURITY) + .assertLocality(PLANET_WALLACH_IX) + .assertEmployeeNumber(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE) + .assertOrganizationalUnits(OU_MOTHER_SCHOOL, OU_SECURITY) .links() .assertLinks(2) .by() - .tag(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR) + .tag(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE) .find() .resolveTarget() .assertKind(ShadowKindType.ACCOUNT) @@ -764,6 +766,77 @@ public void test420ImportOdradeGuardian() throws Exception { } + /** + * Promote Odrade to Mother Superior. The primary contract is changed in this case. + * User object should reflect data from the new primary contract. + */ + @Test + public void test430ImportOdradeMotherSuperior() throws Exception { + // GIVEN + Task task = getTestTask(); + OperationResult result = task.getResult(); + + getDummyResource(RESOURCE_DUMMY_CLEVER_HR_NAME) + .getAccountByUsername(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE) + .replaceAttributeValue(CLEVER_HR_ATTRIBUTE_PRIMARY, Boolean.FALSE); + + DummyAccount account = new DummyAccount(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR); + account.setEnabled(true); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_FIRST_NAME, ACCOUNT_ODRADE_FIRST_NAME); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_LAST_NAME, ACCOUNT_ODRADE_LAST_NAME); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_PERSONAL_NUMBER, ACCOUNT_ODRADE_PERSONAL_NUMBER); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_LOCATION, PLANET_CHAPTERHOUSE); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_PRIMARY, Collections.singleton(Boolean.TRUE)); + account.addAttributeValues(CLEVER_HR_ATTRIBUTE_OU, OU_MOTHER_SUPERIOR_OFFICE); + getDummyResource(RESOURCE_DUMMY_CLEVER_HR_NAME).addAccount(account); + + // Preconditions + assertUsers(getNumberOfUsers() + 3); + + // WHEN + when(); + importCleverHrAccounts(task, result); + + // THEN + then(); + + assertUserAfterByUsername(USER_ODRADE_USERNAME) + .displayWithProjections() + .assertGivenName(ACCOUNT_ODRADE_FIRST_NAME) + .assertFamilyName(ACCOUNT_ODRADE_LAST_NAME) + .assertLocality(PLANET_CHAPTERHOUSE) + .assertEmployeeNumber(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR) + .assertOrganizationalUnits(OU_MOTHER_SUPERIOR_OFFICE, OU_MOTHER_SCHOOL, OU_SECURITY) + .links() + .assertLinks(3) + .by() + .tag(ACCOUNT_ODRADE_CONTRACT_NUMBER_APPRENTICE) + .find() + .resolveTarget() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(SchemaConstants.INTENT_DEFAULT) + .end() + .end() + .by() + .tag(ACCOUNT_ODRADE_CONTRACT_NUMBER_GUARDIAN) + .find() + .resolveTarget() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(SchemaConstants.INTENT_DEFAULT) + .end() + .end() + .by() + .tag(ACCOUNT_ODRADE_CONTRACT_NUMBER_MOTHER_SUPERIOR) + .find() + .resolveTarget() + .assertKind(ShadowKindType.ACCOUNT) + .assertIntent(SchemaConstants.INTENT_DEFAULT) + .end() + .end(); + + assertUsers(getNumberOfUsers() + 3); + } + private void assertEnvoyAccounts(String userOid, String username, String... planets) throws SchemaException, ObjectNotFoundException, ConfigurationException, CommunicationException, SecurityViolationException, ExpressionEvaluationException, InterruptedException, FileNotFoundException, ConnectException, SchemaViolationException, ConflictException { UserAsserter asserter = assertUserAfter(userOid) .displayWithProjections() diff --git a/model/model-intest/src/test/resources/logback-test.xml b/model/model-intest/src/test/resources/logback-test.xml index 89ebbf1a798..5b36fd5763e 100644 --- a/model/model-intest/src/test/resources/logback-test.xml +++ b/model/model-intest/src/test/resources/logback-test.xml @@ -65,7 +65,7 @@ - + @@ -105,8 +105,8 @@ - - + + diff --git a/model/model-intest/src/test/resources/multi-account/resource-dummy-clever-hr.xml b/model/model-intest/src/test/resources/multi-account/resource-dummy-clever-hr.xml index 5db3de6eca9..f954c4a0ec7 100644 --- a/model/model-intest/src/test/resources/multi-account/resource-dummy-clever-hr.xml +++ b/model/model-intest/src/test/resources/multi-account/resource-dummy-clever-hr.xml @@ -68,9 +68,15 @@ employeeNumber + + + + + - true @@ -82,9 +88,28 @@ $focus/givenName + + + + + - true @@ -96,9 +121,18 @@ $focus/familyName + + + + + - true @@ -108,16 +142,20 @@ true $focus/name + + + + + - true @@ -141,6 +179,13 @@ strong locality + + + + + true @@ -171,7 +216,6 @@ - true @@ -181,7 +225,6 @@ - true @@ -191,7 +234,6 @@ - true