Skip to content

Commit 2145c31

Browse files
authored
Merge pull request #1678 from marklogic/feature/optic-fix
Optic test fixes for MarkLogic 12
2 parents 2857d61 + 1cfd6f7 commit 2145c31

File tree

6 files changed

+30
-36
lines changed

6 files changed

+30
-36
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ void bm25() {
2323
PlanSearchOptions options = op.searchOptions()
2424
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
2525
.withBm25LengthWeight(0.25);
26-
List<RowRecord> rows = resultRows(
27-
op.fromSearchDocs(op.cts.wordQuery("contents"), null, options)
28-
.offsetLimit(0, 5)
29-
);
30-
assertEquals(5, rows.size());
26+
List<RowRecord> rows = resultRows(op.fromSearchDocs(op.cts.wordQuery("saxophone"), null, options));
27+
assertEquals(2, rows.size());
3128
}
3229

3330
@Test
@@ -36,10 +33,7 @@ void qualityWeight() {
3633
// It only tests that including a valid qualityWeight value does not cause any problems.
3734
rowManager.withUpdate(false);
3835
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.LOGTFIDF).withQualityWeight(0.75F);
39-
List<RowRecord> rows = resultRows(
40-
op.fromSearchDocs(op.cts.wordQuery("contents"), null, options)
41-
.offsetLimit(0, 5)
42-
);
43-
assertEquals(5, rows.size());
36+
List<RowRecord> rows = resultRows(op.fromSearchDocs(op.cts.wordQuery("saxophone"), null, options));
37+
assertEquals(2, rows.size());
4438
}
4539
}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ void bm25() {
2323
PlanSearchOptions options = op.searchOptions()
2424
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
2525
.withBm25LengthWeight(0.25);
26-
List<RowRecord> rows = resultRows(
27-
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
28-
.offsetLimit(0, 5)
29-
);
30-
assertEquals(5, rows.size());
26+
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
27+
assertEquals(2, rows.size());
3128
}
3229

3330
@Test
@@ -36,8 +33,7 @@ void badBm25LengthWeight() {
3633
PlanSearchOptions options = op.searchOptions()
3734
.withScoreMethod(PlanSearchOptions.ScoreMethod.BM25)
3835
.withBm25LengthWeight(99);
39-
PlanBuilder.ModifyPlan plan = op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
40-
.offsetLimit(0, 5);
36+
PlanBuilder.ModifyPlan plan = op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options);
4137
Exception exception = assertThrows(FailedRequestException.class, () -> resultRows(plan));
4238
String actualMessage = exception.getMessage();
4339
assertTrue(actualMessage.contains("Server Message: XDMP-OPTION"));
@@ -48,11 +44,8 @@ void badBm25LengthWeight() {
4844
void zero() {
4945
rowManager.withUpdate(false);
5046
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.ZERO);
51-
List<RowRecord> rows = resultRows(
52-
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
53-
.offsetLimit(0, 5)
54-
);
55-
assertEquals(5, rows.size());
47+
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
48+
assertEquals(2, rows.size());
5649
rows.forEach(row -> {
5750
assertEquals(0, row.getInt("score"), "The score for every row should be 0.");
5851
});
@@ -64,10 +57,7 @@ void qualityWeight() {
6457
// It only tests that including a valid qualityWeight value does not cause any problems.
6558
rowManager.withUpdate(false);
6659
PlanSearchOptions options = op.searchOptions().withScoreMethod(PlanSearchOptions.ScoreMethod.LOGTFIDF).withQualityWeight(0.75F);
67-
List<RowRecord> rows = resultRows(
68-
op.fromSearch(op.cts.wordQuery("contents"), null, null, options)
69-
.offsetLimit(0, 5)
70-
);
71-
assertEquals(5, rows.size());
60+
List<RowRecord> rows = resultRows(op.fromSearch(op.cts.wordQuery("saxophone"), null, null, options));
61+
assertEquals(2, rows.size());
7262
}
7363
}

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.marklogic.client.test.rows;
22

