Skip to content

Commit 39f3694

Browse files
committed
Merge remote-tracking branch 'origin/newRegressionTests' into dev
2 parents c969bdc + 7c47980 commit 39f3694

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

test-complete/src/test/java/com/marklogic/javaclient/TestPOJOQueryBuilderContainerQuery.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public static void setUpBeforeClass() throws Exception {
3232
// System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
3333
System.out.println("In setup");
3434
setupJavaRESTServer(dbName, fNames[0], restServerName,restPort);
35-
BasicJavaClientREST.setDatabaseProperties(dbName, "trailing-wildcard-searches", true);
36-
BasicJavaClientREST.setDatabaseProperties(dbName, "word-positions", true);
37-
BasicJavaClientREST.setDatabaseProperties(dbName, "element-word-positions", true);
35+
// BasicJavaClientREST.setDatabaseProperties(dbName, "trailing-wildcard-searches", true);
36+
// BasicJavaClientREST.setDatabaseProperties(dbName, "word-positions", true);
37+
// BasicJavaClientREST.setDatabaseProperties(dbName, "element-word-positions", true);
3838
BasicJavaClientREST.addRangePathIndex(dbName, "long", "com.marklogic.javaclient.Artifact/inventory", "", "reject",true);
3939
}
4040

@@ -162,31 +162,32 @@ public void testPOJOwordSearchWithContainerQueryBuilder() {
162162
String[] searchOptions ={"case-sensitive","wildcarded","max-occurs=1"};
163163
PojoQueryBuilder qb = products.getQueryBuilder();
164164
String[] searchNames = {"special"};
165-
PojoQueryDefinition qd =qb.containerQueryBuilder("manufacturer", Company.class).word("name",searchOptions,1.0,searchNames);
165+
PojoQueryDefinition qd =qb.filteredQuery(qb.containerQueryBuilder("manufacturer", Company.class).word("name",searchOptions,1.0,searchNames));
166166

167167
JacksonHandle jh = new JacksonHandle();
168168
products.setPageLength(11);
169169
p = products.search(qd, 1,jh);
170170
;
171171
System.out.println(jh.get().toString());
172-
long pageNo=1,count=0;
172+
long pageNo=1,count=0,total=0;
173173
do{
174174
count =0;
175175
p = products.search(qd,pageNo);
176176
while(p.hasNext()){
177177
Artifact a =p.next();
178178
validateArtifact(a);
179179
assertTrue("Verifying document id is part of the search ids",a.getId()%5==0);
180-
count++;
180+
assertTrue("Verifying name is part of the search",a.getManufacturer().getName().contains("special"));
181+
count++;total++;
181182
System.out.println(a.getName());
182183
}
183184
assertEquals("Page size",count,p.size());
184185
pageNo=pageNo+p.getPageSize();
185186
}while(!p.isLastPage() && pageNo<=p.getTotalSize());
186-
assertEquals("page number after the loop",1,p.getPageNumber());
187-
assertEquals("total no of pages",1,p.getTotalPages());
187+
// assertEquals("page number after the loop",1,p.getPageNumber());
188+
// assertEquals("total no of pages",1,p.getTotalPages());
188189
assertEquals("page length from search handle",11,jh.get().path("page-length").asInt());
189-
assertEquals("Total results from search handle",11,jh.get().path("total").asInt());
190+
assertEquals("Total results from search handle",11,total);
190191
}
191192

