Skip to content

Commit 02c458d

Browse files
authored
Merge pull request #1467 from marklogic/feature/joinDoc-test-addition
Enhanced test for bug 58069
2 parents 1631957 + d201cab commit 02c458d

File tree

1 file changed

+37
-9
lines changed
  • marklogic-client-api/src/test/java/com/marklogic/client/test/rows

1 file changed

+37
-9
lines changed

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/JoinDocTest.java

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
import com.marklogic.client.expression.PlanBuilder;
66
import com.marklogic.client.row.RowRecord;
77
import com.marklogic.client.test.Common;
8+
import com.marklogic.client.type.CtsReferenceExpr;
89
import org.junit.Test;
910

11+
import java.util.HashMap;
1012
import java.util.List;
13+
import java.util.Map;
1114

1215
import static org.junit.Assert.assertEquals;
1316

17+
/**
18+
* Written for bug 58069; see that description for more information.
19+
*/
1420
public class JoinDocTest extends AbstractOpticUpdateTest {
1521

1622
@Test
@@ -19,19 +25,32 @@ public void propertiesFragmentsShouldNotBeReturned() {
1925
return;
2026
}
2127

22-
final int docCount = 50;
23-
24-
JSONDocumentManager mgr = Common.client.newJSONDocumentManager();
25-
DocumentWriteSet writeSet = mgr.newWriteSet();
26-
for (int i = 1; i <= docCount; i++) {
27-
writeSet.add(newWriteOp("/acme/" + i + ".json", mapper.createObjectNode().put("hello", "world")));
28-
}
29-
mgr.write(writeSet);
30-
3128
PlanBuilder.ModifyPlan plan = op
3229
.fromDocUris(op.cts.directoryQuery("/acme/"))
3330
.joinDoc(op.col("doc"), op.col("uri"));
3431

32+
verifyPropertiesFragmentsAreNotReturned(plan);
33+
}
34+
35+
/**
36+
* Same as propertiesFragmentsShouldNotBeReturned, but uses fromLexicons so it can run against ML 10.
37+
*/
38+
@Test
39+
public void propertiesFragmentShouldNotBeReturnedByFromLexicons() {
40+
Map<String, CtsReferenceExpr> lexicons = new HashMap<>();
41+
lexicons.put("uri", op.cts.uriReference());
42+
43+
PlanBuilder.ModifyPlan plan = op.fromLexicons(lexicons, "", op.fragmentIdCol("fragmentId"))
44+
.where(op.cts.directoryQuery("/acme/"))
45+
.joinDoc(op.col("doc"), op.col("uri"));
46+
47+
verifyPropertiesFragmentsAreNotReturned(plan);
48+
}
49+
50+
private void verifyPropertiesFragmentsAreNotReturned(PlanBuilder.ModifyPlan plan) {
51+
final int docCount = 50;
52+
writeDocs(docCount);
53+
3554
List<RowRecord> rows = resultRows(plan);
3655
System.out.println(rows);
3756
assertEquals("If the actual count is double the expected count, then joinDoc is erroneously pulling back " +
@@ -40,4 +59,13 @@ public void propertiesFragmentsShouldNotBeReturned() {
4059
"and we do not have a reliable way to reproduce it. Once it happens, it will happen reliably for awhile, " +
4160
"regardless of the number of URIs being returned by fromDocUris.", docCount, rows.size());
4261
}
62+
63+
private void writeDocs(int docCount) {
64+
JSONDocumentManager mgr = Common.client.newJSONDocumentManager();
65+
DocumentWriteSet writeSet = mgr.newWriteSet();
66+
for (int i = 1; i <= docCount; i++) {
67+
writeSet.add(newWriteOp("/acme/" + i + ".json", mapper.createObjectNode().put("hello", "world")));
68+
}
69+
mgr.write(writeSet);
70+
}
4371
}

0 commit comments

Comments
 (0)