Search in sources :

Example 11 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class TestUcfDummyMulti method test110SearchNonBlocking.

@Test
public void test110SearchNonBlocking() throws Exception {
    final String TEST_NAME = "test100SearchNonBlocking";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    // Determine object class from the schema
    final List<PrismObject<ShadowType>> searchResults = new ArrayList<PrismObject<ShadowType>>();
    ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {

        @Override
        public boolean handle(PrismObject<ShadowType> shadow) {
            System.out.println("Search: found: " + shadow);
            checkUcfShadow(shadow, accountDefinition);
            searchResults.add(shadow);
            return true;
        }
    };
    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
    // WHEN
    cc.search(accountDefinition, new ObjectQuery(), handler, null, null, null, null, result);
    // THEN
    assertEquals("Unexpected number of search results", 1, searchResults.size());
    ConnectorOperationalStatus opStat = cc.getOperationalStatus();
    display("stats", opStat);
    assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
    assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.provisioning.ucf.api.ResultHandler) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 12 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class AbstractCsvTest method test005ParsedSchema.

@Test
public void test005ParsedSchema() throws Exception {
    final String TEST_NAME = "test005ParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // THEN
    // The returned type should have the schema pre-parsed
    assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
    // Also test if the utility method returns the same thing
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
    display("Parsed resource schema", resourceSchema);
    assertNotNull("No resource schema", resourceSchema);
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_CSV_ACCOUNT_OBJECTCLASS);
    assertNotNull("Account definition is missing", accountDef);
    assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
    assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
    assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
    assertFalse("No nativeObjectClass in account", StringUtils.isEmpty(accountDef.getNativeObjectClass()));
    assertAccountDefinition(accountDef);
    ResourceAttributeDefinition<String> icfsNameDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_NAME);
    assertNull("ICFS NAME definition sneaked in", icfsNameDef);
    ResourceAttributeDefinition<String> icfsUidDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_UID);
    assertNull("ICFS UID definition sneaked in", icfsUidDef);
    // Check whether it is reusing the existing schema and not parsing it all over again
    // Not equals() but == ... we want to really know if exactly the same
    // object instance is returned
    assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Example 13 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class AbstractIntegrationTest method assertShadowSecondaryIdentifier.

protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass());
    ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
    assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + expectedIdentifier, idProp);
    if (nameMatchingRule == null) {
        assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue());
    } else {
        PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue());
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Containerable(com.evolveum.midpoint.prism.Containerable) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 14 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class AbstractManualResourceTest method test005ParsedSchema.

@Test
public void test005ParsedSchema() throws Exception {
    final String TEST_NAME = "test005ParsedSchema";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
    // THEN
    // The returned type should have the schema pre-parsed
    assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
    // Also test if the utility method returns the same thing
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
    display("Parsed resource schema", resourceSchema);
    // Check whether it is reusing the existing schema and not parsing it all over again
    // Not equals() but == ... we want to really know if exactly the same
    // object instance is returned
    assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
    ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_ACCOUNT_OBJECTCLASS);
    assertNotNull("Account definition is missing", accountDef);
    assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
    assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
    assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
    assertEquals("Unexpected number of definitions", getNumberOfAccountAttributeDefinitions(), accountDef.getDefinitions().size());
    ResourceAttributeDefinition<String> usernameDef = accountDef.findAttributeDefinition(ATTR_USERNAME);
    assertNotNull("No definition for username", usernameDef);
    assertEquals(1, usernameDef.getMaxOccurs());
    assertEquals(1, usernameDef.getMinOccurs());
    assertTrue("No username create", usernameDef.canAdd());
    assertTrue("No username update", usernameDef.canModify());
    assertTrue("No username read", usernameDef.canRead());
    ResourceAttributeDefinition<String> fullnameDef = accountDef.findAttributeDefinition(ATTR_FULLNAME);
    assertNotNull("No definition for fullname", fullnameDef);
    assertEquals(1, fullnameDef.getMaxOccurs());
    assertEquals(0, fullnameDef.getMinOccurs());
    assertTrue("No fullname create", fullnameDef.canAdd());
    assertTrue("No fullname update", fullnameDef.canModify());
    assertTrue("No fullname read", fullnameDef.canRead());
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 15 with ObjectClassComplexTypeDefinition

use of com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition in project midpoint by Evolveum.

the class TestDummy method testSeachIterativeSingleAttrFilter.

protected <T> void testSeachIterativeSingleAttrFilter(final String TEST_NAME, QName attrQName, T attrVal, GetOperationOptions rootOptions, boolean fullShadow, String... expectedAccountNames) throws Exception {
    ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
    ObjectClassComplexTypeDefinition objectClassDef = resourceSchema.findObjectClassDefinition(SchemaTestConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME);
    ResourceAttributeDefinition<T> attrDef = objectClassDef.findAttributeDefinition(attrQName);
    ObjectFilter filter = QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getName()).eq(attrVal).buildFilter();
    testSeachIterative(TEST_NAME, filter, rootOptions, fullShadow, true, false, expectedAccountNames);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Aggregations

ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)53 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)18 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)17 Test (org.testng.annotations.Test)17 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)16 QName (javax.xml.namespace.QName)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ArrayList (java.util.ArrayList)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)8 Task (com.evolveum.midpoint.task.api.Task)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)5 Containerable (com.evolveum.midpoint.prism.Containerable)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)3