1 |
0ecfd682
|
Andreas Müller
|
/**
|
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.api.service;
|
11 |
|
|
|
12 |
|
|
import java.io.FileNotFoundException;
|
13 |
c781c97b
|
Katja Luther
|
import java.util.List;
|
14 |
0ecfd682
|
Andreas Müller
|
import java.util.UUID;
|
15 |
|
|
|
16 |
|
|
import org.apache.log4j.Logger;
|
17 |
|
|
import org.junit.Assert;
|
18 |
|
|
import org.junit.Test;
|
19 |
|
|
import org.unitils.database.annotations.Transactional;
|
20 |
|
|
import org.unitils.database.util.TransactionMode;
|
21 |
|
|
import org.unitils.dbunit.annotation.DataSet;
|
22 |
|
|
import org.unitils.dbunit.annotation.ExpectedDataSet;
|
23 |
|
|
import org.unitils.spring.annotation.SpringBeanByType;
|
24 |
|
|
|
25 |
912932b1
|
Andreas Müller
|
import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
|
26 |
|
|
import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
|
27 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
28 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
29 |
|
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
30 |
1e8a54ff
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
31 |
d7919b1c
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
32 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.Rank;
|
33 |
9dc896c9
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
34 |
fe34a9eb
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
35 |
c781c97b
|
Katja Luther
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
36 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
37 |
|
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
38 |
fbeefcaf
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
39 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
40 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
41 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
42 |
1c39686b
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
43 |
|
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
44 |
|
|
import eu.etaxonomy.cdm.model.term.VocabularyEnum;
|
45 |
c781c97b
|
Katja Luther
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
46 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
47 |
077e258b
|
Andreas Müller
|
import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
|
48 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
49 |
|
|
|
50 |
|
|
/**
|
51 |
|
|
* @author a.mueller
|
52 |
|
|
*
|
53 |
|
|
*/
|
54 |
|
|
@Transactional(TransactionMode.DISABLED)
|
55 |
|
|
public class IdentifiableServiceBaseTest extends CdmTransactionalIntegrationTest {
|
56 |
|
|
|
57 |
4279b3d2
|
Andreas Müller
|
@SuppressWarnings("unused")
|
58 |
|
|
private static final Logger logger = Logger.getLogger(IdentifiableServiceBaseTest.class);
|
59 |
0ecfd682
|
Andreas Müller
|
|
60 |
|
|
@SpringBeanByType
|
61 |
|
|
private INameService nameService;
|
62 |
|
|
|
63 |
|
|
@SpringBeanByType
|
64 |
|
|
private ITermService termService;
|
65 |
|
|
|
66 |
|
|
@SpringBeanByType
|
67 |
|
|
private IVocabularyService vocService;
|
68 |
|
|
|
69 |
|
|
@SpringBeanByType
|
70 |
|
|
private ITaxonService taxonService;
|
71 |
|
|
|
72 |
c781c97b
|
Katja Luther
|
@SpringBeanByType
|
73 |
|
|
private IReferenceService referenceService;
|
74 |
|
|
|
75 |
0ecfd682
|
Andreas Müller
|
@SpringBeanByType
|
76 |
|
|
private IClassificationService classificationService;
|
77 |
|
|
|
78 |
|
|
/****************** TESTS *****************************/
|
79 |
|
|
|
80 |
|
|
@Test
|
81 |
|
|
public final void voidTestSeriveExists(){
|
82 |
|
|
Assert.assertNotNull("Service shoulb be initialized", nameService);
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
@Test
|
87 |
|
|
@DataSet
|
88 |
|
|
@ExpectedDataSet
|
89 |
|
|
public final void testUpdateTitleCache() {
|
90 |
9dc896c9
|
Andreas Müller
|
Assert.assertEquals("There should be 5 TaxonNames in the data set", 5, nameService.count(TaxonName.class));
|
91 |
39d05e66
|
Andreas Müller
|
Class<TaxonName> clazz = TaxonName.class;
|
92 |
0ecfd682
|
Andreas Müller
|
int stepSize = 2;
|
93 |
57d5b579
|
Andreas Müller
|
nameService.updateCaches(clazz, stepSize, null, null);
|
94 |
0ecfd682
|
Andreas Müller
|
commit();
|
95 |
9dc896c9
|
Andreas Müller
|
// commitAndStartNewTransaction(new String[]{"TaxonName","TaxonName_AUD"});
|
96 |
0ecfd682
|
Andreas Müller
|
}
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
@Test
|
100 |
1e8a54ff
|
Andreas Müller
|
@DataSet(value="IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml")
|
101 |
|
|
public final void testFindByIdentifier(){
|
102 |
0ecfd682
|
Andreas Müller
|
UUID uuidIdentifierType1 = UUID.fromString("02bb62db-a229-4eeb-83e6-a9a093943d5e");
|
103 |
|
|
UUID uuidIdentifierType2 = UUID.fromString("ef6e960f-5289-456c-b25c-cff7f4de2f63");
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
DefinedTerm it1 = (DefinedTerm)termService.find(uuidIdentifierType1);
|
107 |
|
|
Assert.assertNotNull("identifier type must not be null", it1);
|
108 |
|
|
|
109 |
|
|
boolean includeEntity = true;
|
110 |
912932b1
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<Taxon>> taxonPager = taxonService.findByIdentifier(Taxon.class, "ext-1234", it1, null, includeEntity, null, null, null);
|
111 |
0ecfd682
|
Andreas Müller
|
Assert.assertTrue("Result should not be empty", taxonPager.getCount() == 1);
|
112 |
912932b1
|
Andreas Müller
|
IdentifiedEntityDTO<Taxon>.CdmEntity entity = taxonPager.getRecords().get(0).getCdmEntity();
|
113 |
0ecfd682
|
Andreas Müller
|
Taxon taxon = entity.getEntity();
|
114 |
|
|
Assert.assertEquals(UUID.fromString("888cded1-cadc-48de-8629-e32927919879"), taxon.getUuid());
|
115 |
c781c97b
|
Katja Luther
|
Assert.assertEquals(UUID.fromString("888cded1-cadc-48de-8629-e32927919879"), entity.getUuid());
|
116 |
0ecfd682
|
Andreas Müller
|
Assert.assertEquals("Taxon should have 1 identifier", 1, taxon.getIdentifiers().size());
|
117 |
0a140219
|
Andreas Müller
|
Identifier identifier = taxon.getIdentifiers().get(0);
|
118 |
0ecfd682
|
Andreas Müller
|
DefinedTerm type = CdmBase.deproxy(identifier.getType(), DefinedTerm.class);
|
119 |
|
|
Assert.assertEquals(uuidIdentifierType1, type.getUuid());
|
120 |
|
|
|
121 |
9dc896c9
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<TaxonName>> names = nameService.findByIdentifier(
|
122 |
|
|
TaxonName.class, "ext-1234", null, null, includeEntity, null, null, null);
|
123 |
0ecfd682
|
Andreas Müller
|
Assert.assertTrue("Identifier does not exist for TaxonName", names.getCount() == 0);
|
124 |
|
|
|
125 |
|
|
taxonPager = taxonService.findByIdentifier(null, "ext-1234", null, null, includeEntity, null, null, null);
|
126 |
|
|
Assert.assertEquals("Result size for 'ext-1234' should be 1", 1, taxonPager.getRecords().size());
|
127 |
|
|
|
128 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, null, null, null, includeEntity, null, null, null);
|
129 |
|
|
Assert.assertEquals("Result should not be empty", 2 , taxonPager.getRecords().size());
|
130 |
|
|
|
131 |
|
|
//includeEntity
|
132 |
|
|
includeEntity = false;
|
133 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "ext-1234", it1, null, includeEntity, null, null, null);
|
134 |
|
|
entity = taxonPager.getRecords().get(0).getCdmEntity();
|
135 |
|
|
Assert.assertNull("Taxon must not be returned with includeEntity = false", entity.getEntity());
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
//Matchmode
|
140 |
|
|
includeEntity = false;
|
141 |
|
|
MatchMode matchmode = null;
|
142 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "123", null, matchmode, includeEntity, null, null, null);
|
143 |
|
|
Assert.assertTrue("Result size for '123' should be 0", taxonPager.getCount() == 0);
|
144 |
|
|
|
145 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "123", null, MatchMode.EXACT, includeEntity, null, null, null);
|
146 |
|
|
Assert.assertTrue("Result size for '123' should be 0", taxonPager.getCount() == 0);
|
147 |
|
|
|
148 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "123", null, MatchMode.ANYWHERE, includeEntity, null, null, null);
|
149 |
|
|
Assert.assertTrue("Result size for '123' should be 1", taxonPager.getCount() == 1);
|
150 |
|
|
|
151 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "123", null, MatchMode.BEGINNING, includeEntity, null, null, null);
|
152 |
|
|
Assert.assertTrue("Result size for '123' should be 0", taxonPager.getCount() == 0);
|
153 |
|
|
|
154 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "ext", null, MatchMode.BEGINNING, includeEntity, null, null, null);
|
155 |
|
|
Assert.assertTrue("Result size for 'ext' should be 1", taxonPager.getCount() == 2);
|
156 |
|
|
|
157 |
|
|
//Paging
|
158 |
|
|
taxonPager = taxonService.findByIdentifier(null, "ext", null, MatchMode.BEGINNING, includeEntity, null, null, null);
|
159 |
|
|
Assert.assertEquals("Total result size for starts with 'ext' should be 4", 4, taxonPager.getRecords().size());
|
160 |
|
|
taxonPager = taxonService.findByIdentifier(null, "ext", null, MatchMode.BEGINNING, includeEntity, 2, 1, null);
|
161 |
|
|
Assert.assertEquals("Total result size for starts with 'ext' should be 4", Long.valueOf(4), taxonPager.getCount());
|
162 |
|
|
Assert.assertEquals("Result size for starts with 'ext' second page should be 2", Integer.valueOf(2), taxonPager.getPageSize());
|
163 |
|
|
Assert.assertEquals("The third taxon (first on second page) should be ext-syn1", "ext-syn1", taxonPager.getRecords().get(0).getIdentifier().getIdentifier());
|
164 |
|
|
|
165 |
|
|
taxonPager = taxonService.findByIdentifier(Taxon.class, "ext", null, MatchMode.BEGINNING, includeEntity, null, null, null);
|
166 |
|
|
Assert.assertTrue("Result size for 'ext' should be 2", taxonPager.getCount() == 2);
|
167 |
|
|
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
@Test
|
171 |
1e8a54ff
|
Andreas Müller
|
@DataSet(value="IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml")
|
172 |
|
|
public final void testFindByIdentifierClassification(){
|
173 |
0ecfd682
|
Andreas Müller
|
//classification Filter
|
174 |
|
|
Classification classification = classificationService.find(5000);
|
175 |
|
|
TaxonNode rootNode = classification.getRootNode();
|
176 |
912932b1
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<Taxon>> taxonPager = taxonService.findByIdentifier(Taxon.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null, null);
|
177 |
0ecfd682
|
Andreas Müller
|
Assert.assertEquals("Result size for 'ext' should be 1", Long.valueOf(1), taxonPager.getCount());
|
178 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, taxonPager.getRecords().size());
|
179 |
|
|
|
180 |
912932b1
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<Taxon>> taxPager = taxonService.findByIdentifier(Taxon.class, "ext-cache1", null, rootNode, MatchMode.EXACT, false, null, null, null);
|
181 |
0ecfd682
|
Andreas Müller
|
Assert.assertEquals("Result size for 'ext' should be 0", Long.valueOf(0), taxPager.getCount());
|
182 |
|
|
Assert.assertEquals("Result size for 'ext' should be 0", 0, taxPager.getRecords().size());
|
183 |
|
|
|
184 |
|
|
rootNode = null; //check against missing filter
|
185 |
|
|
taxPager = taxonService.findByIdentifier(Taxon.class, "ext-cache1", null, rootNode, MatchMode.EXACT, false, null, null, null);
|
186 |
|
|
Assert.assertEquals("Result size for 'ext-cache1' without filter should be 1", Long.valueOf(1), taxPager.getCount());
|
187 |
|
|
Assert.assertEquals("Result size for 'ext-cache1' without filter should be 1", 1, taxPager.getRecords().size());
|
188 |
|
|
|
189 |
|
|
//TaxonBase
|
190 |
|
|
rootNode = classification.getRootNode();
|
191 |
912932b1
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<TaxonBase>> tbPager = taxonService.findByIdentifier(TaxonBase.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null, null);
|
192 |
0ecfd682
|
Andreas Müller
|
Assert.assertEquals("Result size for 'ext' should be 1", Long.valueOf(1), tbPager.getCount());
|
193 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, tbPager.getRecords().size());
|
194 |
|
|
|
195 |
|
|
tbPager = taxonService.findByIdentifier(TaxonBase.class, "ext-cache1", null, rootNode, MatchMode.EXACT, false, null, null, null);
|
196 |
|
|
Assert.assertEquals("Result size for 'ext' should be 0", Long.valueOf(0), tbPager.getCount());
|
197 |
|
|
Assert.assertEquals("Result size for 'ext' should be 0", 0, tbPager.getRecords().size());
|
198 |
|
|
|
199 |
|
|
//Synonym
|
200 |
912932b1
|
Andreas Müller
|
Pager<IdentifiedEntityDTO<Synonym>> synPager = taxonService.findByIdentifier(Synonym.class, "ext-syn", null, rootNode, MatchMode.BEGINNING, false, null, null, null);
|
201 |
0ecfd682
|
Andreas Müller
|
Assert.assertEquals("1 Synonym should be linked to the according classification", Long.valueOf(1), synPager.getCount());
|
202 |
|
|
Assert.assertEquals("1 Synonym should be linked to the according classification", 1, synPager.getRecords().size());
|
203 |
|
|
|
204 |
|
|
}
|
205 |
|
|
|
206 |
4dc39e99
|
Andreas Müller
|
@Test
|
207 |
1e8a54ff
|
Andreas Müller
|
@DataSet(value="IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml")
|
208 |
c781c97b
|
Katja Luther
|
public final void testListByIdentifier(){
|
209 |
|
|
//classification Filter
|
210 |
|
|
|
211 |
|
|
List<IdentifiedEntityDTO<Taxon>> taxonPager = taxonService.listByIdentifier(Taxon.class, "ext-1234", null, MatchMode.EXACT, false, null, null);//.listByIdentifier(Taxon.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null);
|
212 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, taxonPager.size());
|
213 |
|
|
// Assert.assertEquals("Result size for 'ext' should be 1", 1, taxonPager.getRecords().size());
|
214 |
|
|
taxonPager = taxonService.listByIdentifier(Taxon.class, "ext-1234", null, MatchMode.EXACT, true, null, null);//.listByIdentifier(Taxon.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null);
|
215 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, taxonPager.size());
|
216 |
|
|
IdentifiedEntityDTO<Taxon> identifierDTO = taxonPager.get(0);
|
217 |
|
|
Assert.assertTrue(identifierDTO.getCdmEntity() instanceof UuidAndTitleCache);
|
218 |
|
|
|
219 |
|
|
List<IdentifiedEntityDTO<Taxon>> taxPager = taxonService.listByIdentifier(Taxon.class, "ext-cache1", null, MatchMode.EXACT, false, null, null);
|
220 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, taxPager.size());
|
221 |
|
|
|
222 |
|
|
List<IdentifiedEntityDTO<TaxonBase>> tbPager = taxonService.listByIdentifier(TaxonBase.class, "ext-1234", null, MatchMode.EXACT, false, null, null);
|
223 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1",1, tbPager.size());
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
//Synonym
|
227 |
|
|
List<IdentifiedEntityDTO<Synonym>> synPager = taxonService.listByIdentifier(Synonym.class, "ext-syn", null, MatchMode.BEGINNING, false, null, null);
|
228 |
|
|
Assert.assertEquals("There should be 2 synonyms with identifier ext-syn", 2, synPager.size());
|
229 |
|
|
|
230 |
|
|
List<IdentifiedEntityDTO<Reference>> referenceList = referenceService.listByIdentifier(Reference.class, "123", null, MatchMode.EXACT, false, null, null);//.listByIdentifier(Taxon.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null);
|
231 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, taxonPager.size());
|
232 |
|
|
|
233 |
|
|
referenceList = referenceService.listByIdentifier(Reference.class, "123", null, MatchMode.EXACT, true, null, null);//.listByIdentifier(Taxon.class, "ext-1234", null, rootNode, MatchMode.EXACT, false, null, null);
|
234 |
|
|
Assert.assertEquals("Result size for 'ext' should be 1", 1, referenceList.size());
|
235 |
|
|
IdentifiedEntityDTO<Reference> identifierDTOReference = referenceList.get(0);
|
236 |
|
|
Assert.assertTrue(identifierDTO.getCdmEntity() instanceof UuidAndTitleCache);
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
@Test
|
240 |
|
|
@DataSet(value="IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml")
|
241 |
1e8a54ff
|
Andreas Müller
|
public final void testFindByMarker(){
|
242 |
|
|
//classification Filter
|
243 |
|
|
Classification classification = classificationService.find(5000);
|
244 |
|
|
TaxonNode rootNode = classification.getRootNode();
|
245 |
|
|
Boolean markerValue = true;
|
246 |
|
|
|
247 |
|
|
UUID uuidMarkerTypeCompleted = MarkerType.uuidComplete;
|
248 |
|
|
UUID uuidMarkerTypeDoubtful = UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e");
|
249 |
|
|
|
250 |
|
|
MarkerType markerType1 = (MarkerType)termService.find(uuidMarkerTypeCompleted);
|
251 |
|
|
MarkerType noMarkerType = null;
|
252 |
|
|
MarkerType markerType2 = (MarkerType)termService.find(uuidMarkerTypeDoubtful);
|
253 |
|
|
Assert.assertNotNull(markerType2);
|
254 |
|
|
|
255 |
077e258b
|
Andreas Müller
|
TaxonTitleType titleType = TaxonTitleType.TAXON;
|
256 |
|
|
|
257 |
1e8a54ff
|
Andreas Müller
|
MarkerType markerType = markerType1;
|
258 |
912932b1
|
Andreas Müller
|
Pager<MarkedEntityDTO<Taxon>> taxonPager = taxonService.findByMarker(Taxon.class, markerType, markerValue,
|
259 |
077e258b
|
Andreas Müller
|
rootNode, true, titleType, null, null, null);
|
260 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for 'marker1=true' should be 1", Long.valueOf(1), taxonPager.getCount());
|
261 |
|
|
Assert.assertEquals("Result size for 'marker1=true' should be 1", 1, taxonPager.getRecords().size());
|
262 |
912932b1
|
Andreas Müller
|
MarkedEntityDTO<Taxon> dto = taxonPager.getRecords().get(0);
|
263 |
|
|
MarkedEntityDTO<Taxon>.Marker marker = dto.getMarker();
|
264 |
1e8a54ff
|
Andreas Müller
|
Assert.assertTrue("Flag must be true", marker.getFlag());
|
265 |
|
|
Assert.assertEquals("Flag must be true", uuidMarkerTypeCompleted, marker.getTypeUuid());
|
266 |
0cf72dcb
|
Andreas Müller
|
Assert.assertNotNull("the CDM entity in the dto must not be empty if includeEntity=true", dto.getCdmEntity().getEntity());
|
267 |
|
|
Assert.assertEquals(5000, dto.getCdmEntity().getEntity().getId());
|
268 |
1e8a54ff
|
Andreas Müller
|
|
269 |
077e258b
|
Andreas Müller
|
|
270 |
1e8a54ff
|
Andreas Müller
|
markerValue = false;
|
271 |
077e258b
|
Andreas Müller
|
taxonPager = taxonService.findByMarker(Taxon.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
272 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for 'marker1=false' should be 0", Long.valueOf(0), taxonPager.getCount());
|
273 |
|
|
|
274 |
|
|
markerValue = true;
|
275 |
|
|
markerType = noMarkerType;
|
276 |
077e258b
|
Andreas Müller
|
taxonPager = taxonService.findByMarker(Taxon.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
277 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for not existing marker type should be 0", Long.valueOf(0), taxonPager.getCount());
|
278 |
|
|
|
279 |
|
|
markerType = markerType2;
|
280 |
077e258b
|
Andreas Müller
|
taxonPager = taxonService.findByMarker(Taxon.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
281 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for markerType2 should be 0", Long.valueOf(0), taxonPager.getCount());
|
282 |
|
|
|
283 |
|
|
rootNode = null;
|
284 |
|
|
markerType = markerType1;
|
285 |
077e258b
|
Andreas Müller
|
taxonPager = taxonService.findByMarker(Taxon.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
286 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for no subtree should be 2", Long.valueOf(2), taxonPager.getCount());
|
287 |
|
|
|
288 |
077e258b
|
Andreas Müller
|
Pager<MarkedEntityDTO<TaxonBase>> taxonBasePager = taxonService.findByMarker(TaxonBase.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
289 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for taxa and synonyms without subtree filter with flag = true should be 3", Long.valueOf(3), taxonBasePager.getCount());
|
290 |
|
|
|
291 |
|
|
markerValue = null;
|
292 |
077e258b
|
Andreas Müller
|
taxonBasePager = taxonService.findByMarker(TaxonBase.class, markerType, markerValue, rootNode, false, titleType, null, null, null);
|
293 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for taxa and synonyms without subtree filter with any flag value should be 4", Long.valueOf(4), taxonBasePager.getCount());
|
294 |
|
|
|
295 |
|
|
markerValue = true;
|
296 |
9dc896c9
|
Andreas Müller
|
Pager<MarkedEntityDTO<TaxonName>> namePager = nameService.findByMarker(TaxonName.class, markerType, markerValue, false, null, null, null);
|
297 |
1e8a54ff
|
Andreas Müller
|
Assert.assertEquals("Result size for names with flag = true should be 1", Long.valueOf(1), namePager.getCount());
|
298 |
|
|
|
299 |
|
|
}
|
300 |
|
|
|
301 |
0ecfd682
|
Andreas Müller
|
|
302 |
|
|
|
303 |
|
|
// @Test
|
304 |
|
|
@Override
|
305 |
|
|
public void createTestDataSet() throws FileNotFoundException {
|
306 |
|
|
TermVocabulary<DefinedTerm> voc = vocService.find(VocabularyEnum.IdentifierType.getUuid());
|
307 |
|
|
|
308 |
|
|
DefinedTerm identifierType1 = DefinedTerm.NewIdentifierTypeInstance(null, "identifierType1", null);
|
309 |
|
|
voc.addTerm(identifierType1);
|
310 |
|
|
termService.save(identifierType1);
|
311 |
|
|
DefinedTerm identifierType2 = DefinedTerm.NewIdentifierTypeInstance(null, "identifierType2", null);
|
312 |
|
|
voc.addTerm(identifierType2);
|
313 |
|
|
termService.save(identifierType2);
|
314 |
|
|
|
315 |
|
|
|
316 |
d7919b1c
|
Andreas Müller
|
IBotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
317 |
0ecfd682
|
Andreas Müller
|
Taxon tb = Taxon.NewInstance(name, null);
|
318 |
|
|
tb.addIdentifier("ext-1234", identifierType1);
|
319 |
|
|
name.addIdentifier("ext-name12", identifierType2);
|
320 |
|
|
taxonService.saveOrUpdate(tb);
|
321 |
|
|
|
322 |
|
|
Taxon tb2 = Taxon.NewInstance(null, null);
|
323 |
|
|
tb2.setTitleCache("Cached taxon", true);
|
324 |
|
|
tb2.addIdentifier("ext-cache1", identifierType2);
|
325 |
|
|
taxonService.saveOrUpdate(tb2);
|
326 |
|
|
|
327 |
|
|
Classification classification = Classification.NewInstance("My classification");
|
328 |
|
|
classification.addChildTaxon(tb, null, null);
|
329 |
|
|
classificationService.saveOrUpdate(classification);
|
330 |
|
|
|
331 |
fbeefcaf
|
Andreas Müller
|
tb2.addSynonymName(null, SynonymType.HOMOTYPIC_SYNONYM_OF());
|
332 |
0ecfd682
|
Andreas Müller
|
|
333 |
|
|
commitAndStartNewTransaction(null);
|
334 |
|
|
|
335 |
|
|
// this will write flat xml file to the same package in the test resources
|
336 |
|
|
// the test file is named after the test class like: TestClassName.xml
|
337 |
|
|
writeDbUnitDataSetFile(new String[] {
|
338 |
9dc896c9
|
Andreas Müller
|
"TAXONBASE", "TAXONNAME","IDENTIFIER","TAXONBASE_IDENTIFIER",
|
339 |
|
|
"TAXONNAME_IDENTIFIER",
|
340 |
0ecfd682
|
Andreas Müller
|
"REFERENCE",
|
341 |
|
|
"CLASSIFICATION", "TAXONNODE",
|
342 |
|
|
"HOMOTYPICALGROUP",
|
343 |
fbeefcaf
|
Andreas Müller
|
"TERMVOCABULARY"
|
344 |
a400c76f
|
Andreas Kohlbecker
|
}, "xxxx", true);
|
345 |
0ecfd682
|
Andreas Müller
|
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
}
|