fix: Make mapper static
This commit is contained in:
@@ -3,7 +3,7 @@ package np.com.krrish;
|
|||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
public class Mapper {
|
public class Mapper {
|
||||||
public Object map(Object source, String destination) {
|
public static Object map(Object source, String destination) {
|
||||||
Object object = new Object();
|
Object object = new Object();
|
||||||
try {
|
try {
|
||||||
Class<?> aClass = Class.forName(destination);
|
Class<?> aClass = Class.forName(destination);
|
||||||
|
@@ -5,17 +5,11 @@ import org.junit.jupiter.api.*;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class MapperTest {
|
class MapperTest {
|
||||||
private Mapper mapper;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
mapper = new Mapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testEmptyFieldsMap() {
|
void testEmptyFieldsMap() {
|
||||||
Source source = new Source();
|
Source source = new Source();
|
||||||
Object destination = mapper.map(source, "np.com.krrish.Destination");
|
Object destination = Mapper.map(source, "np.com.krrish.Destination");
|
||||||
assertEquals(Destination.class, destination.getClass());
|
assertEquals(Destination.class, destination.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +19,7 @@ class MapperTest {
|
|||||||
source.setFirst("first");
|
source.setFirst("first");
|
||||||
source.setSecond("second");
|
source.setSecond("second");
|
||||||
|
|
||||||
Destination destination = (Destination) mapper.map(source, "np.com.krrish.Destination");
|
Destination destination = (Destination) Mapper.map(source, "np.com.krrish.Destination");
|
||||||
assertEquals("first", destination.getFirst());
|
assertEquals("first", destination.getFirst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user