Search in sources :

Example 66 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class TestCorrelationConfiramtionEvaluator method test004CorrelationMatchCaseInsensitive.

@Test
public void test004CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test004CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 67 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class TestCorrelationConfiramtionEvaluator method test002CorrelationMoreThanOne.

@Test
public void test002CorrelationMoreThanOne() throws Exception {
    String TEST_NAME = "test002CorrelationMoreThanOne";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    List<ConditionalSearchFilterType> filters = new ArrayList<>();
    ConditionalSearchFilterType filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_FIRST_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_SECOND_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    filters.add(filter);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, filters, resourceType, getSystemConfiguration(), task, result);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 68 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class TestCorrelationConfiramtionEvaluator method test006CorrelationFindCaseInsensitive.

@Test
public void test006CorrelationFindCaseInsensitive() throws Exception {
    String TEST_NAME = "test006CorrelationFindCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    List<ConditionalSearchFilterType> queries = new ArrayList<>();
    queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    //		resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    Collection<? extends ItemDelta> modifications = PropertyDelta.createModificationReplacePropertyCollection(UserType.F_NAME, userType.getDefinition(), new PolyString("JACK", "jack"));
    repositoryService.modifyObject(UserType.class, USER_JACK_OID, modifications, result);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, queries, resourceType, getSystemConfiguration(), task, result);
    System.out.println("matched users " + matchedUsers);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "JACK", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 69 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class TestSynchronizationService method test100AddedAccountJack.

@Test
public void test100AddedAccountJack() throws Exception {
    final String TEST_NAME = "test100AddedAccountJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestSynchronizationService.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    assertLinks(userBefore, 0);
    MockLensDebugListener mockListener = new MockLensDebugListener();
    clockwork.setDebugListener(mockListener);
    PrismObject<ShadowType> accountShadowJack = repoAddObjectFromFile(ACCOUNT_SHADOW_JACK_DUMMY_FILE, result);
    accountShadowJackDummyOid = accountShadowJack.getOid();
    provisioningService.applyDefinition(accountShadowJack, task, result);
    assertNotNull("No oid in shadow", accountShadowJack.getOid());
    DummyAccount dummyAccount = new DummyAccount();
    dummyAccount.setName(ACCOUNT_JACK_DUMMY_USERNAME);
    dummyAccount.setPassword("deadMenTellNoTales");
    dummyAccount.setEnabled(true);
    dummyAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    getDummyResource().addAccount(dummyAccount);
    display("Dummy resource before", getDummyResource());
    ResourceObjectShadowChangeDescription change = new ResourceObjectShadowChangeDescription();
    change.setCurrentShadow(accountShadowJack);
    change.setResource(getDummyResourceObject());
    // WHEN
    synchronizationService.notifyChange(change, task, result);
    // THEN
    LensContext<UserType> context = mockListener.getLastSyncContext();
    display("Resulting context (as seen by debug listener)", context);
    assertNotNull("No resulting context (as seen by debug listener)", context);
    assertNull("Unexpected user primary delta", context.getFocusContext().getPrimaryDelta());
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(getDummyResourceObject().getOid(), ShadowKindType.ACCOUNT, null);
    LensProjectionContext accCtx = context.findProjectionContext(rat);
    assertNotNull("No account sync context for " + rat, accCtx);
    assertEquals("Wrong detected situation in context", SynchronizationSituationType.UNLINKED, accCtx.getSynchronizationSituationDetected());
    assertEquals("Wrong resolved situation in context", SynchronizationSituationType.LINKED, accCtx.getSynchronizationSituationResolved());
    PrismAsserts.assertNoDelta("Unexpected account primary delta", accCtx.getPrimaryDelta());
    //it this really expected?? delta was already executed, should we expect it in the secondary delta?
    //		assertNotNull("Missing account secondary delta", accCtx.getSecondaryDelta());
    //		assertIterationDelta(accCtx.getSecondaryDelta(), 0, "");
    assertLinked(context.getFocusContext().getObjectOld().getOid(), accountShadowJack.getOid());
    PrismObject<ShadowType> shadow = getShadowModelNoFetch(accountShadowJackDummyOid);
    assertIteration(shadow, 0, "");
    assertSituation(shadow, SynchronizationSituationType.LINKED);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    assertLinks(userAfter, 1);
    assertLinked(userAfter, shadow);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MockLensDebugListener(com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 70 with ShadowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.

the class TestActivation method test213HastaLaMananaLargo.

/**
	 * Move time after manana. Largo should be invalid.
	 */
@Test
public void test213HastaLaMananaLargo() throws Exception {
    final String TEST_NAME = "test213HastaLaMananaLargo";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    long startMillis = System.currentTimeMillis();
    Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Let's play with the clock, move the time forward 20 days
    long crrentNow = System.currentTimeMillis() + 20 * 24 * 60 * 60 * 1000;
    clock.override(crrentNow);
    // WHEN
    modelService.recompute(UserType.class, USER_LARGO_OID, null, task, result);
    // THEN
    PrismObject<UserType> userLargo = getUser(USER_LARGO_OID);
    display("User after change execution", userLargo);
    assertValidity(userLargo, TimeIntervalStatusType.AFTER);
    assertValidityTimestamp(userLargo, crrentNow);
    assertEffectiveStatus(userLargo, ActivationStatusType.DISABLED);
    assertUser(userLargo, USER_LARGO_OID, USER_LARGO_USERNAME, "Largo LaGrande", "Largo", "LaGrande");
    accountOid = getSingleLinkOid(userLargo);
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    assertDummyAccountShadowRepo(accountShadow, accountOid, USER_LARGO_USERNAME);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertDummyAccountShadowModel(accountModel, accountOid, USER_LARGO_USERNAME, "Largo LaGrande");
    // Check account in dummy resource
    assertDefaultDummyAccount(USER_LARGO_USERNAME, "Largo LaGrande", false);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestValidityRecomputeTask(com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractSynchronizationStoryTest(com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)

Aggregations

ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)903 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)728 Test (org.testng.annotations.Test)693 Task (com.evolveum.midpoint.task.api.Task)600 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)398 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)170 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)154 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)153 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)129 QName (javax.xml.namespace.QName)123 PrismObject (com.evolveum.midpoint.prism.PrismObject)105 ArrayList (java.util.ArrayList)95 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)89 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)78 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)74 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)64 Entry (org.apache.directory.api.ldap.model.entry.Entry)61 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)60 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)55