fix: Ignore if field does not exist

This commit is contained in:
Krrish Ghimire
2019-12-03 23:25:18 +05:45
parent 8f4f154879
commit 8fc1410cd0
5 changed files with 43 additions and 34 deletions

View File

@@ -1,8 +1,10 @@
package np.com.krrish;
public class Destination {
private String first;
private String second;
public String getFirst() {
String getFirst() {
return first;
}

View File

@@ -1,3 +1,5 @@
package np.com.krrish;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
@@ -13,7 +15,7 @@ class MapperTest {
@Test
void testEmptyFieldsMap() {
Source source = new Source();
Object destination = mapper.map(source, "Destination");
Object destination = mapper.map(source, "np.com.krrish.Destination");
assertEquals(Destination.class, destination.getClass());
}
@@ -23,7 +25,7 @@ class MapperTest {
source.setFirst("first");
source.setSecond("second");
Destination destination = (Destination) mapper.map(source, "Destination");
Destination destination = (Destination) mapper.map(source, "np.com.krrish.Destination");
assertEquals("first", destination.getFirst());
}
}

View File

@@ -1,12 +1,14 @@
package np.com.krrish;
public class Source {
private String first;
private String second;
public void setFirst(String first) {
void setFirst(String first) {
this.first = first;
}
public void setSecond(String second) {
void setSecond(String second) {
this.second = second;
}
}