### Question:
JcrSql2QueryParser extends SqlQueryParser { protected List<JcrColumn> columns( List<? extends Column> columns ) { List<JcrColumn> jcrColumns = new ArrayList<JcrColumn>(); for (Column column : columns) { jcrColumns.add((JcrColumn)column); } return jcrColumns; } JcrSql2QueryParser(); @Override String getLanguage(); static final String LANGUAGE; }### Answer:
@Test public void shouldParseSelectStarFromTwoJoinedSourcesWithWhereContainingJoinCriteria() { query = parse("SELECT * FROM [mgnl:content] JOIN [acme:stuff] ON ISSAMENODE([mgnl:content],[acme:stuff])"); assertThat(query.columns().isEmpty(), is(true)); Join join = isJoin(query.source()); assertThat(join.left(), is((Source)namedSelector(selectorName("mgnl:content")))); assertThat(join.right(), is((Source)namedSelector(selectorName("acme:stuff")))); assertThat(join.type(), is(JoinType.INNER)); SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.joinCondition()); assertThat(joinCondition.selector1Name(), is(selectorName("mgnl:content"))); assertThat(joinCondition.selector2Name(), is(selectorName("acme:stuff"))); assertThat(joinCondition.selector2Path(), is(nullValue())); assertThat(query.constraint(), is(nullValue())); }
@Test public void shouldParseSelectStarFromThreeJoinedSourcesWithWhereContainingJoinCriteria() { query = parse("SELECT * FROM [mgnl:content] JOIN [acme:stuff] ON ISSAMENODE([mgnl:content],[acme:stuff]) JOIN [foo:bar] ON ISSAMENODE([mgnl:content],[foo:bar])"); assertThat(query.columns().isEmpty(), is(true)); Join join = isJoin(query.source()); Join join2 = isJoin(join.left()); assertThat(join2.left(), is((Source)namedSelector(selectorName("mgnl:content")))); assertThat(join2.right(), is((Source)namedSelector(selectorName("acme:stuff")))); assertThat(join2.type(), is(JoinType.INNER)); SameNodeJoinCondition joinCondition2 = isSameNodeJoinCondition(join2.joinCondition()); assertThat(joinCondition2.selector1Name(), is(selectorName("mgnl:content"))); assertThat(joinCondition2.selector2Name(), is(selectorName("acme:stuff"))); assertThat(joinCondition2.selector2Path(), is(nullValue())); assertThat(join.right(), is((Source)namedSelector(selectorName("foo:bar")))); assertThat(join.type(), is(JoinType.INNER)); SameNodeJoinCondition joinCondition = isSameNodeJoinCondition(join.joinCondition()); assertThat(joinCondition.selector1Name(), is(selectorName("mgnl:content"))); assertThat(joinCondition.selector2Name(), is(selectorName("foo:bar"))); assertThat(joinCondition.selector2Path(), is(nullValue())); assertThat(query.constraint(), is(nullValue())); }
@Test public void shouldParseDescendantNodeJoinWithNoCriteria() { query = parse("select * from [lom:Metadata] as lom join [lom:LangString] as lang on isdescendantnode(lang,lom)"); assertThat(query.columns().isEmpty(), is(true)); Join join = isJoin(query.source()); assertThat(join.left(), is((Source)namedSelector(selectorName("lom:Metadata"), selectorName("lom")))); assertThat(join.right(), is((Source)namedSelector(selectorName("lom:LangString"), selectorName("lang")))); assertThat(join.type(), is(JoinType.INNER)); DescendantNodeJoinCondition joinCondition = isDescendantNodeJoinCondition(join.joinCondition()); assertThat(joinCondition.ancestorSelectorName(), is(selectorName("lom"))); assertThat(joinCondition.descendantSelectorName(), is(selectorName("lang"))); }