use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testAccountQueryAttributesAndResource.
@Test
public void testAccountQueryAttributesAndResource() throws Exception {
displayTestTitle("testAccountQueryAttributesAndResource");
SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_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(ShadowType.F_ATTRIBUTES, ICF_NAME));
PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "uid=jbond,ou=People,dc=example,dc=com");
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 test360Ref.
@Test
public void test360Ref() throws Exception {
final String TEST_NAME = "test360Ref";
displayTestTitle(TEST_NAME);
// we test only parsing here, as there are more serialized forms used here
ObjectQuery q1object = QueryBuilder.queryFor(ShadowType.class, getPrismContext()).item(ShadowType.F_RESOURCE_REF).ref("oid1").or().item(ShadowType.F_RESOURCE_REF).ref("oid2", ResourceType.COMPLEX_TYPE).or().item(ShadowType.F_RESOURCE_REF).ref("oid3").or().item(ShadowType.F_RESOURCE_REF).ref("oid4", ResourceType.COMPLEX_TYPE).build();
q1object.getFilter().checkConsistence(true);
String q2xml = FileUtils.readFileToString(new File(TEST_DIR + "/" + TEST_NAME + ".xml"));
displayQueryXml(q2xml);
QueryType q2jaxb = toQueryType(q2xml);
displayQueryType(q2jaxb);
ObjectQuery q2object = toObjectQuery(ShadowType.class, q2jaxb);
System.out.println("q1object:\n" + q1object.debugDump(1));
System.out.println("q2object:\n" + q2object.debugDump(1));
// primitive way of comparing parsed queries
assertEquals("Reparsed query is not as original one (via toString)", q1object.toString(), q2object.toString());
if (!q1object.equivalent(q2object)) {
AssertJUnit.fail("Reparsed query is not as original one (via equivalent):\nq1=" + q1object + "\nq2=" + q2object);
}
}
use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method test900TypeWrong.
@Test
public void test900TypeWrong() throws Exception {
final String TEST_NAME = "test900TypeWrong";
String fileName = TEST_DIR + "/" + TEST_NAME + ".xml";
QueryType jaxb = toQueryType(FileUtils.readFileToString(new File(fileName)));
displayQueryType(jaxb);
try {
ObjectQuery query = toObjectQuery(ObjectType.class, jaxb);
displayQuery(query);
fail("Unexpected success!");
} catch (SchemaException e) {
System.out.println("Got expected exception: " + e.getMessage());
}
}
use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testConvertQueryNullFilter.
@Test
public void testConvertQueryNullFilter() throws Exception {
ObjectQuery query = ObjectQuery.createObjectQuery(ObjectPaging.createPaging(0, 10));
QueryType queryType = QueryJaxbConvertor.createQueryType(query, getPrismContext());
assertNotNull(queryType);
assertNull(queryType.getFilter());
PagingType paging = queryType.getPaging();
assertNotNull(paging);
assertEquals(new Integer(0), paging.getOffset());
assertEquals(new Integer(10), paging.getMaxSize());
}
use of net.opengis.wfs.v_2_0_0.QueryType in project midpoint by Evolveum.
the class TestParseTask method testSerializeTask.
@Test
public static void testSerializeTask() throws Exception {
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, getPrismContext()).item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT).build();
QueryType queryType = QueryJaxbConvertor.createQueryType(query, getPrismContext());
PrismPropertyDefinition queryDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE, getPrismContext());
PrismProperty<QueryType> queryProp = queryDef.instantiate();
queryProp.setRealValue(queryType);
TaskType taskType = getPrismContext().createObject(TaskType.class).asObjectable();
taskType.setExtension(new ExtensionType(getPrismContext()));
taskType.getExtension().asPrismContainerValue().add(queryProp);
taskType.setName(PolyStringType.fromOrig("Test task"));
String xml = getPrismContext().xmlSerializer().serialize(taskType.asPrismObject());
System.out.println("Task serialized:\n" + xml);
PrismObject<TaskType> taskParsed = getPrismContext().parserFor(xml).parse();
String xmlSerializedAgain = getPrismContext().xmlSerializer().serialize(taskParsed);
System.out.println("Task serialized again:\n" + xmlSerializedAgain);
}
Aggregations