-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3075 from ebean-orm/feature/3062-dtoQuery
#3062 - DtoQuery may match the wrong constructor
- Loading branch information
Showing
4 changed files
with
95 additions
and
18 deletions.
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
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
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
76 changes: 76 additions & 0 deletions
76
ebean-test/src/test/java/io/ebean/xtest/base/DtoQuery3Test.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,76 @@ | ||
package io.ebean.xtest.base; | ||
|
||
import io.ebean.xtest.BaseTestCase; | ||
import org.junit.jupiter.api.Test; | ||
import org.tests.model.basic.ResetBasicData; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class DtoQuery3Test extends BaseTestCase { | ||
|
||
@Test | ||
void dtoQuery_when_constructorsClash() { | ||
ResetBasicData.reset(); | ||
|
||
List<DCust> list = server().findDto(DCust.class, "select id, name, status from o_customer").findList(); | ||
|
||
assertThat(list).isNotEmpty(); | ||
for (DCust cust: list) { | ||
assertThat(cust.id()).isNotNull(); | ||
assertThat(cust.name()).isNotNull(); | ||
assertThat(cust.status()).isNotNull(); | ||
} | ||
} | ||
|
||
public static class DCust { | ||
|
||
final Integer id; | ||
String name; | ||
|
||
String status; | ||
|
||
public DCust(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
/** Constructor with 3 args - clashes with the one below */ | ||
public DCust(Integer id, String name, List<String> notUsed) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
/** Constructor with 3 args - clashes with the one above */ | ||
public DCust(Integer id, String name, String status) { | ||
this.id = id; | ||
this.name = name; | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "id:" + id + " name:" + name; | ||
} | ||
|
||
public Integer id() { | ||
return id; | ||
} | ||
|
||
public String name() { | ||
return name; | ||
} | ||
|
||
public void name(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String status() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
} | ||
} |