jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject [4/5] jena git commit: Fixed param to addHaving() to accept Object like other methods.
Date Tue, 08 Mar 2016 20:57:46 GMT
Fixed param to addHaving() to accept Object like other methods.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f4ba1850
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f4ba1850
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f4ba1850

Branch: refs/heads/master
Commit: f4ba1850b60a9f72155ff13455c7a5032eb427ed
Parents: cfa7c67
Author: Claude Warren <claude@apache.org>
Authored: Tue Mar 8 20:54:57 2016 +0000
Committer: Claude Warren <claude@apache.org>
Committed: Tue Mar 8 20:54:57 2016 +0000

----------------------------------------------------------------------
 .../jena/arq/querybuilder/AskBuilder.java       |  4 +-
 .../jena/arq/querybuilder/ConstructBuilder.java |  4 +-
 .../jena/arq/querybuilder/SelectBuilder.java    |  4 +-
 .../clauses/SolutionModifierClause.java         |  2 +-
 .../clauses/SolutionModifierTest.java           |  2 +-
 .../handlers/SolutionModifierHandlerTest.java   | 87 +++++++++-----------
 6 files changed, 49 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
index 30d4edd..feda3da 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
@@ -244,8 +244,8 @@ public class AskBuilder extends AbstractQueryBuilder<AskBuilder>
 	}
 
 	@Override
-	public AskBuilder addHaving(Var var) throws ParseException {
-		getSolutionModifierHandler().addHaving(var);
+	public AskBuilder addHaving(Object var) throws ParseException {
+		getSolutionModifierHandler().addHaving(makeVar(var));
 		return this;
 	}
 

http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
index 0e7263b..e1147e3 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
@@ -177,8 +177,8 @@ public class ConstructBuilder extends AbstractQueryBuilder<ConstructBuilder>
imp
 	}
 
 	@Override
-	public ConstructBuilder addHaving(Var var) throws ParseException {
-		getSolutionModifierHandler().addHaving(var);
+	public ConstructBuilder addHaving(Object var) throws ParseException {
+		getSolutionModifierHandler().addHaving(makeVar(var));
 		return this;
 	}
 

http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
index 1794fe8..69023f7 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
@@ -217,8 +217,8 @@ public class SelectBuilder extends AbstractQueryBuilder<SelectBuilder>
implement
 	}
 
 	@Override
