To support jdk 16, add converters and module-info. (#1167)
To support jdk 16, add converters and module-info. Closes #1057.
This commit is contained in:
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.couchbase.core.convert.CouchbaseCustomConversions;
|
||||
@@ -67,17 +68,35 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
@Test
|
||||
void doesNotAllowSimpleType1() {
|
||||
assertThrows(MappingException.class, () -> converter.write("hello", new CouchbaseDocument()));
|
||||
try {
|
||||
converter.write("hello", new CouchbaseDocument());
|
||||
} catch(Exception e){
|
||||
if(!(e instanceof MappingException) && !e.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")){
|
||||
throw new RuntimeException("Should have thrown MappingException or InaccessibleObjectException", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotAllowSimpleType2() {
|
||||
assertThrows(MappingException.class, () -> converter.write(true, new CouchbaseDocument()));
|
||||
try {
|
||||
converter.write(true, new CouchbaseDocument());
|
||||
} catch(Exception e){
|
||||
if(!(e instanceof MappingException) && !e.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")){
|
||||
throw new RuntimeException("Should have thrown MappingException or InaccessibleObjectException", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotAllowSimpleType3() {
|
||||
assertThrows(MappingException.class, () -> converter.write(42, new CouchbaseDocument()));
|
||||
try {
|
||||
converter.write(42, new CouchbaseDocument());
|
||||
} catch(Exception e){
|
||||
if(!(e instanceof MappingException) && !e.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")){
|
||||
throw new RuntimeException("Should have thrown MappingException or InaccessibleObjectException", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -421,8 +440,11 @@ public class MappingCouchbaseConverterTests {
|
||||
List<Object> converters = new ArrayList<>();
|
||||
converters.add(BigDecimalToStringConverter.INSTANCE);
|
||||
converters.add(StringToBigDecimalConverter.INSTANCE);
|
||||
converter.setCustomConversions(new CouchbaseCustomConversions(converters));
|
||||
CustomConversions customConversions = new CouchbaseCustomConversions(converters);
|
||||
converter.setCustomConversions(customConversions);
|
||||
converter.afterPropertiesSet();
|
||||
((CouchbaseMappingContext) converter.getMappingContext())
|
||||
.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
|
||||
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
|
||||
@@ -469,8 +491,11 @@ public class MappingCouchbaseConverterTests {
|
||||
List<Object> converters = new ArrayList<>();
|
||||
converters.add(BigDecimalToStringConverter.INSTANCE);
|
||||
converters.add(StringToBigDecimalConverter.INSTANCE);
|
||||
converter.setCustomConversions(new CouchbaseCustomConversions(converters));
|
||||
CustomConversions customConversions = new CouchbaseCustomConversions(converters);
|
||||
converter.setCustomConversions(customConversions);
|
||||
converter.afterPropertiesSet();
|
||||
((CouchbaseMappingContext) converter.getMappingContext())
|
||||
.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
|
||||
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
|
||||
@@ -517,8 +542,11 @@ public class MappingCouchbaseConverterTests {
|
||||
List<Object> converters = new ArrayList<>();
|
||||
converters.add(BigDecimalToStringConverter.INSTANCE);
|
||||
converters.add(StringToBigDecimalConverter.INSTANCE);
|
||||
converter.setCustomConversions(new CouchbaseCustomConversions(converters));
|
||||
CustomConversions customConversions = new CouchbaseCustomConversions(converters);
|
||||
converter.setCustomConversions(customConversions);
|
||||
converter.afterPropertiesSet();
|
||||
((CouchbaseMappingContext) converter.getMappingContext())
|
||||
.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
|
||||
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user