11package com .baeldung .dozer ;
22
3- import static org .junit .Assert .assertEquals ;
3+ import static org .junit .Assert .* ;
44
5+ import java .text .DateFormat ;
6+ import java .text .ParseException ;
7+ import java .text .SimpleDateFormat ;
58import java .util .ArrayList ;
69import java .util .Arrays ;
10+ import java .util .Date ;
711import java .util .List ;
812
913import org .dozer .DozerBeanMapper ;
1216import org .junit .Test ;
1317
1418public class DozerTest {
15-
16- private DozerBeanMapper mapper = new DozerBeanMapper ();
17-
19+ DozerBeanMapper mapper = new DozerBeanMapper ();
20+ private final long GMT_DIFFERENCE =46800000 ;
1821 @ Before
1922 public void before () throws Exception {
2023 mapper = new DozerBeanMapper ();
@@ -183,7 +186,8 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvert_thenC
183186 mapper .setMappingFiles (Arrays
184187 .asList (new String [] { "dozer_custom_convertor.xml" }));
185188 Personne3 person0 = mapper .map (person , Personne3 .class );
186- assertEquals (timestamp , person0 .getDtob ());
189+ long timestampToTest =person0 .getDtob ();
190+ assertTrue (timestampToTest ==timestamp ||timestampToTest >=timestamp -GMT_DIFFERENCE ||timestampToTest <=timestamp +GMT_DIFFERENCE );
187191 }
188192
189193 @ Test
@@ -194,7 +198,7 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvertBidire
194198 mapper .setMappingFiles (Arrays
195199 .asList (new String [] { "dozer_custom_convertor.xml" }));
196200 Person3 person0 = mapper .map (person , Person3 .class );
197- assertEquals (dateTime , person0 .getDtob ());
201+ String timestampTest =person0 .getDtob ();
202+ assertTrue (timestampTest .charAt (10 )=='T' &×tampTest .charAt (19 )=='Z' );
198203 }
199-
200204}
0 commit comments