Search in sources :

Example 76 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestSchemaDelta method testDeleteInducementActivationSameNullIdApplyToObject.

@Test
public void testDeleteInducementActivationSameNullIdApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteInducementActivationSameNullIdApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
    //Delta
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    // No container ID
    ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(ROLE_CONSTRUCTION_INDUCEMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
    // WHEN
    roleDelta.applyTo(role);
    // THEN
    System.out.println("Role after delta application:");
    System.out.println(role.debugDump());
    assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
    PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
    PrismContainer<AssignmentType> inducementContainer = role.findContainer(RoleType.F_INDUCEMENT);
    assertNotNull("No inducement", inducementContainer);
    assertEquals("Unexpected number of inducement values", 1, inducementContainer.size());
    PrismContainerValue<AssignmentType> inducementValue = inducementContainer.getValues().iterator().next();
    AssignmentType inducement = inducementValue.asContainerable();
    ActivationType activation = inducement.getActivation();
    // activation should be gone (the error is that it is empty and not gone)
    assertNull("Activation is not gone", activation);
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 77 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestQueryConvertor method testAccountQueryAttributesAndResourceNoNs.

@Test
public void testAccountQueryAttributesAndResourceNoNs() throws Exception {
    displayTestTitle("testAccountQueryAttributesAndResourceNoNs");
    SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_NO_NS_FILE);
    ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
    displayQuery(query);
    assertNotNull(query);
    ObjectFilter filter = query.getFilter();
    PrismAsserts.assertAndFilter(filter, 2);
    ObjectFilter first = getFilterCondition(filter, 0);
    PrismAsserts.assertRefFilter(first, ShadowType.F_RESOURCE_REF, ObjectReferenceType.COMPLEX_TYPE, new ItemPath(ShadowType.F_RESOURCE_REF));
    assertRefFilterValue((RefFilter) first, "aae7be60-df56-11df-8608-0002a5d5c51b");
    ObjectFilter second = getFilterCondition(filter, 1);
    PrismAsserts.assertEqualsFilter(second, ICF_NAME, DOMUtil.XSD_STRING, new ItemPath("attributes", "name"));
    //PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "uid=jbond,ou=People,dc=example,dc=com");
    QueryType convertedQueryType = toQueryType(query);
    System.out.println(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext())));
// TODO: add some asserts
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 78 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestQueryConvertor method testConnectorQuery.

@Test
public void testConnectorQuery() throws Exception {
    displayTestTitle("testConnectorQuery");
    SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_CONNECTOR_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
    ObjectQuery query;
    try {
        query = QueryJaxbConvertor.createObjectQuery(ConnectorType.class, filterType, getPrismContext());
        displayQuery(query);
        assertNotNull(query);
        ObjectFilter filter = query.getFilter();
        PrismAsserts.assertEqualsFilter(query.getFilter(), ConnectorType.F_CONNECTOR_TYPE, DOMUtil.XSD_STRING, new ItemPath(ConnectorType.F_CONNECTOR_TYPE));
        PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, "org.identityconnectors.ldap.LdapConnector");
        QueryType convertedQueryType = toQueryType(query);
        displayQueryType(convertedQueryType);
    } catch (Exception ex) {
        LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
        throw ex;
    }
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 79 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestQueryConvertor method testAccountQueryCompositeOr.

@Test
public void testAccountQueryCompositeOr() throws Exception {
    displayTestTitle("testAccountQueryCompositeOr");
    SearchFilterType filterType = unmarshalFilter(FILTER_OR_COMPOSITE);
    ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
    displayQuery(query);
    assertNotNull(query);
    ObjectFilter filter = query.getFilter();
    PrismAsserts.assertOrFilter(filter, 4);
    ObjectFilter first = getFilterCondition(filter, 0);
    PrismAsserts.assertEqualsFilter(first, ShadowType.F_INTENT, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_INTENT));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "some account type");
    ObjectFilter second = getFilterCondition(filter, 1);
    PrismAsserts.assertEqualsFilter(second, fooBlaDefinition, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_ATTRIBUTES, fooBlaDefinition));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "foo value");
    ObjectFilter third = getFilterCondition(filter, 2);
    PrismAsserts.assertEqualsFilter(third, stringExtensionDefinition, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_EXTENSION, stringExtensionDefinition));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) third, "uid=test,dc=example,dc=com");
    ObjectFilter forth = getFilterCondition(filter, 3);
    PrismAsserts.assertRefFilter(forth, ShadowType.F_RESOURCE_REF, ObjectReferenceType.COMPLEX_TYPE, new ItemPath(ShadowType.F_RESOURCE_REF));
    assertRefFilterValue((RefFilter) forth, "d0db5be9-cb93-401f-b6c1-86ffffe4cd5e");
    QueryType convertedQueryType = toQueryType(query);
    LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext())));
// TODO: add some asserts
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 80 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestQueryConvertor method testGenericQuery.

@Test
public void testGenericQuery() throws Exception {
    displayTestTitle("testGenericQuery");
    SearchFilterType queryType = unmarshalFilter(FILTER_AND_GENERIC_FILE);
    ObjectQuery query = toObjectQuery(GenericObjectType.class, queryType);
    displayQuery(query);
    // check parent filter
    assertNotNull(query);
    ObjectFilter filter = query.getFilter();
    PrismAsserts.assertAndFilter(filter, 2);
    // check first condition
    ObjectFilter first = getFilterCondition(filter, 0);
    PrismAsserts.assertEqualsFilter(first, GenericObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, new ItemPath(GenericObjectType.F_NAME));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) first, createPolyString("generic object"));
    // check second condition
    ObjectFilter second = getFilterCondition(filter, 1);
    PrismAsserts.assertEqualsFilter(second, intExtensionDefinition, DOMUtil.XSD_INT, new ItemPath(ObjectType.F_EXTENSION, new QName(NS_EXTENSION, "intType")));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) second, 123);
    QueryType convertedQueryType = toQueryType(query);
    assertNotNull("Re-serialized query is null ", convertedQueryType);
    assertNotNull("Filter in re-serialized query must not be null.", convertedQueryType.getFilter());
    displayQueryType(convertedQueryType);
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30