fix #7795 untilis xml DataSets can optionally be created without "[NULL]" values
[cdmlib.git] / cdmlib-test / src / main / java / eu / etaxonomy / cdm / test / integration / CdmTransactionalIntegrationTestExample.java
1 /**
2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.cdm.test.integration;
10
11 import java.io.FileNotFoundException;
12 import java.util.UUID;
13
14 import org.unitils.dbunit.annotation.DataSet;
15
16 import eu.etaxonomy.cdm.model.reference.Reference;
17 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
18 import eu.etaxonomy.cdm.model.taxon.Classification;
19 import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
20
21 /**
22 * This is only an example for am implementation of the {@link CdmTransactionalIntegrationTest}
23 * which is never meant to be executed.
24 *
25 * @author a.kohlbecker
26 * @since Jun 15, 2015
27 *
28 */
29 public class CdmTransactionalIntegrationTestExample extends CdmTransactionalIntegrationTest {
30
31 // @SpringBeanByType
32 // private ITaxonDao taxonDao;
33 // @SpringBeanByType
34 // private IClassificationDao classificationDao;
35 // @SpringBeanByType
36 // private IReferenceDao referenceDao;
37
38 private static final String CLASSIFICATION_UUID = "2a5ceebb-4830-4524-b330-78461bf8cb6b";
39
40 /**
41 * This is an example implementation for {@link CdmTransactionalIntegrationTest#createTestDataSet()}:
42 *
43 * {@inheritDoc}
44 */
45 @Override
46 // @Test // uncomment to write out the test data xml file for this test class
47 @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
48 public final void createTestDataSet() throws FileNotFoundException {
49
50 // 1. create the entities and save them
51 Classification europeanAbiesClassification = Classification.NewInstance("European Abies");
52 europeanAbiesClassification.setUuid(UUID.fromString(CLASSIFICATION_UUID));
53 // classificationDao.save(europeanAbiesClassification);
54
55 Reference sec = ReferenceFactory.newBook();
56 sec.setTitleCache("Kohlbecker, A., Testcase standart views, 2013", true);
57 Reference sec_sensu = ReferenceFactory.newBook();
58 sec_sensu.setTitleCache("Komarov, V. L., Flora SSSR 29", true);
59 // referenceDao.save(sec);
60 // referenceDao.save(sec_sensu);
61
62 // 2. end the transaction so that all data is actually written to the db
63 setComplete();
64 endTransaction();
65
66 // use the fileNameAppendix if you are creating a data set file which need to be named differently
67 // from the standard name. For example if a single test method needs different data then the other
68 // methods the test class you may want to set the fileNameAppendix when creating the data for this method.
69 String fileNameAppendix = null;
70
71 // 3.
72 writeDbUnitDataSetFile(new String[] {
73 "TAXONBASE", "TAXONNAME",
74 "TAXONRELATIONSHIP",
75 "REFERENCE",
76 "AGENTBASE", "HOMOTYPICALGROUP",
77 "CLASSIFICATION", "TAXONNODE",
78 "HIBERNATE_SEQUENCES" // IMPORTANT!!!
79 },
80 fileNameAppendix, true );
81 }
82
83 }