[BAEL-12114] - Upgraded MapStruct article
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.mapper;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.dto.CarDTO;
|
||||
import com.baeldung.entity.Car;
|
||||
|
||||
public class CarMapperUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenCarEntitytoCar_whenMaps_thenCorrect() {
|
||||
|
||||
Car entity = new Car();
|
||||
entity.setId(1);
|
||||
entity.setName("Toyota");
|
||||
|
||||
CarDTO carDto = CarMapper.INSTANCE.carToCarDTO(entity);
|
||||
|
||||
assertEquals(carDto.getId(), entity.getId());
|
||||
assertEquals(carDto.getName(), entity.getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user