Search in sources :

Example 16 with SimpleTypeHolder

use of org.springframework.data.mapping.model.SimpleTypeHolder in project spring-data-commons by spring-projects.

the class SimpleTypeHolderUnitTests method addsDefaultTypes.

@Test
public void addsDefaultTypes() {
    SimpleTypeHolder holder = SimpleTypeHolder.DEFAULT;
    assertThat(holder.isSimpleType(String.class)).isTrue();
}
Also used : SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) Test(org.junit.jupiter.api.Test)

Example 17 with SimpleTypeHolder

use of org.springframework.data.mapping.model.SimpleTypeHolder in project spring-data-commons by spring-projects.

the class SimpleTypeHolderUnitTests method addsCustomTypesToSimpleOnes.

@Test
public void addsCustomTypesToSimpleOnes() {
    SimpleTypeHolder holder = new SimpleTypeHolder(Collections.singleton(SimpleTypeHolder.class), true);
    assertThat(holder.isSimpleType(SimpleTypeHolder.class)).isTrue();
    assertThat(holder.isSimpleType(SimpleTypeHolderUnitTests.class)).isFalse();
}
Also used : SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) Test(org.junit.jupiter.api.Test)

Example 18 with SimpleTypeHolder

use of org.springframework.data.mapping.model.SimpleTypeHolder in project spring-data-commons by spring-projects.

the class CustomConversionsUnitTests method registersConverterFactoryCorrectly.

// DATAMONGO-1302, DATACMNS-1035
@Test
void registersConverterFactoryCorrectly() {
    StoreConversions conversions = StoreConversions.of(new SimpleTypeHolder(Collections.singleton(Format.class), true));
    CustomConversions customConversions = new CustomConversions(conversions, Collections.singletonList(new FormatConverterFactory()));
    assertThat(customConversions.getCustomWriteTarget(String.class, SimpleDateFormat.class)).isPresent();
}
Also used : StoreConversions(org.springframework.data.convert.CustomConversions.StoreConversions) SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) Test(org.junit.jupiter.api.Test)

Example 19 with SimpleTypeHolder

use of org.springframework.data.mapping.model.SimpleTypeHolder in project spring-data-commons by spring-projects.

the class AbstractMappingContextUnitTests method detectsEntityTypeEvenIfSimpleTypeHolderConsidersCollectionsSimple.

// GH-2390
@Test
void detectsEntityTypeEvenIfSimpleTypeHolderConsidersCollectionsSimple() {
    context.setSimpleTypeHolder(new SimpleTypeHolder(Collections.emptySet(), true) {

        @Override
        public boolean isSimpleType(Class<?> type) {
            return type == String.class || type.getName().startsWith("java.util.");
        }
    });
    context.getPersistentEntity(WithNestedLists.class);
    // 
    assertThat(context.getPersistentEntities()).map(// 
    it -> (Class) it.getType()).contains(Base.class);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) ShadowingPropertyTypeWithCtor(org.springframework.data.mapping.ShadowingPropertyTypeWithCtor) ArgumentMatchers(org.mockito.ArgumentMatchers) Advised(org.springframework.aop.framework.Advised) RequiredArgsConstructor(lombok.RequiredArgsConstructor) LocalDateTime(java.time.LocalDateTime) TypeInformation(org.springframework.data.util.TypeInformation) BasicPersistentEntity(org.springframework.data.mapping.model.BasicPersistentEntity) Supplier(java.util.function.Supplier) Value(lombok.Value) ArrayList(java.util.ArrayList) PropertyHandler(org.springframework.data.mapping.PropertyHandler) ClassTypeInformation(org.springframework.data.util.ClassTypeInformation) AccessLevel(lombok.AccessLevel) MappingException(org.springframework.data.mapping.MappingException) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) StreamUtils(org.springframework.data.util.StreamUtils) MetaClass(groovy.lang.MetaClass) SpringProxy(org.springframework.aop.SpringProxy) SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) Iterator(java.util.Iterator) Collection(java.util.Collection) EqualsAndHashCode(lombok.EqualsAndHashCode) ShadowedPropertyType(org.springframework.data.mapping.ShadowedPropertyType) ApplicationContext(org.springframework.context.ApplicationContext) PersistentEntity(org.springframework.data.mapping.PersistentEntity) Test(org.junit.jupiter.api.Test) ApplicationEvent(org.springframework.context.ApplicationEvent) Mockito(org.mockito.Mockito) List(java.util.List) TreeMap(java.util.TreeMap) Optional(java.util.Optional) Id(org.springframework.data.annotation.Id) Collections(java.util.Collections) ShadowingPropertyType(org.springframework.data.mapping.ShadowingPropertyType) ShadowedPropertyTypeWithCtor(org.springframework.data.mapping.ShadowedPropertyTypeWithCtor) SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) MetaClass(groovy.lang.MetaClass) Test(org.junit.jupiter.api.Test)

Example 20 with SimpleTypeHolder

use of org.springframework.data.mapping.model.SimpleTypeHolder in project spring-data-commons by spring-projects.

the class AbstractMappingContextUnitTests method setUp.

@BeforeEach
void setUp() {
    context = new SampleMappingContext();
    context.setSimpleTypeHolder(new SimpleTypeHolder(Collections.singleton(LocalDateTime.class), true));
}
Also used : SimpleTypeHolder(org.springframework.data.mapping.model.SimpleTypeHolder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SimpleTypeHolder (org.springframework.data.mapping.model.SimpleTypeHolder)21 Test (org.junit.jupiter.api.Test)19 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MetaClass (groovy.lang.MetaClass)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 TreeMap (java.util.TreeMap)1 Supplier (java.util.function.Supplier)1 AccessLevel (lombok.AccessLevel)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Value (lombok.Value)1 Assertions (org.assertj.core.api.Assertions)1