From 61bd56dd746767e2c759f94f66336bf25ef87ca6 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 8 Jan 2020 15:11:43 +0100 Subject: [PATCH] DATAMONGO-2442 - Polishing. Reduce visibility of test methods for JUnit 5 tests. Original pull request: #818. --- .../aggregation/AggregationUnitTests.java | 76 +++++++++---------- .../aggregation/CondExpressionUnitTests.java | 18 ++--- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java index c8e08c0b8..e51932abe 100755 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java @@ -42,27 +42,27 @@ import org.springframework.data.mongodb.core.query.Criteria; public class AggregationUnitTests { @Test - public void rejectsNullAggregationOperation() { + void rejectsNullAggregationOperation() { assertThatIllegalArgumentException().isThrownBy(() -> newAggregation((AggregationOperation[]) null)); } @Test - public void rejectsNullTypedAggregationOperation() { + void rejectsNullTypedAggregationOperation() { assertThatIllegalArgumentException().isThrownBy(() -> newAggregation(String.class, (AggregationOperation[]) null)); } @Test - public void rejectsNoAggregationOperation() { + void rejectsNoAggregationOperation() { assertThatIllegalArgumentException().isThrownBy(() -> newAggregation(new AggregationOperation[0])); } @Test - public void rejectsNoTypedAggregationOperation() { + void rejectsNoTypedAggregationOperation() { assertThatIllegalArgumentException().isThrownBy(() -> newAggregation(String.class, new AggregationOperation[0])); } @Test // DATAMONGO-753 - public void checkForCorrectFieldScopeTransfer() { + void checkForCorrectFieldScopeTransfer() { assertThatIllegalArgumentException().isThrownBy(() -> { newAggregation( // @@ -74,7 +74,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-753 - public void unwindOperationShouldNotChangeAvailableFields() { + void unwindOperationShouldNotChangeAvailableFields() { newAggregation( // project("a", "b"), // @@ -84,7 +84,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1391 - public void unwindOperationWithIndexShouldPreserveFields() { + void unwindOperationWithIndexShouldPreserveFields() { newAggregation( // project("a", "b"), // @@ -94,7 +94,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1391 - public void unwindOperationWithIndexShouldAddIndexField() { + void unwindOperationWithIndexShouldAddIndexField() { newAggregation( // project("a", "b"), // @@ -104,7 +104,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1391 - public void fullUnwindOperationShouldBuildCorrectClause() { + void fullUnwindOperationShouldBuildCorrectClause() { Document agg = newAggregation( // unwind("a", "x", true)).toDocument("foo", Aggregation.DEFAULT_CONTEXT); @@ -117,7 +117,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1391 - public void unwindOperationWithPreserveNullShouldBuildCorrectClause() { + void unwindOperationWithPreserveNullShouldBuildCorrectClause() { Document agg = newAggregation( // unwind("a", true)).toDocument("foo", Aggregation.DEFAULT_CONTEXT); @@ -130,7 +130,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1550 - public void replaceRootOperationShouldBuildCorrectClause() { + void replaceRootOperationShouldBuildCorrectClause() { Document agg = newAggregation( // replaceRoot().withDocument().andValue("value").as("field")) // @@ -142,7 +142,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-753 - public void matchOperationShouldNotChangeAvailableFields() { + void matchOperationShouldNotChangeAvailableFields() { newAggregation( // project("a", "b"), // @@ -152,7 +152,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-788 - public void referencesToGroupIdsShouldBeRenderedAsReferences() { + void referencesToGroupIdsShouldBeRenderedAsReferences() { Document agg = newAggregation( // project("a"), // @@ -168,7 +168,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-791 - public void allowAggregationOperationsToBePassedAsIterable() { + void allowAggregationOperationsToBePassedAsIterable() { List ops = new ArrayList(); ops.add(project("a")); @@ -185,7 +185,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-791 - public void allowTypedAggregationOperationsToBePassedAsIterable() { + void allowTypedAggregationOperationsToBePassedAsIterable() { List ops = new ArrayList<>(); ops.add(project("a")); @@ -202,7 +202,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-838 - public void expressionBasedFieldsShouldBeReferencableInFollowingOperations() { + void expressionBasedFieldsShouldBeReferencableInFollowingOperations() { Document agg = newAggregation( // project("a").andExpression("b+c").as("foo"), // @@ -216,7 +216,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-908 - public void shouldSupportReferingToNestedPropertiesInGroupOperation() { + void shouldSupportReferingToNestedPropertiesInGroupOperation() { Document agg = newAggregation( // project("cmsParameterId", "rules"), // @@ -234,7 +234,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1585 - public void shouldSupportSortingBySyntheticAndExposedGroupFields() { + void shouldSupportSortingBySyntheticAndExposedGroupFields() { Document agg = newAggregation( // group("cmsParameterId").addToSet("title").as("titles"), // @@ -250,7 +250,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1585 - public void shouldSupportSortingByProjectedFields() { + void shouldSupportSortingByProjectedFields() { Document agg = newAggregation( // project("cmsParameterId") // @@ -269,7 +269,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-924 - public void referencingProjectionAliasesFromPreviousStepShouldReferToTheSameFieldTarget() { + void referencingProjectionAliasesFromPreviousStepShouldReferToTheSameFieldTarget() { Document agg = newAggregation( // project().and("foo.bar").as("ba") // @@ -284,7 +284,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-960 - public void shouldRenderAggregationWithDefaultOptionsCorrectly() { + void shouldRenderAggregationWithDefaultOptionsCorrectly() { Document agg = newAggregation( // project().and("a").as("aa") // @@ -295,7 +295,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-960 - public void shouldRenderAggregationWithCustomOptionsCorrectly() { + void shouldRenderAggregationWithCustomOptionsCorrectly() { AggregationOptions aggregationOptions = newAggregationOptions().explain(true).cursor(new Document("foo", 1)) .allowDiskUse(true).build(); @@ -315,7 +315,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-954, DATAMONGO-1585 - public void shouldSupportReferencingSystemVariables() { + void shouldSupportReferencingSystemVariables() { Document agg = newAggregation( // project("someKey") // @@ -336,7 +336,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1254 - public void shouldExposeAliasedFieldnameForProjectionsIncludingOperationsDownThePipeline() { + void shouldExposeAliasedFieldnameForProjectionsIncludingOperationsDownThePipeline() { Document agg = Aggregation.newAggregation(// project("date") // @@ -350,7 +350,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1254 - public void shouldUseAliasedFieldnameForProjectionsIncludingOperationsDownThePipelineWhenUsingSpEL() { + void shouldUseAliasedFieldnameForProjectionsIncludingOperationsDownThePipelineWhenUsingSpEL() { Document agg = Aggregation.newAggregation(// project("date") // @@ -364,7 +364,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void conditionExpressionBasedFieldsShouldBeReferencableInFollowingOperations() { + void conditionExpressionBasedFieldsShouldBeReferencableInFollowingOperations() { Document agg = newAggregation( // project("a", "answer"), // @@ -382,7 +382,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void shouldRenderProjectionConditionalExpressionCorrectly() { + void shouldRenderProjectionConditionalExpressionCorrectly() { Document agg = Aggregation.newAggregation(// project().and(ConditionalOperators.Cond.newBuilder() // @@ -401,7 +401,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void shouldRenderProjectionConditionalCorrectly() { + void shouldRenderProjectionConditionalCorrectly() { Document agg = Aggregation.newAggregation(// project().and("color").applyCondition(ConditionalOperators.Cond.newBuilder() // @@ -420,7 +420,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void shouldRenderProjectionConditionalWithCriteriaCorrectly() { + void shouldRenderProjectionConditionalWithCriteriaCorrectly() { Document agg = Aggregation.newAggregation(project()// .and("color")// @@ -438,7 +438,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861, DATAMONGO-2242 - public void referencingProjectionAliasesShouldRenderProjectionConditionalWithFieldReferenceCorrectly() { + void referencingProjectionAliasesShouldRenderProjectionConditionalWithFieldReferenceCorrectly() { Document agg = Aggregation.newAggregation(// project().and("color").as("chroma"), project().and("luminosity") // @@ -458,7 +458,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void referencingProjectionAliasesShouldRenderProjectionConditionalWithCriteriaReferenceCorrectly() { + void referencingProjectionAliasesShouldRenderProjectionConditionalWithCriteriaReferenceCorrectly() { Document agg = Aggregation.newAggregation(// project().and("color").as("chroma"), project().and("luminosity") // @@ -477,7 +477,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void shouldRenderProjectionIfNullWithFieldReferenceCorrectly() { + void shouldRenderProjectionIfNullWithFieldReferenceCorrectly() { Document agg = Aggregation.newAggregation(// project().and("color"), // @@ -493,7 +493,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-861 - public void shouldRenderProjectionIfNullWithFallbackFieldReferenceCorrectly() { + void shouldRenderProjectionIfNullWithFallbackFieldReferenceCorrectly() { Document agg = Aggregation.newAggregation(// project("fallback").and("color").as("chroma"), project().and("luminosity") // @@ -507,7 +507,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1552 - public void shouldHonorDefaultCountField() { + void shouldHonorDefaultCountField() { Document agg = Aggregation.newAggregation(// bucket("year"), // @@ -520,7 +520,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1533 - public void groupOperationShouldAllowUsageOfDerivedSpELAggregationExpression() { + void groupOperationShouldAllowUsageOfDerivedSpELAggregationExpression() { Document agg = newAggregation( // project("a"), // @@ -538,7 +538,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1756 - public void projectOperationShouldRenderNestedFieldNamesCorrectly() { + void projectOperationShouldRenderNestedFieldNamesCorrectly() { Document agg = newAggregation(project().and("value1.value").plus("value2.value").as("val")).toDocument("collection", Aggregation.DEFAULT_CONTEXT); @@ -548,7 +548,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-1871 - public void providedAliasShouldAllowNestingExpressionWithAliasCorrectly() { + void providedAliasShouldAllowNestingExpressionWithAliasCorrectly() { Document condition = new Document("$and", Arrays.asList(new Document("$gte", Arrays.asList("$$est.dt", "2015-12-29")), // @@ -565,7 +565,7 @@ public class AggregationUnitTests { } @Test // DATAMONGO-2377 - public void shouldAllowInternalThisAndValueReferences() { + void shouldAllowInternalThisAndValueReferences() { Document untyped = newAggregation( // Arrays.asList( // diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/CondExpressionUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/CondExpressionUnitTests.java index 740560e3f..9b47ae65a 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/CondExpressionUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/CondExpressionUnitTests.java @@ -34,28 +34,28 @@ import org.springframework.data.mongodb.core.query.Criteria; public class CondExpressionUnitTests { @Test // DATAMONGO-861 - public void builderRejectsEmptyFieldName() { + void builderRejectsEmptyFieldName() { assertThatIllegalArgumentException().isThrownBy(() -> newBuilder().when("")); } @Test // DATAMONGO-861 - public void builderRejectsNullFieldName() { + void builderRejectsNullFieldName() { assertThatIllegalArgumentException().isThrownBy(() -> newBuilder().when((Document) null)); } @Test // DATAMONGO-861 - public void builderRejectsNullCriteriaName() { + void builderRejectsNullCriteriaName() { assertThatIllegalArgumentException().isThrownBy(() -> newBuilder().when((Criteria) null)); } @Test // DATAMONGO-861 - public void builderRejectsBuilderAsThenValue() { + void builderRejectsBuilderAsThenValue() { assertThatIllegalArgumentException().isThrownBy( () -> newBuilder().when("isYellow").then(newBuilder().when("field").then("then-value")).otherwise("otherwise")); } @Test // DATAMONGO-861, DATAMONGO-1542, DATAMONGO-2242 - public void simpleBuilderShouldRenderCorrectly() { + void simpleBuilderShouldRenderCorrectly() { Cond operator = ConditionalOperators.when("isYellow").thenValueOf("bright").otherwise("dark"); Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); @@ -69,7 +69,7 @@ public class CondExpressionUnitTests { } @Test // DATAMONGO-861, DATAMONGO-1542, DATAMONGO-2242 - public void simpleCriteriaShouldRenderCorrectly() { + void simpleCriteriaShouldRenderCorrectly() { Cond operator = ConditionalOperators.when(Criteria.where("luminosity").gte(100)).thenValueOf("bright") .otherwise("dark"); @@ -84,7 +84,7 @@ public class CondExpressionUnitTests { } @Test // DATAMONGO-861, DATAMONGO-2242 - public void andCriteriaShouldRenderCorrectly() { + void andCriteriaShouldRenderCorrectly() { Cond operator = ConditionalOperators.when(Criteria.where("luminosity").gte(100) // .andOperator(Criteria.where("hue").is(50), // @@ -106,7 +106,7 @@ public class CondExpressionUnitTests { } @Test // DATAMONGO-861, DATAMONGO-1542, DATAMONGO-2242 - public void twoArgsCriteriaShouldRenderCorrectly() { + void twoArgsCriteriaShouldRenderCorrectly() { Criteria criteria = Criteria.where("luminosity").gte(100) // .and("saturation").and("chroma").is(200); @@ -126,7 +126,7 @@ public class CondExpressionUnitTests { } @Test // DATAMONGO-861, DATAMONGO-1542 - public void nestedCriteriaShouldRenderCorrectly() { + void nestedCriteriaShouldRenderCorrectly() { Cond operator = ConditionalOperators.when(Criteria.where("luminosity").gte(100)) // .thenValueOf(newBuilder() //