Search in sources :

Example 1 with TaxonNodeDtoByNameComparator

use of eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator in project cdmlib by cybertaxonomy.

the class TaxonNodeDtoByNameComparatorTest method testNullSave.

@Test
public void testNullSave() {
    Classification classification = Classification.NewInstance("Greuther, 1993");
    Reference sec = ReferenceFactory.newBook();
    IBotanicalName botname_1 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
    String nameCache_1 = "Epilobium \u00D7aschersonianum Hausskn.";
    botname_1.setNameCache(nameCache_1, true);
    Taxon taxon_1 = Taxon.NewInstance(botname_1, sec);
    IBotanicalName botname_2 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
    String nameCache_2 = "\u00D7Epilobium \u00D7angustifolium";
    botname_2.setNameCache(nameCache_2, true);
    Taxon taxon_2 = Taxon.NewInstance(botname_2, sec);
    TaxonNodeDto node1 = new TaxonNodeDto(classification.addChildTaxon(taxon_1, sec, null));
    TaxonNodeDto node2 = new TaxonNodeDto(classification.addChildTaxon(taxon_2, sec, null));
    TaxonNodeDtoByNameComparator taxonNodeByNameComparator = new TaxonNodeDtoByNameComparator();
    Assert.assertEquals(0, taxonNodeByNameComparator.compare(null, null));
    Assert.assertEquals(-1, taxonNodeByNameComparator.compare(node1, null));
    Assert.assertEquals(1, taxonNodeByNameComparator.compare(null, node1));
}
Also used : IBotanicalName(eu.etaxonomy.cdm.model.name.IBotanicalName) TaxonNodeDtoByNameComparator(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator) Reference(eu.etaxonomy.cdm.model.reference.Reference) Classification(eu.etaxonomy.cdm.model.taxon.Classification) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) TaxonNodeDto(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto) Test(org.junit.Test)

Aggregations

IBotanicalName (eu.etaxonomy.cdm.model.name.IBotanicalName)1 Reference (eu.etaxonomy.cdm.model.reference.Reference)1 Classification (eu.etaxonomy.cdm.model.taxon.Classification)1 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)1 TaxonNodeDto (eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto)1 TaxonNodeDtoByNameComparator (eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator)1 Test (org.junit.Test)1