3+
import com.fasterxml.jackson.databind.node.TextNode;
34
import com.marklogic.client.row.RowRecord;
5+
import com.marklogic.client.test.junit5.RequiresML12;
46
import com.marklogic.client.test.junit5.RequiresMLElevenDotOne;
5-
import org.junit.jupiter.api.Disabled;
67
import org.junit.jupiter.api.Test;
78
import org.junit.jupiter.api.extension.ExtendWith;
89

@@ -57,30 +58,36 @@ void joinDocAndUri() {
5758
}
5859

5960
@Test
60-
@Disabled("See DBQ-643")
61+
// Fixed via MLE-55
62+
@ExtendWith(RequiresML12.class)
6163
void documentRootQuery() {
6264
List<RowRecord> rows = resultRows(op
6365
.fromDocUris(op.cts.documentRootQuery("suggest"))
6466
);
6567

6668
assertEquals(2, rows.size());
67-
assertEquals("/sample/suggestion.xml", rows.get(0).get("uri"));
68-
assertEquals("/sample2/suggestion.xml", rows.get(1).get("uri"));
69+
assertEquals("/sample/suggestion.xml", ((TextNode) rows.get(0).get("uri")).asText());
70+
assertEquals("/sample2/suggestion.xml", ((TextNode) rows.get(1).get("uri")).asText());
6971
}
7072

7173
@Test
72-
@Disabled("See DBQ-643")
74+
// Fixed via MLE-55
75+
@ExtendWith(RequiresML12.class)
7376
void documentFormatQuery() {
7477
List<RowRecord> rows = resultRows(op
75-
.fromDocUris(op.cts.documentFormatQuery("text"))
78+
.fromDocUris(op.cts.andQuery(
79+
op.cts.documentFormatQuery("text"),
80+
op.cts.collectionQuery("document-format-query-test")
81+
))
7682
);
7783

7884
assertEquals(1, rows.size());
79-
assertEquals("/sample/second.txt", rows.get(0).get("uri"));
85+
assertEquals("/sample/second.txt", ((TextNode) rows.get(0).get("uri")).asText());
8086
}
8187

8288
@Test
83-
@Disabled("See DBQ-643")
89+
// Fixed via MLE-55
90+
@ExtendWith(RequiresML12.class)
8491
void documentPermissionQuery() {
8592
List<RowRecord> rows = resultRows(op
8693
.fromDocUris(op.cts.documentPermissionQuery("rest-reader", "read"))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void vectorFunctionsHappyPath() {
5858
.limit(5);
5959
List<RowRecord> rows = resultRows(plan);
6060
assertEquals(2, rows.size());
61+
6162
rows.forEach(row -> {
6263
// Simple a sanity checks to verify that the functions ran. Very little concern about the actual return values.
6364
double cosineSimilarity = row.getDouble("cosineSimilarity");
@@ -89,7 +90,7 @@ void cosineSimilarity_DimensionMismatch() {
8990
Exception exception = assertThrows(FailedRequestException.class, () -> resultRows(plan));
9091
String actualMessage = exception.getMessage();
9192
assertTrue(actualMessage.contains("Server Message: VEC-DIMMISMATCH"), "Unexpected message: " + actualMessage);
92-
assertTrue(actualMessage.contains("Mismatched dimension: Vector dimensions must be equal"), "Unexpected message: " + actualMessage);
93+
assertTrue(actualMessage.contains("Mismatched dimension"), "Unexpected message: " + actualMessage);
9394
}
9495

9596
@Test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*=rest-reader,read,rest-writer,update

test-app/src/main/ml-data/sample/collections.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ suggestion.xml=http://some.org/suggestions
22
first.xml=http://some.org/collection1,http://some.org/collection2
33
lexicon-test1.xml=http://some.org/collection1,http://some.org/collection2
44
lexicon-test2.xml=http://some.org/collection1,http://some.org/collection2
5+
second.txt=document-format-query-test

0 commit comments

Comments
 (0)