use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class TestDummy method test195SearchOnAndOffResource.
/**
* Search with query that queries both the repository and the resource.
* We cannot do this. This should fail.
* MID-2822
*/
@Test
public void test195SearchOnAndOffResource() throws Exception {
final String TEST_NAME = "test195SearchOnAndOffResource";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ObjectQuery query = createOnOffQuery();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
AssertJUnit.fail("Handler called: " + object);
return false;
}
};
try {
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, task, result);
AssertJUnit.fail("unexpected success");
} catch (SchemaException e) {
// This is expected
display("Expected exception", e);
}
// THEN
result.computeStatus();
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class TestDummy method test112SeachIterativeKindIntent.
@Test
public void test112SeachIterativeKindIntent() throws Exception {
final String TEST_NAME = "test112SeachIterativeKindIntent";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, "default", prismContext);
display("query", query);
final List<PrismObject<ShadowType>> foundObjects = new ArrayList<PrismObject<ShadowType>>();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
foundObjects.add(object);
return true;
}
};
rememberShadowFetchOperationCount();
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
// THEN
result.computeStatus();
display("searchObjectsIterative result", result);
TestUtil.assertSuccess(result);
assertShadowFetchOperationCountIncrement(1);
display("Found shadows", foundObjects);
assertEquals(4, foundObjects.size());
checkConsistency(foundObjects);
// MID-1640
assertProtected(foundObjects, 1);
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class PageDebugDownloadBehaviour method dumpObjectsToStream.
private void dumpObjectsToStream(final Writer writer, OperationResult result) throws Exception {
final PageBase page = getPage();
ResultHandler handler = (object, parentResult) -> {
try {
String xml = page.getPrismContext().xmlSerializer().options(createSerializeForExport()).serialize(object);
writer.write('\t');
writer.write(xml);
writer.write('\n');
} catch (IOException | SchemaException ex) {
throw new SystemException(ex.getMessage(), ex);
}
return true;
};
ModelService service = page.getModelService();
GetOperationOptionsBuilder optionsBuilder = page.getSchemaService().getOperationOptionsBuilder().raw().resolveNames();
if (showAllItems) {
optionsBuilder = optionsBuilder.retrieve();
}
service.searchObjectsIterative(type, query, handler, optionsBuilder.build(), page.createSimpleTask(OPERATION_SEARCH_OBJECT), result);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchIterativeTest method test101SequentialIterationWithSmallResult.
// MID-5339
@Test
public void test101SequentialIterationWithSmallResult() throws Exception {
OperationResult result = new OperationResult("test101SequentialIterationWithSmallResult");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
return true;
};
SearchOpAsserter asserter = new SearchOpAsserter();
ObjectQuery query = prismContext.queryFor(UserType.class).item(UserType.F_COST_CENTER).eq(String.valueOf(BASE)).build();
repositoryService.searchObjectsIterative(UserType.class, query, handler, null, true, result);
result.recomputeStatus();
asserter.assertIncrement(1);
assertTrue(result.isSuccess());
assertObjects(objects, 1);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchIterativeTest method test105SimpleNonSequentialIteration.
@Test
public void test105SimpleNonSequentialIteration() throws Exception {
OperationResult result = new OperationResult("test105SimpleNonSequentialIteration");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
return true;
};
SearchOpAsserter searchOpAsserter = new SearchOpAsserter();
OpAsserter countOpAsserter = new OpAsserter(RepositoryService.OP_COUNT_OBJECTS);
repositoryService.searchObjectsIterative(UserType.class, null, handler, null, false, result);
result.recomputeStatus();
countOpAsserter.assertIncrement(1);
searchOpAsserter.assertIncrement(COUNT / BATCH);
assertTrue(result.isSuccess());
assertObjects(objects, COUNT);
}
Aggregations