Skip to content

Commit 816c84b

Browse files
Ajit GeorgeAjit George
authored andcommitted
Merge branch 'newRegressionTests' of https://github.com/marklogic/java-client-api into newRegressionTests
2 parents a6d75ae + 8cdd3cb commit 816c84b

File tree

2 files changed

+47
-37
lines changed

2 files changed

+47
-37
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ public void test1GetAllResourceServices() throws Exception {
207207
TestJSExtension tjs= new TestJSExtension(client);
208208
String expectedResponse="{\"response\":[200, \"OK\"]}";
209209
JSONAssert.assertEquals(expectedResponse, tjs.putJSON("helloJS.json"), false);
210-
String expAftrPut ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\",\"database-name\":\"TestJSResourceExtensionDB\", \"document-count\":1, \"content\":\"This is a JSON document\", \"document-content\":{\"argument1\":\"hello\", \"argument2\":\"Earth\", \"content\":\"This is a JSON document\", \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}, \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}";
210+
String expAftrPut ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\",\"database-name\":\"TestJSResourceExtensionDB\", \"document-count\":1, \"content\":\"This is a JSON document\", \"document-content\":{\"argument1\":\"hello\", \"argument2\":\"Earth\", \"content\":\"This is a JSON document\", \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}, \"response\":[200, \"OK\"], \"outputTypes\":[\"application/json\"]}";
211211
JSONAssert.assertEquals(expAftrPut, tjs.getJSON("helloJS.json"), false);
212212
JSONAssert.assertEquals(expectedResponse, tjs.postJSON("helloJS.json"), false);
213-
String expAftrPost ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"document-count\":1, \"content\":\"This is a JSON document\", \"document-content\":{\"argument1\":\"hello\", \"argument2\":\"Earth\", \"content\":\"This is a JSON document\", \"array\":[1, 2, 3], \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}, \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}";
213+
String expAftrPost ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"document-count\":1, \"content\":\"This is a JSON document\", \"document-content\":{\"argument1\":\"hello\", \"argument2\":\"Earth\", \"content\":\"This is a JSON document\", \"array\":[1, 2, 3], \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}, \"response\":[200, \"OK\"], \"outputTypes\":[\"application/json\"]}";
214214
JSONAssert.assertEquals(expAftrPost, tjs.getJSON("helloJS.json"), false);
215-
String expected ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"document-count\":0, \"content\":\"This is a JSON document\", \"document-content\":null, \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}";
215+
String expected ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"document-count\":0, \"content\":\"This is a JSON document\", \"document-content\":null, \"response\":[200, \"OK\"], \"outputTypes\":[\"application/json\"]}";
216216
// JSONAssert.assertEquals(expected, tjs.getJSON(), false);
217217

218218
JSONAssert.assertEquals(expectedResponse, tjs.deleteJSON("helloJS.json"), false);
@@ -239,14 +239,14 @@ public void test2GetAllResourceServicesMultipleTimes() throws Exception {
239239
assertEquals("Total documents loaded are",150,jh.get().get("document-count").intValue());
240240

241241
String expAftrPut ="{\"argument1\":\"hello\", \"argument2\":\"Earth\", \"content\":\"This is a JSON document\", \"array\":[1, 2, 3], \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}";
242-
String expected ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"database-name\":\"TestJSResourceExtensionDB\", \"document-count\":0, \"content\":\"This is a JSON document\", \"document-content\":null, \"response\":[200, \"OK\"], \"outputTypes\":\"application/json\"}";
242+
String expected ="{\"argument1\":\"helloJS.json\", \"argument2\":\"Earth\", \"database-name\":\"TestJSResourceExtensionDB\", \"document-count\":0, \"content\":\"This is a JSON document\", \"document-content\":null, \"response\":[200, \"OK\"], \"outputTypes\":[\"application/json\"]}";
243243
// verify by reading all the documents to see put and post services correctly inserted documents and delete them
244244
for(int j=0;j<150;j++){
245245
jh.set(jh2.getMapper().readTree(tjs.getJSON("helloJS"+j+".json")));
246246
JSONAssert.assertEquals(expAftrPut,jh.get().get("document-content").findParent("array").toString(), false);
247247
JSONAssert.assertEquals(expectedResponse, tjs.deleteJSON("helloJS"+j+".json"), false);
248248
}
249-
// System.out.println(tjs.getJSON());
249+
System.out.println(tjs.getJSON("helloJS.json"));
250250
JSONAssert.assertEquals(expected, tjs.getJSON("helloJS.json"), false);
251251

252252
}

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

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public void testPOJOWriteWithTransaction() throws Exception {
8383
for(int i=1;i<112;i++){
8484
products.write(this.getArtifact(i),t);
8585
}
86-
// assertEquals("Total number of object recods",111, products.count());
86+
assertEquals("Total number of object recods",111, products.count(t));
8787
for(long i=1;i<112;i++){
88-
// assertTrue("Product id "+i+" does not exist",products.exists(i));
88+
assertTrue("Product id "+i+" does not exist",products.exists(i,t));
8989
this.validateArtifact(products.read(i,t));
9090
}
9191

@@ -116,19 +116,27 @@ public void testPOJOWriteWithTransCollection() throws Exception {
116116
}
117117
}catch(Exception e){throw e;}
118118
finally{t.commit();}
119-
assertEquals("Total number of object recods",110, products.count("numbers"));
120-
assertEquals("Collection even count",55,products.count("even"));
121-
assertEquals("Collection odd count",55,products.count("odd"));
119+
// assertEquals("Total number of object recods",110, products.count("numbers"));
120+
// assertEquals("Collection even count",55,products.count("even"));
121+
// assertEquals("Collection odd count",55,products.count("odd"));
122122
for(long i=112;i<222;i++){
123123
// validate all the records inserted are readable
124124
assertTrue("Product id "+i+" does not exist",products.exists(i));
125125
this.validateArtifact(products.read(i));
126126
}
127-
// t= client.openTransaction();
128-
129-
products.delete((long)112);
130-
assertFalse("Product id 112 exists ?",products.exists((long)112));
131-
products.deleteAll();
127+
Transaction t2= client.openTransaction();
128+
try{
129+
Long[] ids = {(long)112,(long)113};
130+
products.delete(ids,t2);
131+
assertFalse("Product id 112 exists ?",products.exists((long)112,t2));
132+
// assertTrue("Product id 112 exists ?",products.exists((long)112));
133+
products.deleteAll(t2);
134+
for(long i=112;i<222;i++){
135+
assertFalse("Product id "+i+" exists ?",products.exists(i,t2));
136+
// assertTrue("Product id "+i+" exists ?",products.exists(i));
137+
}
138+
}catch(Exception e){throw e;}
139+
finally{t2.commit();}
132140
//see any document exists
133141
for(long i=112;i<222;i++){
134142
assertFalse("Product id "+i+" exists ?",products.exists(i));
@@ -138,7 +146,8 @@ public void testPOJOWriteWithTransCollection() throws Exception {
138146
products.deleteAll();
139147
}
140148
//This test is to read objects into pojo page based on Ids
141-
// until #103 is resolved @Test
149+
// until #103 is resolved
150+
@Test
142151
public void testPOJOWriteWithPojoPage() {
143152
PojoRepository<Artifact,Long> products = client.newPojoRepository(Artifact.class, Long.class);
144153
//Load more than 110 objects into different collections
@@ -154,33 +163,35 @@ public void testPOJOWriteWithPojoPage() {
154163
products.write(this.getArtifact(i),"odd","numbers");
155164
}
156165
}
157-
assertEquals("Total number of object recods",111, products.count("numbers"));
158-
assertEquals("Collection even count",56,products.count("even"));
159-
assertEquals("Collection odd count",55,products.count("odd"));
166+
// assertEquals("Total number of object recods",111, products.count("numbers"));
167+
// assertEquals("Collection even count",56,products.count("even"));
168+
// assertEquals("Collection odd count",55,products.count("odd"));
160169

161170
System.out.println("Default Page length setting on docMgr :"+products.getPageLength());
162171
assertEquals("Default setting for page length",50,products.getPageLength());
163172
products.setPageLength(100);
164-
// assertEquals("explicit setting for page length",1,products.getPageLength());
165-
PojoPage<Artifact> p= products.read(ids);
173+
assertEquals("explicit setting for page length",100,products.getPageLength());
174+
PojoPage<Artifact> p= products.search(1, "numbers");
166175
// test for page methods
167-
//Issue- assertEquals("Number of records",1,p.size());
168-
System.out.println("Page size"+p.size());
169-
// assertEquals("Starting record in first page ",1,p.getStart());
170-
System.out.println("Starting record in first page "+p.getStart());
171-
172-
// assertEquals("Total number of estimated results:",111,p.getTotalSize());
173-
System.out.println("Total number of estimated results:"+p.getTotalSize());
174-
// assertEquals("Total number of estimated pages :",111,p.getTotalPages());
175-
System.out.println("Total number of estimated pages :"+p.getTotalPages());
176-
assertFalse("Is this First page :",p.isFirstPage());//this is bug
176+
assertEquals("Number of records",100,p.size());
177+
// System.out.println("Page size"+p.size());
178+
assertEquals("Starting record in first page ",1,p.getStart());
179+
// System.out.println("Starting record in first page "+p.getStart());
180+
181+
assertEquals("Total number of estimated results:",111,p.getTotalSize());
182+
// System.out.println("Total number of estimated results:"+p.getTotalSize());
183+
assertEquals("Total number of estimated pages :",2,p.getTotalPages());
184+
// System.out.println("Total number of estimated pages :"+p.getTotalPages());
185+
System.out.println("is this firstPage or LastPage:"+p.isFirstPage()+" "+p.isLastPage()+"has previous page"+p.hasPreviousPage());
186+
assertTrue("Is this First page :",p.isFirstPage());//this is bug
177187
assertFalse("Is this Last page :",p.isLastPage());
178188
assertTrue("Is this First page has content:",p.hasContent());
179189
// Need the Issue #75 to be fixed
180-
assertTrue("Is first page has previous page ?",p.hasPreviousPage());
190+
assertFalse("Is first page has previous page ?",p.hasPreviousPage());
181191
long pageNo=1,count=0;
182192
do{
183193
count=0;
194+
p= products.search(pageNo, "numbers");
184195
if(pageNo >1){
185196
assertFalse("Is this first Page", p.isFirstPage());
186197
assertTrue("Is page has previous page ?",p.hasPreviousPage());
@@ -191,14 +202,13 @@ public void testPOJOWriteWithPojoPage() {
191202
count++;
192203
}
193204
// assertEquals("document count", p.size(),count);
194-
System.out.println("Is this Last page :"+p.hasContent()+p.isLastPage());
205+
System.out.println("Is this Last page :"+p.hasContent()+p.isLastPage()+p.getPageNumber());
195206
pageNo = pageNo + p.getPageSize();
196-
}while((p.isLastPage()) && p.hasContent());
197-
assertTrue("page count is 111 ",pageNo == p.getTotalPages());
207+
}while(pageNo< p.getTotalSize());
198208
assertTrue("Page has previous page ?",p.hasPreviousPage());
199-
assertEquals("page size", 1,p.getPageSize());
209+
assertEquals("page size", 11,p.size());
200210
assertEquals("document count", 111,p.getTotalSize());
201-
assertFalse("Page has any records ?",p.hasContent());
211+
assertTrue("Page has any records ?",p.hasContent());
202212

203213

204214
products.deleteAll();

0 commit comments

Comments
 (0)