cleanup
[cdmlib.git] / cdmlib-persistence / src / test / java / eu / etaxonomy / cdm / persistence / hibernate / Level2ValidationEventListenerTest.java
1 /**
2 * Copyright (C) 2007 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.persistence.hibernate;
10
11 import static org.junit.Assert.assertNotNull;
12
13 import java.io.FileNotFoundException;
14 import java.util.UUID;
15
16 import org.apache.logging.log4j.LogManager;
17 import org.apache.logging.log4j.Logger;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.springframework.security.authentication.AuthenticationManager;
21 import org.unitils.spring.annotation.SpringBeanByType;
22
23 import eu.etaxonomy.cdm.model.taxon.Taxon;
24 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25 import eu.etaxonomy.cdm.persistence.dao.permission.IUserDao;
26 import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
27 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
28
29 public class Level2ValidationEventListenerTest extends CdmTransactionalIntegrationTest {
30
31 private static final Logger logger = LogManager.getLogger();
32
33 private UUID uuid;
34 private TaxonBase<?> cdmBase;
35
36 @SpringBeanByType
37 private ITaxonDao cdmEntityDaoBase;
38
39 @SpringBeanByType
40 private AuthenticationManager authenticationManager;
41
42 @SpringBeanByType
43 private IUserDao userDao;
44
45 @Before
46 public void setUp() throws Exception {
47 logger.info("begin setUp()");
48 uuid = UUID.fromString("8d77c380-c76a-11dd-ad8b-0800200c9a66");
49 cdmBase = Taxon.NewInstance(null, null);
50 cdmBase.setUuid(UUID.fromString("e463b270-c76b-11dd-ad8b-0800200c9a66"));
51 logger.info("end setUp()");
52 }
53
54 /************ TESTS ********************************/
55
56 @Test
57 public void testCdmEntityDaoBase() throws Exception {
58 assertNotNull("cdmEntityDaoBase should exist", cdmEntityDaoBase);
59 }
60
61 //@Test
62 //@DataSet
63 //@ExpectedDataSet
64 public void testSaveOrUpdate(){
65 TaxonBase<?> cdmBase = cdmEntityDaoBase.findByUuid(uuid);
66 cdmBase.setDoubtful(true);
67 cdmEntityDaoBase.saveOrUpdate(cdmBase);
68 commit();
69 }
70
71 //@Test
72 //@DataSet
73 //@ExpectedDataSet
74 public void testSave() throws Exception{
75 cdmEntityDaoBase.save(cdmBase);
76 commit();
77 }
78
79 //@Test
80 //@DataSet
81 //@ExpectedDataSet
82 public void testUpdate(){
83 TaxonBase<?> cdmBase = cdmEntityDaoBase.findByUuid(uuid);
84 cdmBase.setDoubtful(true);
85 cdmEntityDaoBase.update(cdmBase);
86 commit();
87 }
88
89 //@Test
90 //@DataSet("CdmEntityDaoBaseTest.xml")
91 //@ExpectedDataSet
92 public void testDelete(){
93 TaxonBase<?> cdmBase = cdmEntityDaoBase.findByUuid(uuid);
94 assertNotNull(cdmBase);
95 cdmEntityDaoBase.delete(cdmBase);
96 }
97
98 @Override
99 public void createTestDataSet() throws FileNotFoundException {}
100 }