use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.
the class BasicQueryUnitTests method equalsContract.
// DATAMONGO-1093
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "EqualsVerifier uses reflection on Optional")
public void equalsContract() {
BasicQuery query1 = new BasicQuery("{ \"name\" : \"Thomas\"}", "{\"name\":1, \"age\":1}");
query1.setSortObject(new Document("name", -1));
BasicQuery query2 = new BasicQuery("{ \"name\" : \"Oliver\"}", "{\"name\":1, \"address\":1}");
query2.setSortObject(new Document("name", 1));
//
EqualsVerifier.forExamples(query1, query2).withRedefinedSuperclass().suppress(Warning.NONFINAL_FIELDS, Warning.NULL_FIELDS, //
Warning.STRICT_INHERITANCE).verify();
}
use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.
the class DbRefMappingMongoConverterUnitTests method lazyLoadingProxyForLazyDbRefOnConcreteCollection.
// DATAMONGO-348
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void lazyLoadingProxyForLazyDbRefOnConcreteCollection() {
String id = "42";
String value = "bubu";
MappingMongoConverter converterSpy = spy(converter);
doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef(any());
Document document = new Document();
ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs();
lazyDbRefs.dbRefToConcreteCollection = new ArrayList<>(Collections.singletonList(new LazyDbRefTarget(id, value)));
converterSpy.write(lazyDbRefs, document);
ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document);
assertProxyIsResolved(result.dbRefToConcreteCollection, false);
assertThat(result.dbRefToConcreteCollection.get(0).getId()).isEqualTo(id);
assertProxyIsResolved(result.dbRefToConcreteCollection, true);
assertThat(result.dbRefToConcreteCollection.get(0).getValue()).isEqualTo(value);
}
use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.
the class DbRefMappingMongoConverterUnitTests method shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoked.
// DATAMONGO-1076
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoked() throws Exception {
MongoPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(WithObjectMethodOverrideLazyDbRefs.class);
MongoPersistentProperty property = entity.getRequiredPersistentProperty("dbRefToPlainObject");
String idValue = new ObjectId().toString();
DBRef dbRef = converter.toDBRef(new LazyDbRefTargetPropertyAccess(idValue), property);
WithObjectMethodOverrideLazyDbRefs result = converter.read(WithObjectMethodOverrideLazyDbRefs.class, new Document("dbRefToPlainObject", dbRef));
ReflectionTestUtils.invokeMethod(result.dbRefToPlainObject, "finalize");
assertProxyIsResolved(result.dbRefToPlainObject, false);
}
use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.
the class DbRefMappingMongoConverterUnitTests method shouldBulkFetchListOfReferences.
// DATAMONGO-1194
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void shouldBulkFetchListOfReferences() {
String id1 = "1";
String id2 = "2";
String value = "val";
MappingMongoConverter converterSpy = spy(converter);
doReturn(Arrays.asList(new Document("_id", id1).append("value", value), new Document("_id", id2).append("value", value))).when(converterSpy).bulkReadRefs(anyList());
Document document = new Document();
ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs();
lazyDbRefs.dbRefToConcreteCollection = new ArrayList<>(Arrays.asList(new LazyDbRefTarget(id1, value), new LazyDbRefTarget(id2, value)));
converterSpy.write(lazyDbRefs, document);
ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document);
assertProxyIsResolved(result.dbRefToConcreteCollection, false);
assertThat(result.dbRefToConcreteCollection.get(0).getId()).isEqualTo(id1);
assertProxyIsResolved(result.dbRefToConcreteCollection, true);
assertThat(result.dbRefToConcreteCollection.get(1).getId()).isEqualTo(id2);
verify(converterSpy, never()).readRef(Mockito.any(DBRef.class));
}
use of org.junit.jupiter.api.condition.DisabledForJreRange in project logging-log4j2 by apache.
the class AbstractScriptFilterTest method testGroovyFilter.
@Test
@DisabledForJreRange(min = JRE.JAVA_12, disabledReason = "Groovy ScriptEngine incompatibilities")
public void testGroovyFilter(final LoggerContext context, @Named("List") final ListAppender app) throws Exception {
final Logger logger = context.getLogger("TestGroovyFilter");
logger.traceEntry();
logger.info("This should not be logged");
ThreadContext.put("UserId", "JohnDoe");
logger.info("This should be logged");
ThreadContext.clearMap();
try {
final List<String> messages = app.getMessages();
assertNotNull(messages, "No Messages");
assertEquals(messages.size(), 2, "Incorrect number of messages. Expected 2, Actual " + messages.size());
} finally {
app.clear();
}
}
Aggregations