Project

General

Profile

Download (3.1 KB) Statistics
| Branch: | Tag: | Revision:
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.vaadin.presenter;
11

    
12
import java.util.UUID;
13

    
14
import org.apache.log4j.Logger;
15
import org.json.JSONException;
16
import org.junit.Assert;
17
import org.junit.BeforeClass;
18
import org.junit.Test;
19
import org.unitils.dbunit.annotation.DataSet;
20

    
21
import eu.etaxonomy.cdm.vaadin.CdmVaadinBaseTest;
22
import eu.etaxonomy.cdm.vaadin.container.IdUuidName;
23
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree;
24
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
25

    
26
/**
27
 * @author cmathew
28
 * @date 9 Apr 2015
29
 *
30
 */
31
@DataSet
32
public class ConceptRelationshipPresenterTest extends CdmVaadinBaseTest {
33

    
34
    private static final Logger logger = Logger.getLogger(ConceptRelationshipPresenterTest.class);
35

    
36
    private static ConceptRelationshipPresenter crp;
37
    private static D3ConceptRelationshipTree crTree;
38

    
39
    @BeforeClass
40
    public static void init() {
41
        crTree = new D3ConceptRelationshipTree();
42
        crp = new ConceptRelationshipPresenter(crTree);
43
    }
44

    
45

    
46
    @Test
47
    public void testRefreshRelationshipView() throws JSONException {
48
        UUID taxonUuid = UUID.fromString("5f713f69-e03e-4a11-8a55-700fbbf44805");
49
        crp.refreshRelationshipView(new IdUuidName(30, taxonUuid, null), Direction.LEFT_RIGHT);
50
        String expected = "{\"direction\":\"left-right\",\"name\":\"Taxon d\",\"children\":[{\"name\":\"Congruent to\",\"children\":[{\"name\":\"Taxon e\",\"uuid\":\"84e99e24-f50a-4726-92d0-6088430c492a\",\"type\":\"taxon\"}],\"uuid\":\"511f504b-ae3b-4f04-b7b9-35c222f06e10\",\"type\":\"conceptr\"},{\"name\":\"Includes\",\"children\":[{\"name\":\"Taxon a\",\"uuid\":\"eaac797e-cac7-4649-97cf-c7b580076895\",\"type\":\"taxon\"}],\"uuid\":\"0e8b7922-974d-4389-b71e-af6fc9f98c56\",\"type\":\"conceptr\"},{\"name\":\"Includes\",\"children\":[{\"name\":\"Taxon b\",\"uuid\":\"5004a8e7-b907-4744-b67e-44ccb057ab3b\",\"type\":\"taxon\"}],\"uuid\":\"6fd9947e-21c3-4190-8748-57d9661e8659\",\"type\":\"conceptr\"},{\"name\":\"Excludes\",\"children\":[{\"name\":\"Taxon c\",\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\",\"type\":\"taxon\"}],\"uuid\":\"cc761030-38d2-4b5d-954d-32329c0ea106\",\"type\":\"conceptr\"}],\"uuid\":\"5f713f69-e03e-4a11-8a55-700fbbf44805\",\"type\":\"taxon\"}";
51
        logger.warn(crTree.getState().getConceptRelationshipTree());
52
        Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
53

    
54
        taxonUuid = UUID.fromString("3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9");
55
        crp.refreshRelationshipView(new IdUuidName(20, taxonUuid, null), Direction.RIGHT_LEFT);
56
        expected = "{\"direction\":\"right-left\",\"name\":\"Taxon c\",\"children\":[],\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\",\"type\":\"taxon\"}";
57
        logger.warn(crTree.getState().getConceptRelationshipTree());
58
        Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
59

    
60
    }
61

    
62

    
63
}
(2-2/5)