1313import org .apiaddicts .apitools .apigen .generatorcore .config .validation .Validation ;
1414import org .apiaddicts .apitools .apigen .generatorcore .config .validation .ValidationType ;
1515import org .apiaddicts .apitools .apigen .generatorcore .spec .OpenAPIExtended ;
16- import org .junit .jupiter .api .BeforeAll ;
1716import org .junit .jupiter .api .Test ;
1817
1918import java .math .BigDecimal ;
2625// TODO #14909 refactor tests to use individualized api fragments
2726class ConfigurationExtractorTest {
2827
29- private static Configuration configuration ;
30-
31- @ BeforeAll
32- static void prepareTest () {
33- OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
34- configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
35- assertNotNull (configuration );
36- }
37-
3828 private static OpenAPIExtended load (String fileName ) {
3929 ParseOptions parseOptions = new ParseOptions ();
4030 parseOptions .setResolveFully (true );
@@ -44,6 +34,8 @@ private static OpenAPIExtended load(String fileName) {
4434
4535 @ Test
4636 void checkExtractedProjectInfoFromYAML () {
37+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
38+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
4739 assertEquals (configuration .getName (), "test" );
4840 assertEquals (configuration .getDescription (), "test" );
4941 assertEquals ("the.test" , configuration .getGroup ());
@@ -53,6 +45,8 @@ void checkExtractedProjectInfoFromYAML() {
5345
5446 @ Test
5547 void checkExtractedEntitiesFromYAML () {
48+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
49+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
5650 assertNotNull (configuration .getEntities ());
5751
5852 List <Entity > entities = configuration .getEntities ();
@@ -107,6 +101,8 @@ void checkExtractedEntitiesFromYAML() {
107101
108102 @ Test
109103 void checkExtractedValidationsFromYAMLModels () {
104+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
105+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
110106 assertNotNull (configuration .getEntities ());
111107
112108 List <Validation > validations = configuration .getEntities ().get (0 ).getAttributes ().get (0 ).getValidations ();
@@ -162,12 +158,16 @@ void checkExtractedValidationsFromYAMLModels() {
162158
163159 @ Test
164160 void checkExtractedValidationsFromYAMLResources () {
161+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
162+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
165163 List <Validation > validations = configuration .getControllers ().get (0 ).getEndpoints ().get (0 ).getRequest ().getAttributes ().get (0 ).getValidations ();
166164 assertEquals (ValidationType .NOT_NULL , validations .get (0 ).getType (), "Check NotNull Validation" );
167165 }
168166
169167 @ Test
170168 void checkExtractedControllersFromYAML () {
169+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
170+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
171171 assertNotNull (configuration .getControllers ());
172172
173173 List <Controller > controllers = configuration .getControllers ();
@@ -197,6 +197,8 @@ void checkExtractedControllersFromYAML() {
197197
198198 @ Test
199199 void checkExtractedEndpointsParametersFromYAML () {
200+ OpenAPIExtended openAPIExtended = load ("testApi.yaml" );
201+ Configuration configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
200202 assertNotNull (configuration .getControllers ());
201203 Controller controller = configuration .getControllers ().get (0 );
202204
@@ -273,7 +275,6 @@ private void checkBooleanParameter(Parameter parameter) {
273275 @ Test
274276 void allOfWithProperties () {
275277 OpenAPIExtended openAPIExtended = load ("0001_allOffProps.yaml" );
276- configuration = new ConfigurationExtractor (openAPIExtended ).extract ();
277278 Schema <?> schema = openAPIExtended .getSchemas ().get ("standard_response_res_one" );
278279 Map <String , Schema > props = schema .getProperties ();
279280 assertTrue (props .containsKey ("data" ), "'data' property expected" );
0 commit comments