Browse Source

fix: Make mapper static

master
Krrish Ghimire 5 years ago
parent
commit
7a7d25635e
  1. 2
      src/np/com/krrish/Mapper.java
  2. 10
      test/np/com/krrish/MapperTest.java

2
src/np/com/krrish/Mapper.java

@ -3,7 +3,7 @@ package np.com.krrish;
import java.lang.reflect.*;
public class Mapper {
public Object map(Object source, String destination) {
public static Object map(Object source, String destination) {
Object object = new Object();
try {
Class<?> aClass = Class.forName(destination);

10
test/np/com/krrish/MapperTest.java

@ -5,17 +5,11 @@ import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
class MapperTest {
private Mapper mapper;
@BeforeEach
void setUp() {
mapper = new Mapper();
}
@Test
void testEmptyFieldsMap() {
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());
}
@ -25,7 +19,7 @@ class MapperTest {
source.setFirst("first");
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());
}
}

Loading…
Cancel
Save