77import java .io .File ;
88import java .nio .file .Files ;
99import java .nio .file .Path ;
10- import java .util .ArrayList ;
1110import java .util .Collections ;
1211import java .util .List ;
1312
@@ -40,7 +39,7 @@ public abstract class AbstractRecipeTest extends AbstractXmlTestSupport implemen
4039 * Creates the recipe with violations and configs.
4140 */
4241 protected abstract Recipe createRecipe (List <CheckstyleViolation > violations ,
43- List < CheckConfiguration > checkConfigs );
42+ CheckConfiguration checkConfigs );
4443
4544 @ Override
4645 protected String getPackageLocation () {
@@ -58,7 +57,7 @@ protected void verify(String testCaseName) throws Exception {
5857
5958 final List <CheckstyleViolation > violations = runCheckstyleAndGetViolations (inputPath );
6059
61- final List < CheckConfiguration > checkConfigs = getAllCheckConfigurations (inputPath );
60+ final CheckConfiguration checkConfigs = getAllCheckConfigurations (inputPath );
6261
6362 final String beforeCode = readFile (getPath (inputPath ));
6463 final String expectedAfterCode = readFile (getPath (outputPath ));
@@ -94,28 +93,11 @@ private List<CheckstyleViolation> runCheckstyleAndGetViolations(String inputPath
9493 }
9594 }
9695
97- private List < CheckConfiguration > getAllCheckConfigurations (String inputPath ) throws Exception {
96+ private CheckConfiguration getAllCheckConfigurations (String inputPath ) throws Exception {
9897 final String configFilePath = getPath (inputPath );
9998 final TestInputConfiguration testInputConfiguration =
10099 InlineConfigParser .parse (configFilePath );
101- final Configuration parsedConfig = testInputConfiguration .createConfiguration ();
102-
103- final List <CheckConfiguration > checkConfigs = new ArrayList <>();
104-
105- for (Configuration child : parsedConfig .getChildren ()) {
106- if ("TreeWalker" .equals (child .getName ())) {
107- for (Configuration check : child .getChildren ()) {
108- final CheckConfiguration checkConfig = ConfigurationLoader .mapConfiguration (check );
109- checkConfigs .add (checkConfig );
110- }
111- }
112- }
113-
114- if (checkConfigs .isEmpty ()) {
115- throw new IllegalStateException ("No check configurations found" );
116- }
117-
118- return checkConfigs ;
100+ return ConfigurationLoader .mapConfiguration (testInputConfiguration .createConfiguration ());
119101 }
120102
121103 /**
0 commit comments