use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class TypeDesignationDaoHibernateImplTest method testSaveTypeDesignationsWithAuditing.
@Test
@ExpectedDataSet
public // Auditing didn't work for SpecimenTypeDesignations. See #2396
void testSaveTypeDesignationsWithAuditing() {
// creating new Typedesignation for a new Name:
// 1. new TaxonName with UUID 8564287e-9654-4b8b-a38c-0ccdd9e885db
TaxonName name1 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
name1.setTitleCache("Name1", true);
name1.setUuid(UUID.fromString("8564287e-9654-4b8b-a38c-0ccdd9e885db"));
// 2. new TypeDesignation with uuid ceca086e-e8d3-444e-abfb-c47f76835130
SpecimenTypeDesignation desig1 = SpecimenTypeDesignation.NewInstance();
desig1.setUuid(UUID.fromString("ceca086e-e8d3-444e-abfb-c47f76835130"));
// //REMOVE
// desig1.setOriginalNameString("orig");
//
name1.addTypeDesignation(desig1, true);
nameDao.saveOrUpdate(name1);
commitAndStartNewTransaction(new String[] { "TypeDesignationBase", "TypeDesignationBase_AUD" });
// System.out.println(desig1.getId());
// System.out.println(desig1.getUuid());
// printDataSet(System.err, new String[]{"TaxonName","TaxonName_AUD",
// "HomotypicalGroup","HomotypicalGroup_AUD",
// "TypeDesignationBase","TypeDesignationBase_AUD",
// "TaxonName_TypeDesignationBase","TaxonName_TypeDesignationBase_AUD"
// });
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class AgentDaoImplTest method testPersonTitleCache.
@Test
@ExpectedDataSet
public void testPersonTitleCache() {
Person person = Person.NewTitledInstance("");
person.setNomenclaturalTitle("Abbrev. tit.");
person.setUuid(UUID.fromString("ee7c3b99-bf23-43dc-a64b-d37d3c6ea414"));
agentDao.save(person);
commitAndStartNewTransaction(null);
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class AgentDaoImplTest method testDelete.
@Test
@DataSet("AgentDaoImplTest.testFind.xml")
@ExpectedDataSet
public void testDelete() throws Exception {
Person person = (Person) agentDao.findByUuid(personUuid);
agentDao.delete(person);
person = (Person) agentDao.findByUuid(personUuid);
Assert.assertNull(person);
commitAndStartNewTransaction(null);
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class CacheStrategyGeneratorTest method testOnSaveOrUpdateNames.
@Test
@DataSet("CacheStrategyGeneratorTest.xml")
@ExpectedDataSet
public void testOnSaveOrUpdateNames() {
// names
TaxonName name = cdmEntityDaoBase.findByUuid(UUID.fromString("a49a3963-c4ea-4047-8588-2f8f15352730"));
name.setTitleCache(null, false);
name.setNameCache(null, false);
name.setGenusOrUninomial("Abies");
name.setAuthorshipCache("Mill.", true);
cdmEntityDaoBase.saveOrUpdate(name);
TaxonName name2 = cdmEntityDaoBase.findByUuid(UUID.fromString("05a438d6-065f-49ef-84db-c7dc2c259975"));
name2.setProtectedFullTitleCache(false);
name2.setProtectedTitleCache(false);
name2.setProtectedNameCache(false);
name2.setGenusOrUninomial("Abies");
name2.setSpecificEpithet("alba");
name2.setAuthorshipCache("Mill.", true);
IBook ref = ReferenceFactory.newBook();
ref.setTitle("My Book");
name2.setNomenclaturalReference(ref);
name2.setNomenclaturalMicroReference("44");
cdmEntityDaoBase.saveOrUpdate(name2);
Assert.assertEquals(name, cdmEntityDaoBase.findByUuid(name.getUuid()));
IBotanicalName nameTest = cdmEntityDaoBase.findByUuid(name.getUuid());
Assert.assertEquals(name2, cdmEntityDaoBase.findByUuid(name2.getUuid()));
logger.debug("FulltitleCache: " + cdmEntityDaoBase.findByUuid(name2.getUuid()).getFullTitleCache());
logger.debug("updated: " + cdmEntityDaoBase.findByUuid(name2.getUuid()).getUpdated());
TaxonName name3 = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
name3.setFullTitleCache("Test: MyBook");
name3.setTitleCache("Test", true);
cdmEntityDaoBase.saveOrUpdate(name3);
List<TaxonName> taxa = cdmEntityDaoBase.findByTitle("Test");
TaxonName nameBase = taxa.get(0);
IBotanicalName botName = nameBase;
logger.debug("created " + botName.getCreated());
logger.debug("updated: " + botName.getUpdated());
// IBotanicalName name3 = (IBotanicalName)cdmEntityDaoBase.findByUuid(UUID.fromString("049a3963-c4ea-4047-8588-2f8f15352730"));
// printDataSet(System.err, new String[]{"TaxonName", "Reference"});
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class CdmDeleteListenerTest method testOnDelete.
@Test
@DataSet("CdmDeleteListenerTest.xml")
@ExpectedDataSet
public void testOnDelete() throws Exception {
TaxonName name = taxonNameDao.findByUuid(uuid);
/**
* Ended up with some horrible hibernate errors otherwise
*/
taxonNameDao.refresh(name, new LockOptions(LockMode.READ), null);
assertNotNull(name);
// int nRels = taxonDao.countAllRelationships(); //TODO needs fixing on test side or dao method side as it jumps into auditing
// Assert.assertEquals("There should be 2 relationships", 2, nRels);
Set<NameRelationship> relations = name.getNameRelations();
Assert.assertEquals("There must be 1 name relationship", 1, relations.size());
name.removeNameRelationship(relations.iterator().next());
Set<HybridRelationship> hybridRels = name.getHybridParentRelations();
Assert.assertEquals("There must be 1 parent relationship", 1, hybridRels.size());
taxonNameDao.saveOrUpdate(name);
setComplete();
endTransaction();
startNewTransaction();
// nRels = taxonDao.countAllRelationships();
// Assert.assertEquals("There should be 1 relationship now", 1, nRels);
}
Aggregations