use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestBrokenResources method test102GetAccountMurrayRaw.
@Test
public void test102GetAccountMurrayRaw() throws Exception {
TestUtil.displayTestTile(this, "test102GetAccountMurrayRaw");
// GIVEN
Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test102GetAccountMurrayRaw");
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
// WHEN
PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_CSVFILE_OID, options, task, result);
display("getObject account", account);
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess("getObject result", result);
// TODO: better asserts
assertNotNull("Null resource", account);
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method getShadowModel.
protected PrismObject<ShadowType> getShadowModel(String accountOid, boolean noFetch, boolean assertSuccess) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getAccount");
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> opts = null;
if (noFetch) {
GetOperationOptions rootOpts = new GetOperationOptions();
rootOpts.setNoFetch(true);
opts = SelectorOptions.createCollection(rootOpts);
}
PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, accountOid, opts, task, result);
result.computeStatus();
if (assertSuccess) {
TestUtil.assertSuccess("getObject(Account) result not success", result);
}
return account;
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestDummy method test107AGetModifiedAccountFromCacheMax.
// test102-test106 in the superclasses
/**
* Make a native modification to an account and read it with max staleness option.
* As there is no caching enabled this should throw an error.
*
* Note: This test is overridden in TestDummyCaching
*
* MID-3481
*/
@Test
public void test107AGetModifiedAccountFromCacheMax() throws Exception {
final String TEST_NAME = "test107AGetModifiedAccountFromCacheMax";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
rememberShadowFetchOperationCount();
DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Nice Pirate");
accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor");
accountWill.setEnabled(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createMaxStaleness());
XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
try {
ShadowType shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result).asObjectable();
AssertJUnit.fail("Unexpected success");
} catch (ConfigurationException e) {
// Caching is disabled, this is expected.
TestUtil.displayThen(TEST_NAME);
display("Expected exception", e);
result.computeStatus();
TestUtil.assertFailure(result);
}
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
checkRepoAccountShadowWillBasic(shadowRepo, null, startTs, null);
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.DISABLED);
assertShadowFetchOperationCountIncrement(0);
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestDummyCaching method test107BGetModifiedAccountFromCacheHighStaleness.
/**
* Make a native modification to an account and read it with high staleness option.
* This should return cached data.
* MID-3481
*/
@Test
@Override
public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception {
final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
rememberShadowFetchOperationCount();
DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
accountWill.setEnabled(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createStaleness(1000000L));
XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
assertShadowFetchOperationCountIncrement(0);
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
display("Retrieved account shadow", shadow);
assertNotNull("No dummy account", shadow);
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow);
assertEquals("Unexpected number of attributes", 7, attributes.size());
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
checkRepoAccountShadowWillBasic(shadowRepo, null, startTs, null);
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.DISABLED);
checkConsistency(shadow);
assertCachingMetadata(shadow, true, null, startTs);
assertShadowFetchOperationCountIncrement(0);
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestDummy method test107BGetModifiedAccountFromCacheHighStaleness.
/**
* Make a native modification to an account and read it with high staleness option.
* In this test there is no caching enabled, so this should return fresh data.
*
* Note: This test is overridden in TestDummyCaching
*
* MID-3481
*/
@Test
public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception {
final String TEST_NAME = "test107BGetModifiedAccountFromCacheHighStaleness";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
rememberShadowFetchOperationCount();
DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
accountWill.setEnabled(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createStaleness(1000000L));
XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, null, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
checkRepoAccountShadowWillBasic(shadowRepo, null, startTs, null);
assertShadowFetchOperationCountIncrement(1);
assertSteadyResource();
}
Aggregations