use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class MidPointAbstractDataSource method getFieldValue.
@Override
public Object getFieldValue(JRField jrField) throws JRException {
// TODO Auto-generated method stub
String fieldName = jrField.getName();
if (fieldName.equals("oid")) {
return currentObject.getOid();
}
Item i = currentObject.findItem(new QName(fieldName));
if (i == null) {
return null;
}
if (i instanceof PrismProperty) {
if (i.isSingleValue()) {
return ((PrismProperty) i).getRealValue();
}
return ((PrismProperty) i).getRealValues();
} else if (i instanceof PrismReference) {
if (i.isSingleValue()) {
return ((PrismReference) i).getValue().asReferencable();
}
List<Referencable> refs = new ArrayList<Referencable>();
for (PrismReferenceValue refVal : ((PrismReference) i).getValues()) {
refs.add(refVal.asReferencable());
}
return refs;
} else if (i instanceof PrismContainer) {
if (i.isSingleValue()) {
return ((PrismContainer) i).getValue().asContainerable();
}
List<Containerable> containers = new ArrayList<Containerable>();
for (Object pcv : i.getValues()) {
if (pcv instanceof PrismContainerValue) {
containers.add(((PrismContainerValue) pcv).asContainerable());
}
}
return containers;
} else
throw new JRException("Could not get value of the fileld: " + fieldName);
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class TestOpenDjNegative method test004ResourceAndConnectorCaching.
@Test
public void test004ResourceAndConnectorCaching() throws Exception {
TestUtil.displayTestTile("test004ResourceAndConnectorCaching");
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + ".test004ResourceAndConnectorCaching");
Task task = taskManager.createTaskInstance();
// WHEN
// This should NOT throw an exception. It should just indicate the failure in results
resource = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
ResourceType resourceType = resource.asObjectable();
// THEN
result.computeStatus();
display("getObject(resource) result", result);
TestUtil.assertFailure(result);
TestUtil.assertFailure(resource.asObjectable().getFetchResult());
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
assertNull("Resource schema found", resourceSchema);
// WHEN
PrismObject<ResourceType> resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, task, result);
// THEN
result.computeStatus();
display("getObject(resourceAgain) result", result);
TestUtil.assertFailure(result);
TestUtil.assertFailure(resourceAgain.asObjectable().getFetchResult());
ResourceType resourceTypeAgain = resourceAgain.asObjectable();
assertNotNull("No connector ref", resourceTypeAgain.getConnectorRef());
assertNotNull("No connector ref OID", resourceTypeAgain.getConnectorRef().getOid());
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismContainer<Containerable> configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain));
assertTrue("Configurations not equals", configurationContainer.equals(configurationContainerAgain));
ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext);
assertNull("Resource schema (again)", resourceSchemaAgain);
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractIntegrationTest method assertShadowRepo.
protected void assertShadowRepo(PrismObject<ShadowType> accountShadow, String oid, String username, ResourceType resourceType, QName objectClass, MatchingRule<String> nameMatchingRule) throws SchemaException {
assertShadowCommon(accountShadow, oid, username, resourceType, objectClass, nameMatchingRule, true);
PrismContainer<Containerable> attributesContainer = accountShadow.findContainer(ShadowType.F_ATTRIBUTES);
List<Item<?, ?>> attributes = attributesContainer.getValue().getItems();
// Collection secIdentifiers = ShadowUtil.getSecondaryIdentifiers(accountShadow);
if (attributes == null) {
AssertJUnit.fail("No attributes in repo shadow");
}
RefinedResourceSchema refinedSchema = null;
try {
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
} catch (SchemaException e) {
AssertJUnit.fail(e.getMessage());
}
ObjectClassComplexTypeDefinition objClassDef = refinedSchema.getRefinedDefinition(objectClass);
Collection secIdentifiers = objClassDef.getSecondaryIdentifiers();
if (secIdentifiers == null) {
AssertJUnit.fail("No secondary identifiers in repo shadow");
}
// repo shadow should contains all secondary identifiers + ICF_UID
assertRepoShadowAttributes(attributes, secIdentifiers.size() + 1);
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractIntegrationTest method getIcfUid.
protected String getIcfUid(PrismObject<ShadowType> shadow) {
PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
assertNotNull("Null attributes in " + shadow, attributesContainer);
assertFalse("Empty attributes in " + shadow, attributesContainer.isEmpty());
PrismProperty<String> icfUidProp = attributesContainer.findProperty(new QName(SchemaConstants.NS_ICF_SCHEMA, "uid"));
assertNotNull("No ICF name attribute in " + shadow, icfUidProp);
return icfUidProp.getRealValue();
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class TestDummyNegative method testGetResourceBrokenSchema.
public void testGetResourceBrokenSchema(BreakMode breakMode, String testName) throws Exception {
TestUtil.displayTestTile(testName);
// GIVEN
OperationResult result = new OperationResult(TestDummyNegative.class.getName() + "." + testName);
// precondition
PrismObject<ResourceType> repoResource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
display("Repo resource (before)", repoResource);
PrismContainer<Containerable> schema = repoResource.findContainer(ResourceType.F_SCHEMA);
assertTrue("Schema found in resource before the test (precondition)", schema == null || schema.isEmpty());
dummyResource.setSchemaBreakMode(breakMode);
try {
// WHEN
PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
// THEN
display("Resource with broken schema", resource);
OperationResultType fetchResult = resource.asObjectable().getFetchResult();
result.computeStatus();
display("getObject result", result);
assertEquals("Unexpected result of getObject operation", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
assertNotNull("No fetch result", fetchResult);
display("fetchResult", fetchResult);
assertEquals("Unexpected result of fetchResult", OperationResultStatusType.PARTIAL_ERROR, fetchResult.getStatus());
} finally {
dummyResource.setSchemaBreakMode(BreakMode.NONE);
}
}
Aggregations