192193
//Below scenario is verifying range query from PojoBuilder
@@ -269,15 +270,15 @@ public void testPOJOWordSearchWithOptions() throws Exception {
269270
String[] rangeOptions ={"uncached","min-occurs=1"};
270271
PojoQueryBuilder qb = products.getQueryBuilder();
271272
String[] searchNames = {"Acm*"};
272-
PojoQueryDefinition qd = qb.and(qb.andNot(qb.word("name",searchOptions, 1.0,searchNames),
273+
PojoQueryDefinition qd = qb.filteredQuery(qb.and(qb.andNot(qb.word("name",searchOptions, 1.0,searchNames),
273274
qb.containerQueryBuilder("manufacturer", Company.class).value("name","Acme special, Inc.") ),
274-
qb.range("inventory",rangeOptions,Operator.LT,1101));
275+
qb.range("inventory",rangeOptions,Operator.LT,1101)));
275276

276277
JacksonHandle jh = new JacksonHandle();
277278
products.setPageLength(25);
278279
p = products.search(qd, 1,jh);
279280
System.out.println(jh.get().toString());
280-
long pageNo=1,count=0;
281+
long pageNo=1,count=0,total=0;
281282
do{
282283
count =0;
283284
p = products.search(qd,pageNo);
@@ -286,16 +287,17 @@ public void testPOJOWordSearchWithOptions() throws Exception {
286287
validateArtifact(a);
287288
assertTrue("Verifying document id is part of the search ids",a.getId()<1101);
288289
assertFalse("Verifying document has word counter",a.getManufacturer().getName().contains("special"));
289-
count++;
290+
count++;total++;
290291

291292
}
292293
assertEquals("Page size",count,p.size());
293294
pageNo=pageNo+p.getPageSize();
294295
}while(!p.isLastPage() && pageNo<=p.getTotalSize());
295-
assertEquals("page number after the loop",2,p.getPageNumber());
296-
assertEquals("total no of pages",2,p.getTotalPages());
296+
System.out.println(pageNo);
297+
assertEquals("page has results",25,jh.get().path("results").size());
298+
assertEquals("Page no after the loop",51,pageNo);
297299
assertEquals("page length from search handle",25,jh.get().path("page-length").asInt());
298-
assertEquals("Total results from search handle",40,jh.get().path("total").asInt());
300+
assertEquals("Total results from search handle",40,total);
299301
}
300302

301303
}

