use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method importCSVFile.
private SpeciesBackupImportJob importCSVFile(String fileName) throws Exception {
File file = getTestFile(fileName);
CollectTaxonomy taxonomy = new CollectTaxonomy();
taxonomy.setSurvey(survey);
taxonomy.setName(TEST_TAXONOMY_NAME);
speciesManager.save(taxonomy);
SpeciesBackupImportJob job = jobManager.createJob(SpeciesBackupImportJob.class);
job.setFile(file);
job.setSurvey(survey);
job.setTaxonomyName(TEST_TAXONOMY_NAME);
jobManager.start(job, false);
return job;
}
use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method testExport.
@Test
public void testExport() throws Exception {
SpeciesBackupImportJob job = importCSVFile(VALID_TEST_CSV);
assertTrue(job.isCompleted());
CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
assertNotNull(summaries);
}
use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method testSpeciesImport.
@Test
public void testSpeciesImport() throws Exception {
SpeciesBackupImportJob job = importCSVFile(VALID_TEST_CSV);
assertTrue(job.isCompleted());
SpeciesBackupImportTask task = (SpeciesBackupImportTask) job.getTasks().get(0);
assertTrue(task.getSkippedRows().isEmpty());
TaxonomyDefinition taxonomyDef = survey.getReferenceDataSchema().getTaxonomyDefinition(TEST_TAXONOMY_NAME);
assertEquals(Arrays.asList("info1", "info2"), taxonomyDef.getAttributeNames());
{
String code = "OLE/CAP/macrocarpa";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(code, "Olea capensis ssp. macrocarpa");
expected.setInfoAttributes(Arrays.asList("info_value_1", "info_value_2"));
expected.setTaxonRank(SUBSPECIES);
assertEquals(expected, occurrence);
}
{
String code = "ALB/ADI";
TaxonOccurrence occurrence = findByCode(code);
TaxonOccurrence expected = new TaxonOccurrence(code, "Albizia adianthifolia");
expected.setInfoAttributes(Arrays.asList("info_value_3", null));
expected.setTaxonRank(SPECIES);
assertEquals(expected, occurrence);
}
}
Aggregations