Project

General

Profile

Revision 404c44e6

ID404c44e63de05551ff8a884732c944fd041e79a2
Parent 8f006e1e
Child bc14dee7

Added by Andreas Müller almost 4 years ago

ref #7175 add test for DwcA Export if includeUnpublished works

View differences:

cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/dwca/out/DwcaExportTest.java
52 52
 *
53 53
 */
54 54
public class DwcaExportTest  extends CdmTransactionalIntegrationTest{
55

  
55 56
    @SuppressWarnings("unused")
56 57
    private static final Logger logger = Logger.getLogger(DwcaExportTest.class);
57 58

  
59
    private static final UUID UUID_SUBSPEC_NODE = UUID.fromString("f8c9933a-fe3a-42ce-8a92-000e27bfdfac");
60
    private static final String UUID_UNPUBLISHED_TAXON = "e5cdc392-4e0b-49ad-84e9-8c4b22d1827c";
61

  
62

  
58 63
    @SpringBeanByName
59 64
    private CdmApplicationAwareDefaultExport<DwcaTaxExportConfigurator> defaultExport;
60 65

  
......
72 77
        DwcaTaxExportConfigurator config = DwcaTaxExportConfigurator.NewInstance(null, destinationFolder, null);
73 78
        config.setTarget(TARGET.EXPORT_DATA);
74 79
        ExportResult result = defaultExport.invoke(config);
75
        System.out.println(result.createReport());
80
//        System.out.println(result.createReport());
76 81
        ExportDataWrapper<?> exportData = result.getExportData();
77 82
        @SuppressWarnings("unchecked")
78 83
        Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
......
113 118
        createFullTestDataSet();
114 119
        File destinationFolder = null;
115 120
        DwcaTaxExportConfigurator config = DwcaTaxExportConfigurator.NewInstance(null, destinationFolder, null);
116
        config.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(UUID.fromString("f8c9933a-fe3a-42ce-8a92-000e27bfdfac")));
121
        config.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(UUID_SUBSPEC_NODE));
117 122
        config.setTarget(TARGET.EXPORT_DATA);
118 123
        ExportResult result = defaultExport.invoke(config);
119 124
        System.out.println(result.createReport());
......
219 224
        Assert.assertNotNull("Core must not be null", core);
220 225
        String coreStr = new String(core);
221 226
        String expected =  "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"f983cc5e-4c77-4c80-8cb0-73d43df31ee9\",\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"3f52e136-f2e1-4f9a-9010-2f35908fbd39\",\"Genus species Mill.\",\"Species\",\"accepted\"";
222
//        System.out.println(coreStr);
227
        System.out.println(coreStr);
223 228
        Assert.assertTrue(coreStr.contains(expected));
224 229
        String expectedClassification = "\"Family|Genus|Genus species\"";
225 230
        Assert.assertTrue(coreStr.contains(expectedClassification));
231
        Assert.assertFalse(coreStr.contains(UUID_UNPUBLISHED_TAXON));
226 232

  
227 233

  
228 234
        //reference
......
244 250

  
245 251
    }
246 252

  
253
    @Test
254
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/BlankDataSet.xml")
255
    public void testUnpublished(){
256
        createFullTestDataSet();
257
        File destinationFolder = null;
258
        DwcaTaxExportConfigurator config = DwcaTaxExportConfigurator.NewInstance(null, destinationFolder, null);
259
        config.setTarget(TARGET.EXPORT_DATA);
260
        config.getTaxonNodeFilter().setIncludeUnpublished(true);
261
        ExportResult result = defaultExport.invoke(config);
262

  
263
        //core
264
        ExportDataWrapper<?> exportData = result.getExportData();
265
        @SuppressWarnings("unchecked")
266
        Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
267
        byte[] core = data.get(DwcaTaxExportFile.TAXON.getTableName());
268
        Assert.assertNotNull("Core must not be null", core);
269
        String coreStr = new String(core);
270
        String expected =  "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
271
        Assert.assertTrue(coreStr.contains(expected));
272

  
273
        Assert.assertTrue(coreStr.contains(UUID_UNPUBLISHED_TAXON));
274
    }
