Renaming test methods and formatting

This commit is contained in:
Sasa M 2020-04-21 21:29:38 +02:00
parent 43852c4303
commit d1b282220d
9 changed files with 26 additions and 28 deletions

View File

@ -20,23 +20,23 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version> <version>${commons-lang3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.modelmapper</groupId> <groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId> <artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version> <version>${modelmapper.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId> <artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version> <version>${hamcrest.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -7,10 +7,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* @author sasam0320
* @description
* This is a helper class that contains methods for generic mapping of the users list. * 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. * Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT.
*
* @author sasam0320
*/ */
public class MapperUtil { public class MapperUtil {

View File

@ -1,8 +1,8 @@
package com.baeldung.modelmapper; package com.baeldung.modelmapper;
/** /**
* User model entity class
* @author sasam0320 * @author sasam0320
* @description User model entity class
*/ */
public class User { public class User {

View File

@ -1,8 +1,8 @@
package com.baeldung.modelmapper; package com.baeldung.modelmapper;
/** /**
* UserDTO model class
* @author sasam0320 * @author sasam0320
* @description UserDTO model class
*/ */
public class UserDTO { public class UserDTO {

View File

@ -3,8 +3,8 @@ package com.baeldung.modelmapper;
import java.util.Collection; import java.util.Collection;
/** /**
* UserList class that contain collection of users
* @author sasam0320 * @author sasam0320
* @description UserList class that contain collection of users
*/ */
public class UserList { public class UserList {

View File

@ -3,8 +3,8 @@ package com.baeldung.modelmapper;
import java.util.List; import java.util.List;
/** /**
* UserListDTO class that contain list of username properties
* @author sasam0320 * @author sasam0320
* @description UserListDTO class that contain list of username properties
*/ */
public class UserListDTO { public class UserListDTO {

View File

@ -7,10 +7,9 @@ import java.util.ArrayList;
import java.util.List; 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. * 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. * In the configuration method, we call a converter to do the mapping.
* @author sasam0320
*/ */
public class UserPropertyMap extends PropertyMap<UserList, UserListDTO> { public class UserPropertyMap extends PropertyMap<UserList, UserListDTO> {

View File

@ -13,18 +13,17 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
/** /**
* @sasam0320
* @description
* This class has test methods of mapping Integer to Character list, * This class has test methods of mapping Integer to Character list,
* mapping user list to DTO list using MapperUtil generic methods and Converter * mapping user list to DTO list using MapperUtil generic methods and Converter
*
* @author sasam0320
*/ */
public class UserMappingTest { public class UsersListMappingUnitTest {
private ModelMapper mapper; private ModelMapper mapper;
private List<User> users; private List<User> users;
@ -42,7 +41,7 @@ public class UserMappingTest {
} }
@Test @Test
public void testMapIntegerList() { public void whenMapIntegerToCharList() {
List<Integer> integers = new ArrayList<Integer>(); List<Integer> integers = new ArrayList<Integer>();
@ -53,12 +52,12 @@ public class UserMappingTest {
List<Character> characters = mapper.map(integers, new TypeToken<List<Character>>() { List<Character> characters = mapper.map(integers, new TypeToken<List<Character>>() {
}.getType()); }.getType());
assertThat(characters, hasItems('1','2','3')); assertThat(characters, hasItems('1', '2', '3'));
} }
@Test @Test
public void testMapGenericTypeLists() { public void givenUsersList_whenUseGenericType_thenMapToDto() {
// Mapping lists using generic type methods // Mapping lists using generic type methods

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>parent-java</artifactId> <artifactId>parent-java</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
@ -45,9 +45,9 @@
<guava.version>23.0</guava.version> <guava.version>23.0</guava.version>
<commons.io.version>2.6</commons.io.version> <commons.io.version>2.6</commons.io.version>
<jmh.version>1.19</jmh.version> <jmh.version>1.19</jmh.version>
<modelmapper.version>2.3.6</modelmapper.version> <modelmapper.version>2.3.6</modelmapper.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<hamcrest.version>1.3</hamcrest.version> <hamcrest.version>1.3</hamcrest.version>
</properties> </properties>
</project> </project>