Skip to content

Commit 6aaf4f3

Browse files
authored
style: make JUnit 5 test classes and methods package private (#620)
Signed-off-by: Niels Pardon <par@zurich.ibm.com>
1 parent 194f4e4 commit 6aaf4f3

67 files changed

Lines changed: 240 additions & 249 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-logic/src/main/resources/substrait-pmd.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<rule ref="category/java/codestyle.xml/UnnecessaryModifier" />
1414
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass" />
1515
<rule ref="category/java/codestyle.xml/UseExplicitTypes" />
16+
<rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate" />
1617
<rule ref="category/java/bestpractices.xml/MissingOverride" />
1718
<rule ref="category/java/bestpractices.xml/UnusedAssignment" />
1819
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />

core/src/test/java/io/substrait/extendedexpression/ExtendedExpressionRoundTripTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.junit.jupiter.params.provider.Arguments;
2323
import org.junit.jupiter.params.provider.MethodSource;
2424

25-
public class ExtendedExpressionRoundTripTest extends TestBase {
25+
class ExtendedExpressionRoundTripTest extends TestBase {
2626

2727
private static Stream<Arguments> expressionReferenceProvider() {
2828
return Stream.of(
@@ -34,15 +34,15 @@ private static Stream<Arguments> expressionReferenceProvider() {
3434

3535
@ParameterizedTest
3636
@MethodSource("expressionReferenceProvider")
37-
public void testRoundTrip(ExtendedExpression.ExpressionReferenceBase expressionReference) {
37+
void testRoundTrip(ExtendedExpression.ExpressionReferenceBase expressionReference) {
3838
List<ExtendedExpression.ExpressionReferenceBase> expressionReferences = new ArrayList<>();
3939
expressionReferences.add(expressionReference);
4040
NamedStruct namedStruct = getImmutableNamedStruct();
4141
assertExtendedExpressionOperation(expressionReferences, namedStruct);
4242
}
4343

4444
@Test
45-
public void getNoExpressionDefined() {
45+
void getNoExpressionDefined() {
4646
IllegalStateException illegalStateException =
4747
Assertions.assertThrows(
4848
IllegalStateException.class,
@@ -55,7 +55,7 @@ public void getNoExpressionDefined() {
5555
}
5656

5757
@Test
58-
public void getNoAggregateFunctionDefined() {
58+
void getNoAggregateFunctionDefined() {
5959
IllegalStateException illegalStateException =
6060
Assertions.assertThrows(
6161
IllegalStateException.class,

core/src/test/java/io/substrait/extension/ExtensionCollectionMergeTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import org.junit.jupiter.api.Test;
99

10-
public class ExtensionCollectionMergeTest {
10+
class ExtensionCollectionMergeTest {
1111

1212
@Test
13-
public void testMergeCollectionsWithDifferentUriUrnMappings() {
13+
void testMergeCollectionsWithDifferentUriUrnMappings() {
1414
String yaml1 =
1515
"%YAML 1.2\n"
1616
+ "---\n"
@@ -47,7 +47,7 @@ public void testMergeCollectionsWithDifferentUriUrnMappings() {
4747
}
4848

4949
@Test
50-
public void testMergeCollectionsWithIdenticalMappings() {
50+
void testMergeCollectionsWithIdenticalMappings() {
5151
String yaml =
5252
"%YAML 1.2\n"
5353
+ "---\n"
@@ -69,7 +69,7 @@ public void testMergeCollectionsWithIdenticalMappings() {
6969
}
7070

7171
@Test
72-
public void testMergeCollectionsWithConflictingMappings() {
72+
void testMergeCollectionsWithConflictingMappings() {
7373
String yaml1 =
7474
"%YAML 1.2\n" + "---\n" + "urn: extension:conflict:urn1\n" + "scalar_functions: []\n";
7575

core/src/test/java/io/substrait/extension/ExtensionCollectionUriUrnTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import org.junit.jupiter.api.Test;
99

10-
public class ExtensionCollectionUriUrnTest {
10+
class ExtensionCollectionUriUrnTest {
1111

1212
@Test
13-
public void testHasUrnAndHasUri() {
13+
void testHasUrnAndHasUri() {
1414
String yamlContent =
1515
"%YAML 1.2\n"
1616
+ "---\n"
@@ -28,7 +28,7 @@ public void testHasUrnAndHasUri() {
2828
}
2929

3030
@Test
31-
public void testGetNonexistentMappings() {
31+
void testGetNonexistentMappings() {
3232
String yamlContent =
3333
"%YAML 1.2\n" + "---\n" + "urn: extension:test:minimal\n" + "scalar_functions: []\n";
3434

@@ -40,7 +40,7 @@ public void testGetNonexistentMappings() {
4040
}
4141

4242
@Test
43-
public void testEmptyUriThrowsException() {
43+
void testEmptyUriThrowsException() {
4444
String yamlContent =
4545
"%YAML 1.2\n" + "---\n" + "urn: extension:test:empty\n" + "scalar_functions: []\n";
4646

@@ -50,7 +50,7 @@ public void testEmptyUriThrowsException() {
5050
}
5151

5252
@Test
53-
public void testNullUriThrowsException() {
53+
void testNullUriThrowsException() {
5454
String yamlContent =
5555
"%YAML 1.2\n" + "---\n" + "urn: extension:test:null\n" + "scalar_functions: []\n";
5656

core/src/test/java/io/substrait/extension/ExtensionCollectorUriUrnTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import io.substrait.proto.Plan;
66
import org.junit.jupiter.api.Test;
77

8-
public class ExtensionCollectorUriUrnTest {
8+
class ExtensionCollectorUriUrnTest {
99

1010
@Test
11-
public void testExtensionCollectorScalarFuncWithoutURI() {
11+
void testExtensionCollectorScalarFuncWithoutURI() {
1212
String uri = "test://uri";
1313
BidiMap<String, String> uriUrnMap = new BidiMap<String, String>();
1414
uriUrnMap.put(uri, "extension:test:basic");

core/src/test/java/io/substrait/extension/ImmutableExtensionLookupUriUrnTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
import io.substrait.proto.SimpleExtensionURN;
1111
import org.junit.jupiter.api.Test;
1212

13-
public class ImmutableExtensionLookupUriUrnTest {
13+
class ImmutableExtensionLookupUriUrnTest {
1414

1515
@Test
16-
public void testUrnResolutionWorks() {
16+
void testUrnResolutionWorks() {
1717
// Create URN-only plan (normal case)
1818
SimpleExtensionURN urnProto =
1919
SimpleExtensionURN.newBuilder()
@@ -41,7 +41,7 @@ public void testUrnResolutionWorks() {
4141
}
4242

4343
@Test
44-
public void testUriToUrnFallbackWorks() {
44+
void testUriToUrnFallbackWorks() {
4545
// Create an ExtensionCollection with URI/URN mapping
4646
BidiMap<String, String> uriUrnMap = new BidiMap<>();
4747
uriUrnMap.put("http://example.com/extensions/test", "extension:test:mapped");
@@ -77,7 +77,7 @@ public void testUriToUrnFallbackWorks() {
7777
}
7878

7979
@Test
80-
public void testUriWithoutMappingThrowsError() {
80+
void testUriWithoutMappingThrowsError() {
8181
// Create URI-only plan without mapping
8282
SimpleExtensionURI uriProto =
8383
SimpleExtensionURI.newBuilder()
@@ -111,7 +111,7 @@ public void testUriWithoutMappingThrowsError() {
111111
}
112112

113113
@Test
114-
public void testMissingUrnAndUriThrowsError() {
114+
void testMissingUrnAndUriThrowsError() {
115115
// Create plan with missing URN/URI reference
116116
SimpleExtensionDeclaration.ExtensionFunction func =
117117
SimpleExtensionDeclaration.ExtensionFunction.newBuilder()
@@ -142,7 +142,7 @@ public void testMissingUrnAndUriThrowsError() {
142142
// ==========================================================================
143143

144144
@Test
145-
public void testFunctionCase1_NonZeroUrnReference() {
145+
void testFunctionCase1_NonZeroUrnReference() {
146146
// Case 1: Non-zero URN reference resolves
147147
SimpleExtensionURN urnProto =
148148
SimpleExtensionURN.newBuilder()
@@ -169,7 +169,7 @@ public void testFunctionCase1_NonZeroUrnReference() {
169169
}
170170

171171
@Test
172-
public void testFunctionCase2_NonZeroUriReference() {
172+
void testFunctionCase2_NonZeroUriReference() {
173173
// Case 2: Non-zero URI reference resolves via mapping
174174
BidiMap<String, String> uriUrnMap = new BidiMap<>();
175175
uriUrnMap.put("http://example.com/case2", "extension:test:case2");
@@ -203,7 +203,7 @@ public void testFunctionCase2_NonZeroUriReference() {
203203
}
204204

205205
@Test
206-
public void testFunctionCase3_ZeroBothResolveConsistent() {
206+
void testFunctionCase3_ZeroBothResolveConsistent() {
207207
// Case 3: Both 0 references resolve to consistent URN
208208
BidiMap<String, String> uriUrnMap = new BidiMap<>();
209209
uriUrnMap.put("http://example.com/case3", "extension:test:case3");
@@ -249,7 +249,7 @@ public void testFunctionCase3_ZeroBothResolveConsistent() {
249249
}
250250

251251
@Test
252-
public void testFunctionCase3_ZeroBothResolveConflict() {
252+
void testFunctionCase3_ZeroBothResolveConflict() {
253253
// Case 3: Both 0 references resolve but to different URNs - should throw
254254
BidiMap<String, String> uriUrnMap = new BidiMap<>();
255255
uriUrnMap.put("http://example.com/conflict", "extension:test:different");
@@ -299,7 +299,7 @@ public void testFunctionCase3_ZeroBothResolveConflict() {
299299
}
300300

301301
@Test
302-
public void testFunctionCase4_ZeroUrnOnly() {
302+
void testFunctionCase4_ZeroUrnOnly() {
303303
// Case 4: Only 0 URN reference resolves
304304
SimpleExtensionURN urnProto =
305305
SimpleExtensionURN.newBuilder()
@@ -327,7 +327,7 @@ public void testFunctionCase4_ZeroUrnOnly() {
327327
}
328328

329329
@Test
330-
public void testFunctionCase5_ZeroUriOnly() {
330+
void testFunctionCase5_ZeroUriOnly() {
331331
// Case 5: Only 0 URI reference resolves
332332
BidiMap<String, String> uriUrnMap = new BidiMap<>();
333333
uriUrnMap.put("http://example.com/case5", "extension:test:case5");
@@ -366,7 +366,7 @@ public void testFunctionCase5_ZeroUriOnly() {
366366
// ==========================================================================
367367

368368
@Test
369-
public void testTypeCase1_NonZeroUrnReference() {
369+
void testTypeCase1_NonZeroUrnReference() {
370370
// Case 1: Non-zero URN reference resolves
371371
SimpleExtensionURN urnProto =
372372
SimpleExtensionURN.newBuilder()
@@ -393,7 +393,7 @@ public void testTypeCase1_NonZeroUrnReference() {
393393
}
394394

395395
@Test
396-
public void testTypeCase2_NonZeroUriReference() {
396+
void testTypeCase2_NonZeroUriReference() {
397397
// Case 2: Non-zero URI reference resolves via mapping
398398
BidiMap<String, String> uriUrnMap = new BidiMap<>();
399399
uriUrnMap.put("http://example.com/case2", "extension:test:case2");
@@ -427,7 +427,7 @@ public void testTypeCase2_NonZeroUriReference() {
427427
}
428428

429429
@Test
430-
public void testTypeCase3_ZeroBothResolveConsistent() {
430+
void testTypeCase3_ZeroBothResolveConsistent() {
431431
// Case 3: Both 0 references resolve to consistent URN
432432
BidiMap<String, String> uriUrnMap = new BidiMap<>();
433433
uriUrnMap.put("http://example.com/case3", "extension:test:case3");
@@ -473,7 +473,7 @@ public void testTypeCase3_ZeroBothResolveConsistent() {
473473
}
474474

475475
@Test
476-
public void testTypeCase3_ZeroBothResolveConflict() {
476+
void testTypeCase3_ZeroBothResolveConflict() {
477477
// Case 3: Both 0 references resolve but to different URNs - should throw
478478
BidiMap<String, String> uriUrnMap = new BidiMap<>();
479479
uriUrnMap.put("http://example.com/conflict", "extension:test:different");
@@ -523,7 +523,7 @@ public void testTypeCase3_ZeroBothResolveConflict() {
523523
}
524524

525525
@Test
526-
public void testTypeCase4_ZeroUrnOnly() {
526+
void testTypeCase4_ZeroUrnOnly() {
527527
// Case 4: Only 0 URN reference resolves
528528
SimpleExtensionURN urnProto =
529529
SimpleExtensionURN.newBuilder()
@@ -551,7 +551,7 @@ public void testTypeCase4_ZeroUrnOnly() {
551551
}
552552

553553
@Test
554-
public void testTypeCase5_ZeroUriOnly() {
554+
void testTypeCase5_ZeroUriOnly() {
555555
// Case 5: Only 0 URI reference resolves
556556
BidiMap<String, String> uriUrnMap = new BidiMap<>();
557557
uriUrnMap.put("http://example.com/case5", "extension:test:case5");
@@ -586,7 +586,7 @@ public void testTypeCase5_ZeroUriOnly() {
586586
}
587587

588588
@Test
589-
public void testTypeUriToUrnFallbackWorks() {
589+
void testTypeUriToUrnFallbackWorks() {
590590
// Test the same logic but for types instead of functions
591591
BidiMap<String, String> uriUrnMap = new BidiMap<>();
592592
uriUrnMap.put("http://example.com/types/test", "extension:types:mapped");

core/src/test/java/io/substrait/extension/TypeExtensionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* <li>Roundtrip between POJO and Proto
2525
* </ul>
2626
*/
27-
public class TypeExtensionTest {
27+
class TypeExtensionTest {
2828

2929
static final TypeCreator R = TypeCreator.of(false);
3030

core/src/test/java/io/substrait/extension/UriUrnMigrationEndToEndTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* 3. Convert POJO -> proto using PlanProtoConverter 4. Verify output contains proper
2525
* extensioninformation
2626
*/
27-
public class UriUrnMigrationEndToEndTest {
27+
class UriUrnMigrationEndToEndTest {
2828

2929
/** Load a proto Plan from a JSON resource file using JsonFormat */
3030
private Plan loadPlanFromJson(String resourcePath) throws IOException {
@@ -45,7 +45,7 @@ private Plan loadPlanFromJson(String resourcePath) throws IOException {
4545
}
4646

4747
@Test
48-
public void testUriUrnMigrationEndToEnd() throws IOException {
48+
void testUriUrnMigrationEndToEnd() throws IOException {
4949

5050
// List of (inputPath, expectedPath, extensionCollection) tuples
5151
List<String[]> testCases =
@@ -91,7 +91,7 @@ public void testUriUrnMigrationEndToEnd() throws IOException {
9191
}
9292

9393
@Test
94-
public void testUnresolvableUriThrowsException() throws IOException {
94+
void testUnresolvableUriThrowsException() throws IOException {
9595
Plan inputPlan = loadPlanFromJson("uri-urn-migration/unresolvable-uri-plan.json");
9696

9797
ProtoPlanConverter protoToPojo =

core/src/test/java/io/substrait/extension/UrnValidationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import org.junit.jupiter.api.Test;
99

10-
public class UrnValidationTest {
10+
class UrnValidationTest {
1111

1212
@Test
13-
public void testMissingUrnThrowsException() {
13+
void testMissingUrnThrowsException() {
1414
String yamlWithoutUrn = "%YAML 1.2\n" + "---\n" + "scalar_functions:\n" + " - name: test\n";
1515
IllegalArgumentException exception =
1616
assertThrows(
@@ -19,7 +19,7 @@ public void testMissingUrnThrowsException() {
1919
}
2020

2121
@Test
22-
public void testInvalidUrnFormatThrowsException() {
22+
void testInvalidUrnFormatThrowsException() {
2323
String yamlWithInvalidUrn =
2424
"%YAML 1.2\n"
2525
+ "---\n"
@@ -35,7 +35,7 @@ public void testInvalidUrnFormatThrowsException() {
3535
}
3636

3737
@Test
38-
public void testValidUrnWorks() {
38+
void testValidUrnWorks() {
3939
String yamlWithValidUrn =
4040
"%YAML 1.2\n"
4141
+ "---\n"
@@ -46,7 +46,7 @@ public void testValidUrnWorks() {
4646
}
4747

4848
@Test
49-
public void testUriUrnMapIsPopulated() {
49+
void testUriUrnMapIsPopulated() {
5050
String yamlWithValidUrn =
5151
"%YAML 1.2\n"
5252
+ "---\n"

core/src/test/java/io/substrait/relation/AggregateRelTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static io.substrait.proto.Expression createFieldReference(int col) {
5858
}
5959

6060
@Test
61-
public void testDeprecatedGroupingExpressionConversion() {
61+
void testDeprecatedGroupingExpressionConversion() {
6262
Expression col1Ref = createFieldReference(0);
6363
Expression col2Ref = createFieldReference(1);
6464

@@ -89,7 +89,7 @@ public void testDeprecatedGroupingExpressionConversion() {
8989
}
9090

9191
@Test
92-
public void testAggregateWithSingleGrouping() {
92+
void testAggregateWithSingleGrouping() {
9393
Expression col1Ref = createFieldReference(0);
9494
Expression col2Ref = createFieldReference(1);
9595

@@ -122,7 +122,7 @@ public void testAggregateWithSingleGrouping() {
122122
}
123123

124124
@Test
125-
public void testAggregateWithMultipleGroupings() {
125+
void testAggregateWithMultipleGroupings() {
126126
Expression col1Ref = createFieldReference(0);
127127
Expression col2Ref = createFieldReference(1);
128128

0 commit comments

Comments
 (0)