use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class AddGetObjectTest method addGetFullAccount.
/**
* Attempt to store full account in the repo and then get it out again. The
* potential problem is that there are attributes that do not have a fixed
* (static) definition.
*/
@Test
public void addGetFullAccount() throws Exception {
LOGGER.info("===[ addGetFullAccount ]===");
File file = new File(FOLDER_BASIC, "account-full.xml");
PrismObject<ShadowType> fileAccount = prismContext.parseObject(new File(FOLDER_BASIC, "account-full.xml"));
// apply appropriate schema
PrismObject<ResourceType> resource = prismContext.parseObject(new File(FOLDER_BASIC, "resource-opendj.xml"));
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
ShadowUtil.applyResourceSchema(fileAccount, resourceSchema);
OperationResult result = new OperationResult("ADD");
String oid = repositoryService.addObject(fileAccount, null, result);
PrismObject<ShadowType> repoAccount = repositoryService.getObject(ShadowType.class, oid, null, result);
ObjectDelta<ShadowType> delta = fileAccount.diff(repoAccount);
AssertJUnit.assertNotNull(delta);
LOGGER.info("delta\n{}", new Object[] { delta.debugDump(3) });
AssertJUnit.assertTrue(delta.isEmpty());
ShadowType repoShadow = repoAccount.asObjectable();
AssertJUnit.assertNotNull(repoShadow.getSynchronizationSituation());
AssertJUnit.assertEquals(SynchronizationSituationType.LINKED, repoShadow.getSynchronizationSituation());
AssertJUnit.assertNotNull(repoShadow.getSynchronizationSituationDescription());
AssertJUnit.assertEquals(1, repoShadow.getSynchronizationSituationDescription().size());
AssertJUnit.assertEquals(SynchronizationSituationType.LINKED, repoShadow.getSynchronizationSituationDescription().get(0).getSituation());
AssertJUnit.assertEquals("syncChannel", repoShadow.getSynchronizationSituationDescription().get(0).getChannel());
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class AdUtils method assertAdSchema.
public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject<ResourceType> resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException {
ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext);
display("Resource schema", resourceSchema);
RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
display("Refined schema", refinedSchema);
ObjectClassComplexTypeDefinition accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(accountObjectClass);
assertNotNull("No definition for object class " + accountObjectClass, accountObjectClassDefinition);
display("Account object class def", accountObjectClassDefinition);
ResourceAttributeDefinition<String> cnDef = accountObjectClassDefinition.findAttributeDefinition("cn");
PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, 1);
assertTrue("cn read", cnDef.canRead());
assertTrue("cn modify", cnDef.canModify());
assertTrue("cn add", cnDef.canAdd());
ResourceAttributeDefinition<String> samAccountNameDef = accountObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_SAM_ACCOUNT_NAME_NAME);
PrismAsserts.assertDefinition(samAccountNameDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME), DOMUtil.XSD_STRING, 0, 1);
assertTrue("samAccountNameDef read", samAccountNameDef.canRead());
assertTrue("samAccountNameDef modify", samAccountNameDef.canModify());
assertTrue("samAccountNameDef add", samAccountNameDef.canAdd());
ResourceAttributeDefinition<String> oDef = accountObjectClassDefinition.findAttributeDefinition("o");
PrismAsserts.assertDefinition(oDef, new QName(MidPointConstants.NS_RI, "o"), DOMUtil.XSD_STRING, 0, -1);
assertTrue("o read", oDef.canRead());
assertTrue("o modify", oDef.canModify());
assertTrue("o add", oDef.canAdd());
ResourceAttributeDefinition<Long> createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp");
PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), DOMUtil.XSD_LONG, 0, 1);
assertTrue("createTimeStampDef read", createTimestampDef.canRead());
assertFalse("createTimeStampDef modify", createTimestampDef.canModify());
assertFalse("createTimeStampDef add", createTimestampDef.canAdd());
ResourceAttributeDefinition<Long> isCriticalSystemObjectDef = accountObjectClassDefinition.findAttributeDefinition("isCriticalSystemObject");
PrismAsserts.assertDefinition(isCriticalSystemObjectDef, new QName(MidPointConstants.NS_RI, "isCriticalSystemObject"), DOMUtil.XSD_BOOLEAN, 0, 1);
assertTrue("isCriticalSystemObject read", isCriticalSystemObjectDef.canRead());
assertTrue("isCriticalSystemObject modify", isCriticalSystemObjectDef.canModify());
assertTrue("isCriticalSystemObject add", isCriticalSystemObjectDef.canAdd());
ResourceAttributeDefinition<Long> nTSecurityDescriptorDef = accountObjectClassDefinition.findAttributeDefinition("nTSecurityDescriptor");
PrismAsserts.assertDefinition(nTSecurityDescriptorDef, new QName(MidPointConstants.NS_RI, "nTSecurityDescriptor"), DOMUtil.XSD_BASE64BINARY, 0, 1);
assertTrue("nTSecurityDescriptor read", nTSecurityDescriptorDef.canRead());
assertTrue("nTSecurityDescriptor modify", nTSecurityDescriptorDef.canModify());
assertTrue("nTSecurityDescriptor add", nTSecurityDescriptorDef.canAdd());
ResourceAttributeDefinition<Long> lastLogonDef = accountObjectClassDefinition.findAttributeDefinition("lastLogon");
PrismAsserts.assertDefinition(lastLogonDef, new QName(MidPointConstants.NS_RI, "lastLogon"), DOMUtil.XSD_LONG, 0, 1);
assertTrue("lastLogonDef read", lastLogonDef.canRead());
assertTrue("lastLogonDef modify", lastLogonDef.canModify());
assertTrue("lastLogonDef add", lastLogonDef.canAdd());
return accountObjectClassDefinition;
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class AddGetObjectTest method addGetFullAccountShadow.
@Test
private void addGetFullAccountShadow() throws Exception {
LOGGER.info("===[ simpleAddAccountShadowTest ]===");
OperationResult result = new OperationResult("testAddAccountShadow");
File file = new File(FOLDER_BASIC, "account-accountTypeShadow.xml");
try {
PrismObject<ShadowType> account = prismContext.parseObject(file);
// apply appropriate schema
PrismObject<ResourceType> resource = prismContext.parseObject(new File(FOLDER_BASIC, "resource-opendj.xml"));
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
ShadowUtil.applyResourceSchema(account, resourceSchema);
repositoryService.addObject(account, null, result);
PrismObject<ShadowType> afterAdd = repositoryService.getObject(ShadowType.class, account.getOid(), null, result);
AssertJUnit.assertNotNull(afterAdd);
} catch (Exception ex) {
LOGGER.error("Exception occurred", ex);
throw ex;
}
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class IntegrationTestTools method applyResourceSchema.
public static void applyResourceSchema(ShadowType accountType, ResourceType resourceType, PrismContext prismContext) throws SchemaException {
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
ShadowUtil.applyResourceSchema(accountType.asPrismObject(), resourceSchema);
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class TestImportRecon method test001SanityAzure.
@Test
public void test001SanityAzure() throws Exception {
final String TEST_NAME = "test001SanityAzure";
TestUtil.displayTestTile(this, TEST_NAME);
display("Dummy resource azure", dummyResourceAzure);
// WHEN
ResourceSchema resourceSchemaAzure = RefinedResourceSchemaImpl.getResourceSchema(resourceDummyAzureType, prismContext);
display("Dummy azure resource schema", resourceSchemaAzure);
// THEN
dummyResourceCtlAzure.assertDummyResourceSchemaSanityExtended(resourceSchemaAzure);
ObjectClassComplexTypeDefinition orgOcDef = resourceSchemaAzure.findObjectClassDefinition(dummyResourceCtlAzure.getOrgObjectClassQName());
assertNotNull("No org object class def in azure resource schema", orgOcDef);
}
Aggregations