Skip to content

Commit 277b114

Browse files
committed
Add tests
1 parent 264ec00 commit 277b114

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 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+
* * https://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 test.org.springdoc.ui.app18;
20+
21+
import org.springframework.web.bind.annotation.GetMapping;
22+
import org.springframework.web.bind.annotation.RequestParam;
23+
import org.springframework.web.bind.annotation.RestController;
24+
25+
import javax.validation.Valid;
26+
import javax.validation.constraints.Size;
27+
28+
@RestController
29+
public class HelloController {
30+
31+
@GetMapping(value = "/persons")
32+
public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) {
33+
34+
}
35+
36+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 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+
* * https://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 test.org.springdoc.ui.app18;
20+
21+
import org.junit.jupiter.api.Test;
22+
import org.skyscreamer.jsonassert.JSONAssert;
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.boot.test.context.SpringBootTest;
25+
import test.org.springdoc.ui.AbstractSpringDocActuatorTest;
26+
27+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
28+
properties = {"management.endpoints.web.exposure.include:*",
29+
"springdoc.use-management-port=true",
30+
"springdoc.swagger-ui.try-it-out-enabled=true",
31+
"management.server.port=9095",
32+
"management.server.base-path=/test",
33+
"management.endpoints.web.base-path=/application"
34+
})
35+
class SpringDocApp18Test extends AbstractSpringDocActuatorTest {
36+
37+
@Test
38+
public void testIndexSwaggerConfigTryItOutEnabledExists() throws Exception {
39+
String contentAsString = actuatorRestTemplate.getForObject("/test/application/swaggerui/swagger-config", String.class);
40+
String expected = getContent("results/app18-1.json");
41+
JSONAssert.assertEquals(expected, contentAsString, true);
42+
}
43+
44+
@SpringBootApplication
45+
static class SpringDocTestApp {
46+
}
47+
48+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"configUrl": "/test/application/swaggerui/swagger-config",
3+
"oauth2RedirectUrl": "http://localhost:9095/test/application/swagger-ui/oauth2-redirect.html",
4+
"validatorUrl": "",
5+
"url": "/test/application/openapi",
6+
"tryItOutEnabled": "true"
7+
}

0 commit comments

Comments
 (0)