use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestActivation method test150ModifyUserJackAssignYellowAccount.
/**
* Assign yellow account.
*/
@Test
public void test150ModifyUserJackAssignYellowAccount() throws Exception {
final String TEST_NAME = "test150ModifyUserJackAssignYellowAccount";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_YELLOW_OID, null, true);
deltas.add(accountAssignmentUserDelta);
XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack);
accountYellowOid = getLinkRefOid(userJack, RESOURCE_DUMMY_YELLOW_OID);
// Check account in dummy resource
assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, "jack", "Jack Sparrow", true);
// Check shadow
PrismObject<ShadowType> accountShadowYellow = getShadowModel(accountYellowOid);
assertAccountShadowModel(accountShadowYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME, getDummyResourceType(RESOURCE_DUMMY_YELLOW_NAME));
assertAdministrativeStatusEnabled(accountShadowYellow);
TestUtil.assertCreateTimestamp(accountShadowYellow, start, end);
assertEnableTimestampShadow(accountShadowYellow, start, end);
// Check user
TestUtil.assertModifyTimestamp(userJack, start, end);
assertAdministrativeStatusEnabled(userJack);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestConnectorMultiInstance method test125ReadJackDummyYellowTwoBlocking.
/**
* Block two read operations. Make sure that new connector instance is created.
*/
@Test
public void test125ReadJackDummyYellowTwoBlocking() throws Exception {
final String TEST_NAME = "test125ReadJackDummyYellowTwoBlocking";
TestUtil.displayTestTile(this, TEST_NAME);
dummyResourceYellow.setBlockOperations(true);
final Holder<PrismObject<ShadowType>> shadowHolder1 = new Holder<>();
final Holder<PrismObject<ShadowType>> shadowHolder2 = new Holder<>();
// WHEN
Thread t1 = executeInNewThread("get1", new FailableRunnable() {
@Override
public void run() throws Exception {
PrismObject<ShadowType> shadow = getShadowModel(accountJackYellowOid);
LOGGER.trace("Got shadow {}", shadow);
shadowHolder1.setValue(shadow);
}
});
Thread t2 = executeInNewThread("get2", new FailableRunnable() {
@Override
public void run() throws Exception {
PrismObject<ShadowType> shadow = getShadowModel(accountJackYellowOid);
LOGGER.trace("Got shadow {}", shadow);
shadowHolder2.setValue(shadow);
}
});
// Give the new threads a chance to get blocked
Thread.sleep(500);
assertConnectorInstances("yellow (blocked)", RESOURCE_DUMMY_YELLOW_OID, 2, 0);
assertNull("Unexpected shadow 1", shadowHolder1.getValue());
assertNull("Unexpected shadow 2", shadowHolder2.getValue());
dummyResourceYellow.unblockAll();
t1.join();
t2.join();
// THEN
dummyResourceYellow.setBlockOperations(false);
PrismObject<ShadowType> shadowYellow1 = shadowHolder1.getValue();
assertNotNull("No shadow 1", shadowHolder1.getValue());
display("Shadow yellow 1", shadowYellow1);
PrismObject<ShadowType> shadowYellow2 = shadowHolder2.getValue();
assertNotNull("No shadow 2", shadowHolder2.getValue());
display("Shadow yellow 2", shadowYellow2);
assertConnectorInstances("yellow", RESOURCE_DUMMY_YELLOW_OID, 0, 2);
assertConnectorToStringDifferent(shadowYellow2, dummyResourceCtlYellow, getConnectorToString(shadowYellow1, dummyResourceCtlYellow));
assertConnectorStaticVal(shadowYellow1, dummyResourceCtlYellow, initialConnectorStaticVal);
assertConnectorStaticVal(shadowYellow2, dummyResourceCtlYellow, initialConnectorStaticVal);
assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestConnectorMultiInstance method test200GuybrushAssignDummyBlack.
@Test
public void test200GuybrushAssignDummyBlack() throws Exception {
final String TEST_NAME = "test200GuybrushAssignDummyBlack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
assignAccount(USER_GUYBRUSH_OID, RESOURCE_DUMMY_BLACK_OID, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = getUser(USER_GUYBRUSH_OID);
accountGuybrushBlackOid = getSingleLinkOid(userJack);
assertDummyAccount(RESOURCE_DUMMY_BLACK_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
PrismObject<ShadowType> shadowBlack = getShadowModel(accountGuybrushBlackOid);
display("Shadow black", shadowBlack);
assertConnectorInstances("black", RESOURCE_DUMMY_BLACK_OID, 0, 1);
assertConnectorInstances("yellow", RESOURCE_DUMMY_YELLOW_OID, 0, 2);
assertConnectorToStringDifferent(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorStaticVal);
assertConnectorToStringDifferent(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorToString);
assertConnectorStaticVal(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorStaticVal);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestConnectorMultiInstance method test110ReadJackDummyYellowBlocking.
/**
* Block the operation during read. Just to make sure that the stats for active
* connector instances work.
*/
@Test
public void test110ReadJackDummyYellowBlocking() throws Exception {
final String TEST_NAME = "test110ReadJackDummyYellowBlocking";
TestUtil.displayTestTile(this, TEST_NAME);
dummyResourceYellow.setBlockOperations(true);
final Holder<PrismObject<ShadowType>> shadowHolder = new Holder<>();
// WHEN
Thread t = executeInNewThread("get1", new FailableRunnable() {
@Override
public void run() throws Exception {
PrismObject<ShadowType> shadow = getShadowModel(accountJackYellowOid);
LOGGER.trace("Got shadow {}", shadow);
shadowHolder.setValue(shadow);
}
});
// Give the new thread a chance to get blocked
Thread.sleep(200);
assertConnectorInstances("yellow (blocked)", RESOURCE_DUMMY_YELLOW_OID, 1, 0);
assertNull("Unexpected shadow", shadowHolder.getValue());
dummyResourceYellow.unblock();
// THEN
t.join();
dummyResourceYellow.setBlockOperations(false);
PrismObject<ShadowType> shadowYellow = shadowHolder.getValue();
assertNotNull("No shadow", shadowHolder.getValue());
display("Shadow yellow", shadowYellow);
assertConnectorInstances("yellow", RESOURCE_DUMMY_YELLOW_OID, 0, 1);
assertConnectorToString(shadowYellow, dummyResourceCtlYellow, initialConnectorToString);
assertConnectorStaticVal(shadowYellow, dummyResourceCtlYellow, initialConnectorStaticVal);
assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestConsistencySimple method executeTest.
private void executeTest(final String TEST_NAME, FocusOperation focusOperation, ShadowOperation shadowOperation, ResourceObjectOperation resourceObjectOperation) throws Exception {
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestConsistencySimple.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
cleanUpBeforeTest(task, result);
assignAccount(USER_JACK_OID, RESOURCE_DUMMY_OID, SchemaConstants.INTENT_DEFAULT, task, result);
PrismObject<UserType> jack = getUser(USER_JACK_OID);
display("Jack with account", jack);
assertEquals("Unexpected # of accounts for jack", 1, jack.asObjectable().getLinkRef().size());
ShadowType shadow = getObject(ShadowType.class, jack.asObjectable().getLinkRef().get(0).getOid()).asObjectable();
display("Shadow", shadow);
if (shadowOperation != ShadowOperation.KEEP) {
@SuppressWarnings("unchecked") ObjectDelta<UserType> removeLinkRefDelta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_LINK_REF).replace().asObjectDelta(USER_JACK_OID);
executeChanges(removeLinkRefDelta, ModelExecuteOptions.createRaw(), task, result);
jack = getUser(USER_JACK_OID);
assertEquals("Unexpected # of accounts for jack after linkRef removal", 0, jack.asObjectable().getLinkRef().size());
if (shadowOperation == ShadowOperation.DELETE) {
deleteObjectRaw(ShadowType.class, shadow.getOid(), task, result);
assertNoObject(ShadowType.class, shadow.getOid());
} else {
if (shadowOperation == ShadowOperation.UNLINK_AND_TOMBSTONE) {
@SuppressWarnings("unchecked") ObjectDelta<ShadowType> markAsDead = (ObjectDelta<ShadowType>) DeltaBuilder.deltaFor(ShadowType.class, prismContext).item(ShadowType.F_DEAD).replace(Boolean.TRUE).asObjectDelta(shadow.getOid());
executeChanges(markAsDead, ModelExecuteOptions.createRaw(), task, result);
}
assertNotNull("jack's shadow does not exist", getObject(ShadowType.class, shadow.getOid()));
}
}
if (resourceObjectOperation == ResourceObjectOperation.DELETE) {
getDummyResource().deleteAccountByName("jack");
assertNoDummyAccount(null, "jack");
} else {
assertDummyAccount(null, "jack");
}
// WHEN
switch(focusOperation) {
case RECOMPUTE:
recomputeUser(USER_JACK_OID, task, result);
break;
case RECONCILE:
ObjectDelta<UserType> emptyDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result);
break;
default:
throw new IllegalArgumentException("focusOperation: " + focusOperation);
}
// THEN
result.computeStatus();
if (ASSERT_SUCCESS) {
TestUtil.assertSuccess(result);
}
jack = getUser(USER_JACK_OID);
display("Jack after " + focusOperation, jack);
assertEquals("Unexpected # of accounts for jack", 1, jack.asObjectable().getLinkRef().size());
String shadowOidAfter = jack.asObjectable().getLinkRef().get(0).getOid();
// check the shadow really exists
assertNotNull("jack's shadow does not exist after " + focusOperation, getObject(ShadowType.class, shadowOidAfter));
// check number of jack's shadows
List<PrismObject<ShadowType>> shadows = getJacksShadows(result);
display("Shadows for 'jack' on dummy resource", shadows);
// TODO some of them may be marked as dead (solve if this occurs)
assertEquals("Unexpected # of dummy shadows for 'jack'", 1, shadows.size());
// other checks
assertDummyAccount(null, "jack");
cleanUpAfterTest(task, result);
}
Aggregations