Search in sources :

Example 31 with ExpectedDataSet

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();
}
Also used : IBotanicalName(eu.etaxonomy.cdm.model.name.IBotanicalName) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) SpecimenTypeDesignation(eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) Test(org.junit.Test) ExpectedDataSet(org.unitils.dbunit.annotation.ExpectedDataSet)

Example 32 with ExpectedDataSet

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"
// });
}
Also used : TypeDesignationBase(eu.etaxonomy.cdm.model.name.TypeDesignationBase) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) SpecimenTypeDesignation(eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) Test(org.junit.Test) ExpectedDataSet(org.unitils.dbunit.annotation.ExpectedDataSet) DataSet(org.unitils.dbunit.annotation.DataSet) ExpectedDataSet(org.unitils.dbunit.annotation.ExpectedDataSet)

Aggregations

Test (org.junit.Test)32 ExpectedDataSet (org.unitils.dbunit.annotation.ExpectedDataSet)32 CdmTransactionalIntegrationTest (eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest)26 DataSet (org.unitils.dbunit.annotation.DataSet)25 Person (eu.etaxonomy.cdm.model.agent.Person)8 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)6 EntityValidation (eu.etaxonomy.cdm.model.validation.EntityValidation)6 CdmIntegrationTest (eu.etaxonomy.cdm.test.integration.CdmIntegrationTest)6 TextData (eu.etaxonomy.cdm.model.description.TextData)5 SpecimenTypeDesignation (eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation)5 Employee (eu.etaxonomy.cdm.persistence.validation.Employee)5 DateTime (org.joda.time.DateTime)5 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)4 EntityConstraintViolation (eu.etaxonomy.cdm.model.validation.EntityConstraintViolation)4 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)3 FileNotFoundException (java.io.FileNotFoundException)3 HashSet (java.util.HashSet)3 Language (eu.etaxonomy.cdm.model.common.Language)2 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)2 Media (eu.etaxonomy.cdm.model.media.Media)2