forked from slemesle/selma
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #110 : Selma get confused when field's name ends with the name of
the containing class.
- Loading branch information
1 parent
31a6eb3
commit 934aa18
Showing
6 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/fr/xebia/extras/selma/beans/Home.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.xebia.extras.selma.beans; | ||
|
||
/** | ||
* @author FaniloRandria | ||
*/ | ||
public class Home { | ||
|
||
private Phone phoneHome; | ||
|
||
public Home (Phone phoneHome) { | ||
this.phoneHome = phoneHome; | ||
} | ||
|
||
public Phone getPhoneHome() { | ||
return phoneHome; | ||
} | ||
|
||
public void setPhoneHome(Phone phoneHome) { | ||
this.phoneHome = phoneHome; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
processor/src/test/java/fr/xebia/extras/selma/beans/HomeDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.xebia.extras.selma.beans; | ||
|
||
/** | ||
* @author FaniloRandria | ||
*/ | ||
public class HomeDto { | ||
|
||
public String phone; | ||
|
||
public String getPhone() { | ||
return phone; | ||
} | ||
|
||
public void setPhone(String phone) { | ||
this.phone = phone; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/fr/xebia/extras/selma/beans/Phone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.xebia.extras.selma.beans; | ||
|
||
/** | ||
* @author FaniloRandria | ||
*/ | ||
public class Phone { | ||
|
||
private String phoneNumber; | ||
|
||
public Phone (String phoneNumber) { | ||
this.phoneNumber = phoneNumber; | ||
} | ||
|
||
public String getPhoneNumber() { | ||
return phoneNumber; | ||
} | ||
|
||
public void setPhoneNumber(String phoneNumber) { | ||
this.phoneNumber = phoneNumber; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
processor/src/test/java/fr/xebia/extras/selma/it/HomeMapperIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fr.xebia.extras.selma.it; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
import fr.xebia.extras.selma.Selma; | ||
import fr.xebia.extras.selma.beans.Home; | ||
import fr.xebia.extras.selma.beans.HomeDto; | ||
import fr.xebia.extras.selma.beans.Phone; | ||
import fr.xebia.extras.selma.it.mappers.HomeMapper; | ||
import fr.xebia.extras.selma.it.utils.Compile; | ||
import fr.xebia.extras.selma.it.utils.IntegrationTestBase; | ||
|
||
/** | ||
* @author FaniloRandria | ||
*/ | ||
@Compile(withClasses = HomeMapper.class) | ||
public class HomeMapperIT extends IntegrationTestBase { | ||
|
||
public static final String NUMBER_PHONE = "06-11-22-33-44"; | ||
|
||
@Test | ||
public void beanMapperTest() throws Exception { | ||
HomeMapper mapper = Selma.getMapper(HomeMapper.class); | ||
Phone phone = new Phone(NUMBER_PHONE); | ||
Home home = new Home(phone); | ||
HomeDto homeDto = mapper.toDto(home); | ||
assertThat(homeDto.getPhone()).isEqualTo(NUMBER_PHONE); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
processor/src/test/java/fr/xebia/extras/selma/it/mappers/HomeMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package fr.xebia.extras.selma.it.mappers; | ||
|
||
import fr.xebia.extras.selma.Field; | ||
import fr.xebia.extras.selma.Mapper; | ||
import fr.xebia.extras.selma.Maps; | ||
import fr.xebia.extras.selma.beans.Home; | ||
import fr.xebia.extras.selma.beans.HomeDto; | ||
|
||
/** | ||
* @author FaniloRandria | ||
*/ | ||
@Mapper | ||
public interface HomeMapper { | ||
|
||
@Maps(withCustomFields = { | ||
@Field(value = {"phone", "phoneHome.phoneNumber"}) | ||
}) HomeDto toDto (Home in); | ||
|
||
} |