Renaming test methods and formatting
This commit is contained in:
parent
43852c4303
commit
d1b282220d
|
@ -20,23 +20,23 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>${modelmapper.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<version>${hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -7,10 +7,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sasam0320
|
||||
* @description
|
||||
* This is a helper class that contains methods for generic mapping of the users list.
|
||||
* Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT.
|
||||
*
|
||||
* @author sasam0320
|
||||
*/
|
||||
public class MapperUtil {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung.modelmapper;
|
||||
|
||||
/**
|
||||
* User model entity class
|
||||
* @author sasam0320
|
||||
* @description User model entity class
|
||||
*/
|
||||
public class User {
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung.modelmapper;
|
||||
|
||||
/**
|
||||
* UserDTO model class
|
||||
* @author sasam0320
|
||||
* @description UserDTO model class
|
||||
*/
|
||||
public class UserDTO {
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.baeldung.modelmapper;
|
|||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* UserList class that contain collection of users
|
||||
* @author sasam0320
|
||||
* @description UserList class that contain collection of users
|
||||
*/
|
||||
public class UserList {
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.baeldung.modelmapper;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserListDTO class that contain list of username properties
|
||||
* @author sasam0320
|
||||
* @description UserListDTO class that contain list of username properties
|
||||
*/
|
||||
public class UserListDTO {
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sasam0320
|
||||
* @description
|
||||
* UserPropertyMap class instantiates the converter to map the data from the user list to the user name list.
|
||||
* In the configuration method, we call a converter to do the mapping.
|
||||
* @author sasam0320
|
||||
*/
|
||||
public class UserPropertyMap extends PropertyMap<UserList, UserListDTO> {
|
||||
|
||||
|
|
|
@ -13,18 +13,17 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* @sasam0320
|
||||
* @description
|
||||
* This class has test methods of mapping Integer to Character list,
|
||||
* mapping user list to DTO list using MapperUtil generic methods and Converter
|
||||
*
|
||||
* @author sasam0320
|
||||
*/
|
||||
public class UserMappingTest {
|
||||
public class UsersListMappingUnitTest {
|
||||
|
||||
private ModelMapper mapper;
|
||||
private List<User> users;
|
||||
|
@ -42,7 +41,7 @@ public class UserMappingTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMapIntegerList() {
|
||||
public void whenMapIntegerToCharList() {
|
||||
|
||||
List<Integer> integers = new ArrayList<Integer>();
|
||||
|
||||
|
@ -53,12 +52,12 @@ public class UserMappingTest {
|
|||
List<Character> characters = mapper.map(integers, new TypeToken<List<Character>>() {
|
||||
}.getType());
|
||||
|
||||
assertThat(characters, hasItems('1','2','3'));
|
||||
assertThat(characters, hasItems('1', '2', '3'));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapGenericTypeLists() {
|
||||
public void givenUsersList_whenUseGenericType_thenMapToDto() {
|
||||
|
||||
// Mapping lists using generic type methods
|
||||
|
|
@ -1,8 +1,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">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
@ -45,9 +45,9 @@
|
|||
<guava.version>23.0</guava.version>
|
||||
<commons.io.version>2.6</commons.io.version>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
<modelmapper.version>2.3.6</modelmapper.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<hamcrest.version>1.3</hamcrest.version>
|
||||
<modelmapper.version>2.3.6</modelmapper.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<hamcrest.version>1.3</hamcrest.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue