Revision c781c97b
Added by Katja Luther over 6 years ago
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/IdentifiableServiceBaseTest.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.api.service; |
11 | 11 |
|
12 | 12 |
import java.io.FileNotFoundException; |
13 |
import java.util.List; |
|
13 | 14 |
import java.util.UUID; |
14 | 15 |
|
15 | 16 |
import org.apache.log4j.Logger; |
... | ... | |
34 | 35 |
import eu.etaxonomy.cdm.model.name.Rank; |
35 | 36 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
36 | 37 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
38 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
37 | 39 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
38 | 40 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
39 | 41 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
40 | 42 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
41 | 43 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
42 | 44 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
45 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
43 | 46 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
44 | 47 |
import eu.etaxonomy.cdm.persistence.query.TaxonTitleType; |
45 | 48 |
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest; |
... | ... | |
66 | 69 |
@SpringBeanByType |
67 | 70 |
private ITaxonService taxonService; |
68 | 71 |
|
72 |
@SpringBeanByType |
|
73 |
private IReferenceService referenceService; |
|
74 |
|
|
69 | 75 |
@SpringBeanByType |
70 | 76 |
private IClassificationService classificationService; |
71 | 77 |
|
... | ... | |
106 | 112 |
IdentifiedEntityDTO<Taxon>.CdmEntity entity = taxonPager.getRecords().get(0).getCdmEntity(); |
107 | 113 |
Taxon taxon = entity.getEntity(); |
108 | 114 |
Assert.assertEquals(UUID.fromString("888cded1-cadc-48de-8629-e32927919879"), taxon.getUuid()); |
109 |
Assert.assertEquals(UUID.fromString("888cded1-cadc-48de-8629-e32927919879"), entity.getCdmUuid());
|
|
115 |
Assert.assertEquals(UUID.fromString("888cded1-cadc-48de-8629-e32927919879"), entity.getUuid()); |
|
110 | 116 |
Assert.assertEquals("Taxon should have 1 identifier", 1, taxon.getIdentifiers().size()); |
111 | 117 |
Identifier<?> identifier = taxon.getIdentifiers().get(0); |
112 | 118 |
DefinedTerm type = CdmBase.deproxy(identifier.getType(), DefinedTerm.class); |
... | ... | |
199 | 205 |
|
200 | 206 |
@Test |
201 | 207 |
@DataSet(value="IdentifiableServiceBaseTest.testFindByIdentifierOrMarker.xml") |
208 |
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") |
|
202 | 241 |
public final void testFindByMarker(){ |
203 | 242 |
//classification Filter |
204 | 243 |
Classification classification = classificationService.find(5000); |
Also available in: Unified diff
implement possibility to get cdmEntities by identifiers in dialogs