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.junit.Assert;
|
16
|
import org.junit.BeforeClass;
|
17
|
import org.junit.Test;
|
18
|
import org.unitils.dbunit.annotation.DataSet;
|
19
|
|
20
|
import eu.etaxonomy.cdm.vaadin.CdmVaadinBaseTest;
|
21
|
import eu.etaxonomy.cdm.vaadin.container.IdUuidName;
|
22
|
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree;
|
23
|
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
|
24
|
|
25
|
/**
|
26
|
* @author cmathew
|
27
|
* @date 9 Apr 2015
|
28
|
*
|
29
|
*/
|
30
|
@DataSet
|
31
|
public class ConceptRelationshipPresenterTest extends CdmVaadinBaseTest {
|
32
|
|
33
|
private static final Logger logger = Logger.getLogger(ConceptRelationshipPresenterTest.class);
|
34
|
|
35
|
private static ConceptRelationshipPresenter crp;
|
36
|
private static D3ConceptRelationshipTree crTree;
|
37
|
|
38
|
@BeforeClass
|
39
|
public static void init() {
|
40
|
crTree = new D3ConceptRelationshipTree();
|
41
|
crp = new ConceptRelationshipPresenter(crTree);
|
42
|
}
|
43
|
|
44
|
|
45
|
@Test
|
46
|
public void testRefreshRelationshipView() {
|
47
|
UUID taxonUuid = UUID.fromString("5f713f69-e03e-4a11-8a55-700fbbf44805");
|
48
|
crp.refreshRelationshipView(new IdUuidName(30, taxonUuid, null), Direction.LEFT_RIGHT);
|
49
|
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\"}";
|
50
|
logger.warn(crTree.getState().getConceptRelationshipTree());
|
51
|
Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
|
52
|
|
53
|
taxonUuid = UUID.fromString("3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9");
|
54
|
crp.refreshRelationshipView(new IdUuidName(20, taxonUuid, null), Direction.RIGHT_LEFT);
|
55
|
expected = "{\"direction\":\"right-left\",\"name\":\"Taxon c\",\"children\":[],\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\",\"type\":\"taxon\"}";
|
56
|
logger.warn(crTree.getState().getConceptRelationshipTree());
|
57
|
Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
|
58
|
|
59
|
}
|
60
|
|
61
|
|
62
|
}
|