2016-09-02 00:00:43 +01:00
|
|
|
package com.baeldung.mapper;
|
2016-08-12 18:44:08 +08:00
|
|
|
|
2016-08-19 10:25:27 +08:00
|
|
|
import static org.junit.Assert.assertEquals;
|
2016-08-12 18:44:08 +08:00
|
|
|
|
2016-09-02 00:00:43 +01:00
|
|
|
import com.baeldung.dto.SimpleSource;
|
|
|
|
|
import com.baeldung.entity.SimpleDestination;
|
2016-08-12 18:44:08 +08:00
|
|
|
import org.junit.Test;
|
2016-08-19 10:25:27 +08:00
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
2016-08-12 18:44:08 +08:00
|
|
|
|
2016-08-19 10:25:27 +08:00
|
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
|
|
@ContextConfiguration("classpath:applicationContext.xml")
|
2016-08-12 18:44:08 +08:00
|
|
|
public class SimpleSourceDestinationMapperTest {
|
|
|
|
|
|
2016-08-19 10:25:27 +08:00
|
|
|
@Autowired
|
|
|
|
|
SimpleSourceDestinationMapper simpleSourceDestinationMapper;
|
2016-08-19 10:28:02 +08:00
|
|
|
|
2016-08-17 18:02:45 +08:00
|
|
|
@Test
|
|
|
|
|
public void givenSimpleSourceToSimpleDestination_whenMaps_thenCorrect() {
|
|
|
|
|
SimpleSource simpleSource = new SimpleSource();
|
|
|
|
|
simpleSource.setName("SourceName");
|
|
|
|
|
simpleSource.setDescription("SourceDescription");
|
|
|
|
|
|
|
|
|
|
SimpleDestination destination = simpleSourceDestinationMapper.sourceToDestination(simpleSource);
|
|
|
|
|
|
|
|
|
|
assertEquals(simpleSource.getName(), destination.getName());
|
|
|
|
|
assertEquals(simpleSource.getDescription(), destination.getDescription());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void givenSimpleDestinationToSourceDestination_whenMaps_thenCorrect() {
|
|
|
|
|
SimpleDestination destination = new SimpleDestination();
|
|
|
|
|
destination.setName("DestinationName");
|
|
|
|
|
destination.setDescription("DestinationDescription");
|
|
|
|
|
|
|
|
|
|
SimpleSource source = simpleSourceDestinationMapper.destinationToSource(destination);
|
|
|
|
|
|
|
|
|
|
assertEquals(destination.getName(), source.getName());
|
|
|
|
|
assertEquals(destination.getDescription(), source.getDescription());
|
|
|
|
|
}
|
2016-08-12 18:44:08 +08:00
|
|
|
|
|
|
|
|
}
|