|
| 1 | +/* |
| 2 | + * Copyright (C) 2004-2016 the Seasar Foundation and the Others. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
| 13 | + * either express or implied. See the License for the specific language |
| 14 | + * governing permissions and limitations under the License. |
| 15 | + */ |
| 16 | +package org.seasar.doma.boot; |
| 17 | + |
| 18 | +import org.junit.Test; |
| 19 | +import org.seasar.doma.jdbc.SelectOptions; |
| 20 | +import org.seasar.doma.jdbc.SelectOptionsAccessor; |
| 21 | +import org.springframework.data.domain.PageRequest; |
| 22 | + |
| 23 | +import static org.hamcrest.CoreMatchers.is; |
| 24 | +import static org.junit.Assert.assertThat; |
| 25 | + |
| 26 | +public class PageablesTest { |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testToSelectOptions() throws Exception { |
| 30 | + SelectOptions options = Pageables.toSelectOptions(new PageRequest(0, 10)); |
| 31 | + assertThat(SelectOptionsAccessor.getOffset(options), is(0L)); |
| 32 | + assertThat(SelectOptionsAccessor.getLimit(options), is(10L)); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void testToSelectOptions2() throws Exception { |
| 37 | + SelectOptions options = Pageables.toSelectOptions(new PageRequest(2, 10)); |
| 38 | + assertThat(SelectOptionsAccessor.getOffset(options), is(20L)); |
| 39 | + assertThat(SelectOptionsAccessor.getLimit(options), is(10L)); |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + public void testToSelectOptions3() throws Exception { |
| 44 | + SelectOptions options = Pageables.toSelectOptions(new PageRequest(2, 5)); |
| 45 | + assertThat(SelectOptionsAccessor.getOffset(options), is(10L)); |
| 46 | + assertThat(SelectOptionsAccessor.getLimit(options), is(5L)); |
| 47 | + } |
| 48 | +} |
0 commit comments