Search in sources :

Example 26 with ExpectedDataSet

use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.

the class TaxonNodeDaoHibernateImplTest method testSortindexForJavassist.

@Test
@DataSet(value = "TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml")
@ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml")
public // test if TaxonNode.remove(index) works correctly with proxies
void testSortindexForJavassist() {
    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 firstTopLevelTaxon = (Taxon) taxonDao.findByUuid(UUID.fromString("7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331"));
    Classification classification = classificationDao.findByUuid(ClassificationUuid);
    TaxonNode childNode = classification.addParentChild(taxonWithLazyLoadedParentNodeOnTopLevel, firstTopLevelTaxon, null, null);
    this.taxonNodeDao.saveOrUpdate(childNode);
    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 27 with ExpectedDataSet

use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.

the class DescriptionElementDaoHibernateImplTest method testRemoveLanguageString.

/**
 * See #2114
 */
@Test
// (value="DescriptionElementDaoHibernateImplTest.xml")
@DataSet
@ExpectedDataSet
public void testRemoveLanguageString() {
    // test write
    TextData textDataTwo = (TextData) descriptionElementDao.findByUuid(uuidDobuleTextData);
    Assert.assertEquals("There should be exactly 2 languageText in the multilanguageText", 2, textDataTwo.size());
    Assert.assertTrue("The language should be English", textDataTwo.containsKey(Language.ENGLISH()));
    textDataTwo.removeText(Language.ENGLISH());
    Assert.assertEquals("There should be only 1 language left", 1, textDataTwo.size());
    descriptionElementDao.saveOrUpdate(textDataTwo);
    setComplete();
    endTransaction();
    try {
        if (printDatasets) {
            printDataSet(System.out, new String[] { "LanguageString", "DescriptionElementBase", "DESCRIPTIONELEMENTBASE_LANGUAGESTRING" });
        }
    } catch (Exception e) {
        logger.warn(e);
    }
}
Also used : 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)

Example 28 with ExpectedDataSet

use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.

the class AgentDaoImplTest method testSave.

@Test
@DataSet("AgentDaoImplTest.testSave.xml")
@ExpectedDataSet
public void testSave() {
    Person person = Person.NewInstance();
    person.setGivenName("ben");
    agentDao.save(person);
    commit();
}
Also used : Person(eu.etaxonomy.cdm.model.agent.Person) 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 29 with ExpectedDataSet

use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.

the class AgentDaoImplTest method testUpdate.

@Test
@DataSet
@ExpectedDataSet
public void testUpdate() {
    Person person = (Person) agentDao.findByUuid(personUuid);
    assert person != null : "person must exist";
    person.setGivenName("Benjamin");
    agentDao.update(person);
    // commitAndStartNewTransaction(new String[]{"AGENTBASE_AUD","AGENTBASE"});
    commit();
}
Also used : Person(eu.etaxonomy.cdm.model.agent.Person) 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 30 with ExpectedDataSet

use of org.unitils.dbunit.annotation.ExpectedDataSet in project cdmlib by cybertaxonomy.

the class TypeDesignationDaoHibernateImplTest method testSaveTypeDesignationsBidirectionalCascade.

@Test
@ExpectedDataSet
public void testSaveTypeDesignationsBidirectionalCascade() {
    SpecimenTypeDesignation desig1 = SpecimenTypeDesignation.NewInstance();
    desig1.setUuid(UUID.fromString("a1b8af89-b724-469b-b0ce-027c2199aadd"));
    TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
    name.setUuid(UUID.fromString("503d78dc-5d4c-4eb6-b682-0ab90fdee02c"));
    name.setTitleCache("Name saved via cascade", true);
    name.addTypeDesignation(desig1, false);
    typeDesignationDao.saveOrUpdate(desig1);
    commit();
}
Also used : 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)

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