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.jscomponent.D3ConceptRelationshipTree;
|
23
|
|
24
|
/**
|
25
|
* @author cmathew
|
26
|
* @date 9 Apr 2015
|
27
|
*
|
28
|
*/
|
29
|
@DataSet
|
30
|
public class ConceptRelationshipPresenterTest extends CdmVaadinBaseTest {
|
31
|
|
32
|
private static final Logger logger = Logger.getLogger(ConceptRelationshipPresenterTest.class);
|
33
|
|
34
|
private static ConceptRelationshipPresenter crp;
|
35
|
private static D3ConceptRelationshipTree crTree;
|
36
|
|
37
|
@BeforeClass
|
38
|
public static void init() {
|
39
|
crTree = new D3ConceptRelationshipTree();
|
40
|
crp = new ConceptRelationshipPresenter(crTree);
|
41
|
}
|
42
|
|
43
|
@Test
|
44
|
public void testUpdateConceptRelationship() throws JSONException {
|
45
|
UUID taxonUuid = UUID.fromString("5f713f69-e03e-4a11-8a55-700fbbf44805");
|
46
|
crp.updateConceptRelationship(taxonUuid);
|
47
|
String expected = "{\"name\":\"Taxon D sec. ???\",\"children\":[{\"name\":\"Includes\",\"children\":[{\"name\":\"Taxon A sec. Journal Reference 1\",\"uuid\":\"eaac797e-cac7-4649-97cf-c7b580076895\"},{\"name\":\"Taxon B sec. ???\",\"uuid\":\"77e7d93e-75c6-4dd4-850d-7b5809654378\"}],\"uuid\":\"0501c385-cab1-4fbe-b945-fc747419bb13\"},{\"name\":\"Excludes\",\"children\":[{\"name\":\"Taxon C sec. ???\",\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\"}],\"uuid\":\"4535a63c-4a3f-4d69-9350-7bf02e2c23be\"}],\"uuid\":\"5f713f69-e03e-4a11-8a55-700fbbf44805\"}";
|
48
|
Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
|
49
|
|
50
|
taxonUuid = UUID.fromString("3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9");
|
51
|
crp.updateConceptRelationship(taxonUuid);
|
52
|
expected = "{\"name\":\"Taxon C sec. ???\",\"uuid\":\"3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9\"}";
|
53
|
Assert.assertEquals(expected, crTree.getState().getConceptRelationshipTree());
|
54
|
}
|
55
|
}
|