use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.
the class TestImportRecon method test001SanityAzure.
@Test
public void test001SanityAzure() throws Exception {
displayDumpable("Dummy resource azure", dummyResourceAzure);
// WHEN
ResourceSchema resourceSchemaAzure = ResourceSchemaFactory.getRawSchema(resourceDummyAzureType);
displayDumpable("Dummy azure resource schema", resourceSchemaAzure);
// THEN
dummyResourceCtlAzure.assertDummyResourceSchemaSanityExtended(resourceSchemaAzure);
ResourceObjectClassDefinition orgOcDef = resourceSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
assertNotNull("No org object class def in azure resource schema", orgOcDef);
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.
the class TestImportRecon method test002SanityAzureRefined.
@Test
public void test002SanityAzureRefined() throws Exception {
// WHEN
ResourceSchema refinedSchemaAzure = ResourceSchemaFactory.getCompleteSchema(resourceDummyAzureType);
displayDumpable("Dummy azure refined schema", refinedSchemaAzure);
// THEN
dummyResourceCtlAzure.assertRefinedSchemaSanity(refinedSchemaAzure);
ResourceObjectClassDefinition orgOcDef = refinedSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
assertNotNull("No org object class def in azure refined schema", orgOcDef);
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.
the class TestUcfDummyMulti method test210TwoBlockingSearches.
@Test
public void test210TwoBlockingSearches() throws Exception {
// GIVEN
UcfExecutionContext ctx = createExecutionContext();
final ResourceObjectClassDefinition accountDefinition = resourceSchema.findObjectClassDefinitionRequired(ACCOUNT_OBJECT_CLASS_NAME);
// Determine object class from the schema
OperationResult result1 = createOperationResult();
final List<PrismObject<ShadowType>> searchResults1 = new ArrayList<>();
final ObjectHandler handler1 = (ucfObject, result) -> {
checkUcfShadow(ucfObject.getResourceObject(), accountDefinition);
searchResults1.add(ucfObject.getResourceObject());
return true;
};
OperationResult result2 = createOperationResult();
final List<PrismObject<ShadowType>> searchResults2 = new ArrayList<>();
final ObjectHandler handler2 = (ucfObject, result) -> {
checkUcfShadow(ucfObject.getResourceObject(), accountDefinition);
searchResults2.add(ucfObject.getResourceObject());
return true;
};
dummyResource.setBlockOperations(true);
// WHEN
Thread t1 = new Thread(() -> {
try {
cc.search(accountDefinition, null, handler1, null, null, null, null, ctx, result1);
} catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
logger.error("Error in the search: {}", e.getMessage(), e);
}
});
t1.setName("search1");
t1.start();
// Give the new thread a chance to get blocked
Thread.sleep(500);
ConnectorOperationalStatus opStat = cc.getOperationalStatus();
displayDumpable("stats (blocked 1)", opStat);
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
assertEquals("Unexpected number of search results", 0, searchResults1.size());
Thread t2 = new Thread(() -> {
try {
cc.search(accountDefinition, null, handler2, null, null, null, null, ctx, result2);
} catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
logger.error("Error in the search: {}", e.getMessage(), e);
}
});
t2.setName("search2");
t2.start();
// Give the new thread a chance to get blocked
Thread.sleep(500);
opStat = cc.getOperationalStatus();
displayDumpable("stats (blocked 2)", opStat);
assertEquals("Wrong pool active", (Integer) 2, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
assertEquals("Unexpected number of search results", 0, searchResults1.size());
dummyResource.unblockAll();
t1.join();
t2.join();
dummyResource.setBlockOperations(false);
// THEN
assertEquals("Unexpected number of search results 1", 1, searchResults1.size());
assertEquals("Unexpected number of search results 2", 1, searchResults2.size());
opStat = cc.getOperationalStatus();
displayDumpable("stats (final)", opStat);
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 2, opStat.getPoolStatusNumIdle());
PrismObject<ShadowType> searchResult1 = searchResults1.get(0);
displayDumpable("Search result 1", searchResult1);
PrismObject<ShadowType> searchResult2 = searchResults2.get(0);
displayDumpable("Search result 2", searchResult2);
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.
the class TestUcfDummyMulti method test110SearchNonBlocking.
@Test
public void test110SearchNonBlocking() 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());
ConnectorOperationalStatus opStat = cc.getOperationalStatus();
displayDumpable("stats", opStat);
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
}
use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.
the class ResourceTypeUtil method validateSchema.
// TODO: maybe later move to ResourceSchema?
public static void validateSchema(ResourceSchema resourceSchema, PrismObject<ResourceType> resource) throws SchemaException {
Set<QName> objectClassNames = new HashSet<>();
for (ResourceObjectClassDefinition objectClassDefinition : resourceSchema.getObjectClassDefinitions()) {
QName typeName = objectClassDefinition.getTypeName();
if (objectClassNames.contains(typeName)) {
throw new SchemaException("Duplicate definition of object class " + typeName + " in resource schema of " + resource);
}
objectClassNames.add(typeName);
validateObjectClassDefinition(objectClassDefinition, resource);
}
}
Aggregations