use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method checkQuery.
private void checkQuery(Class<? extends Containerable> objectClass, ObjectQuery q1object, String q2xml) throws Exception {
// step 1 (serialization of Q1 + comparison)
displayText("Query 1:");
displayQuery(q1object);
QueryType q1jaxb = toQueryType(q1object);
displayQueryType(q1jaxb);
String q1xml = toXml(q1jaxb);
displayQueryXml(q1xml);
// XMLAssert.assertXMLEqual("Serialized query is not correct: Expected:\n" + q2xml + "\n\nReal:\n" + q1xml, q2xml, q1xml);
// step 2 (parsing of Q2 + comparison)
displayText("Query 2:");
displayQueryXml(q2xml);
QueryType q2jaxb = toQueryType(q2xml);
displayQueryType(q2jaxb);
ObjectQuery q2object = toObjectQuery(objectClass, q2jaxb);
// primitive way of comparing parsed queries
assertEquals("Reparsed query is not as original one (via toString)", q1object.toString(), q2object.toString());
assertTrue("Reparsed query is not as original one (via equivalent):\nq1=" + q1object + "\nq2=" + q2object, q1object.equivalent(q2object));
}
use of net.opengis.wfs.v_2_0_0.QueryType 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
}
use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testShadowKindTypeQuery.
@Test
public void testShadowKindTypeQuery() throws Exception {
displayTestTitle("testShadowKindTypeQuery");
SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
ObjectQuery query;
try {
ObjectFilter kindFilter = QueryBuilder.queryFor(ShadowType.class, getPrismContext()).item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT).buildFilter();
query = ObjectQuery.createObjectQuery(kindFilter);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
assertTrue("filter is not an instance of type filter", filter instanceof EqualFilter);
EqualFilter typeFilter = (EqualFilter) filter;
assertEquals(typeFilter.getSingleValue().getRealValue(), ShadowKindType.ACCOUNT);
QueryType convertedQueryType = toQueryType(query);
toObjectQuery(ShadowType.class, convertedQueryType);
displayQueryType(convertedQueryType);
} catch (Exception ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
}
}
use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method test430OrgFilterDefaultScope.
@Test
public void test430OrgFilterDefaultScope() throws Exception {
final String TEST_NAME = "test430OrgFilterDefaultScope";
displayTestTitle(TEST_NAME);
// default scope is SUBTREE
String queryXml = "<?xml version='1.0'?><query><filter><org>\n" + " <orgRef>\n" + " <oid>333</oid>\n" + " </orgRef>\n" + " </org></filter></query>";
QueryType queryJaxb = toQueryType(queryXml);
displayQueryType(queryJaxb);
ObjectQuery query = toObjectQuery(OrgType.class, queryJaxb);
displayQuery(query);
ObjectQuery expectedQuery = QueryBuilder.queryFor(OrgType.class, getPrismContext()).isChildOf("333").build();
// primitive way of comparing queries
assertEquals("Parsed query is wrong", expectedQuery.toString(), query.toString());
// now reserialize the parsed query and compare with XML - the XML contains explicit scope=SUBTREE (as this is set when parsing original queryXml)
checkQueryRoundtripFile(OrgType.class, query, TEST_NAME);
}
use of net.opengis.wfs.v_2_0_0.QueryType 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);
}
Aggregations