minor cleanup work

This commit is contained in:
eugenp 2016-12-12 15:16:08 +02:00
parent 0f8a022379
commit 69cd5e0b4d
8 changed files with 364 additions and 384 deletions

View File

@ -1,320 +1,335 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>jee7schedule</artifactId> <artifactId>jee7schedule</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<description>JavaEE 7 Arquillian Archetype Sample</description> <description>JavaEE 7 Arquillian Archetype Sample</description>
<packaging>war</packaging> <packaging>war</packaging>
<properties> <properties>
<java.min.version>1.7</java.min.version> <java.min.version>1.7</java.min.version>
<maven.min.version>3.0.0</maven.min.version> <maven.min.version>3.0.0</maven.min.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<javaee_api.version>7.0</javaee_api.version> <javaee_api.version>7.0</javaee_api.version>
<arquillian_core.version>1.1.11.Final</arquillian_core.version> <arquillian_core.version>1.1.11.Final</arquillian_core.version>
<wildfly.version>8.2.1.Final</wildfly.version> <wildfly.version>8.2.1.Final</wildfly.version>
<awaitility.version>1.7.0</awaitility.version> <awaitility.version>1.7.0</awaitility.version>
<undertow-websockets-jsr.version>1.4.6.Final</undertow-websockets-jsr.version> <undertow-websockets-jsr.version>1.4.6.Final</undertow-websockets-jsr.version>
<resteasy.version>3.0.19.Final</resteasy.version> <resteasy.version>3.0.19.Final</resteasy.version>
<glassfish-embedded-all.version>4.1.1</glassfish-embedded-all.version> <glassfish-embedded-all.version>4.1.1</glassfish-embedded-all.version>
<javax.json.version>1.0.4</javax.json.version> <javax.json.version>1.0.4</javax.json.version>
<tyrus.version>1.13</tyrus.version> <tyrus.version>1.13</tyrus.version>
<jersey.version>2.25</jersey.version> <jersey.version>2.25</jersey.version>
<arquillian-glassfish.version>1.0.0.Final</arquillian-glassfish.version> <arquillian-glassfish.version>1.0.0.Final</arquillian-glassfish.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
</properties>
<prerequisites> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven>${maven.min.version}</maven> <maven-war-plugin.version>2.6</maven-war-plugin.version>
</prerequisites> </properties>
<dependencyManagement> <prerequisites>
<dependencies> <maven>${maven.min.version}</maven>
<dependency> </prerequisites>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian_core.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencyManagement>
<dependency> <dependencies>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee_api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.min.version}</source>
<target>${java.min.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>wildfly-managed-arquillian</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<serverProfile>standalone-full.xml</serverProfile>
<serverRoot>${project.build.directory}/wildfly-${version.wildfly}</serverRoot>
</properties>
<dependencies>
<dependency> <dependency>
<groupId>io.undertow</groupId> <groupId>org.jboss.arquillian</groupId>
<artifactId>undertow-websockets-jsr</artifactId> <artifactId>arquillian-bom</artifactId>
<version>${undertow-websockets-jsr.version}</version> <version>${arquillian_core.version}</version>
<scope>test</scope> <scope>import</scope>
<type>pom</type>
</dependency> </dependency>
<dependency> </dependencies>
<groupId>org.jboss.resteasy</groupId> </dependencyManagement>
<artifactId>resteasy-client</artifactId>
<version>${resteasy.version}</version> <dependencies>
<scope>test</scope> <dependency>
</dependency> <groupId>javax</groupId>
<dependency> <artifactId>javaee-api</artifactId>
<groupId>org.jboss.resteasy</groupId> <version>${javaee_api.version}</version>
<artifactId>resteasy-jaxb-provider</artifactId> <scope>provided</scope>
<version>${resteasy.version}</version> </dependency>
<scope>test</scope>
</dependency> <dependency>
<dependency> <groupId>junit</groupId>
<groupId>org.jboss.resteasy</groupId> <artifactId>junit</artifactId>
<artifactId>resteasy-json-p-provider</artifactId> <version>${junit.version}</version>
<version>${resteasy.version}</version> <scope>test</scope>
<scope>test</scope> </dependency>
</dependency> <dependency>
<dependency> <groupId>org.jboss.arquillian.junit</groupId>
<groupId>org.wildfly</groupId> <artifactId>arquillian-junit-container</artifactId>
<artifactId>wildfly-arquillian-container-managed</artifactId> <scope>test</scope>
<version>${wildfly.version}</version> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>com.jayway.awaitility</groupId>
</dependencies> <artifactId>awaitility</artifactId>
<build> <version>${awaitility.version}</version>
<plugins> <scope>test</scope>
<plugin> </dependency>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version> <dependency>
<configuration> <groupId>org.jboss.shrinkwrap.resolver</groupId>
<skip>${maven.test.skip}</skip> <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
</configuration> <scope>test</scope>
<executions> <type>jar</type>
<execution> </dependency>
<id>unpack</id>
<phase>process-test-classes</phase> <dependency>
<goals> <groupId>org.jboss.shrinkwrap.resolver</groupId>
<goal>unpack</goal> <artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
</goals> <scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.min.version}</source>
<target>${java.min.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*LongRunningUnitTest.java</exclude>
<exclude>**/*ManualTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>wildfly-managed-arquillian</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<serverProfile>standalone-full.xml</serverProfile>
<serverRoot>${project.build.directory}/wildfly-${version.wildfly}</serverRoot>
</properties>
<dependencies>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
<version>${undertow-websockets-jsr.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${resteasy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>${resteasy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-p-provider</artifactId>
<version>${resteasy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${wildfly.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<configuration> <configuration>
<artifactItems> <skip>${maven.test.skip}</skip>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${wildfly.version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration> </configuration>
</execution> <executions>
</executions> <execution>
</plugin> <id>unpack</id>
<plugin> <phase>process-test-classes</phase>
<artifactId>maven-surefire-plugin</artifactId> <goals>
<version>2.17</version> <goal>unpack</goal>
<configuration> </goals>
<environmentVariables> <configuration>
<JBOSS_HOME>${project.build.directory}/wildfly-${wildfly.version}</JBOSS_HOME> <artifactItems>
</environmentVariables> <artifactItem>
</configuration> <groupId>org.wildfly</groupId>
</plugin> <artifactId>wildfly-dist</artifactId>
</plugins> <version>${wildfly.version}</version>
</build> <type>zip</type>
</profile> <overWrite>false</overWrite>
<profile> <outputDirectory>${project.build.directory}</outputDirectory>
<id>wildfly-remote-arquillian</id> </artifactItem>
<dependencies> </artifactItems>
<dependency> </configuration>
<groupId>io.undertow</groupId> </execution>
<artifactId>undertow-websockets-jsr</artifactId> </executions>
<version>${undertow-websockets-jsr.version}</version> </plugin>
<scope>test</scope> <plugin>
</dependency> <artifactId>maven-surefire-plugin</artifactId>
<dependency> <version>2.17</version>
<groupId>org.jboss.resteasy</groupId> <configuration>
<artifactId>resteasy-client</artifactId> <environmentVariables>
<version>${resteasy.version}</version> <JBOSS_HOME>${project.build.directory}/wildfly-${wildfly.version}</JBOSS_HOME>
<scope>test</scope> </environmentVariables>
</dependency> </configuration>
<dependency> </plugin>
<groupId>org.jboss.resteasy</groupId> </plugins>
<artifactId>resteasy-jaxb-provider</artifactId> </build>
<version>${resteasy.version}</version> </profile>
<scope>test</scope> <profile>
</dependency> <id>wildfly-remote-arquillian</id>
<dependency> <dependencies>
<groupId>org.jboss.resteasy</groupId> <dependency>
<artifactId>resteasy-json-p-provider</artifactId> <groupId>io.undertow</groupId>
<version>${resteasy.version}</version> <artifactId>undertow-websockets-jsr</artifactId>
<scope>test</scope> <version>${undertow-websockets-jsr.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.wildfly</groupId> <dependency>
<artifactId>wildfly-arquillian-container-remote</artifactId> <groupId>org.jboss.resteasy</groupId>
<version>${wildfly.version}</version> <artifactId>resteasy-client</artifactId>
<scope>test</scope> <version>${resteasy.version}</version>
</dependency> <scope>test</scope>
</dependencies> </dependency>
</profile> <dependency>
<profile> <groupId>org.jboss.resteasy</groupId>
<id>glassfish-embedded-arquillian</id> <artifactId>resteasy-jaxb-provider</artifactId>
<dependencies> <version>${resteasy.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish.main.extras</groupId> </dependency>
<artifactId>glassfish-embedded-all</artifactId> <dependency>
<version>${glassfish-embedded-all.version}</version> <groupId>org.jboss.resteasy</groupId>
<scope>test</scope> <artifactId>resteasy-json-p-provider</artifactId>
</dependency> <version>${resteasy.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish</groupId> </dependency>
<artifactId>javax.json</artifactId> <dependency>
<version>${javax.json.version}</version> <groupId>org.wildfly</groupId>
<scope>test</scope> <artifactId>wildfly-arquillian-container-remote</artifactId>
</dependency> <version>${wildfly.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish.tyrus</groupId> </dependency>
<artifactId>tyrus-client</artifactId> </dependencies>
<version>${tyrus.version}</version> </profile>
<scope>test</scope> <profile>
</dependency> <id>glassfish-embedded-arquillian</id>
<dependency> <dependencies>
<groupId>org.glassfish.tyrus</groupId> <dependency>
<artifactId>tyrus-container-grizzly-client</artifactId> <groupId>org.glassfish.main.extras</groupId>
<version>${tyrus.version}</version> <artifactId>glassfish-embedded-all</artifactId>
<scope>test</scope> <version>${glassfish-embedded-all.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.glassfish.jersey.core</groupId> <dependency>
<artifactId>jersey-client</artifactId> <groupId>org.glassfish</groupId>
<version>${jersey.version}</version> <artifactId>javax.json</artifactId>
<scope>test</scope> <version>${javax.json.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.jboss.arquillian.container</groupId> <dependency>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId> <groupId>org.glassfish.tyrus</groupId>
<version>${arquillian-glassfish.version}</version> <artifactId>tyrus-client</artifactId>
<scope>test</scope> <version>${tyrus.version}</version>
</dependency> <scope>test</scope>
</dependencies> </dependency>
</profile> <dependency>
<profile> <groupId>org.glassfish.tyrus</groupId>
<id>glassfish-remote-arquillian</id> <artifactId>tyrus-container-grizzly-client</artifactId>
<dependencies> <version>${tyrus.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish</groupId> </dependency>
<artifactId>javax.json</artifactId> <dependency>
<version>${javax.json.version}</version> <groupId>org.glassfish.jersey.core</groupId>
<scope>test</scope> <artifactId>jersey-client</artifactId>
</dependency> <version>${jersey.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish.tyrus</groupId> </dependency>
<artifactId>tyrus-client</artifactId> <dependency>
<version>${tyrus.version}</version> <groupId>org.jboss.arquillian.container</groupId>
<scope>test</scope> <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
</dependency> <version>${arquillian-glassfish.version}</version>
<dependency> <scope>test</scope>
<groupId>org.glassfish.tyrus</groupId> </dependency>
<artifactId>tyrus-container-grizzly-client</artifactId> </dependencies>
<version>${tyrus.version}</version> </profile>
<scope>test</scope> <profile>
</dependency> <id>glassfish-remote-arquillian</id>
<dependency> <dependencies>
<groupId>org.glassfish.jersey.core</groupId> <dependency>
<artifactId>jersey-client</artifactId> <groupId>org.glassfish</groupId>
<version>${jersey.version}</version> <artifactId>javax.json</artifactId>
<scope>test</scope> <version>${javax.json.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.glassfish.jersey.media</groupId> <dependency>
<artifactId>jersey-media-json-jackson</artifactId> <groupId>org.glassfish.tyrus</groupId>
<version>${jersey.version}</version> <artifactId>tyrus-client</artifactId>
<scope>test</scope> <version>${tyrus.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.glassfish.jersey.media</groupId> <dependency>
<artifactId>jersey-media-json-processing</artifactId> <groupId>org.glassfish.tyrus</groupId>
<version>${jersey.version}</version> <artifactId>tyrus-container-grizzly-client</artifactId>
<scope>test</scope> <version>${tyrus.version}</version>
</dependency> <scope>test</scope>
<dependency> </dependency>
<groupId>org.jboss.arquillian.container</groupId> <dependency>
<artifactId>arquillian-glassfish-remote-3.1</artifactId> <groupId>org.glassfish.jersey.core</groupId>
<version>${arquillian-glassfish.version}</version> <artifactId>jersey-client</artifactId>
<scope>test</scope> <version>${jersey.version}</version>
</dependency> <scope>test</scope>
</dependencies> </dependency>
</profile> <dependency>
</profiles> <groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-processing</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-remote-3.1</artifactId>
<version>${arquillian-glassfish.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project> </project>

View File

@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class AutomaticTimerBeanTest { public class AutomaticTimerBeanIntegrationTest {
//the @AutomaticTimerBean has a method called every 10 seconds //the @AutomaticTimerBean has a method called every 10 seconds
//testing the difference ==> 100000 //testing the difference ==> 100000

View File

@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class ProgrammaticAtFixedRateTimerBeanTest { public class ProgrammaticAtFixedRateTimerBeanIntegrationTest {
final static long TIMEOUT = 1000; final static long TIMEOUT = 1000;
final static long TOLERANCE = 500l; final static long TOLERANCE = 500l;

View File

@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class ProgrammaticTimerBeanTest { public class ProgrammaticTimerBeanIntegrationTest {
final static long TIMEOUT = 5000l; final static long TIMEOUT = 5000l;
final static long TOLERANCE = 1000l; final static long TOLERANCE = 1000l;

View File

@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.is;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class ProgrammaticWithFixedDelayTimerBeanTest { public class ProgrammaticWithFixedDelayTimerBeanIntegrationTest {
final static long TIMEOUT = 15000l; final static long TIMEOUT = 15000l;
final static long TOLERANCE = 1000l; final static long TOLERANCE = 1000l;

View File

@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
public class ScheduleTimerBeanTest { public class ScheduleTimerBeanIntegrationTest {
final static long TIMEOUT = 5000l; final static long TIMEOUT = 5000l;
final static long TOLERANCE = 1000l; final static long TOLERANCE = 1000l;

View File

@ -14,7 +14,7 @@
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</properties> </properties>
<name>Orika</name> <name>orika</name>
<dependencies> <dependencies>

View File

@ -4,31 +4,31 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import ma.glasnost.orika.BoundMapperFacade; import ma.glasnost.orika.BoundMapperFacade;
import ma.glasnost.orika.CustomMapper; import ma.glasnost.orika.CustomMapper;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory; import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.impl.DefaultMapperFactory; import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.junit.Before;
import org.junit.Test;
public class OrikaTest { public class OrikaTest {
MapperFactory mapperFactory; MapperFactory mapperFactory;
CustomMapper<Personne3, Person3> customMapper; CustomMapper<Personne3, Person3> customMapper;
// constant to help us cover time zone differences // constant to help us cover time zone differences
private final long GMT_DIFFERENCE = 46800000; private final long GMT_DIFFERENCE = 46800000;
//
@Before @Before
public void before() { public void before() {
mapperFactory = new DefaultMapperFactory.Builder().build(); mapperFactory = new DefaultMapperFactory.Builder().build();
@ -68,8 +68,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDest_whenMapsUsingBoundMapper_thenCorrect() { public void givenSrcAndDest_whenMapsUsingBoundMapper_thenCorrect() {
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
.getMapperFacade(Source.class, Dest.class);
Source src = new Source("baeldung", 10); Source src = new Source("baeldung", 10);
Dest dest = boundMapper.map(src); Dest dest = boundMapper.map(src);
assertEquals(dest.getAge(), src.getAge()); assertEquals(dest.getAge(), src.getAge());
@ -78,8 +77,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDest_whenMapsUsingBoundMapperInReverse_thenCorrect() { public void givenSrcAndDest_whenMapsUsingBoundMapperInReverse_thenCorrect() {
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
.getMapperFacade(Source.class, Dest.class);
Dest src = new Dest("baeldung", 10); Dest src = new Dest("baeldung", 10);
Source dest = boundMapper.mapReverse(src); Source dest = boundMapper.mapReverse(src);
assertEquals(dest.getAge(), src.getAge()); assertEquals(dest.getAge(), src.getAge());
@ -88,8 +86,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDest_whenMapsUsingBoundMapperByObject_thenCorrect() { public void givenSrcAndDest_whenMapsUsingBoundMapperByObject_thenCorrect() {
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
.getMapperFacade(Source.class, Dest.class);
Source src = new Source("baeldung", 10); Source src = new Source("baeldung", 10);
Dest dest = new Dest(); Dest dest = new Dest();
boundMapper.map(src, dest); boundMapper.map(src, dest);
@ -99,8 +96,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDest_whenMapsUsingBoundMapperByObjectInReverse_thenCorrect() { public void givenSrcAndDest_whenMapsUsingBoundMapperByObjectInReverse_thenCorrect() {
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
.getMapperFacade(Source.class, Dest.class);
Dest src = new Dest("baeldung", 10); Dest src = new Dest("baeldung", 10);
Source dest = new Source(); Source dest = new Source();
boundMapper.mapReverse(src, dest); boundMapper.mapReverse(src, dest);
@ -110,9 +106,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDestWithDifferentFieldNames_whenMaps_thenCorrect() { public void givenSrcAndDestWithDifferentFieldNames_whenMaps_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class) mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").field("age", "age").register();
.field("nom", "name").field("surnom", "nickname")
.field("age", "age").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
@ -127,8 +121,7 @@ public class OrikaTest {
@Test @Test
public void givenBothDifferentAndSameFieldNames_whenFailsToMapSameNameFieldAutomatically_thenCorrect() { public void givenBothDifferentAndSameFieldNames_whenFailsToMapSameNameFieldAutomatically_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class) mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").register();
.field("nom", "name").field("surnom", "nickname").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Personne frenchPerson = new Personne("Claire", "cla", 25); Personne frenchPerson = new Personne("Claire", "cla", 25);
@ -139,9 +132,7 @@ public class OrikaTest {
@Test @Test
public void givenBothDifferentAndSameFieldNames_whenMapsSameNameFieldByDefault_thenCorrect() { public void givenBothDifferentAndSameFieldNames_whenMapsSameNameFieldByDefault_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class) mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").byDefault().register();
.field("nom", "name").field("surnom", "nickname").byDefault()
.register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Personne frenchPerson = new Personne("Claire", "cla", 25); Personne frenchPerson = new Personne("Claire", "cla", 25);
@ -155,9 +146,7 @@ public class OrikaTest {
@Test @Test
public void givenUnidirectionalMappingSetup_whenMapsUnidirectionally_thenCorrect() { public void givenUnidirectionalMappingSetup_whenMapsUnidirectionally_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class) mapperFactory.classMap(Personne.class, Person.class).fieldAToB("nom", "name").fieldAToB("surnom", "nickname").fieldAToB("age", "age").register();
.fieldAToB("nom", "name").fieldAToB("surnom", "nickname")
.fieldAToB("age", "age").register();
; ;
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Personne frenchPerson = new Personne("Claire", "cla", 25); Personne frenchPerson = new Personne("Claire", "cla", 25);
@ -169,11 +158,9 @@ public class OrikaTest {
} }
@Test @Test
public void givenSrcAndDest_whenCanExcludeField_thenCorrect() { public void givenSrcAndDest_whenCanExcludeField_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class).exclude("nom") mapperFactory.classMap(Personne.class, Person.class).exclude("nom").field("surnom", "nickname").field("age", "age").register();
.field("surnom", "nickname").field("age", "age").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Personne frenchPerson = new Personne("Claire", "cla", 25); Personne frenchPerson = new Personne("Claire", "cla", 25);
@ -186,9 +173,7 @@ public class OrikaTest {
@Test @Test
public void givenSpecificConstructorToUse_whenMaps_thenCorrect() { public void givenSpecificConstructorToUse_whenMaps_thenCorrect() {
mapperFactory.classMap(Personne.class, Person.class).constructorB() mapperFactory.classMap(Personne.class, Person.class).constructorB().field("nom", "name").field("surnom", "nickname").field("age", "age").register();
.field("nom", "name").field("surnom", "nickname")
.field("age", "age").register();
; ;
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Personne frenchPerson = new Personne("Claire", "cla", 25); Personne frenchPerson = new Personne("Claire", "cla", 25);
@ -202,12 +187,9 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithListAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() { public void givenSrcWithListAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
mapperFactory.classMap(PersonNameList.class, PersonNameParts.class) mapperFactory.classMap(PersonNameList.class, PersonNameParts.class).field("nameList[0]", "firstName").field("nameList[1]", "lastName").register();
.field("nameList[0]", "firstName")
.field("nameList[1]", "lastName").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
List<String> nameList = Arrays.asList(new String[]{"Sylvester", List<String> nameList = Arrays.asList(new String[] { "Sylvester", "Stallone" });
"Stallone"});
PersonNameList src = new PersonNameList(nameList); PersonNameList src = new PersonNameList(nameList);
PersonNameParts dest = mapper.map(src, PersonNameParts.class); PersonNameParts dest = mapper.map(src, PersonNameParts.class);
assertEquals(dest.getFirstName(), "Sylvester"); assertEquals(dest.getFirstName(), "Sylvester");
@ -216,11 +198,9 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithArrayAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() { public void givenSrcWithArrayAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
mapperFactory.classMap(PersonNameArray.class, PersonNameParts.class) mapperFactory.classMap(PersonNameArray.class, PersonNameParts.class).field("nameArray[0]", "firstName").field("nameArray[1]", "lastName").register();
.field("nameArray[0]", "firstName")
.field("nameArray[1]", "lastName").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
String[] nameArray = new String[]{"Vin", "Diesel"}; String[] nameArray = new String[] { "Vin", "Diesel" };
PersonNameArray src = new PersonNameArray(nameArray); PersonNameArray src = new PersonNameArray(nameArray);
PersonNameParts dest = mapper.map(src, PersonNameParts.class); PersonNameParts dest = mapper.map(src, PersonNameParts.class);
assertEquals(dest.getFirstName(), "Vin"); assertEquals(dest.getFirstName(), "Vin");
@ -229,9 +209,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithMapAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() { public void givenSrcWithMapAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
mapperFactory.classMap(PersonNameMap.class, PersonNameParts.class) mapperFactory.classMap(PersonNameMap.class, PersonNameParts.class).field("nameMap['first']", "firstName").field("nameMap[\"last\"]", "lastName").register();
.field("nameMap['first']", "firstName")
.field("nameMap[\"last\"]", "lastName").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Map<String, String> nameMap = new HashMap<>(); Map<String, String> nameMap = new HashMap<>();
nameMap.put("first", "Leornado"); nameMap.put("first", "Leornado");
@ -244,9 +222,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithNestedFields_whenMaps_thenCorrect() { public void givenSrcWithNestedFields_whenMaps_thenCorrect() {
mapperFactory.classMap(PersonContainer.class, PersonNameParts.class) mapperFactory.classMap(PersonContainer.class, PersonNameParts.class).field("name.firstName", "firstName").field("name.lastName", "lastName").register();
.field("name.firstName", "firstName")
.field("name.lastName", "lastName").register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
PersonContainer src = new PersonContainer(new Name("Nick", "Canon")); PersonContainer src = new PersonContainer(new Name("Nick", "Canon"));
PersonNameParts dest = mapper.map(src, PersonNameParts.class); PersonNameParts dest = mapper.map(src, PersonNameParts.class);
@ -266,8 +242,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect() { public void givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder() MapperFactory mapperFactory = new DefaultMapperFactory.Builder().mapNulls(false).build();
.mapNulls(false).build();
mapperFactory.classMap(Source.class, Dest.class); mapperFactory.classMap(Source.class, Dest.class);
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Source src = new Source(null, 10); Source src = new Source(null, 10);
@ -279,8 +254,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithNullAndLocalConfigForNoNull_whenFailsToMap_ThenCorrect() { public void givenSrcWithNullAndLocalConfigForNoNull_whenFailsToMap_ThenCorrect() {
mapperFactory.classMap(Source.class, Dest.class).field("age", "age") mapperFactory.classMap(Source.class, Dest.class).field("age", "age").mapNulls(false).field("name", "name").byDefault().register();
.mapNulls(false).field("name", "name").byDefault().register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Source src = new Source(null, 10); Source src = new Source(null, 10);
Dest dest = new Dest("Clinton", 55); Dest dest = new Dest("Clinton", 55);
@ -302,9 +276,7 @@ public class OrikaTest {
@Test @Test
public void givenDestWithNullReverseMappedToSourceAndLocalConfigForNoNull_whenFailsToMap_thenCorrect() { public void givenDestWithNullReverseMappedToSourceAndLocalConfigForNoNull_whenFailsToMap_thenCorrect() {
mapperFactory.classMap(Source.class, Dest.class).field("age", "age") mapperFactory.classMap(Source.class, Dest.class).field("age", "age").mapNullsInReverse(false).field("name", "name").byDefault().register();
.mapNullsInReverse(false).field("name", "name").byDefault()
.register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Dest src = new Dest(null, 10); Dest src = new Dest(null, 10);
Source dest = new Source("Vin", 44); Source dest = new Source("Vin", 44);
@ -315,9 +287,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcWithNullAndFieldLevelConfigForNoNull_whenFailsToMap_ThenCorrect() { public void givenSrcWithNullAndFieldLevelConfigForNoNull_whenFailsToMap_ThenCorrect() {
mapperFactory.classMap(Source.class, Dest.class).field("age", "age") mapperFactory.classMap(Source.class, Dest.class).field("age", "age").fieldMap("name", "name").mapNulls(false).add().byDefault().register();
.fieldMap("name", "name").mapNulls(false).add().byDefault()
.register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
Source src = new Source(null, 10); Source src = new Source(null, 10);
Dest dest = new Dest("Clinton", 55); Dest dest = new Dest("Clinton", 55);
@ -328,8 +298,7 @@ public class OrikaTest {
@Test @Test
public void givenSrcAndDest_whenCustomMapperWorks_thenCorrect() { public void givenSrcAndDest_whenCustomMapperWorks_thenCorrect() {
mapperFactory.classMap(Personne3.class, Person3.class) mapperFactory.classMap(Personne3.class, Person3.class).customize(customMapper).register();
.customize(customMapper).register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
long timestamp = new Long("1182882159000"); long timestamp = new Long("1182882159000");
Personne3 personne3 = new Personne3("Leornardo", timestamp); Personne3 personne3 = new Personne3("Leornardo", timestamp);
@ -339,14 +308,12 @@ public class OrikaTest {
// since different timezones will resolve the timestamp to a different // since different timezones will resolve the timestamp to a different
// datetime string, it suffices to check only for format rather than // datetime string, it suffices to check only for format rather than
// specific date // specific date
assertTrue(timestampTest.charAt(10) == 'T' assertTrue(timestampTest.charAt(10) == 'T' && timestampTest.charAt(19) == 'Z');
&& timestampTest.charAt(19) == 'Z');
} }
@Test @Test
public void givenSrcAndDest_whenCustomMapperWorksBidirectionally_thenCorrect() { public void givenSrcAndDest_whenCustomMapperWorksBidirectionally_thenCorrect() {
mapperFactory.classMap(Personne3.class, Person3.class) mapperFactory.classMap(Personne3.class, Person3.class).customize(customMapper).register();
.customize(customMapper).register();
MapperFacade mapper = mapperFactory.getMapperFacade(); MapperFacade mapper = mapperFactory.getMapperFacade();
String dateTime = "2007-06-26T21:22:39Z"; String dateTime = "2007-06-26T21:22:39Z";
@ -355,12 +322,10 @@ public class OrikaTest {
Personne3 personne3 = mapper.map(person3, Personne3.class); Personne3 personne3 = mapper.map(person3, Personne3.class);
long timestampToTest = personne3.getDtob(); long timestampToTest = personne3.getDtob();
/* /*
* since different timezones will resolve the datetime to a different * since different timezones will resolve the datetime to a different
* unix timestamp, we must provide a range of tolerance * unix timestamp, we must provide a range of tolerance
*/ */
assertTrue(timestampToTest == timestamp assertTrue(timestampToTest == timestamp || timestampToTest >= timestamp - GMT_DIFFERENCE || timestampToTest <= timestamp + GMT_DIFFERENCE);
|| timestampToTest >= timestamp - GMT_DIFFERENCE
|| timestampToTest <= timestamp + GMT_DIFFERENCE);
} }