BAEL-5319 - Remove Basic Error Controller in Swagger (#11743)
* BAEL-5319 - Remove Basic Error Controller in Swagger * BAEL-5319 - fixed style * BAEL-5319 - removed comments and private info * BAEL-5319 - removed private info * two space indent for line continuation, optimized import. Co-authored-by: gpiazzolla <gaetano.piazzolla@dxc.com>
This commit is contained in:
committed by
GitHub
parent
9b8a5a0fa7
commit
533f2014a8
+33
@@ -0,0 +1,33 @@
|
||||
package com.baeldung.swaggerconf;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@AutoConfigureMockMvc
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class SwaggerConfExcludeErrorControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mvc;
|
||||
|
||||
@Test
|
||||
public void whenCallingSwaggerJSON_stringObjectDoesNotContainAnyErrorControllers() throws Exception {
|
||||
ResultActions resultActions = mvc.perform(get("/v2/api-docs")).andExpect(status().isOk());
|
||||
MvcResult result = resultActions.andReturn();
|
||||
String content = result.getResponse().getContentAsString();
|
||||
Assert.assertNotNull(content);
|
||||
Assert.assertFalse(content.contains("error-controller"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user