Revision 986f6827
Added by Andreas Müller almost 6 years ago
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImplTest.java | ||
---|---|---|
127 | 127 |
@ExpectedDataSet |
128 | 128 |
public void testSave() { |
129 | 129 |
Person person = Person.NewInstance(); |
130 |
person.setFirstname("ben");
|
|
130 |
person.setGivenName("ben");
|
|
131 | 131 |
agentDao.save(person); |
132 | 132 |
commit(); |
133 | 133 |
} |
... | ... | |
138 | 138 |
public void testUpdate() { |
139 | 139 |
Person person = (Person)agentDao.findByUuid(personUuid); |
140 | 140 |
assert person != null : "person must exist"; |
141 |
person.setFirstname("Benjamin");
|
|
141 |
person.setGivenName("Benjamin");
|
|
142 | 142 |
agentDao.update(person); |
143 | 143 |
// commitAndStartNewTransaction(new String[]{"AGENTBASE_AUD","AGENTBASE"}); |
144 | 144 |
commit(); |
... | ... | |
148 | 148 |
@DataSet("AgentDaoImplTest.testFind.xml") |
149 | 149 |
public void testFindInCurrentView() { |
150 | 150 |
Person person = (Person)agentDao.findByUuid(personUuid); |
151 |
Assert.assertEquals("The person's firstname should be \'Benjamin\' in the current view", "Benjamin", person.getFirstname());
|
|
151 |
Assert.assertEquals("The person's givenname should be \'Benjamin\' in the current view", "Benjamin", person.getGivenName());
|
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
@Test |
... | ... | |
156 | 156 |
public void testFindInPreviousView() { |
157 | 157 |
AuditEventContextHolder.getContext().setAuditEvent(previousAuditEvent); |
158 | 158 |
Person person = (Person)agentDao.findByUuid(personUuid); |
159 |
Assert.assertEquals("The person's firstname should be \'Ben\' in the previous view",person.getFirstname(),"Ben");
|
|
159 |
Assert.assertEquals("The person's givenname should be \'Ben\' in the previous view",person.getGivenName(),"Ben");
|
|
160 | 160 |
} |
161 | 161 |
|
162 | 162 |
@Test |
... | ... | |
267 | 267 |
List<AgentBase> personResults = agentDao.list(Person.class, restrictions, (Integer)null, (Integer)null, null, null); |
268 | 268 |
Assert.assertEquals("list() should return 5 Persons entities", 5, personResults.size()); |
269 | 269 |
|
270 |
Restriction<String> firstNameExact = new Restriction<>("firstname", MatchMode.EXACT);
|
|
271 |
restrictions.add(firstNameExact);
|
|
270 |
Restriction<String> givenNameExact = new Restriction<>("givenname", MatchMode.EXACT);
|
|
271 |
restrictions.add(givenNameExact);
|
|
272 | 272 |
|
273 | 273 |
personResults = agentDao.list(Person.class, restrictions, (Integer)null, (Integer)null, null, null); |
274 | 274 |
Assert.assertEquals("list() empty value lists should be ignored", 5, personResults.size()); |
275 | 275 |
|
276 |
firstNameExact.addValue("Ben");
|
|
276 |
givenNameExact.addValue("Ben");
|
|
277 | 277 |
restrictions.clear(); |
278 |
restrictions.add(firstNameExact);
|
|
278 |
restrictions.add(givenNameExact);
|
|
279 | 279 |
personResults = agentDao.list(Person.class, restrictions, (Integer)null, (Integer)null, null, null); |
280 |
Assert.assertEquals("list() should return 1 AgentBase entity having the firstname 'Ben'", 1 ,personResults.size());
|
|
280 |
Assert.assertEquals("list() should return 1 AgentBase entity having the givenname 'Ben'", 1 ,personResults.size());
|
|
281 | 281 |
} |
282 | 282 |
|
283 | 283 |
@Test |
... | ... | |
289 | 289 |
|
290 | 290 |
Assert.assertEquals("count() should return 5 Persons entities", 5, agentDao.count(Person.class, restrictions)); |
291 | 291 |
|
292 |
Restriction<String> firstNameExact = new Restriction<>("firstname", MatchMode.EXACT);
|
|
293 |
restrictions.add(firstNameExact);
|
|
292 |
Restriction<String> givenNameExact = new Restriction<>("givenname", MatchMode.EXACT);
|
|
293 |
restrictions.add(givenNameExact);
|
|
294 | 294 |
|
295 | 295 |
Assert.assertEquals("count() empty value lists should be ignored", 5, agentDao.count(Person.class, restrictions)); |
296 | 296 |
|
297 |
firstNameExact.addValue("Ben");
|
|
297 |
givenNameExact.addValue("Ben");
|
|
298 | 298 |
restrictions.clear(); |
299 |
restrictions.add(firstNameExact);
|
|
300 |
Assert.assertEquals("count() should return 1 Persons entity having the firstname 'Ben'", 1 , agentDao.count(Person.class, restrictions));
|
|
299 |
restrictions.add(givenNameExact);
|
|
300 |
Assert.assertEquals("count() should return 1 Persons entity having the givenname 'Ben'", 1 , agentDao.count(Person.class, restrictions));
|
|
301 | 301 |
} |
302 | 302 |
|
303 | 303 |
@Test |
Also available in: Unified diff
ref #7238 rename lastName and firstName