Skip to content

Commit 85d0de3

Browse files
fix: checkstyle and others
1 parent c58f0b9 commit 85d0de3

25 files changed

+1097
-978
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*]
2+
indent_style = space
3+
indent_size = 2
4+
end_of_line = lf
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true

.vscode/settings.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"java.checkstyle.configuration": "checkstyle.xml",
3-
"java.checkstyle.version": "8.41",
2+
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
3+
"java.checkstyle.version": "9.3",
44
"editor.formatOnSave": true,
55
"editor.formatOnPaste": true,
66
"editor.formatOnType": true,
@@ -10,14 +10,13 @@
1010
},
1111
"java.configuration.updateBuildConfiguration": "automatic",
1212
"java.compile.nullAnalysis.mode": "automatic",
13-
"java.format.enabled": true,
1413
"java.import.generatesMetadataFilesAtProjectRoot": true,
1514
"java.sources.organizeImports.starThreshold": 99,
1615
"java.sources.organizeImports.staticStarThreshold": 99,
1716
"[java]": {
18-
"editor.defaultFormatter": "redhat.java",
19-
"editor.formatOnSave": true,
20-
"editor.formatOnPaste": true,
21-
"editor.formatOnType": true
17+
"editor.defaultFormatter": null,
18+
"editor.formatOnSave": false,
19+
"editor.formatOnPaste": false,
20+
"editor.formatOnType": false
2221
}
2322
}

checkstyle.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
</module>
1818

1919
<module name="TreeWalker">
20+
<!-- Indentation -->
21+
<module name="Indentation">
22+
<property name="basicOffset" value="2" />
23+
<property name="braceAdjustment" value="0" />
24+
<property name="caseIndent" value="2" />
25+
<property name="throwsIndent" value="4" />
26+
<property name="lineWrappingIndentation" value="4" />
27+
<property name="arrayInitIndent" value="2" />
28+
</module>
29+
2030
<!-- Checks for Naming Conventions -->
2131
<module name="ConstantName" />
2232
<module name="LocalFinalVariableName" />

pom.xml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
<java.version>11</java.version>
4141
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4242
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
43+
<checkstyle.version>10.12.7</checkstyle.version>
44+
<google-formatter-plugin.version>1.7.5</google-formatter-plugin.version>
4345
</properties>
4446

4547
<dependencies>
@@ -119,6 +121,20 @@
119121
<scope>provided</scope>
120122
</dependency>
121123

124+
<dependency>
125+
<groupId>org.slf4j</groupId>
126+
<artifactId>slf4j-simple</artifactId>
127+
<version>2.0.9</version>
128+
<scope>test</scope>
129+
</dependency>
130+
131+
<dependency>
132+
<groupId>org.mockito</groupId>
133+
<artifactId>mockito-core</artifactId>
134+
<version>5.10.0</version>
135+
<scope>test</scope>
136+
</dependency>
137+
122138
</dependencies>
123139

124140
<build>
@@ -235,13 +251,38 @@
235251
</executions>
236252
</plugin>
237253

238-
<!-- Checkstyle for code style checking -->
254+
<!-- Google Java Formatter Plugin (theoryinpractise) -->
255+
<plugin>
256+
<groupId>com.theoryinpractise</groupId>
257+
<artifactId>googleformatter-maven-plugin</artifactId>
258+
<version>${google-formatter-plugin.version}</version>
259+
<executions>
260+
<execution>
261+
<id>reformat-sources</id>
262+
<goals>
263+
<goal>format</goal>
264+
</goals>
265+
<!-- You can optionally tie this to a phase e.g.
266+
<phase>process-sources</phase> -->
267+
</execution>
268+
</executions>
269+
</plugin>
270+
271+
<!-- Maven Checkstyle Plugin -->
239272
<plugin>
240273
<groupId>org.apache.maven.plugins</groupId>
241274
<artifactId>maven-checkstyle-plugin</artifactId>
242275
<version>3.3.1</version>
276+
<dependencies>
277+
<dependency>
278+
<groupId>com.puppycrawl.tools</groupId>
279+
<artifactId>checkstyle</artifactId>
280+
<version>${checkstyle.version}</version>
281+
</dependency>
282+
</dependencies>
243283
<configuration>
244-
<configLocation>google_checks.xml</configLocation>
284+
<configLocation>${basedir}/checkstyle.xml</configLocation>
285+
<encoding>UTF-8</encoding>
245286
<consoleOutput>true</consoleOutput>
246287
<failsOnError>true</failsOnError>
247288
<linkXRef>false</linkXRef>

