Skip to content

Commit aaacec6

Browse files
committed
setup and teardown for test
1 parent 0942572 commit aaacec6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import io.swagger.v3.core.converter.ModelConverters;
44
import io.swagger.v3.core.util.Json;
5+
import org.junit.jupiter.api.AfterAll;
6+
import org.junit.jupiter.api.AfterEach;
7+
import org.junit.jupiter.api.BeforeAll;
8+
import org.junit.jupiter.api.BeforeEach;
59
import org.junit.jupiter.api.Test;
610
import org.springdoc.core.Constants;
711
import org.springdoc.core.converters.ModelConverterRegistrar;
@@ -26,10 +30,21 @@ public class SpringDocApp157Test extends AbstractSpringDocTest {
2630
@SpringBootApplication
2731
static class SpringBootApp {}
2832

33+
private StringyConverter myConverter = new StringyConverter();
34+
private ModelConverters converters = ModelConverters.getInstance();
35+
36+
@BeforeEach
37+
public void registerConverter() {
38+
converters.addConverter(myConverter);
39+
}
40+
41+
@AfterEach
42+
public void unregisterConverter() {
43+
converters.removeConverter(myConverter);
44+
}
45+
2946
@Test
3047
public void testApp() throws Exception {
31-
// Not sure why the converter isn't registered automatically. Register it here.
32-
new ModelConverterRegistrar(List.of(new StringyConverter()));
3348
mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL))
3449
.andExpect(status().isOk())
3550
.andExpect(jsonPath("$.openapi", is("3.0.1")))

0 commit comments

Comments
 (0)