Revision 8b7fdba9
Added by Andreas Müller about 3 years ago
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmGenericDaoImplTest.java | ||
---|---|---|
158 | 158 |
import eu.etaxonomy.cdm.persistence.dao.occurrence.IOccurrenceDao; |
159 | 159 |
import eu.etaxonomy.cdm.persistence.dao.reference.IReferenceDao; |
160 | 160 |
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao; |
161 |
import eu.etaxonomy.cdm.persistence.dto.ReferencingObjectDto; |
|
161 | 162 |
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy; |
162 | 163 |
import eu.etaxonomy.cdm.strategy.match.IMatchStrategyEqual; |
163 | 164 |
import eu.etaxonomy.cdm.strategy.match.MatchException; |
... | ... | |
421 | 422 |
logger.info(debug); |
422 | 423 |
} |
423 | 424 |
|
425 |
|
|
426 |
//similar to testGetReferencingObjectsCdmBase but with DTO |
|
427 |
@Test |
|
428 |
@DataSets({ |
|
429 |
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"), |
|
430 |
@DataSet("/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")}) |
|
431 |
public void testGetReferencingObjectsDto() { |
|
432 |
|
|
433 |
IBotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()); |
|
434 |
name.setTitleCache("A name", true); |
|
435 |
Reference ref1 = ReferenceFactory.newArticle(); |
|
436 |
Taxon taxon = Taxon.NewInstance(name, ref1); |
|
437 |
Person author = Person.NewInstance(); |
|
438 |
author.setTitleCache("Author", true); |
|
439 |
ref1.addAnnotation(Annotation.NewInstance("A1", Language.DEFAULT())); |
|
440 |
ref1.setAuthorship(author); |
|
441 |
name.setCombinationAuthorship(author); |
|
442 |
name.setBasionymAuthorship(author); //to test deduplication |
|
443 |
|
|
444 |
name.setNomenclaturalReference(ref1); |
|
445 |
|
|
446 |
taxonDao.save(taxon); |
|
447 |
// UUID uuid = UUID.fromString("613980ac-9bd5-43b9-a374-d71e1794688f"); |
|
448 |
// Reference ref1 = referenceService.findByUuid(uuid); |
|
449 |
commitAndStartNewTransaction(null); |
|
450 |
|
|
451 |
int i = 1; |
|
452 |
Set<ReferencingObjectDto> referencedObjects = cdmGenericDao.getReferencingObjectsDto(ref1); |
|
453 |
String debug = "############## RESULT for ref1 ###################\n"; |
|
454 |
for (ReferencingObjectDto dto: referencedObjects){ |
|
455 |
debug += "Object"+ i++ +": " + dto.getType().getSimpleName() + " - " + dto + "\n"; |
|
456 |
} |
|
457 |
//was 3 before bidirectionality was removed for supplemental data |
|
458 |
assertEquals(2, referencedObjects.size()); |
|
459 |
debug += "############## END ###################\n"; |
|
460 |
|
|
461 |
// UUID uuidAuthor = UUID.fromString("4ce66544-a5a3-4601-ab0b-1f0a1338327b"); |
|
462 |
// AgentBase author = agentService.findByUuid(uuidAuthor); |
|
463 |
|
|
464 |
referencedObjects = cdmGenericDao.getReferencingObjectsDto(author); |
|
465 |
i = 1; |
|
466 |
debug += "############## RESULT for author ###################\n"; |
|
467 |
for (ReferencingObjectDto dto: referencedObjects){ |
|
468 |
debug += "Object"+ i++ +": " + dto.getType().getSimpleName() + " - " + dto + "\n"; |
|
469 |
} |
|
470 |
assertEquals("The both taxon names should be dedulicated", 2, referencedObjects.size()); |
|
471 |
debug += "############## END ###################\n"; |
|
472 |
logger.warn(debug); |
|
473 |
} |
|
474 |
|
|
424 | 475 |
/** |
425 | 476 |
* 2nd test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmGenericDaoImpl#getReferencingObjects(CdmBase)}. |
426 | 477 |
*/ |
Also available in: Unified diff
ref #9541 DTOs for referencing objects and server side initialization