Skip to content

Commit

Permalink
GH-4923 Spaces inserted by PropertyPathBuilder cause problems with Al…
Browse files Browse the repository at this point in the history
…legroGraph (#4928)
  • Loading branch information
hmottestad authored Mar 14, 2024
2 parents 7e6e284 + 0722900 commit 5c0a1b3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public InversePath(PropertyPath path) {
this.path = path;
}

@Override
public String getQueryString() {
return "^ " + path.getQueryString();
return "^" + path.getQueryString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public InversePredicatePath(IRI predicate) {

@Override
public String getQueryString() {
return "^ " + predicate.getQueryString();
return "^" + predicate.getQueryString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public NegatedPropertySet(PredicatePathOrInversePredicatePath... properties) {
@Override
public String getQueryString() {
if (properties.length == 1) {
return "! " + properties[0].getQueryString();
return "!" + properties[0].getQueryString();
} else {
return Arrays
.stream(properties)
.map(QueryElement::getQueryString)
.collect(Collectors.joining(" | ", "! ( ", " )"));
.collect(Collectors.joining(" | ", "!( ", " )"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public OneOrMorePath(PropertyPath path) {

@Override
public String getQueryString() {
return path.getQueryString() + " +";
return path.getQueryString() + "+";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public ZeroOrMorePath(PropertyPath path) {

@Override
public String getQueryString() {
return path.getQueryString() + " *";
return path.getQueryString() + "*";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public ZeroOrOnePath(PropertyPath path) {

@Override
public String getQueryString() {
return path.getQueryString() + " ?";
return path.getQueryString() + "?";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void testInversePath() {
.path(iri(RDFS.COMMENT))
.inv()
.build();
assertEquals("^ ( <" + RDFS.COMMENT + "> )", p.getQueryString());
assertEquals("^( <" + RDFS.COMMENT + "> )", p.getQueryString());
}

@Test
Expand All @@ -131,7 +131,7 @@ public void testOneOrMorePath() {
.path(iri(RDFS.COMMENT))
.oneOrMore()
.build();
assertEquals("<" + RDFS.COMMENT + "> +", p.getQueryString());
assertEquals("<" + RDFS.COMMENT + ">+", p.getQueryString());
}

@Test
Expand All @@ -140,7 +140,7 @@ public void testZeroOrMorePath() {
.path(iri(RDFS.COMMENT))
.zeroOrMore()
.build();
assertEquals("<" + RDFS.COMMENT + "> *", p.getQueryString());
assertEquals("<" + RDFS.COMMENT + ">*", p.getQueryString());
}

@Test
Expand All @@ -149,7 +149,7 @@ public void testZeroOrOnePath() {
.path(iri(RDFS.COMMENT))
.zeroOrOne()
.build();
assertEquals("<" + RDFS.COMMENT + "> ?", p.getQueryString());
assertEquals("<" + RDFS.COMMENT + ">?", p.getQueryString());
}

@Test
Expand All @@ -159,7 +159,7 @@ public void testNegatedPropertySetSingle() {
.negProp()
.pred(iri(RDFS.COMMENT))
.build();
assertEquals("! <" + RDFS.COMMENT + ">", p.getQueryString());
assertEquals("!<" + RDFS.COMMENT + ">", p.getQueryString());
}

@Test
Expand All @@ -169,7 +169,7 @@ public void testNegatedPropertySetSingleInverted() {
.negProp()
.invPred(iri(RDFS.COMMENT))
.build();
assertEquals("! ^ <" + RDFS.COMMENT + ">", p.getQueryString());
assertEquals("!^<" + RDFS.COMMENT + ">", p.getQueryString());
}

@Test
Expand All @@ -180,7 +180,7 @@ public void testNegatedPropertySetMultipleInverted() {
.invPred(iri(RDFS.COMMENT))
.invPred(iri(RDFS.LABEL))
.build();
assertEquals("! ( ^ <" + RDFS.COMMENT + "> | ^ <" + RDFS.LABEL + "> )", p.getQueryString());
assertEquals("!( ^<" + RDFS.COMMENT + "> | ^<" + RDFS.LABEL + "> )", p.getQueryString());
}

@Test
Expand All @@ -193,7 +193,7 @@ public void testNegatedPropertySetMultipleMixed() {
.invPred(iri(RDFS.SUBPROPERTYOF))
.pred(iri(RDFS.COMMENT))
.build();
assertEquals("! ( ^ <" + RDFS.SUBCLASSOF + "> | <" + RDFS.LABEL + "> | ^ <" + RDFS.SUBPROPERTYOF
assertEquals("!( ^<" + RDFS.SUBCLASSOF + "> | <" + RDFS.LABEL + "> | ^<" + RDFS.SUBPROPERTYOF
+ "> | <" + RDFS.COMMENT + "> )", p.getQueryString());
}

Expand Down

0 comments on commit 5c0a1b3

Please sign in to comment.