Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4dd594a

Browse files
Dilip KrishnanDilip Krishnan
authored andcommitted
Added test for demonstrating 1749
(1749)
1 parent e9aada1 commit 4dd594a

3 files changed

Lines changed: 160 additions & 1 deletion

File tree

springfox-spring-web/src/test/java/springfox/documentation/spring/web/dummy/controllers/BugsController.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
import org.springframework.web.bind.annotation.RequestMethod;
3535
import org.springframework.web.bind.annotation.RequestParam;
3636
import org.springframework.web.bind.annotation.RestController;
37+
import springfox.documentation.spring.web.dummy.models.Bug1749;
3738
import springfox.documentation.spring.web.dummy.models.Example;
3839

40+
import javax.servlet.http.HttpServletResponse;
41+
import javax.validation.Valid;
3942
import java.net.MalformedURLException;
4043
import java.net.URL;
4144
import java.nio.ByteBuffer;
@@ -189,11 +192,23 @@ public ResponseEntity<Bug1777> bug1777() {
189192
}
190193

191194

192-
@RequestMapping(value = "/1778", method = RequestMethod.GET)
195+
@RequestMapping(value = "/1778", method = GET)
193196
public ResponseEntity<Void> bug1778(TestClass testClass, TestClass2 testClass2) {
194197
return ResponseEntity.ok().build();
195198
}
196199

200+
@ApiOperation(value = "Retrieve all the companies")
201+
@RequestMapping(value = "/1749", method = GET)
202+
public List<String> getAllPaged(
203+
@Valid Bug1749 request,
204+
HttpServletResponse response,
205+
@RequestParam(required = false) String email,
206+
@RequestParam(required = false) String companyName,
207+
@RequestParam(required = false) Boolean like) throws Exception {
208+
throw new UnsupportedOperationException();
209+
}
210+
211+
197212
class TestClass {
198213

199214
private String s;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
*
3+
* Copyright 2017-2018 the original author or authors.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
package springfox.documentation.spring.web.dummy.controllers;
20+
21+
public enum SortDirection {
22+
ASC,
23+
DESC
24+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
*
3+
* Copyright 2017-2018 the original author or authors.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
package springfox.documentation.spring.web.dummy.models;
20+
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
22+
import springfox.documentation.spring.web.dummy.controllers.SortDirection;
23+
24+
import javax.validation.constraints.Max;
25+
import javax.validation.constraints.Min;
26+
import javax.validation.constraints.NotNull;
27+
import java.util.HashMap;
28+
import java.util.Map;
29+
30+
public class Bug1749 {
31+
@NotNull
32+
@Min(value = 1, message = "must be > 1")
33+
private Integer pageNumber = 1;
34+
@NotNull
35+
@Max(value = 50, message = "must be < 50")
36+
private Integer pageSize = 20;
37+
private SortDirection sortDirection;
38+
private String sortField;
39+
40+
public Bug1749(int pageNumber, int pageSize) {
41+
this.pageNumber = pageNumber;
42+
this.pageSize = pageSize;
43+
}
44+
45+
public Bug1749(int pageNumber, int pageSize, String sortField) {
46+
this(pageNumber, pageSize);
47+
this.sortField = sortField;
48+
}
49+
50+
public Bug1749(int pageNumber, int pageSize, String sortField, SortDirection sortDirection) {
51+
this(pageNumber, pageSize, sortField);
52+
this.sortDirection = sortDirection;
53+
}
54+
55+
public Map<String, String> toMap() {
56+
Map<String, String> map = new HashMap<String, String>();
57+
map.put("pageNumber", Integer.toString(pageNumber));
58+
map.put("pageSize", Integer.toString(pageSize));
59+
if (sortDirection != null) {
60+
map.put("sortDirection", sortDirection.toString());
61+
}
62+
if (sortField != null) {
63+
map.put("sortField", sortField);
64+
}
65+
return map;
66+
}
67+
68+
// region Auto-generated code
69+
public Bug1749() {
70+
}
71+
72+
@JsonIgnore
73+
public boolean isAscending() {
74+
return sortDirection == SortDirection.ASC;
75+
}
76+
77+
@JsonIgnore
78+
public boolean isSet() {
79+
return pageNumber != null && pageSize != null;
80+
}
81+
82+
public Bug1749 setSort(String field, SortDirection direction) {
83+
this.sortField = field;
84+
this.sortDirection = direction;
85+
return this;
86+
}
87+
88+
public Integer getPageNumber() {
89+
return pageNumber;
90+
}
91+
92+
public void setPageNumber(Integer pageNumber) {
93+
this.pageNumber = pageNumber;
94+
}
95+
96+
public Integer getPageSize() {
97+
return pageSize;
98+
}
99+
100+
public void setPageSize(Integer pageSize) {
101+
this.pageSize = pageSize;
102+
}
103+
104+
public SortDirection getSortDirection() {
105+
return sortDirection;
106+
}
107+
108+
public void setSortDirection(SortDirection sortDirection) {
109+
this.sortDirection = sortDirection;
110+
}
111+
112+
public String getSortField() {
113+
return sortField;
114+
}
115+
116+
public void setSortField(String sortField) {
117+
this.sortField = sortField;
118+
}
119+
// endregion
120+
}

0 commit comments

Comments
 (0)