use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class TestNotifyChange method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
// Resources
DummyResourceContoller dummyResourceCtlGrouper = DummyResourceContoller.create(RESOURCE_GROUPER_ID, resourceDummyGrouper);
DummyResource dummyResourceGrouper = dummyResourceCtlGrouper.getDummyResource();
dummyResourceGrouper.setSyncStyle(DummySyncStyle.SMART);
dummyResourceGrouper.populateWithDefaultSchema();
resourceDummyGrouper = importAndGetObjectFromFile(ResourceType.class, RESOURCE_GROUPER_FILE, RESOURCE_GROUPER_OID, initTask, initResult);
dummyResourceCtlGrouper.setResource(resourceDummyGrouper);
}
use of com.evolveum.midpoint.test.DummyResourceContoller in project midpoint by Evolveum.
the class TestDummyNegative method test240GetBrokenAccounts.
/**
* Checks the behaviour when getting broken accounts, i.e. accounts that cannot be retrieved
* because of e.g.
*
* - inability to convert from ConnId to resource object (`ShadowType`)
* - inability to create or update midPoint shadow
*
* The current behavior is that `getObject` throws an exception in these cases.
* This may or may not be ideal. We can consider changing that (to signalling via `fetchResult`)
* later. But that would mean adapting the clients so that they would check the `fetchResult`
* and use the resulting shadow only if it's OK.
*
* Because the `getObject` operation requires a shadow to exists, we have to create these objects
* in a good shape, retrieve them, and break them afterwards.
*/
@Test
public void test240GetBrokenAccounts() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
DummyResourceContoller controller = RESOURCE_DUMMY_BROKEN_ACCOUNTS.controller;
DummyResource resource = controller.getDummyResource();
// create good accounts
createAccount(GOOD_ACCOUNT, 1, null);
createAccount(INCONVERTIBLE_ACCOUNT, 2, null);
createAccount(UNSTORABLE_ACCOUNT, 3, null);
// here we create the shadows
SearchResultList<PrismObject<ShadowType>> accounts = provisioningService.searchObjects(ShadowType.class, getAllAccountsQuery(RESOURCE_DUMMY_BROKEN_ACCOUNTS), null, task, result);
String goodOid = selectAccountByName(accounts, GOOD_ACCOUNT).getOid();
String inconvertibleOid = selectAccountByName(accounts, INCONVERTIBLE_ACCOUNT).getOid();
String unstorableOid = selectAccountByName(accounts, UNSTORABLE_ACCOUNT).getOid();
// break the accounts
resource.getAccountByUsername(INCONVERTIBLE_ACCOUNT).replaceAttributeValue(ENABLE_DATE_NAME, "WRONG");
resource.getAccountByUsername(UNSTORABLE_ACCOUNT).replaceAttributeValue(ATTR_NUMBER, "WRONG");
when(GOOD_ACCOUNT);
PrismObject<ShadowType> goodReloaded = provisioningService.getObject(ShadowType.class, goodOid, null, task, result);
then(GOOD_ACCOUNT);
assertShadow(goodReloaded, GOOD_ACCOUNT).assertSuccessOrNoFetchResult();
when(INCONVERTIBLE_ACCOUNT);
try {
provisioningService.getObject(ShadowType.class, inconvertibleOid, null, task, result);
assertNotReached();
} catch (SchemaException e) {
then(INCONVERTIBLE_ACCOUNT);
displayExpectedException(e);
// Note: this is the current implementation. We might change it to return something,
// and fill-in fetchResult appropriately.
}
when(UNSTORABLE_ACCOUNT);
try {
provisioningService.getObject(ShadowType.class, unstorableOid, null, task, result);
assertNotReached();
} catch (Exception e) {
then(UNSTORABLE_ACCOUNT);
displayExpectedException(e);
// Note: this is the current implementation. We might change it to return something,
// and fill-in fetchResult appropriately.
}
}
Aggregations