Commit 16a60304a49aff30d928d6f5bedf0c12d0d92e03
1 parent
8e100d32
test: mehr TestDataBuilders
Showing
4 changed files
with
54 additions
and
5 deletions
src/main/java/net/ziemers/swxercise/lg/model/user/Profile.java
... | ... | @@ -133,7 +133,7 @@ public class Profile extends BaseEntity { |
133 | 133 | return username; |
134 | 134 | } |
135 | 135 | |
136 | - public void setUsername(String username) { | |
136 | + private void setUsername(String username) { | |
137 | 137 | this.username = username; |
138 | 138 | } |
139 | 139 | |
... | ... | @@ -183,4 +183,9 @@ public class Profile extends BaseEntity { |
183 | 183 | this.mailaddress = mailaddress; |
184 | 184 | } |
185 | 185 | |
186 | + public Profile withMailaddress(final String mailaddress) { | |
187 | + setMailaddress(mailaddress); | |
188 | + return this; | |
189 | + } | |
190 | + | |
186 | 191 | } | ... | ... |
src/main/java/net/ziemers/swxercise/lg/model/testdata/testdatabuilder/AbstractTestDataBuilder.java renamed to src/test/java/net/ziemers/swxercise/lg/testdata/testdatabuilder/AbstractTestDataBuilder.java
src/test/java/net/ziemers/swxercise/lg/testdata/testdatabuilder/user/ProfileTestDataBuilder.java
0 → 100644
1 | +package net.ziemers.swxercise.lg.testdata.testdatabuilder.user; | |
2 | + | |
3 | +import net.ziemers.swxercise.lg.model.user.Profile; | |
4 | +import net.ziemers.swxercise.lg.testdata.testdatabuilder.AbstractTestDataBuilder; | |
5 | + | |
6 | +import javax.persistence.EntityManager; | |
7 | + | |
8 | +public class ProfileTestDataBuilder extends AbstractTestDataBuilder { | |
9 | + | |
10 | + private String username = "tziemer"; | |
11 | + | |
12 | + private String password = "secret"; | |
13 | + | |
14 | + private String mailaddress = "tziemer@ziemers.net"; | |
15 | + | |
16 | + public ProfileTestDataBuilder(final EntityManager em) { | |
17 | + super(em); | |
18 | + } | |
19 | + | |
20 | + @Override | |
21 | + public Profile build() { | |
22 | + return new Profile(username, password) | |
23 | + .withMailaddress(mailaddress); | |
24 | + } | |
25 | + | |
26 | + public ProfileTestDataBuilder withUsername(final String username) { | |
27 | + this.username = username; | |
28 | + return this; | |
29 | + } | |
30 | + | |
31 | + public ProfileTestDataBuilder withPassword(final String password) { | |
32 | + this.password = password; | |
33 | + return this; | |
34 | + } | |
35 | + | |
36 | + public ProfileTestDataBuilder withMailaddress(final String mailaddress) { | |
37 | + this.mailaddress = mailaddress; | |
38 | + return this; | |
39 | + } | |
40 | + | |
41 | +} | ... | ... |
src/main/java/net/ziemers/swxercise/lg/model/testdata/testdatabuilder/UserTestDataBuilder.java renamed to src/test/java/net/ziemers/swxercise/lg/testdata/testdatabuilder/user/UserTestDataBuilder.java
1 | -package net.ziemers.swxercise.lg.model.testdata.testdatabuilder; | |
1 | +package net.ziemers.swxercise.lg.testdata.testdatabuilder.user; | |
2 | 2 | |
3 | 3 | import net.ziemers.swxercise.lg.model.user.Address; |
4 | 4 | import net.ziemers.swxercise.lg.model.user.Profile; |
5 | 5 | import net.ziemers.swxercise.lg.model.user.User; |
6 | +import net.ziemers.swxercise.lg.testdata.testdatabuilder.AbstractTestDataBuilder; | |
7 | + | |
8 | +import javax.persistence.EntityManager; | |
6 | 9 | |
7 | 10 | public class UserTestDataBuilder extends AbstractTestDataBuilder<User> { |
8 | 11 | |
... | ... | @@ -14,7 +17,7 @@ public class UserTestDataBuilder extends AbstractTestDataBuilder<User> { |
14 | 17 | |
15 | 18 | private Address address = null; |
16 | 19 | |
17 | - public UserTestDataBuilder(final EntityManger em) { | |
20 | + public UserTestDataBuilder(final EntityManager em) { | |
18 | 21 | super(em); |
19 | 22 | profile = new ProfileTestDataBuilder(em).build(); |
20 | 23 | } |
... | ... | @@ -36,7 +39,7 @@ public class UserTestDataBuilder extends AbstractTestDataBuilder<User> { |
36 | 39 | return this; |
37 | 40 | } |
38 | 41 | |
39 | - public UserTestDataBuidler withProfile(final Profile profile) { | |
42 | + public UserTestDataBuilder withProfile(final Profile profile) { | |
40 | 43 | this.profile = profile; |
41 | 44 | return this; |
42 | 45 | } | ... | ... |