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