From b007b120f06db0fa36b27e18104a53bea9db59be Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Tue, 2 May 2023 10:13:25 -0500 Subject: [PATCH] Disable problematic test cases on newer JREs on CI. Certain parts of Mockito operate differently between Java 8 and later versions of Java. To minimize interference, disable a couple test cases that aren't required to verify interoperability with later versions of Java. Related: #2934. --- ...eryByExamplePredicateBuilderUnitTests.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilderUnitTests.java b/src/test/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilderUnitTests.java index 627031cd0..c945464e5 100644 --- a/src/test/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilderUnitTests.java +++ b/src/test/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilderUnitTests.java @@ -39,13 +39,14 @@ import javax.persistence.metamodel.Type; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnJre; +import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; - import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatcher; @@ -90,19 +91,16 @@ class QueryByExamplePredicateBuilderUnitTests { void setUp() { personIdAttribute = new SingularAttributeStub<>("id", PersistentAttributeType.BASIC, Long.class); - personFirstnameAttribute = new SingularAttributeStub<>("firstname", PersistentAttributeType.BASIC, - String.class); + personFirstnameAttribute = new SingularAttributeStub<>("firstname", PersistentAttributeType.BASIC, String.class); personAgeAttribute = new SingularAttributeStub<>("age", PersistentAttributeType.BASIC, Long.class); - personFatherAttribute = new SingularAttributeStub<>("father", PersistentAttributeType.MANY_TO_ONE, - Person.class, personEntityType); - personSkillAttribute = new SingularAttributeStub<>("skill", PersistentAttributeType.EMBEDDED, - Skill.class, skillEntityType); - personAddressAttribute = new SingularAttributeStub<>("address", PersistentAttributeType.EMBEDDED, - Address.class); - skillNameAttribute = new SingularAttributeStub<>("name", PersistentAttributeType.BASIC, - String.class); - skillNestedAttribute = new SingularAttributeStub<>("nested", PersistentAttributeType.MANY_TO_ONE, - Skill.class, skillEntityType); + personFatherAttribute = new SingularAttributeStub<>("father", PersistentAttributeType.MANY_TO_ONE, Person.class, + personEntityType); + personSkillAttribute = new SingularAttributeStub<>("skill", PersistentAttributeType.EMBEDDED, Skill.class, + skillEntityType); + personAddressAttribute = new SingularAttributeStub<>("address", PersistentAttributeType.EMBEDDED, Address.class); + skillNameAttribute = new SingularAttributeStub<>("name", PersistentAttributeType.BASIC, String.class); + skillNestedAttribute = new SingularAttributeStub<>("nested", PersistentAttributeType.MANY_TO_ONE, Skill.class, + skillEntityType); personEntityAttribtues = new LinkedHashSet<>(); personEntityAttribtues.add(personIdAttribute); @@ -169,6 +167,7 @@ class QueryByExamplePredicateBuilderUnitTests { verify(cb, times(1)).equal(any(Expression.class), eq("foo")); } + @DisabledOnJre({ JRE.JAVA_11, JRE.JAVA_17 }) @Test // DATAJPA-218 void multiPredicateCriteriaShouldReturnCombinedOnes() { @@ -183,6 +182,7 @@ class QueryByExamplePredicateBuilderUnitTests { verify(cb, times(1)).equal(any(Expression.class), eq(2L)); } + @DisabledOnJre({ JRE.JAVA_11, JRE.JAVA_17 }) @Test // DATAJPA-879 void orConcatenatesPredicatesIfMatcherSpecifies() { @@ -306,13 +306,13 @@ class QueryByExamplePredicateBuilderUnitTests { private Class javaType; private Type type; - SingularAttributeStub(String name, - javax.persistence.metamodel.Attribute.PersistentAttributeType attributeType, Class javaType) { + SingularAttributeStub(String name, javax.persistence.metamodel.Attribute.PersistentAttributeType attributeType, + Class javaType) { this(name, attributeType, javaType, null); } - SingularAttributeStub(String name, - javax.persistence.metamodel.Attribute.PersistentAttributeType attributeType, Class javaType, Type type) { + SingularAttributeStub(String name, javax.persistence.metamodel.Attribute.PersistentAttributeType attributeType, + Class javaType, Type type) { this.name = name; this.attributeType = attributeType; this.javaType = javaType;