protected PlanNode sourceNode( QueryContext context, PlanNode parent, String selectorName, String... columnNames) { PlanNode node = new PlanNode(Type.SOURCE, parent); SelectorName selector = selector(selectorName); node.addSelector(selector); node.setProperty(Property.PROJECT_COLUMNS, columns(context, selector, columnNames)); node.setProperty(Property.PROJECT_COLUMN_TYPES, columnTypes(context, selector, columnNames)); return node; }
protected void assertSelectors(PlanNode node, String... selectors) { Set<SelectorName> selectorSet = new HashSet<SelectorName>(); for (String selectorName : selectors) { selectorSet.add(new SelectorName(selectorName)); } assertThat("Selectors don't match", node.getSelectors(), is(selectorSet)); }
@SafeVarargs protected final <T> void assertPropertyIsList( PlanNode node, Property name, Class<T> valueType, T... values) { assertThat( "Property value doesn't match", node.getPropertyAsList(name, valueType), is(Arrays.asList(values))); }
protected void assertSortOrderBy(PlanNode sortNode, String... selectors) { List<SelectorName> expected = new ArrayList<SelectorName>(selectors.length); for (String selectorName : selectors) { expected.add(new SelectorName(selectorName)); } List<SelectorName> actualSortedBy = sortNode.getPropertyAsList(Property.SORT_ORDER_BY, SelectorName.class); assertThat("Sort node order-by doesn't match selector name list", actualSortedBy, is(expected)); }
protected void assertProperty(PlanNode node, Property name, Object value) { assertThat("Property value doesn't match", node.getProperty(name), is(value)); }
protected void assertSameChildren(PlanNode node, PlanNode... children) { assertThat(node.getChildCount(), is(children.length)); for (int i = 0; i != node.getChildCount(); ++i) { assertThat(node.getChild(i).isSameAs(children[i]), is(true)); } }
protected void assertChildren(PlanNode node, PlanNode... children) { assertThat(node.getChildCount(), is(children.length)); for (int i = 0; i != node.getChildCount(); ++i) { assertThat(node.getChild(i), is(sameInstance(children[i]))); } }
protected <T> void assertPropertyIsList( PlanNode node, Property name, Class<T> valueType, List<T> values) { assertThat("Property value doesn't match", node.getPropertyAsList(name, valueType), is(values)); }