use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class TypeDesignationDaoHibernateImplTest method testSaveTypeDesignationsCascadeFromSpecimen.
@Test
@ExpectedDataSet
public // test save from specimen to name via type designation
void testSaveTypeDesignationsCascadeFromSpecimen() {
IBotanicalName name1 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
name1.setTitleCache("Name1", true);
name1.setUuid(UUID.fromString("7ce3a355-8f7c-4417-a0b3-41869de4f60b"));
SpecimenTypeDesignation desig1 = SpecimenTypeDesignation.NewInstance();
desig1.setUuid(UUID.fromString("c0e03472-b9f9-4886-b3bd-c1c70dd21a5f"));
name1.addTypeDesignation(desig1, true);
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance();
specimen.setUuid(UUID.fromString("4c3231a9-336e-4b21-acf2-129683627de4"));
specimen.setTitleCache("Specimen to cascade", true);
desig1.setTypeSpecimen(specimen);
occurrenceDao.saveOrUpdate(specimen);
commit();
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class TypeDesignationDaoHibernateImplTest method testSaveTypeDesignations.
@Test
@DataSet
// not yet necessary with current test
@ExpectedDataSet
public void testSaveTypeDesignations() {
List<TypeDesignationBase<?>> typeDesignations = typeDesignationDao.getAllTypeDesignations(100, 0);
assertEquals(typeDesignations.size(), 2);
SpecimenTypeDesignation specTypeDesig = null;
for (TypeDesignationBase<?> typeDesignation : typeDesignations) {
if (typeDesignation.isInstanceOf(SpecimenTypeDesignation.class)) {
specTypeDesig = CdmBase.deproxy(typeDesignation, SpecimenTypeDesignation.class);
}
}
TaxonName newName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
newName.setUuid(UUID.fromString("c16c3bc5-d3d0-4676-91a1-848ebf011e7c"));
newName.setTitleCache("Name used as typified name", true);
newName.addTypeDesignation(specTypeDesig, false);
nameDao.saveOrUpdate(newName);
// typeDesignationDao.saveOrUpdate(specTypeDesig);
commitAndStartNewTransaction(null);
specTypeDesig = (SpecimenTypeDesignation) typeDesignationDao.load(specTypeDesig.getUuid());
Assert.assertNotNull("specimen type designation should exists in db", specTypeDesig);
specTypeDesig.getTypifiedNames().size();
Set<TaxonName> typifiedNames = specTypeDesig.getTypifiedNames();
Assert.assertEquals("There should be 2 typified names for this type designation now", 2, typifiedNames.size());
// printDataSet(System.out, new String[]{"TaxonName","TaxonName_AUD",
// "HomotypicalGroup","HomotypicalGroup_AUD",
// "TypeDesignationBase","TypeDesignationBase_AUD",
// "TaxonName_TypeDesignationBase", "TaxonName_TypeDesignationBase_AUD"
// });
}
Aggregations