Skip to content

Commit 22990c9

Browse files
committed
Extra assertions on default group (on current behavior)
1 parent b7380a6 commit 22990c9

File tree

6 files changed

+93
-4
lines changed

6 files changed

+93
-4
lines changed

springdoc-openapi-webflux-core/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* * Copyright 2019-2020 the original author or authors.
3+
* * Copyright 2019-2022 the original author or authors.
44
* *
55
* * Licensed under the Apache License, Version 2.0 (the "License");
66
* * you may not use this file except in compliance with the License.
@@ -18,13 +18,18 @@
1818

1919
package test.org.springdoc.api.app145;
2020

21+
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.fail;
23+
2124
import org.junit.jupiter.api.Test;
2225
import org.springdoc.core.Constants;
2326
import test.org.springdoc.api.AbstractSpringDocActuatorTest;
2427

2528
import org.springframework.boot.autoconfigure.SpringBootApplication;
2629
import org.springframework.boot.test.context.SpringBootTest;
2730
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
31+
import org.springframework.http.HttpStatus;
32+
import org.springframework.web.reactive.function.client.WebClientResponseException;
2833

2934

3035
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT,
@@ -47,4 +52,19 @@ public void testApp() {
4752
.expectStatus().isNotFound();
4853
}
4954

55+
@Test
56+
public void testApp3() throws Exception {
57+
try {
58+
webClient.get().uri("/application/openapi"+ "/"+Constants.DEFAULT_GROUP_NAME).retrieve()
59+
.bodyToMono(String.class).block();
60+
fail();
61+
}
62+
catch (WebClientResponseException ex) {
63+
if (ex.getStatusCode() == HttpStatus.NOT_FOUND)
64+
assertTrue(true);
65+
else
66+
fail();
67+
}
68+
}
69+
5070
}

springdoc-openapi-webflux-core/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,11 @@ public void testApp1() throws Exception {
6868
assertEquals(expected, result, true);
6969
}
7070

71+
@Test
72+
public void testApp2() throws Exception {
73+
webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME)
74+
.exchange()
75+
.expectStatus().isNotFound();
76+
}
77+
7178
}

springdoc-openapi-webflux-core/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@
1919
package test.org.springdoc.api.app148;
2020

2121
import org.junit.jupiter.api.Test;
22+
import org.springdoc.core.Constants;
23+
2224
import test.org.springdoc.api.AbstractSpringDocActuatorTest;
2325

2426
import org.springframework.boot.autoconfigure.SpringBootApplication;
2527
import org.springframework.boot.test.context.SpringBootTest;
2628
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
29+
import org.springframework.http.HttpStatus;
30+
import org.springframework.web.reactive.function.client.WebClientResponseException;
2731

32+
import static org.junit.jupiter.api.Assertions.assertTrue;
33+
import static org.junit.jupiter.api.Assertions.fail;
2834
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;
2935

3036

@@ -59,4 +65,18 @@ public void testApp2() throws Exception {
5965
assertEquals(expected, result, true);
6066
}
6167

68+
@Test
69+
public void testApp3() throws Exception {
70+
try {
71+
webClient.get().uri("/test/application/openapi" + "/"+Constants.DEFAULT_GROUP_NAME).retrieve()
72+
.bodyToMono(String.class).block();
73+
fail();
74+
}
75+
catch (WebClientResponseException ex) {
76+
if (ex.getStatusCode() == HttpStatus.NOT_FOUND)
77+
assertTrue(true);
78+
else
79+
fail();
80+
}
81+
}
6282
}

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* * Copyright 2019-2020 the original author or authors.
3+
* * Copyright 2019-2022 the original author or authors.
44
* *
55
* * Licensed under the Apache License, Version 2.0 (the "License");
66
* * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2828
import org.springframework.http.HttpStatus;
2929
import org.springframework.web.client.HttpClientErrorException;
30+
import org.springframework.web.client.HttpStatusCodeException;
3031

3132
import static org.junit.jupiter.api.Assertions.assertTrue;
3233
import static org.junit.jupiter.api.Assertions.fail;
@@ -75,4 +76,18 @@ public void testApp2() throws Exception {
7576
assertEquals(expected, result, true);
7677
}
7778

79+
@Test
80+
public void testApp3() throws Exception {
81+
try {
82+
actuatorRestTemplate.getForObject("/application/openapi"+ "/"+Constants.DEFAULT_GROUP_NAME, String.class);
83+
fail();
84+
}
85+
catch (HttpStatusCodeException ex) {
86+
// TODO: Currently obtain status 500 on MVC... Webflux obtain 404...
87+
if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR)
88+
assertTrue(true);
89+
else
90+
fail();
91+
}
92+
}
7893
}

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* * Copyright 2019-2020 the original author or authors.
3+
* * Copyright 2019-2022 the original author or authors.
44
* *
55
* * Licensed under the Apache License, Version 2.0 (the "License");
66
* * you may not use this file except in compliance with the License.
@@ -61,4 +61,10 @@ public void testApp1() throws Exception {
6161
.andExpect(content().json(getContent("results/app147-2.json"), true));
6262
}
6363

64+
@Test
65+
public void testApp2() throws Exception {
66+
mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/"+Constants.DEFAULT_GROUP_NAME))
67+
.andExpect(status().isNotFound());
68+
}
69+
6470
}

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* * Copyright 2019-2020 the original author or authors.
3+
* * Copyright 2019-2022 the original author or authors.
44
* *
55
* * Licensed under the Apache License, Version 2.0 (the "License");
66
* * you may not use this file except in compliance with the License.
@@ -19,12 +19,18 @@
1919
package test.org.springdoc.api.app148;
2020

2121
import org.junit.jupiter.api.Test;
22+
import org.springdoc.core.Constants;
23+
2224
import test.org.springdoc.api.AbstractSpringDocActuatorTest;
2325

2426
import org.springframework.boot.autoconfigure.SpringBootApplication;
2527
import org.springframework.boot.test.context.SpringBootTest;
2628
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
29+
import org.springframework.http.HttpStatus;
30+
import org.springframework.web.client.HttpStatusCodeException;
2731

32+
import static org.junit.jupiter.api.Assertions.assertTrue;
33+
import static org.junit.jupiter.api.Assertions.fail;
2834
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;
2935

3036

@@ -59,4 +65,19 @@ public void testApp2() throws Exception {
5965
assertEquals(expected, result, true);
6066
}
6167

68+
@Test
69+
public void testApp3() throws Exception {
70+
try {
71+
actuatorRestTemplate.getForObject("/test/application/openapi" + "/"+Constants.DEFAULT_GROUP_NAME, String.class);
72+
fail();
73+
}
74+
catch (HttpStatusCodeException ex) {
75+
// TODO: Currently obtain status 500 on MVC... Webflux obtain 404...
76+
if (ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR)
77+
assertTrue(true);
78+
else
79+
fail();
80+
}
81+
}
82+
6283
}

0 commit comments

Comments
 (0)