fix: Ignore if field does not exist
This commit is contained in:
14
test/np/com/krrish/Destination.java
Normal file
14
test/np/com/krrish/Destination.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package np.com.krrish;
|
||||
|
||||
public class Destination {
|
||||
private String first;
|
||||
private String second;
|
||||
|
||||
String getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public String getSecond() {
|
||||
return second;
|
||||
}
|
||||
}
|
31
test/np/com/krrish/MapperTest.java
Normal file
31
test/np/com/krrish/MapperTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package np.com.krrish;
|
||||
|
||||
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");
|
||||
assertEquals(Destination.class, destination.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMapWithSameFields() {
|
||||
Source source = new Source();
|
||||
source.setFirst("first");
|
||||
source.setSecond("second");
|
||||
|
||||
Destination destination = (Destination) mapper.map(source, "np.com.krrish.Destination");
|
||||
assertEquals("first", destination.getFirst());
|
||||
}
|
||||
}
|
14
test/np/com/krrish/Source.java
Normal file
14
test/np/com/krrish/Source.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package np.com.krrish;
|
||||
|
||||
public class Source {
|
||||
private String first;
|
||||
private String second;
|
||||
|
||||
void setFirst(String first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
void setSecond(String second) {
|
||||
this.second = second;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user