1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
|
15
|
import java.io.FileNotFoundException;
|
16
|
import java.util.List;
|
17
|
|
18
|
import org.hibernate.criterion.Criterion;
|
19
|
import org.junit.Test;
|
20
|
import org.unitils.dbunit.annotation.DataSet;
|
21
|
import org.unitils.spring.annotation.SpringBeanByType;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.common.User;
|
24
|
import eu.etaxonomy.cdm.persistence.dao.common.IUserDao;
|
25
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
26
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
27
|
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
|
28
|
|
29
|
@DataSet
|
30
|
public class UserDaoHibernateImplTest extends CdmIntegrationTest {
|
31
|
|
32
|
@SpringBeanByType
|
33
|
IUserDao userDao;
|
34
|
|
35
|
|
36
|
@Test
|
37
|
public void testFindUserByUsername() {
|
38
|
User user = userDao.findUserByUsername("test");
|
39
|
|
40
|
assertNotNull("findUserByUsername should return a user", user);
|
41
|
assertEquals("the user should have had their authorities loaded",2,user.getAuthorities().size());
|
42
|
}
|
43
|
|
44
|
@Test
|
45
|
public void findByUsername(){
|
46
|
String queryString = "test";
|
47
|
MatchMode matchmode = MatchMode.ANYWHERE;
|
48
|
List<Criterion> criteria = null;
|
49
|
Integer pageSize = null;
|
50
|
Integer pageNumber = null;
|
51
|
List<OrderHint> orderHints = null;
|
52
|
List<String> propertyPaths = null;
|
53
|
List<User> list = userDao.findByUsername(queryString, matchmode, criteria, pageSize, pageNumber, orderHints, propertyPaths);
|
54
|
|
55
|
assertNotNull("A list should be returned", list);
|
56
|
assertEquals("3 users should be returned", 3, list.size());
|
57
|
|
58
|
pageSize = 2;
|
59
|
list = userDao.findByUsername(queryString, matchmode, criteria, pageSize, pageNumber, orderHints, propertyPaths);
|
60
|
assertNotNull("A list should be returned", list);
|
61
|
assertEquals("2 users should be returned", 2, list.size());
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
|
66
|
*/
|
67
|
@Override
|
68
|
public void createTestDataSet() throws FileNotFoundException {
|
69
|
// TODO Auto-generated method stub
|
70
|
|
71
|
}
|
72
|
}
|