Project

General

Profile

Download (2.8 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.api.service;
2

    
3
import static org.junit.Assert.assertNotNull;
4
import static org.junit.Assert.assertNull;
5

    
6
import java.io.FileNotFoundException;
7
import java.util.UUID;
8

    
9
import org.junit.Assert;
10
import org.junit.Test;
11
import org.unitils.spring.annotation.SpringBeanByType;
12

    
13
import eu.etaxonomy.cdm.model.description.PolytomousKey;
14
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
15
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
16

    
17
public class PolytomousKeyNodeServiceTest extends CdmIntegrationTest{
18

    
19
	@SpringBeanByType
20
	IPolytomousKeyNodeService service;
21

    
22
	@SpringBeanByType
23
	IPolytomousKeyService keyService;
24

    
25
	/****************** TESTS *****************************/
26

    
27
	/**
28
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#setDao(eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao)}.
29
	 */
30
	@Test
31
	public final void testSetDao() {
32
		Assert.assertNotNull(service);
33
		Assert.assertNotNull(keyService);
34
	}
35

    
36
	@Test
37
    //@DataSet(value="CommonServiceImplTest.xml")
38
    public final void testDelete(){
39

    
40
        PolytomousKey key = PolytomousKey.NewTitledInstance("TestPolytomousKey");
41
        UUID uuidKey =  keyService.save(key).getUuid();
42
        PolytomousKeyNode node = PolytomousKeyNode.NewInstance("Test statement");
43
        key.setRoot(node);
44
        key.setStartNumber(0);
45

    
46
        PolytomousKeyNode child = PolytomousKeyNode.NewInstance("Test statement Nr 2");
47
        //child.setKey(key);
48

    
49
        node.addChild(child,0);
50
        UUID uuidNode = service.save(node).getUuid();
51

    
52
        PolytomousKeyNode child1 = PolytomousKeyNode.NewInstance("Test statement Nr 3");
53
        //child.setKey(key);
54

    
55
        child.addChild(child1,0);
56
        UUID uuidChild = service.save(child).getUuid();
57

    
58
        PolytomousKeyNode child2 = PolytomousKeyNode.NewInstance("Test statement Nr 4");
59
        //child.setKey(key);
60

    
61
        child1.addChild(child2,0);
62
        UUID uuidChild1 = service.save(child1).getUuid();
63

    
64

    
65
        node = service.load(uuidChild1);
66
        UUID uuidChild2 = node.getChildAt(0).getUuid();
67
        assertNotNull(node);
68
        service.delete(uuidChild1, false);
69
        node = service.load(uuidChild1);
70
        assertNull(node);
71
        node = service.load(uuidChild2);
72
        assertNotNull(node);
73

    
74
        node = service.load(uuidChild);
75

    
76
        assertNotNull(node);
77
        service.delete(uuidChild, true);
78
        node = service.load(uuidChild);
79
        assertNull(node);
80
        node = service.load(uuidChild2);
81
        assertNull(node);
82

    
83
    }
84

    
85
    /* (non-Javadoc)
86
     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
87
     */
88
    @Override
89
    public void createTestDataSet() throws FileNotFoundException {
90
        // TODO Auto-generated method stub
91

    
92
    }
93

    
94
}
(18-18/38)