-	public SelectBuilder addHaving(Var var) throws ParseException {
-		getSolutionModifierHandler().addHaving(var);
+	public SelectBuilder addHaving(Object var) throws ParseException {
+		getSolutionModifierHandler().addHaving(makeVar(var));
 		return this;
 	}
 

http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
index 2467422..de445c1 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
@@ -146,7 +146,7 @@ public interface SolutionModifierClause<T extends AbstractQueryBuilder<T>>
{
 	 *            the variable to have.
 	 * @return The builder for chaining.
 	 */
-	public T addHaving(Var var) throws ParseException;
+	public T addHaving(Object var) throws ParseException;
 
 	/**
 	 * Set the limit.

http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierTest.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierTest.java
b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierTest.java
index c6312d7..d144395 100644
--- a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierTest.java
+++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierTest.java
@@ -178,7 +178,7 @@ public class SolutionModifierTest<T extends SolutionModifierClause<?>>
extends A
 	}
 
 	@ContractTest
-	public void testAddHavingVar() throws ParseException {
+	public void testAddHavingObject() throws ParseException {
 		SolutionModifierClause<?> solutionModifier = getProducer().newInstance();
 		AbstractQueryBuilder<?> builder = solutionModifier.addHaving(Var.alloc("foo"));
 		assertContainsRegex(HAVING + var("foo"), builder.buildString());

http://git-wip-us.apache.org/repos/asf/jena/blob/f4ba1850/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/SolutionModifierHandlerTest.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/SolutionModifierHandlerTest.java
b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/SolutionModifierHandlerTest.java
index 5d04748..62bad25 100644
--- a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/SolutionModifierHandlerTest.java
+++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/SolutionModifierHandlerTest.java
@@ -24,12 +24,12 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.jena.arq.querybuilder.handlers.SolutionModifierHandler;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.query.Query ;
-import org.apache.jena.query.SortCondition ;
-import org.apache.jena.sparql.core.Var ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.query.Query;
+import org.apache.jena.query.SortCondition;
+import org.apache.jena.sparql.core.Var;
 import org.apache.jena.sparql.expr.E_Random;
-import org.apache.jena.sparql.lang.sparql_11.ParseException ;
+import org.apache.jena.sparql.lang.sparql_11.ParseException;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -46,10 +46,9 @@ public class SolutionModifierHandlerTest extends AbstractHandlerTest {
 
 	@Test
 	public void testAddAll() throws ParseException {
-		SolutionModifierHandler solutionModifier2 = new SolutionModifierHandler(
-				new Query());
-		solutionModifier2.addOrderBy( Var.alloc("orderBy"));
-		solutionModifier2.addGroupBy( Var.alloc("groupBy"));
+		SolutionModifierHandler solutionModifier2 = new SolutionModifierHandler(new Query());
+		solutionModifier2.addOrderBy(Var.alloc("orderBy"));
+		solutionModifier2.addGroupBy(Var.alloc("groupBy"));
 		solutionModifier2.addHaving("?having<10");
 		solutionModifier2.setLimit(500);
 		solutionModifier2.setOffset(200);
@@ -58,8 +57,7 @@ public class SolutionModifierHandlerTest extends AbstractHandlerTest {
 
 		String[] s = byLine(query.toString());
 		assertContainsRegex(GROUP_BY + var("groupBy"), s);
-		assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE
-				+ LT + OPT_SPACE + "10" + CLOSE_PAREN, s);
+		assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + OPT_SPACE +
"10" + CLOSE_PAREN, s);
 		assertContainsRegex(ORDER_BY + var("orderBy"), s);
 		assertContainsRegex(LIMIT + "500", s);
 		assertContainsRegex(OFFSET + "200", s);
@@ -74,11 +72,12 @@ public class SolutionModifierHandlerTest extends AbstractHandlerTest {
 		solutionModifier.setOffset(200);
 
 		String[] s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+var("groupBy"), s);
-		assertContainsRegex(HAVING + OPEN_PAREN+ "SUM" + OPEN_PAREN + var("lprice") + CLOSE_PAREN+
OPT_SPACE+GT+"10"+CLOSE_PAREN, s);
+		assertContainsRegex(GROUP_BY + var("groupBy"), s);
+		assertContainsRegex(HAVING + OPEN_PAREN + "SUM" + OPEN_PAREN + var("lprice") + CLOSE_PAREN
+ OPT_SPACE + GT
+				+ "10" + CLOSE_PAREN, s);
 		assertContainsRegex(ORDER_BY + var("orderBy"), s);
-		assertContainsRegex(LIMIT+"500", s);
-		assertContainsRegex(OFFSET+"200", s);
+		assertContainsRegex(LIMIT + "500", s);
+		assertContainsRegex(OFFSET + "200", s);
 
 	}
 
@@ -87,81 +86,77 @@ public class SolutionModifierHandlerTest extends AbstractHandlerTest {
 		solutionModifier.addOrderBy(Var.alloc("orderBy"));
 		List<SortCondition> sc = query.getOrderBy();
 		assertEquals("Wrong number of conditions", 1, sc.size());
-		assertEquals("Wrong value", sc.get(0).expression.asVar(),
-				Var.alloc("orderBy"));
+		assertEquals("Wrong value", sc.get(0).expression.asVar(), Var.alloc("orderBy"));
 
 		solutionModifier.addOrderBy(Var.alloc("orderBy2"));
 		sc = query.getOrderBy();
 		assertEquals("Wrong number of conditions", 2, sc.size());
-		assertEquals("Wrong value", sc.get(0).expression.asVar(),
-				Var.alloc("orderBy"));
-		assertEquals("Wrong value", sc.get(1).expression.asVar(),
-				Var.alloc("orderBy2"));
+		assertEquals("Wrong value", sc.get(0).expression.asVar(), Var.alloc("orderBy"));
+		assertEquals("Wrong value", sc.get(1).expression.asVar(), Var.alloc("orderBy2"));
 	}
 
 	@Test
 	public void testAddGroupByVar() {
-		solutionModifier.addGroupBy( Var.alloc("groupBy"));
+		solutionModifier.addGroupBy(Var.alloc("groupBy"));
 		String[] s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+var("groupBy"), s);
+		assertContainsRegex(GROUP_BY + var("groupBy"), s);
 
-		solutionModifier.addGroupBy( Var.alloc("groupBy2") );
+		solutionModifier.addGroupBy(Var.alloc("groupBy2"));
 		s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+var("groupBy")+SPACE+var("groupBy2"), s);
+		assertContainsRegex(GROUP_BY + var("groupBy") + SPACE + var("groupBy2"), s);
 	}
 
 	@Test
 	public void testAddGroupByExpr() {
-		solutionModifier.addGroupBy( new E_Random());
+		solutionModifier.addGroupBy(new E_Random());
 		String[] s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+"rand"+OPEN_PAREN+CLOSE_PAREN, s);
+		assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN, s);
 
-		solutionModifier.addGroupBy( Var.alloc("groupBy2") );
+		solutionModifier.addGroupBy(Var.alloc("groupBy2"));
 		s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+"rand"+OPEN_PAREN+CLOSE_PAREN+SPACE+var("groupBy2"), s);
+		assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("groupBy2"),
s);
 	}
-	
+
 	@Test
 	public void testAddGroupByVarAndExpr() {
-		solutionModifier.addGroupBy( Var.alloc( "groupBy"), new E_Random());
+		solutionModifier.addGroupBy(Var.alloc("groupBy"), new E_Random());
 		String[] s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+OPEN_PAREN+"rand"+OPEN_PAREN+CLOSE_PAREN+SPACE+"AS"+SPACE+var("groupBy")+CLOSE_PAREN,
s);
+		assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE +
"AS" + SPACE
+				+ var("groupBy") + CLOSE_PAREN, s);
 
-		solutionModifier.addGroupBy( Var.alloc("groupBy2") );
+		solutionModifier.addGroupBy(Var.alloc("groupBy2"));
 		s = byLine(query.toString());
-		assertContainsRegex(GROUP_BY+OPEN_PAREN+"rand"+OPEN_PAREN+CLOSE_PAREN+SPACE+"AS"+SPACE+var("groupBy")+CLOSE_PAREN+SPACE+var("groupBy2"),
s);
+		assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE +
"AS" + SPACE
+				+ var("groupBy") + CLOSE_PAREN + SPACE + var("groupBy2"), s);
 	}
 
 	@Test
 	public void testAddHavingString() throws ParseException {
 		solutionModifier.addHaving("?having<10");
-		assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE
-				+ LT + 10 + CLOSE_PAREN, query.toString());
+		assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + 10 + CLOSE_PAREN,
query.toString());
 
 		solutionModifier.addHaving("?having2");
-		assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE
-				+ LT + 10 + CLOSE_PAREN + OPT_SPACE
-				+ var("having2"), query.toString());
+		assertContainsRegex(
+				HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + 10 + CLOSE_PAREN + OPT_SPACE +
var("having2"),
+				query.toString());
 	}
 
 	@Test
 	public void testAddHavingVar() throws ParseException {
 		solutionModifier.addHaving(Var.alloc("foo"));
-		assertContainsRegex(HAVING + var("foo") , query.toString());
+		assertContainsRegex(HAVING + var("foo"), query.toString());
 
 		solutionModifier.addHaving("?having2");
-		assertContainsRegex(HAVING + var("foo") + SPACE
-				+ var("having2"), query.toString());
+		assertContainsRegex(HAVING + var("foo") + SPACE + var("having2"), query.toString());
 	}
 
 	@Test
 	public void testAddHavingExpr() throws ParseException {
-		solutionModifier.addHaving( new E_Random());
-		assertContainsRegex(HAVING +  "rand"+OPEN_PAREN+CLOSE_PAREN , query.toString());
+		solutionModifier.addHaving(new E_Random());
+		assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN, query.toString());
 
 		solutionModifier.addHaving("?having2");
-		assertContainsRegex(HAVING + "rand"+OPEN_PAREN+CLOSE_PAREN + SPACE
-				+ var("having2"), query.toString());
+		assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("having2"),
query.toString());
 	}
 
 	@Test


Mime
View raw message