275

  
247 276
    /**
248 277
     * {@inheritDoc}
249 278
     */
......
257 286
        setUuid(classification, "4096df99-7274-421e-8843-211b603d832e");
258 287

  
259 288
        NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
289

  
290
        //family
260 291
        TaxonName familyName = parser.parseReferencedName("Family L., Sp. Pl. 3: 22. 1752",
261 292
                NomenclaturalCode.ICNAFP, Rank.FAMILY());
262 293
        setUuid(familyName,"e983cc5e-4c77-4c80-8cb0-73d43df31ef7");
......
267 298
        setUuid(node1, "0fae5ad5-ffa2-4100-bcd7-8aa9dda0aebc");
268 299
        nodesToSave.add(node1);
269 300

  
301
        //genus
270 302
        TaxonName genusName = parser.parseReferencedName("Genus Humb., The book of botany 3: 22. 1804",
271 303
                NomenclaturalCode.ICNAFP, Rank.GENUS());
272 304
        setUuid(genusName,"5e83cc5e-4c77-4d80-8cb0-73d63df35ee3");
......
278 310
        setUuid(node2, "43ca733b-fe3a-42ce-8a92-000e27badf44");
279 311
        nodesToSave.add(node2);
280 312

  
281

  
313
        //species
282 314
        TaxonName speciesName = parser.parseReferencedName("Genus species Mill., The book of botany 3: 22. 1804",
283 315
                NomenclaturalCode.ICNAFP, Rank.SPECIES());
284 316
        setUuid(speciesName,"f983cc5e-4c77-4c80-8cb0-73d43df31ee9");
......
290 322
        setUuid(node3, "a0c9733a-fe3a-42ce-8a92-000e27bfdfa3");
291 323
        nodesToSave.add(node3);
292 324

  
325
        //subspecies
293 326
        TaxonName subspeciesName = parser.parseReferencedName("Genus species subsp. subspec Mill., The book of botany 3: 22. 1804",
294 327
                NomenclaturalCode.ICNAFP, Rank.SUBSPECIES());
295 328
        setUuid(subspeciesName,"3483cc5e-4c77-4c80-8cb0-73d43df31ee3");
......
298 331
        Taxon subspecies = Taxon.NewInstance(subspeciesName, sec1);
299 332
        setUuid(subspecies, "b2c86698-500e-4efb-b9ae-6bb6e701d4bc");
300 333
        TaxonNode node4 = node3.addChildTaxon(subspecies, sec1, "33");
301
        setUuid(node4, "f8c9933a-fe3a-42ce-8a92-000e27bfdfac");
334
        node4.setUuid(UUID_SUBSPEC_NODE);
302 335
        nodesToSave.add(node4);
303 336

  
337
        //unpublished
338
        TaxonName unpublishedName = parser.parseReferencedName("Genus species subsp. unpublish Mill., The book of botany 3: 22. 1804",
339
                NomenclaturalCode.ICNAFP, Rank.SUBSPECIES());
340
        setUuid(unpublishedName,"ebcf6bb6-6da8-46fe-9c22-127aa4cb9549");
341
        setUuid((Reference)unpublishedName.getNomenclaturalReference(), "51725dbd-e4a1-43ea-8363-fe8eb1152a49");
342

  
343
        Taxon unpublishedSpecies = Taxon.NewInstance(unpublishedName, sec1);
344
        unpublishedSpecies.setPublish(false);
345
        setUuid(unpublishedSpecies, UUID_UNPUBLISHED_TAXON);
346
        TaxonNode nodeUnpublished = node3.addChildTaxon(unpublishedSpecies, sec1, "34");
347
        setUuid(nodeUnpublished, "01368584-b626-4255-9dc4-ff011d44f493");
348
        nodesToSave.add(nodeUnpublished);
349

  
304 350
        classificationService.save(classification);
305 351
        taxonNodeService.save(nodesToSave);
306 352

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)