Search in sources :

Example 1 with ExpectedDataSet

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

Example 2 with ExpectedDataSet

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" });
}
Also used : Proxy(javassist.util.proxy.Proxy) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) Classification(eu.etaxonomy.cdm.model.taxon.Classification) 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)

Example 3 with ExpectedDataSet

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"});
}
Also used : LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) State(eu.etaxonomy.cdm.model.description.State) CategoricalData(eu.etaxonomy.cdm.model.description.CategoricalData) UUID(java.util.UUID) StateData(eu.etaxonomy.cdm.model.description.StateData) DefinedTerm(eu.etaxonomy.cdm.model.term.DefinedTerm) 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)

Example 4 with ExpectedDataSet

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);
    }
}
Also used : Language(eu.etaxonomy.cdm.model.common.Language) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) TextData(eu.etaxonomy.cdm.model.description.TextData) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) FileNotFoundException(java.io.FileNotFoundException) 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)

Example 5 with ExpectedDataSet

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);
    }
}
Also used : Language(eu.etaxonomy.cdm.model.common.Language) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) TextData(eu.etaxonomy.cdm.model.description.TextData) FileNotFoundException(java.io.FileNotFoundException) 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