@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }
@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }
@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }