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");
}
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");
}
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");
}
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);
}
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);
}
Aggregations