Search in sources :

Example 86 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestMultiAccount method test020ImportPaulAtreides.

/**
 * Sanity/preparation. Import absolutely ordinary account.
 */
@Test
public void test020ImportPaulAtreides() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyAccount account = new DummyAccount(ACCOUNT_PAUL_ATREIDES_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_PAUL_ATREIDES_FULL_NAME);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, ACCOUNT_PAUL_ATREIDES_ID);
    // account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, TITLE_DUKE);
    getDummyResource(RESOURCE_DUMMY_MULTI_GREEN_NAME).addAccount(account);
    // Preconditions
    assertUsers(getNumberOfUsers());
    // WHEN
    when();
    importMultiGreenAccounts(task, result);
    // THEN
    then();
    // @formatter:off
    accountPaulOid = assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).displayWithProjections().assertFullName(ACCOUNT_PAUL_ATREIDES_FULL_NAME).assertEmployeeNumber(ACCOUNT_PAUL_ATREIDES_ID).assertOrganizationalUnits(ACCOUNT_PAUL_ATREIDES_FULL_NAME).singleLink().resolveTarget().assertKind(ShadowKindType.ACCOUNT).assertIntent(INTENT_DEFAULT).assertTagIsOid().getOid();
    // @formatter:on
    assertUsers(getNumberOfUsers() + 1);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 87 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestMultiAccount method test210ImportMahdi.

/**
 * Import yet another admin account that correlates to Paul.
 */
@Test
public void test210ImportMahdi() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyAccount account = new DummyAccount(ACCOUNT_MAHDI_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_MAHDI_FULL_NAME);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, ACCOUNT_PAUL_ATREIDES_ID);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, ACCOUNT_MAHDI_TITLE);
    getDummyResource(RESOURCE_DUMMY_MULTI_GREEN_NAME).addAccount(account);
    // Preconditions
    assertUsers(getNumberOfUsers() + 1);
    // WHEN
    when();
    importMultiGreenAccounts(task, result);
    // THEN
    then();
    // @formatter:off
    assertUserAfterByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).displayWithProjections().assertFullName(ACCOUNT_PAUL_ATREIDES_FULL_NAME).assertEmployeeNumber(ACCOUNT_PAUL_ATREIDES_ID).links().assertLiveLinks(4).link(accountPaulOid).resolveTarget().display().assertKind(ShadowKindType.ACCOUNT).assertIntent(INTENT_DEFAULT).assertTag(accountPaulOid).end().end().link(accountMuaddibOid).resolveTarget().display().assertKind(ShadowKindType.ACCOUNT).assertIntent(INTENT_DEFAULT).assertTag(accountMuaddibOid).end().end().link(accountDukeOid).resolveTarget().display().assertKind(ShadowKindType.ACCOUNT).assertIntent(INTENT_ADMIN).assertTag(ACCOUNT_DUKE_TITLE).end().end().by().notTags(accountPaulOid, accountMuaddibOid, ACCOUNT_DUKE_TITLE).find().resolveTarget().display().assertKind(ShadowKindType.ACCOUNT).assertIntent(INTENT_ADMIN).assertTag(ACCOUNT_MAHDI_TITLE).getOid();
    // @formatter:on
    assertUsers(getNumberOfUsers() + 1);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 88 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestTaskReporting method test110ImportWithSingleMalformedAccount.

@Test
public void test110ImportWithSingleMalformedAccount() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    // This will cause problem when updating shadow
    DummyAccount account = RESOURCE_DUMMY_SOURCE.controller.getDummyResource().getAccountByUsername(MALFORMED_SHADOW_NAME);
    account.replaceAttributeValue(ATTR_NUMBER, "WRONG");
    // Other kinds of failures are still disabled, to check last failed object name in case of malformed accounts
    when();
    rerunTaskErrorsOk(TASK_IMPORT.oid, result);
    then();
    stabilize();
    // @formatter:off
    assertTask(TASK_IMPORT.oid, "import task after").display().assertPartialError().assertClosed().assertProgress(9).rootItemProcessingInformation().display().assertSuccessCount(8).assertFailureCount(1).assertLastFailureObjectName("u-000001").end().rootSynchronizationInformation().display().assertTransition(LINKED, LINKED, LINKED, null, 8, 0, // Those 9 records were already linked and remain so.
    0).assertTransition(LINKED, null, null, null, 0, 1, // Malformed account has a LINKED shadow
    0).assertTransitions(2).end();
// @formatter:on
// TODO assert redirected errors in the task
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractEmptyModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractEmptyModelIntegrationTest)

Example 89 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestTaskReporting method createAccount.

private void createAccount(int i) throws ObjectAlreadyExistsException, SchemaViolationException, ConnectException, FileNotFoundException, ConflictException, InterruptedException {
    String name = formatAccountName(i);
    DummyAccount account = RESOURCE_DUMMY_SOURCE.controller.addAccount(name);
    account.addAttributeValue(ATTR_NUMBER, i);
    account.addAttributeValue(ATTR_FAILURE_MODE, getFailureMode(i));
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 90 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestThresholds method test199ModifyAccountDescription.

/**
 * Modifies description (-> cost center) of each 4th account, to trigger cost center modification policy rule.
 * - fullName of each 25th, to allow full name modification policy rule to pass (4 users are changed).
 */
@Test
public void test199ModifyAccountDescription() throws Exception {
    for (int i = 0; i < ACCOUNTS; i += 4) {
        DummyAccount account = getAccount(i);
        account.replaceAttributeValue(ATTR_DESCRIPTION_NAME, "changed");
        System.out.println("Changed description (cost center): " + account.getName());
    }
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractEmptyModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractEmptyModelIntegrationTest)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)261 Test (org.testng.annotations.Test)211 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)158 Task (com.evolveum.midpoint.task.api.Task)152 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)40 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)24 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 ArrayList (java.util.ArrayList)19 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)18 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)10 QName (javax.xml.namespace.QName)10 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)9 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)9