diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/CustomMethodRepositoryTest.java b/src/test/java/org/springframework/data/elasticsearch/repositories/CustomMethodRepositoryTest.java index f2e285d4e..029b14f58 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/CustomMethodRepositoryTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/CustomMethodRepositoryTest.java @@ -71,7 +71,7 @@ public class CustomMethodRepositoryTest { sampleEntity.setMessage("some message"); repository.save(sampleEntity); //when - Page page = repository.findByType("test", new PageRequest(1, 10)); + Page page = repository.findByType("test", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(greaterThanOrEqualTo(1L))); @@ -87,7 +87,7 @@ public class CustomMethodRepositoryTest { sampleEntity.setMessage("some message"); repository.save(sampleEntity); //when - Page page = repository.findByTypeNot("test", new PageRequest(1, 10)); + Page page = repository.findByTypeNot("test", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -103,7 +103,7 @@ public class CustomMethodRepositoryTest { sampleEntity.setMessage("customQuery"); repository.save(sampleEntity); //when - Page page = repository.findByMessage("customQuery", new PageRequest(1, 10)); + Page page = repository.findByMessage("customQuery", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(greaterThanOrEqualTo(1L))); @@ -130,7 +130,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity2); //when - Page page = repository.findByRateLessThan(10, new PageRequest(1, 10)); + Page page = repository.findByRateLessThan(10, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -148,7 +148,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByRateBefore(10, new PageRequest(1, 10)); + Page page = repository.findByRateBefore(10, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -166,7 +166,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByRateAfter(10, new PageRequest(1, 10)); + Page page = repository.findByRateAfter(10, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -184,7 +184,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByMessageLike("fo", new PageRequest(1, 10)); + Page page = repository.findByMessageLike("fo", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -202,7 +202,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByMessageStartingWith("fo", new PageRequest(1, 10)); + Page page = repository.findByMessageStartingWith("fo", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -220,7 +220,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByMessageEndingWith("o", new PageRequest(1, 10)); + Page page = repository.findByMessageEndingWith("o", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -238,7 +238,7 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity); //when - Page page = repository.findByMessageContaining("fo", new PageRequest(1, 10)); + Page page = repository.findByMessageContaining("fo", new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -265,7 +265,7 @@ public class CustomMethodRepositoryTest { List ids = Arrays.asList(documentId,documentId2); //when - Page page = repository.findByIdIn(ids, new PageRequest(1, 10)); + Page page = repository.findByIdIn(ids, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(2L))); @@ -292,7 +292,7 @@ public class CustomMethodRepositoryTest { List ids = Arrays.asList(documentId); //when - Page page = repository.findByIdNotIn(ids, new PageRequest(1, 10)); + Page page = repository.findByIdNotIn(ids, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -319,7 +319,7 @@ public class CustomMethodRepositoryTest { sampleEntity2.setAvailable(false); repository.save(sampleEntity2); //when - Page page = repository.findByAvailableTrue(new PageRequest(1, 10)); + Page page = repository.findByAvailableTrue(new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -345,7 +345,7 @@ public class CustomMethodRepositoryTest { sampleEntity2.setAvailable(false); repository.save(sampleEntity2); //when - Page page = repository.findByAvailableFalse(new PageRequest(1, 10)); + Page page = repository.findByAvailableFalse(new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L))); @@ -381,14 +381,14 @@ public class CustomMethodRepositoryTest { repository.save(sampleEntity3); //when - Page page = repository.findByMessageOrderByTypeAsc("foo",new PageRequest(1, 10)); + Page 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(); @@ -407,7 +407,7 @@ public class CustomMethodRepositoryTest { sampleEntity2.setAvailable(false); repository.save(sampleEntity2); //when - Page page = repository.findByAvailable(false,new PageRequest(1, 10)); + Page page = repository.findByAvailable(false, new PageRequest(0, 10)); //then assertThat(page, is(notNullValue())); assertThat(page.getTotalElements(), is(equalTo(1L)));