use of com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext in project midpoint by Evolveum.
the class TestUcfDummyMulti method test200BlockingSearch.
@Test
public void test200BlockingSearch() throws Exception {
// GIVEN
UcfExecutionContext ctx = createExecutionContext();
OperationResult result = createOperationResult();
final ResourceObjectClassDefinition accountDefinition = resourceSchema.findObjectClassDefinitionRequired(ACCOUNT_OBJECT_CLASS_NAME);
// Determine object class from the schema
final List<PrismObject<ShadowType>> searchResults = new ArrayList<>();
final ObjectHandler handler = (ucfObject, lResult) -> {
checkUcfShadow(ucfObject.getResourceObject(), accountDefinition);
searchResults.add(ucfObject.getResourceObject());
return true;
};
dummyResource.setBlockOperations(true);
// WHEN
Thread t = new Thread(() -> {
try {
cc.search(accountDefinition, null, handler, null, null, null, null, ctx, result);
} catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
logger.error("Error in the search: {}", e.getMessage(), e);
}
});
t.setName("search1");
t.start();
// Give the new thread a chance to get blocked
Thread.sleep(500);
ConnectorOperationalStatus opStat = cc.getOperationalStatus();
displayDumpable("stats (blocked)", opStat);
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
assertEquals("Unexpected number of search results", 0, searchResults.size());
dummyResource.unblock();
t.join();
dummyResource.setBlockOperations(false);
// THEN
assertEquals("Unexpected number of search results", 1, searchResults.size());
opStat = cc.getOperationalStatus();
displayDumpable("stats (final)", opStat);
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
PrismObject<ShadowType> searchResult = searchResults.get(0);
displayDumpable("Search result", searchResult);
}
use of com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext in project midpoint by Evolveum.
the class TestUcfDummy method test050Search.
@Test
public void test050Search() throws Exception {
// GIVEN
UcfExecutionContext ctx = createExecutionContext();
final ResourceObjectClassDefinition accountDefinition = resourceSchema.findObjectClassDefinitionRequired(ACCOUNT_OBJECT_CLASS_NAME);
// Determine object class from the schema
final List<PrismObject<ShadowType>> searchResults = new ArrayList<>();
ObjectHandler handler = (ucfObject, result) -> {
displayDumpable("Search: found", ucfObject);
checkUcfShadow(ucfObject.getResourceObject(), accountDefinition);
searchResults.add(ucfObject.getResourceObject());
return true;
};
OperationResult result = createOperationResult();
// WHEN
cc.search(accountDefinition, null, handler, null, null, null, null, ctx, result);
// THEN
assertEquals("Unexpected number of search results", 1, searchResults.size());
}
Aggregations