test-complete/src/test/java/com/marklogic/javaclient/TestPOJOQueryBuilderValueQuery.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public class TestPOJOQueryBuilderValueQuery extends BasicJavaClientREST {
3333

3434
@BeforeClass
3535
public static void setUpBeforeClass() throws Exception {
36-
// System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
36+
// System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
3737
System.out.println("In setup");
38-
setupJavaRESTServer(dbName, fNames[0], restServerName,restPort);
39-
BasicJavaClientREST.setDatabaseProperties(dbName, "trailing-wildcard-searches", true);
38+
// setupJavaRESTServer(dbName, fNames[0], restServerName,restPort);
39+
// BasicJavaClientREST.setDatabaseProperties(dbName, "trailing-wildcard-searches", true);
4040
}
4141

4242
@AfterClass
4343
public static void tearDownAfterClass() throws Exception {
4444
System.out.println("In tear down" );
45-
tearDownJavaRESTServer(dbName, fNames, restServerName);
45+
// tearDownJavaRESTServer(dbName, fNames, restServerName);
4646
}
4747
@Before
4848
public void setUp() throws Exception {
@@ -159,15 +159,15 @@ public void testPOJOValueSearchWithStrings() {
159159
PojoRepository<Artifact,Long> products = client.newPojoRepository(Artifact.class, Long.class);
160160
PojoPage<Artifact> p;
161161
this.loadSimplePojos(products);
162-
String[] searchOptions ={"case-sensitive","wildcarded","min-occurs=2"};
162+
String[] searchOptions ={"case-sensitive","wildcarded","min-occurs=1"};
163163
PojoQueryBuilder qb = products.getQueryBuilder();
164-
String[] searchNames = {"Acme spe*","Widgets spe*"};
165-
PojoQueryDefinition qd = qb.value("name",searchOptions,100.0,searchNames);
164+
String[] searchNames = {"Acme spe* *","Widgets spe* *"};
165+
PojoQueryDefinition qd =qb.filteredQuery(qb.value("name",searchOptions,100.0,searchNames));
166166
JacksonHandle jh = new JacksonHandle();
167167
products.setPageLength(5);
168168
p = products.search(qd, 1,jh);
169169

170-
assertEquals("total no of pages",3,p.getTotalPages());
170+
// assertEquals("total no of pages",3,p.getTotalPages()); since page methods are estimates
171171
System.out.println(jh.get().toString());
172172
long pageNo=1,count=0;
173173
do{
@@ -177,16 +177,15 @@ public void testPOJOValueSearchWithStrings() {
177177
Artifact a =p.next();
178178
validateArtifact(a);
179179
assertTrue("Verifying document id is part of the search ids",a.getId()%5==0);
180+
assertTrue("Verifying document name has Acme/Wigets special",a.getManufacturer().getName().contains("Acme special")||a.getManufacturer().getName().contains("Widgets special"));
180181
count++;
181182
System.out.println(a.getId());
182183
}
183184
assertEquals("Page size",count,p.size());
184185
pageNo=pageNo+p.getPageSize();
185186
}while(!p.isLastPage() && pageNo<=p.getTotalSize());
186-
assertEquals("page number after the loop",3,p.getPageNumber());
187-
assertEquals("total no of pages",3,p.getTotalPages());
188-
assertEquals("page length from search handle",5,jh.get().path("page-length").asInt());
189-
assertEquals("Total results from search handle",11,jh.get().path("total").asInt());
187+
assertEquals("page length from search handle",5,jh.get().path("results").size());
188+
// assertEquals("Total results from search handle",11,jh.get().path("total").asInt());
190189
}
191190
//Below scenario is verifying value query from PojoBuilder that matches to no document
192191
//Issue 127 is logged for the below scenario
@@ -199,7 +198,7 @@ public void testPOJOValueSearchWithNoResults() throws Exception {
199198
String[] searchOptions ={"case-sensitive","wildcarded","min-occurs=2"};
200199
PojoQueryBuilder qb = products.getQueryBuilder();
201200
String[] searchNames = {"acme*"};
202-
PojoQueryDefinition qd = qb.value("name",searchOptions,100.0,searchNames);
201+
PojoQueryDefinition qd =qb.filteredQuery( qb.value("name",searchOptions,100.0,searchNames));
203202
JacksonHandle jh = new JacksonHandle();
204203
products.setPageLength(5);
205204
p = products.search(qd, 1,jh);
@@ -272,21 +271,21 @@ public void testPOJOWordSearchWithOptions() throws Exception {
272271
PojoPage<Artifact> p;
273272
this.loadSimplePojos(products);
274273
setupServerRequestLogging(client,true);
275-
String[] searchOptions ={"case-sensitive","wildcarded","min-occurs=2"};
274+
String[] searchOptions ={"case-sensitive","wildcarded","min-occurs=1"};
276275
PojoQueryBuilder qb = products.getQueryBuilder();
277276
String[] searchNames = {"count*"};
278-
PojoQueryDefinition qd = qb.word("name",searchOptions,0.0,searchNames);
277+
PojoQueryDefinition qd = qb.filteredQuery(qb.word("name",searchOptions,0.0,searchNames));
279278
JacksonHandle jh = new JacksonHandle();
280279
products.setPageLength(5);
281280
p = products.search(qd, 1,jh);
282281
setupServerRequestLogging(client,false);
283282
System.out.println(jh.get().toString());
284-
assertEquals("total no of pages",3,p.getTotalPages());
283+
// assertEquals("total no of pages",3,p.getTotalPages());
285284

286285
long pageNo=1,count=0;
287286
do{
288287
count =0;
289-
p = products.search(qd,pageNo);
288+
p = products.search(qd,pageNo,jh);
290289
while(p.hasNext()){
291290
Artifact a =p.next();
292291
validateArtifact(a);
@@ -295,13 +294,13 @@ public void testPOJOWordSearchWithOptions() throws Exception {
295294
count++;
296295

297296
}
297+
System.out.println(jh.get().toString());
298298
assertEquals("Page size",count,p.size());
299299
pageNo=pageNo+p.getPageSize();
300300
}while(!p.isLastPage() && pageNo<=p.getTotalSize());
301301
assertEquals("page number after the loop",3,p.getPageNumber());
302302
assertEquals("total no of pages",3,p.getTotalPages());
303303
assertEquals("page length from search handle",5,jh.get().path("page-length").asInt());
304-
assertEquals("Total results from search handle",11,jh.get().path("total").asInt());
305-
}
304+
}
306305

307306
}

0 commit comments

Comments
 (0)