use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class DistinctStageTest method suppressionByType.
@Test
public void suppressionByType() {
TranslatableQueryWrapper wrapper = new MockQueryWrapperBuilder().withDistinct(true).withMetaData(new MockQueryMetadataBuilder().build()).build();
TranslatorContext context = new MockTranslatorContext(wrapper);
DbAttribute attribute = new DbAttribute();
attribute.setType(Types.LONGVARBINARY);
Node node = new ColumnNode("t0", "attr", null, attribute);
context.addResultNode(node);
assertFalse(context.isDistinctSuppression());
DistinctStage stage = new DistinctStage();
stage.perform(context);
assertTrue(context.isDistinctSuppression());
}
use of org.apache.cayenne.access.sqlbuilder.sqltree.ColumnNode in project cayenne by apache.
the class GroupByStageTest method groupByWithAggregates.
// result column + aggregate
@Test
public void groupByWithAggregates() {
context.addResultNode(new ColumnNode("t0", "column", null, null));
context.addResultNode(new EmptyNode(), true, PropertyFactory.COUNT, "count");
GroupByStage stage = new GroupByStage();
stage.perform(context);
Node node = context.getSelectBuilder().build();
assertEquals(1, node.getChildrenCount());
assertThat(node.getChild(0), instanceOf(GroupByNode.class));
assertEquals(1, node.getChild(0).getChildrenCount());
assertThat(node.getChild(0).getChild(0), instanceOf(ColumnNode.class));
ColumnNode columnNode = (ColumnNode) node.getChild(0).getChild(0);
assertEquals("t0", columnNode.getTable());
assertEquals("column", columnNode.getColumn());
}
Aggregations