@@ -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