Search in sources :

Example 11 with ExpectedDataSet

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"
// });
}
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)

Example 12 with ExpectedDataSet

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);
}
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)

Example 13 with ExpectedDataSet

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);
}
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 14 with ExpectedDataSet

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"});
}
Also used : IBotanicalName(eu.etaxonomy.cdm.model.name.IBotanicalName) IBook(eu.etaxonomy.cdm.model.reference.IBook) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) 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 15 with ExpectedDataSet

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);
}
Also used : LockOptions(org.hibernate.LockOptions) NameRelationship(eu.etaxonomy.cdm.model.name.NameRelationship) HybridRelationship(eu.etaxonomy.cdm.model.name.HybridRelationship) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) 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