@Override public void checkConsistence(boolean requireDefinitions) { if (type == null) { throw new IllegalArgumentException("Null type in "+this); } // null subfilter is legal. It means "ALL". if (filter != null) { filter.checkConsistence(requireDefinitions); } }
@Override public void checkConsistence(boolean requireDefinitions) { if (conditions == null) { throw new IllegalArgumentException("Null conditions in "+this); } if (conditions.isEmpty()) { throw new IllegalArgumentException("Empty conditions in "+this); } for (ObjectFilter condition: conditions) { if (condition == null) { throw new IllegalArgumentException("Null subfilter in "+this); } condition.checkConsistence(requireDefinitions); } }
@Override public void checkConsistence(boolean requireDefinitions) { if (fullPath.isEmpty()) { throw new IllegalArgumentException("Null or empty path in "+this); } if (requireDefinitions && definition == null) { throw new IllegalArgumentException("Null definition in "+this); } // null subfilter is legal. It means "ALL". if (filter != null) { filter.checkConsistence(requireDefinitions); } }
attributeQuery.getFilter().checkConsistence(true);
@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 = getPrismContext().queryFor(ShadowType.class) .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)); assertEquals("Reparsed query is not as original one (via toString)", q1object.toString(), q2object.toString()); // primitive way of comparing parsed queries if (!q1object.equivalent(q2object)) { AssertJUnit.fail("Reparsed query is not as original one (via equivalent):\nq1="+q1object+"\nq2="+q2object); } }
filter.checkConsistence(false);
query.getFilter().checkConsistence(true);