src/main/java/io/github/mikeddavydov/jpwise/JPWise.java

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
import io.github.mikeddavydov.jpwise.core.TestParameter;
2020

2121
/**
22-
* A facade class providing a simplified API for the JPWise test generation
23-
* framework. This class
24-
* offers static methods for building test inputs and generating test
25-
* combinations using either
22+
* A facade class providing a simplified API for the JPWise test generation framework. This class
23+
* offers static methods for building test inputs and generating test combinations using either
2624
* pairwise or combinatorial algorithms.
2725
*
28-
* <p>
29-
* Example usage:
26+
* <p>Example usage:
3027
*
3128
* <pre>
3229
* // Direct generation
@@ -54,8 +51,7 @@ private JPWise() {
5451
}
5552

5653
/**
57-
* Creates a new InputBuilder for fluently constructing test inputs. This is an
58-
* alias for {@link
54+
* Creates a new InputBuilder for fluently constructing test inputs. This is an alias for {@link
5955
* #builder()}.
6056
*
6157
* @return A new InputBuilder instance
@@ -96,8 +92,7 @@ public static InputBuilder withParameters(Collection<TestParameter> parameters)
9692
}
9793

9894
/**
99-
* Generates test combinations using the pairwise algorithm with default
100-
* settings.
95+
* Generates test combinations using the pairwise algorithm with default settings.
10196
*
10297
* @param parameters The test parameters
10398
* @return A table of generated test combinations
@@ -108,8 +103,7 @@ public static CombinationTable generatePairwise(TestParameter... parameters) {
108103
}
109104

110105
/**
111-
* Generates test combinations using the pairwise algorithm with default
112-
* settings.
106+
* Generates test combinations using the pairwise algorithm with default settings.
113107
*
114108
* @param parameters The test parameters
115109
* @return A table of generated test combinations
@@ -122,11 +116,10 @@ public static CombinationTable generatePairwise(Collection<TestParameter> parame
122116
/**
123117
* Generates test combinations using a configured pairwise algorithm.
124118
*
125-
* @param algorithm The configured pairwise algorithm instance
119+
* @param algorithm The configured pairwise algorithm instance
126120
* @param parameters The test parameters
127121
* @return A table of generated test combinations
128-
* @throws NullPointerException if algorithm, parameters array, or any parameter
129-
* is null
122+
* @throws NullPointerException if algorithm, parameters array, or any parameter is null
130123
*/
131124
public static CombinationTable generatePairwise(
132125
PairwiseAlgorithm algorithm, TestParameter... parameters) {
@@ -137,11 +130,10 @@ public static CombinationTable generatePairwise(
137130
/**
138131
* Generates test combinations using a configured pairwise algorithm.
139132
*
140-
* @param algorithm The configured pairwise algorithm instance
133+
* @param algorithm The configured pairwise algorithm instance
141134
* @param parameters The test parameters
142135
* @return A table of generated test combinations
143-
* @throws NullPointerException if algorithm, parameters collection, or any
144-
* parameter is null
136+
* @throws NullPointerException if algorithm, parameters collection, or any parameter is null
145137
*/
146138
public static CombinationTable generatePairwise(
147139
PairwiseAlgorithm algorithm, Collection<TestParameter> parameters) {
@@ -150,8 +142,7 @@ public static CombinationTable generatePairwise(
150142
}
151143

152144
/**
153-
* Generates test combinations using the pairwise algorithm with default
154-
* settings.
145+
* Generates test combinations using the pairwise algorithm with default settings.
155146
*
156147
* @param input The test input configuration
157148
* @return A table of generated test combinations
@@ -164,7 +155,7 @@ public static CombinationTable generatePairwise(TestInput input) {
164155
/**
165156
* Generates test combinations using a configured pairwise algorithm.
166157
*
167-
* @param input The test input configuration
158+
* @param input The test input configuration
168159
* @param algorithm The configured pairwise algorithm instance
169160
* @return A table of generated test combinations
170161
* @throws NullPointerException if input or algorithm is null
@@ -176,8 +167,7 @@ public static CombinationTable generatePairwise(TestInput input, PairwiseAlgorit
176167
}
177168

178169
/**
179-
* Generates test combinations using the combinatorial algorithm with default
180-
* settings.
170+
* Generates test combinations using the combinatorial algorithm with default settings.
181171
*
182172
* @param parameters The test parameters
183173
* @return A table of generated test combinations
@@ -188,14 +178,12 @@ public static CombinationTable generateCombinatorial(TestParameter... parameters
188178
}
189179

190180
/**
191-
* Generates test combinations using the combinatorial algorithm with default
192-
* settings.
181+
* Generates test combinations using the combinatorial algorithm with default settings.
193182
*
194183
* @param parameters The test parameters
195-
* @param limit The maximum number of combinations to generate
184+
* @param limit The maximum number of combinations to generate
196185
* @return A table of generated test combinations
197-
* @throws NullPointerException if parameters collection or any element is
198-
* null
186+
* @throws NullPointerException if parameters collection or any element is null
199187
* @throws IllegalArgumentException if limit is less than 1
200188
*/
201189
public static CombinationTable generateCombinatorial(
@@ -206,12 +194,11 @@ public static CombinationTable generateCombinatorial(
206194
/**
207195
* Generates test combinations using a configured combinatorial algorithm.
208196
*
209-
* @param algorithm The configured combinatorial algorithm instance
210-
* @param limit The maximum number of combinations to generate
197+
* @param algorithm The configured combinatorial algorithm instance
198+
* @param limit The maximum number of combinations to generate
211199
* @param parameters The test parameters
212200
* @return A table of generated test combinations
213-
* @throws NullPointerException if algorithm, parameters array, or any
214-
* parameter is null
201+
* @throws NullPointerException if algorithm, parameters array, or any parameter is null
215202
* @throws IllegalArgumentException if limit is less than 1
216203
*/
217204
public static CombinationTable generateCombinatorial(
@@ -221,8 +208,7 @@ public static CombinationTable generateCombinatorial(
221208
}
222209

223210
/**
224-
* Generates test combinations using the combinatorial algorithm with default
225-
* settings.
211+
* Generates test combinations using the combinatorial algorithm with default settings.
226212
*
227213
* @param input The test input configuration
228214
* @return A table of generated test combinations
@@ -235,7 +221,7 @@ public static CombinationTable generateCombinatorial(TestInput input) {
235221
/**
236222
* Generates test combinations using a configured combinatorial algorithm.
237223
*
238-
* @param input The test input configuration
224+
* @param input The test input configuration
239225
* @param algorithm The configured combinatorial algorithm instance
240226
* @return A table of generated test combinations
241227
* @throws NullPointerException if input or algorithm is null
@@ -246,14 +232,13 @@ public static CombinationTable generateCombinatorial(
246232
}
247233

248234
/**
249-
* Generates test combinations using a configured combinatorial algorithm with a
250-
* limit.
235+
* Generates test combinations using a configured combinatorial algorithm with a limit.
251236
*
252-
* @param input The test input configuration
237+
* @param input The test input configuration
253238
* @param algorithm The configured combinatorial algorithm instance
254-
* @param limit The maximum number of combinations to generate
239+
* @param limit The maximum number of combinations to generate
255240
* @return A table of generated test combinations
256-
* @throws NullPointerException if input or algorithm is null
241+
* @throws NullPointerException if input or algorithm is null
257242
* @throws IllegalArgumentException if limit is less than 1
258243
*/
259244
public static CombinationTable generateCombinatorial(
@@ -268,19 +253,22 @@ public static CombinationTable generateCombinatorial(
268253
}
269254

270255
private static CombinationTable executeGeneration(
271-
TestInput input, GenerationAlgorithm algorithm, int nWiseOrLimit) {
272-
logger.debug("JPWise.executeGeneration called with algorithm: {}, nWiseOrLimit: {}",
273-
algorithm.getClass().getSimpleName(), nWiseOrLimit);
274-
Objects.requireNonNull(input, "input must not be null");
275-
Objects.requireNonNull(algorithm, "algorithm must not be null");
276-
if (nWiseOrLimit < 1) {
277-
throw new IllegalArgumentException("nWiseOrLimit must generally be positive.");
278-
}
279-
256+
TestInput input, GenerationAlgorithm algorithm, Integer nWiseOrLimit) {
257+
logger.info(
258+
"Executing generation with algorithm: {} for TestInput with {} parameters. NWise/Limit: {}",
259+
algorithm.getClass().getSimpleName(),
260+
input.getTestParameters().size(),
261+
nWiseOrLimit == null ? "default" : nWiseOrLimit);
262+
263+
// Create the generator and run the algorithm.
264+
// The nWiseOrLimit is now handled by the algorithm's constructor if needed.
280265
TestGenerator generator = new TestGenerator(input);
281-
logger.debug("JPWise.executeGeneration: TestGenerator created. Calling TestGenerator.generate()...");
282-
CombinationTable result = generator.generate(algorithm, nWiseOrLimit);
283-
logger.info("Generated {} test combinations", result.size());
266+
logger.debug(
267+
"JPWise.executeGeneration: TestGenerator created. Calling TestGenerator.generate()...");
268+
CombinationTable result = generator.generate(algorithm);
269+
logger.debug(
270+
"JPWise.executeGeneration: TestGenerator.generate() returned. Result size: {}",
271+
result.size());
284272
return result;
285273
}
286274

@@ -310,7 +298,7 @@ public InputBuilder parameter(TestParameter parameter) {
310298
/**
311299
* Creates and adds a parameter with the given name and partitions.
312300
*
313-
* @param name The parameter name
301+
* @param name The parameter name
314302
* @param partitions The parameter's partitions
315303
* @return This builder instance
316304
* @throws NullPointerException if name or partitions array is null
@@ -322,12 +310,11 @@ public InputBuilder parameter(String name, EquivalencePartition... partitions) {
322310
}
323311

324312
/**
325-
* Creates and adds a parameter with the given name, partitions, and
326-
* compatibility rules.
313+
* Creates and adds a parameter with the given name, partitions, and compatibility rules.
327314
*
328-
* @param name The parameter name
315+
* @param name The parameter name
329316
* @param partitions The parameter's partitions
330-
* @param rules The parameter's compatibility rules
317+
* @param rules The parameter's compatibility rules
331318
* @return This builder instance
332319
* @throws NullPointerException if any argument is null
333320
*/
@@ -382,8 +369,7 @@ public TestInput build() {
382369
}
383370

384371
/**
385-
* Convenience method to generate test combinations using the pairwise algorithm
386-
* with default
372+
* Convenience method to generate test combinations using the pairwise algorithm with default
387373
* settings.
388374
*
389375
* @return A table of generated test combinations
@@ -394,8 +380,7 @@ public CombinationTable generatePairwise() {
394380
}
395381

396382
/**
397-
* Convenience method to generate test combinations using the combinatorial
398-
* algorithm with
383+
* Convenience method to generate test combinations using the combinatorial algorithm with
399384
* default settings.
400385
*
401386
* @return A table of generated test combinations
@@ -405,8 +390,7 @@ public CombinationTable generateCombinatorial() {
405390
}
406391

407392
/**
408-
* Convenience method to generate test combinations using the combinatorial
409-
* algorithm with a
393+
* Convenience method to generate test combinations using the combinatorial algorithm with a
410394
* limit.
411395
*
412396
* @param limit The maximum number of combinations to generate

0 commit comments

Comments
 (0)