use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class TaxonDaoHibernateImplTest method testDelete.
@Test
@DataSet
public // @ExpectedDataSet
void testDelete() {
Taxon taxon = (Taxon) taxonDao.findByUuid(acherontia);
assert taxon != null : "taxon must exist";
taxonDao.delete(taxon);
taxon = (Taxon) taxonDao.findByUuid(acherontia);
assert taxon == null : "taxon must not exist";
setComplete();
endTransaction();
// try {
// printDataSet(new FileOutputStream("test.xml"), TABLE_NAMES);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class TaxonNodeDaoHibernateImplTest method testSortindexForJavassist2.
@Test
@DataSet(value = "TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml")
@ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForJavassist2-result.xml")
public // test if TaxonNode.addNode(node) works correctly with proxies
void testSortindexForJavassist2() {
Taxon taxonWithLazyLoadedParentNodeOnTopLevel = (Taxon) taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"));
TaxonNode parent = taxonWithLazyLoadedParentNodeOnTopLevel.getTaxonNodes().iterator().next().getParent();
Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof Proxy);
Taxon newTaxon = Taxon.NewInstance(null, null);
Classification classification = classificationDao.findByUuid(ClassificationUuid);
TaxonNode newNode = classification.addChildTaxon(newTaxon, 0, null, null);
newNode.setUuid(UUID.fromString("58728644-1155-4520-98f7-309fdb62abd7"));
this.taxonNodeDao.saveOrUpdate(newNode);
commitAndStartNewTransaction(new String[] { "TaxonNode" });
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class DescriptionElementDaoHibernateImplTest method testSaveCategoricalData.
// test cascading for modifying text (and others)
@Test
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class)
@ExpectedDataSet(factory = MultiSchemaXmlDataSetFactory.class)
public void testSaveCategoricalData() {
UUID uuidDummyState = UUID.fromString("881b9c80-626d-47a6-b308-a63ee5f4178f");
State state = (State) termDao.findByUuid(uuidDummyState);
CategoricalData categoricalData = CategoricalData.NewInstance();
categoricalData.setUuid(UUID.fromString("5c3f2340-f675-4d50-af96-89a2a12993b8"));
categoricalData.setFeature(Feature.DESCRIPTION());
StateData stateData = StateData.NewInstance(state);
stateData.setUuid(UUID.fromString("04b9190d-d4ab-4c3a-8dec-8293dc820ddc"));
stateData.putModifyingText(Language.ENGLISH(), "test modifier");
LanguageString langString = stateData.getModifyingText().get(Language.ENGLISH());
langString.setUuid(UUID.fromString("53a91bd4-d758-47ec-a385-94799bdb9f32"));
categoricalData.addStateData(stateData);
DefinedTerm modifier = DefinedTerm.SEX_FEMALE();
System.out.println(modifier.getId());
stateData.addModifier(modifier);
descriptionElementDao.save(categoricalData);
commit();
// commitAndStartNewTransaction(new String[]{"Hibernate_sequences","DescriptionElementBase","DescriptionElementBase_StateData","StateData_DefinedTermBase", "StateData", "StateData_LanguageString", "LanguageString"});
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class DescriptionElementDaoHibernateImplTest method testPersistMultiLanguageString.
/**
* See #2114
*/
@Test
// (value="DescriptionElementDaoHibernateImplTest.xml")
@DataSet
@ExpectedDataSet
public void testPersistMultiLanguageString() {
// test write
TextData singleLanguageTextData = (TextData) descriptionElementDao.findByUuid(uuidSingleTextData);
Map<Language, LanguageString> multiLangText = singleLanguageTextData.getMultilanguageText();
Assert.assertEquals("There should be exactly 1 languageText in the multilanguageText", 1, multiLangText.size());
Assert.assertTrue("The language should be English", multiLangText.containsKey(Language.ENGLISH()));
singleLanguageTextData.putText(Language.GERMAN(), "Ein test auf deutsch");
Assert.assertEquals("There should be exactly 2 languageText in the multilanguageText", 2, singleLanguageTextData.size());
String germanText = singleLanguageTextData.getText(Language.GERMAN());
Assert.assertNotNull("German text should exist", germanText);
LanguageString germanLanguageText = singleLanguageTextData.getLanguageText(Language.GERMAN());
Assert.assertNotNull("German language text should exist", germanLanguageText);
singleLanguageTextData.putText(Language.ENGLISH(), singleLanguageTextData.getText(Language.ENGLISH()));
descriptionElementDao.saveOrUpdate(singleLanguageTextData);
setComplete();
endTransaction();
try {
if (printDatasets) {
printDataSet(System.out, new String[] { "LanguageString", "DescriptionElementBase", "DESCRIPTIONELEMENTBASE_LANGUAGESTRING" });
}
} catch (Exception e) {
logger.warn(e);
}
}
use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.
the class DescriptionElementDaoHibernateImplTest method testChangeLanguageString.
/**
* See #2114
*/
@Test
// (value="DescriptionElementDaoHibernateImplTest.xml")
@DataSet
@ExpectedDataSet
public void testChangeLanguageString() {
// test write
TextData singleLanguageTextData = (TextData) descriptionElementDao.findByUuid(uuidSingleTextData);
Map<Language, LanguageString> multiLangText = singleLanguageTextData.getMultilanguageText();
Assert.assertEquals("There should be exactly 1 languageText in the multilanguageText", 1, multiLangText.size());
Assert.assertTrue("The language should be English", multiLangText.containsKey(Language.ENGLISH()));
singleLanguageTextData.putText(Language.ENGLISH(), "A new English text");
descriptionElementDao.saveOrUpdate(singleLanguageTextData);
setComplete();
endTransaction();
try {
if (printDatasets) {
printDataSet(System.out, new String[] { "LanguageString", "DescriptionElementBase", "DESCRIPTIONELEMENTBASE_LANGUAGESTRING" });
}
} catch (Exception e) {
logger.warn(e);
}
}
Aggregations