Merge pull request #551 from egimaben/master

fixed failing test
This commit is contained in:
Alex Theedom 2016-07-31 15:50:46 +01:00 committed by GitHub
commit 0c8ba0bb44

View File

@ -1,9 +1,13 @@
package com.baeldung.dozer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.dozer.DozerBeanMapper;
@ -12,9 +16,8 @@ import org.junit.Before;
import org.junit.Test;
public class DozerTest {
private DozerBeanMapper mapper = new DozerBeanMapper();
DozerBeanMapper mapper = new DozerBeanMapper();
private final long GMT_DIFFERENCE=46800000;
@Before
public void before() throws Exception {
mapper = new DozerBeanMapper();
@ -183,7 +186,8 @@ public class DozerTest {
mapper.setMappingFiles(Arrays
.asList(new String[] { "dozer_custom_convertor.xml" }));
Personne3 person0 = mapper.map(person, Personne3.class);
assertEquals(timestamp, person0.getDtob());
long timestampToTest=person0.getDtob();
assertTrue(timestampToTest==timestamp||timestampToTest>=timestamp-GMT_DIFFERENCE||timestampToTest<=timestamp+GMT_DIFFERENCE);
}
@Test
@ -194,7 +198,7 @@ public class DozerTest {
mapper.setMappingFiles(Arrays
.asList(new String[] { "dozer_custom_convertor.xml" }));
Person3 person0 = mapper.map(person, Person3.class);
assertEquals(dateTime, person0.getDtob());
String timestampTest=person0.getDtob();
assertTrue(timestampTest.charAt(10)=='T'&&timestampTest.charAt(19)=='Z');
}
}