99import ch .jalu .configme .properties .types .NumberType ;
1010import ch .jalu .configme .properties .types .RegexType ;
1111import ch .jalu .configme .properties .types .StringType ;
12+ import ch .jalu .configme .properties .types .TemporalType ;
1213import ch .jalu .typeresolver .typeimpl .WildcardTypeImpl ;
1314import org .junit .jupiter .api .Test ;
1415import org .junit .jupiter .api .extension .ExtendWith ;
1516import org .mockito .junit .jupiter .MockitoExtension ;
1617
17- import java .time .LocalDate ;
1818import java .util .ArrayList ;
1919import java .util .Arrays ;
2020import java .util .List ;
@@ -59,7 +59,7 @@ void shouldReturnDefaultLeafTypes() {
5959 List <MapperLeafType > leafTypes = LeafValueHandlerImpl .createDefaultLeafTypes ();
6060
6161 // then
62- assertThat (leafTypes , hasSize (12 ));
62+ assertThat (leafTypes , hasSize (15 ));
6363 assertThat (leafTypes .get (0 ), sameInstance (BooleanType .BOOLEAN ));
6464 assertThat (leafTypes .get (1 ), sameInstance (StringType .STRING ));
6565 assertThat (leafTypes .get (2 ), sameInstance (NumberType .INTEGER ));
@@ -72,6 +72,9 @@ void shouldReturnDefaultLeafTypes() {
7272 assertThat (leafTypes .get (9 ), sameInstance (NumberType .BIG_INTEGER ));
7373 assertThat (leafTypes .get (10 ), sameInstance (NumberType .BIG_DECIMAL ));
7474 assertThat (leafTypes .get (11 ), sameInstance (RegexType .REGEX ));
75+ assertThat (leafTypes .get (12 ), sameInstance (TemporalType .LOCAL_DATE ));
76+ assertThat (leafTypes .get (13 ), sameInstance (TemporalType .LOCAL_TIME ));
77+ assertThat (leafTypes .get (14 ), sameInstance (TemporalType .LOCAL_DATE_TIME ));
7578 }
7679
7780 @ Test
@@ -96,7 +99,7 @@ void shouldCreateValueHandlerWithBuilder() {
9699 .addType (leafType1 )
97100 .addDefaults ()
98101 .addType (leafType2 )
99- .removeMatchingTypes (type -> type instanceof NumberType )
102+ .removeMatchingTypes (type -> type instanceof NumberType || type instanceof TemporalType )
100103 .build ();
101104
102105 // then
@@ -166,13 +169,11 @@ void shouldNotConvertForUnsupportedTargetTypes() {
166169 Object object = "2020-02-13" ;
167170
168171 ConvertErrorRecorder errorRecorder = mock (ConvertErrorRecorder .class );
169- MappingContext dateContext = MappingContextImpl .createRoot (of (LocalDate .class ), errorRecorder );
170172 MappingContext wildcardContext = MappingContextImpl .createRoot (of (WildcardTypeImpl .newUnboundedWildcard ()), errorRecorder );
171173
172174 LeafValueHandlerImpl leafValueHandler = new LeafValueHandlerImpl (LeafValueHandlerImpl .createDefaultLeafTypes ());
173175
174176 // when / then
175- assertThat (leafValueHandler .convert (object , dateContext ), nullValue ());
176177 assertThat (leafValueHandler .convert (object , wildcardContext ), nullValue ());
177178 }
178179
@@ -194,7 +195,6 @@ void shouldNotConvertUnsupportedValuesToExportValues() {
194195 ExportContext exportContext = ExportContextImpl .createRoot ();
195196
196197 // when / then
197- assertThat (leafValueHandler .toExportValue (LocalDate .now (), exportContext ), nullValue ());
198198 assertThat (leafValueHandler .toExportValue (new Object (), exportContext ), nullValue ());
199199 }
200200
0 commit comments