2 * Copyright (C) 2012 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.api
.application
;
11 import static org
.junit
.Assert
.assertEquals
;
13 import java
.io
.FileNotFoundException
;
14 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.junit
.Test
;
20 import org
.unitils
.dbunit
.annotation
.DataSet
;
21 import org
.unitils
.dbunit
.annotation
.ExpectedDataSet
;
22 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
25 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
26 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
27 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
28 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
29 import eu
.etaxonomy
.cdm
.api
.service
.TaxonServiceImplTest
;
30 import eu
.etaxonomy
.cdm
.datagenerator
.TaxonGenerator
;
31 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
34 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
37 * test for the {@link FirstDataInserter}
39 * @author a.kohlbecker
43 public class FirstDataInserterTest
extends CdmTransactionalIntegrationTest
{
45 private final String
[] tableNames
= new String
[]{"USERACCOUNT", "USERACCOUNT_GRANTEDAUTHORITYIMPL", "GRANTEDAUTHORITYIMPL", "CDMMETADATA"};
47 @SuppressWarnings("unused")
48 private static final Logger logger
= Logger
.getLogger(TaxonServiceImplTest
.class);
51 private ITaxonService taxonService
;
54 private INameService nameService
;
57 private IReferenceService referenceService
;
60 private IClassificationService classificationService
;
63 private IDescriptionService descriptionService
;
66 @DataSet(value
="FirstDataInserterTest.testBlankDB.xml")
67 @ExpectedDataSet(value
="FirstDataInserterTest.testBlankDB-result.xml")
68 public void testBlankDB(){
70 commitAndStartNewTransaction(null);
71 // printDataSet(System.err, tableNames);
75 @DataSet(value
="FirstDataInserterTest.testBlankDB.xml")
76 public void testInsertData(){
77 commitAndStartNewTransaction(null);
79 Taxon newTaxon
= TaxonGenerator
.getTestTaxon();
80 UUID taxonUUID
= taxonService
.save(newTaxon
).getUuid();
81 nameService
.save(newTaxon
.getName().getBasionyms());
82 List
<TaxonNode
> childNodes
= newTaxon
.getTaxonNodes().iterator().next().getChildNodes();
83 classificationService
.saveTaxonNodeAll(childNodes
);
84 taxonService
.saveOrUpdate(childNodes
.stream().filter(tn
->!tn
.getTaxon().getAllMisappliedNames().isEmpty()).findFirst().get().getTaxon().getAllMisappliedNames().iterator().next());
86 TaxonDescription description
= TaxonGenerator
.getTestDescription(1);
87 newTaxon
.addDescription(description
);
88 Set
<TaxonDescription
> descriptions
= newTaxon
.getDescriptions();
89 descriptionService
.save(description
);
92 newTaxon
= (Taxon
)taxonService
.find(taxonUUID
);
93 descriptions
= newTaxon
.getDescriptions();
94 assertEquals(2, descriptions
.size());
99 public void createTestDataSet() throws FileNotFoundException
{}