Commit c77bdd6c authored by Matija Obreza's avatar Matija Obreza

Fixed 'nothosubsp.' for subspecific hybrids

parent 71232b8f
......@@ -35,6 +35,7 @@ import com.opencsv.bean.CsvBind;
public class SpeciesRow implements Serializable {
private static final String PREFIX_SUBSPECIES = "subsp. ";
private static final String PREFIX_NOTHOSUBSPECIES = "nothosubsp. ";
private static final String PREFIX_VARIETY = "var. ";
private static final String PREFIX_SUBVARIETY = "subvar. ";
private static final String PREFIX_FORMA = "f.";
......@@ -1103,6 +1104,9 @@ public class SpeciesRow implements Serializable {
return PREFIX_VARIETY + varietyName;
}
if (subspeciesName != null) {
if (subspecificHybrid) {
return PREFIX_NOTHOSUBSPECIES + subspeciesName;
}
return PREFIX_SUBSPECIES + subspeciesName;
}
return null;
......
......@@ -21,6 +21,7 @@ import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.genesys.taxonomy.checker.BestScore;
import org.genesys.taxonomy.checker.InMemoryTaxonomyDatabase;
import org.genesys.taxonomy.checker.StringSimilarity;
......@@ -46,6 +47,40 @@ public class TaxonomyCheckerTest extends DatabaseTest {
CHECKER = null;
}
@Test
public void testMedicago_sativa() {
for (SpeciesRow speciesRow : DATABASE.listSpecies("Medicago", "sativa", 1000)) {
// System.err.println(speciesRow);
// System.err.println(speciesRow.getName() + " -> " + speciesRow.getSubtaxa());
String ourName = "Medicago " + speciesRow.getSpeciesName();
if (StringUtils.isNotBlank(speciesRow.getSubtaxa())) {
ourName += " " + speciesRow.getSubtaxa();
}
assertThat(speciesRow.getName(), equalTo(ourName));
if (speciesRow.getSubspeciesName() != null && speciesRow.getSubspeciesName().equals("tunetana")) {
assertThat(speciesRow.getSubtaxa(), equalTo("nothosubsp. tunetana"));
}
}
assertThat(DATABASE.containsSubtaxa("Medicago", "sativa", "nothosubsp. tunetana"), equalTo(true));
assertThat(DATABASE.containsSubtaxa("Medicago", "sativa", "subsp. tunetana"), equalTo(false));
}
@Test
public void testPisum_sativum() {
for (SpeciesRow speciesRow : DATABASE.listSpecies("Pisum", "sativum", 1000)) {
System.err.println(speciesRow);
// System.err.println(speciesRow.getName() + " -> " + speciesRow.getSubtaxa());
String ourName = "Pisum " + speciesRow.getSpeciesName();
if (StringUtils.isNotBlank(speciesRow.getSubtaxa())) {
ourName += " " + speciesRow.getSubtaxa();
}
assertThat(speciesRow.getName(), equalTo(ourName));
if (speciesRow.getSubspeciesName() != null && speciesRow.getSubspeciesName().equals("elatius")) {
System.err.println(speciesRow);
}
}
}
@Test
public void testCucumisMeloConomon() {
if (CHECKER == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment