use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestDummy method test108GetAccountLowStaleness.
/**
* Staleness of one millisecond is too small for the cache to work.
* Fresh data should be returned - both in case the cache is enabled and disabled.
* MID-3481
*/
@Test
public void test108GetAccountLowStaleness() throws Exception {
final String TEST_NAME = "test106GetModifiedAccount";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
rememberShadowFetchOperationCount();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createStaleness(1L));
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(1);
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
display("Retrieved account shadow", shadow);
assertNotNull("No dummy account", shadow);
checkAccountShadow(shadow, result, true, startTs, endTs);
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor");
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, startTs, endTs, null);
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Interceptor");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
checkConsistency(shadow);
assertCachingMetadata(shadow, false, startTs, endTs);
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestDummy method test203GetGroupNoFetch.
@Test
public void test203GetGroupNoFetch() throws Exception {
final String TEST_NAME = "test203GetGroupNoFetch";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
GetOperationOptions rootOptions = new GetOperationOptions();
rootOptions.setNoFetch(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOptions);
rememberDummyResourceGroupMembersReadCount(null);
// WHEN
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, GROUP_PIRATES_OID, options, null, result);
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
display("Retrieved group shadow", shadow);
assertNotNull("No dummy group", shadow);
assertDummyResourceGroupMembersReadCountIncrement(null, 0);
checkGroupShadow(shadow, result, false);
checkConsistency(shadow);
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestEditSchema method test123LookupLanguagesGetByKeyContainingWithPaging.
@Test
public void test123LookupLanguagesGetByKeyContainingWithPaging() throws Exception {
final String TEST_NAME = "test123LookupLanguagesGetByKeyContainingWithPaging";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
ObjectPaging paging = ObjectPaging.createPaging(2, 1, LookupTableRowType.F_KEY, OrderDirection.ASCENDING);
RelationalValueSearchQuery query = new RelationalValueSearchQuery(LookupTableRowType.F_KEY, "_", RelationalValueSearchType.SUBSTRING, paging);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(query));
PrismObject<LookupTableType> lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" });
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestEditSchema method test133LookupLanguagesGetByValueContainingWithPaging.
@Test
public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception {
final String TEST_NAME = "test123LookupLanguagesGetByKeyContainingWithPaging";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
// using sorting key other than the one used in search
ObjectPaging paging = ObjectPaging.createPaging(0, 1, LookupTableRowType.F_LABEL, OrderDirection.DESCENDING);
RelationalValueSearchQuery query = new RelationalValueSearchQuery(LookupTableRowType.F_VALUE, "n", RelationalValueSearchType.SUBSTRING, paging);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(query));
PrismObject<LookupTableType> lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" });
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class TestEditSchema method test124LookupLanguagesGetByKeyContainingReturningNothing.
@Test
public void test124LookupLanguagesGetByKeyContainingReturningNothing() throws Exception {
final String TEST_NAME = "test124LookupLanguagesGetByKeyContainingReturningNothing";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
RelationalValueSearchQuery query = new RelationalValueSearchQuery(LookupTableRowType.F_KEY, "xyz", RelationalValueSearchType.SUBSTRING);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(query));
PrismObject<LookupTableType> lookup = modelService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, options, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
IntegrationTestTools.display("Languages", lookup);
assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig());
PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0);
assertSteadyResources();
}
Aggregations