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.Group;
|
24
|
import eu.etaxonomy.cdm.persistence.dao.common.IGroupDao;
|
25
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
26
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
27
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
28
|
|
29
|
@DataSet
|
30
|
public class GroupDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
|
31
|
|
32
|
@SpringBeanByType
|
33
|
IGroupDao groupDao;
|
34
|
|
35
|
@Test
|
36
|
public void testFindGroupByUsername() {
|
37
|
Group group = groupDao.findGroupByName("Admins");
|
38
|
|
39
|
assertNotNull("findGroupByName should return a group", group);
|
40
|
// assertEquals("the user should have had their authorities loaded",2,group.getAuthorities().size());
|
41
|
}
|
42
|
|
43
|
@Test
|
44
|
public void findByName(){
|
45
|
String queryString = "Admins";
|
46
|
MatchMode matchmode = MatchMode.ANYWHERE;
|
47
|
List<Criterion> criteria = null;
|
48
|
Integer pageSize = null;
|
49
|
Integer pageNumber = null;
|
50
|
List<OrderHint> orderHints = null;
|
51
|
List<String> propertyPaths = null;
|
52
|
List<Group> list = groupDao.findByName(queryString, matchmode, criteria, pageSize, pageNumber, orderHints, propertyPaths);
|
53
|
|
54
|
assertNotNull("A list should be returned", list);
|
55
|
assertEquals("2 groups should be returned", 2, list.size());
|
56
|
|
57
|
}
|
58
|
|
59
|
/* (non-Javadoc)
|
60
|
* @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
|
61
|
*/
|
62
|
@Override
|
63
|
public void createTestDataSet() throws FileNotFoundException {
|
64
|
// TODO Auto-generated method stub
|
65
|
|
66
|
}
|
67
|
|
68
|
}
|