Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions dozer-tutorial/src/test/java/com/baeldung/dozer/DozerTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,9 +16,8 @@
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();
Expand Down Expand Up @@ -183,7 +186,8 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvert_thenC
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
Expand All @@ -194,7 +198,7 @@ public void givenSrcAndDestWithDifferentFieldTypes_whenAbleToCustomConvertBidire
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');
}

}