Skip to content

Commit

Permalink
changed page number to 0 from1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizwan Idrees committed Mar 22, 2013
1 parent a973512 commit 33f506f
Showing 1 changed file with 17 additions and 17 deletions.
Expand Up @@ -71,7 +71,7 @@ public void shouldExecuteCustomMethod(){
sampleEntity.setMessage("some message");
repository.save(sampleEntity);
//when
Page<SampleEntity> page = repository.findByType("test", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByType("test", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(greaterThanOrEqualTo(1L)));
Expand All @@ -87,7 +87,7 @@ public void shouldExecuteCustomMethodForNot(){
sampleEntity.setMessage("some message");
repository.save(sampleEntity);
//when
Page<SampleEntity> page = repository.findByTypeNot("test", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByTypeNot("test", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -103,7 +103,7 @@ public void shouldExecuteCustomMethodWithQuery(){
sampleEntity.setMessage("customQuery");
repository.save(sampleEntity);
//when
Page<SampleEntity> page = repository.findByMessage("customQuery", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessage("customQuery", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(greaterThanOrEqualTo(1L)));
Expand All @@ -130,7 +130,7 @@ public void shouldExecuteCustomMethodWithLessThan(){
repository.save(sampleEntity2);

//when
Page<SampleEntity> page = repository.findByRateLessThan(10, new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByRateLessThan(10, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -148,7 +148,7 @@ public void shouldExecuteCustomMethodWithBefore(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByRateBefore(10, new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByRateBefore(10, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -166,7 +166,7 @@ public void shouldExecuteCustomMethodWithAfter(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByRateAfter(10, new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByRateAfter(10, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -184,7 +184,7 @@ public void shouldExecuteCustomMethodWithLike(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByMessageLike("fo", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessageLike("fo", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -202,7 +202,7 @@ public void shouldExecuteCustomMethodForStartingWith(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByMessageStartingWith("fo", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessageStartingWith("fo", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -220,7 +220,7 @@ public void shouldExecuteCustomMethodForEndingWith(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByMessageEndingWith("o", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessageEndingWith("o", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -238,7 +238,7 @@ public void shouldExecuteCustomMethodForContains(){
repository.save(sampleEntity);

//when
Page<SampleEntity> page = repository.findByMessageContaining("fo", new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessageContaining("fo", new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -265,7 +265,7 @@ public void shouldExecuteCustomMethodForIn(){
List<String> ids = Arrays.asList(documentId,documentId2);

//when
Page<SampleEntity> page = repository.findByIdIn(ids, new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByIdIn(ids, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(2L)));
Expand All @@ -292,7 +292,7 @@ public void shouldExecuteCustomMethodForNotIn(){
List<String> ids = Arrays.asList(documentId);

//when
Page<SampleEntity> page = repository.findByIdNotIn(ids, new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByIdNotIn(ids, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -319,7 +319,7 @@ public void shouldExecuteCustomMethodForTrue(){
sampleEntity2.setAvailable(false);
repository.save(sampleEntity2);
//when
Page<SampleEntity> page = repository.findByAvailableTrue(new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByAvailableTrue(new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand All @@ -345,7 +345,7 @@ public void shouldExecuteCustomMethodForFalse(){
sampleEntity2.setAvailable(false);
repository.save(sampleEntity2);
//when
Page<SampleEntity> page = repository.findByAvailableFalse(new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByAvailableFalse(new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand Down Expand Up @@ -381,14 +381,14 @@ public void shouldExecuteCustomMethodForOrderBy(){
repository.save(sampleEntity3);

//when
Page<SampleEntity> page = repository.findByMessageOrderByTypeAsc("foo",new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByMessageOrderByTypeAsc("foo",new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
}

@Test
public void testCustomMethodForBoolean(){
public void shouldExecuteCustomMethodWithBooleanParameter(){
//given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
Expand All @@ -407,7 +407,7 @@ public void testCustomMethodForBoolean(){
sampleEntity2.setAvailable(false);
repository.save(sampleEntity2);
//when
Page<SampleEntity> page = repository.findByAvailable(false,new PageRequest(1, 10));
Page<SampleEntity> page = repository.findByAvailable(false, new PageRequest(0, 10));
//then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
Expand Down

0 comments on commit 33f506f

Please sign in to comment.