Skip to content

Commit 56b06dd

Browse files
committed
DATAJDBC-614 - Adding unit tests.
Original pull request: #227.
1 parent 735b1bc commit 56b06dd

File tree

1 file changed

+65
-0
lines changed
  • spring-data-relational/src/test/java/org/springframework/data/relational/core/query

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2020 the original author or authors.
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+
* https://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, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.relational.core.query;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
20+
import org.junit.Test;
21+
import org.springframework.data.domain.PageRequest;
22+
import org.springframework.data.domain.Sort;
23+
24+
/**
25+
* Tests the {@link Query} class.
26+
*
27+
* @author Jens Schauder
28+
*/
29+
public class QueryUnitTests {
30+
31+
@Test // DATAJDBC614
32+
public void withCombinesSortAndPaging() {
33+
34+
Query query = Query.empty() //
35+
.sort(Sort.by("alpha")) //
36+
.with(PageRequest.of(2, 20, Sort.by("beta")));
37+
38+
assertThat(query.getSort().get()) //
39+
.extracting(Sort.Order::getProperty) //
40+
.containsExactly("alpha", "beta");
41+
}
42+
43+
@Test // DATAJDBC614
44+
public void withCombinesEmptySortAndPaging() {
45+
46+
Query query = Query.empty() //
47+
.with(PageRequest.of(2, 20, Sort.by("beta")));
48+
49+
assertThat(query.getSort().get()) //
50+
.extracting(Sort.Order::getProperty) //
51+
.containsExactly("beta");
52+
}
53+
54+
@Test // DATAJDBC614
55+
public void withCombinesSortAndUnsortedPaging() {
56+
57+
Query query = Query.empty() //
58+
.sort(Sort.by("alpha")) //
59+
.with(PageRequest.of(2, 20));
60+
61+
assertThat(query.getSort().get()) //
62+
.extracting(Sort.Order::getProperty) //
63+
.containsExactly("alpha");
64+
}
65+
}

0 commit comments

Comments
 (0)