Revision 08af4f8a
Added by Cherian Mathew almost 9 years ago
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/EditConceptRelationshipPresenterTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 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 |
*/ |
|
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 | 10 |
package eu.etaxonomy.cdm.vaadin.presenter; |
11 | 11 |
|
12 | 12 |
import java.sql.SQLException; |
13 | 13 |
import java.util.Arrays; |
14 | 14 |
import java.util.List; |
15 |
import java.util.Map; |
|
15 | 16 |
import java.util.UUID; |
16 | 17 |
|
17 | 18 |
import org.apache.log4j.Logger; |
... | ... | |
87 | 88 |
Assert.assertNotEquals(newRelTypeUuid, oldRelTypeUuid); |
88 | 89 |
|
89 | 90 |
// change both to taxon and relationship type |
90 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, newToTaxonUuid); |
|
91 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, newToTaxonUuid);
|
|
91 | 92 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class); |
92 | 93 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
93 | 94 |
|
... | ... | |
96 | 97 |
Assert.assertEquals(newRelTypeUuid, tr.getType().getUuid()); |
97 | 98 |
|
98 | 99 |
// reset old values |
99 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, oldRelTypeUuid, oldToTaxonUuid); |
|
100 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, oldRelTypeUuid, oldToTaxonUuid);
|
|
100 | 101 |
|
101 | 102 |
// change only relationship type |
102 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, null); |
|
103 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, null);
|
|
103 | 104 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class); |
104 | 105 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
105 | 106 |
|
... | ... | |
108 | 109 |
Assert.assertEquals(newRelTypeUuid, tr.getType().getUuid()); |
109 | 110 |
|
110 | 111 |
// reset old values |
111 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, oldRelTypeUuid, oldToTaxonUuid); |
|
112 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, oldRelTypeUuid, oldToTaxonUuid);
|
|
112 | 113 |
|
113 | 114 |
// change only to taxon |
114 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, null, newToTaxonUuid); |
|
115 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, null, newToTaxonUuid);
|
|
115 | 116 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class); |
116 | 117 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
117 | 118 |
|
... | ... | |
126 | 127 |
UUID fromTaxonUuid = UUID.fromString("5f713f69-e03e-4a11-8a55-700fbbf44805"); |
127 | 128 |
UUID taxonRelUuid = UUID.fromString("cac9fa65-9b15-445f-80e4-56f77952f7ec"); |
128 | 129 |
|
129 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid); |
|
130 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid);
|
|
130 | 131 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class); |
131 |
Assert.assertEquals(3, taxon.getRelationsFromThisTaxon().size());
|
|
132 |
Assert.assertEquals(4, taxon.getRelationsFromThisTaxon().size());
|
|
132 | 133 |
|
133 | 134 |
TaxonRelationship tr = getFromRelwithUuid(taxon, taxonRelUuid); |
134 | 135 |
Assert.assertNull(tr); |
... | ... | |
136 | 137 |
fromTaxonUuid = UUID.fromString("666b484f-dc1e-4578-b404-86bc6d2e47fa"); |
137 | 138 |
taxonRelUuid = UUID.fromString("9634d870-bab1-4fdc-8845-c7e71aa8dc6b"); |
138 | 139 |
|
139 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid); |
|
140 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid);
|
|
140 | 141 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class); |
141 | 142 |
Assert.assertEquals(0, taxon.getRelationsFromThisTaxon().size()); |
142 | 143 |
} |
143 | 144 |
|
145 |
|
|
146 |
@Test |
|
147 |
public void testGetRelTypeToTaxonIunMap() { |
|
148 |
UUID fromTaxonUuid = UUID.fromString("5f713f69-e03e-4a11-8a55-700fbbf44805"); |
|
149 |
UUID taxonRelUuid = UUID.fromString("cc761030-38d2-4b5d-954d-32329c0ea106"); |
|
150 |
Map<String, IdUuidName> map = ecrp.getRelTypeToTaxonIunMap(fromTaxonUuid, taxonRelUuid); |
|
151 |
|
|
152 |
IdUuidName relTypeIun = map.get(EditConceptRelationshipPresenter.REL_TYPE_KEY); |
|
153 |
Assert.assertEquals(924, relTypeIun.getId()); |
|
154 |
|
|
155 |
IdUuidName toTaxonIun = map.get(EditConceptRelationshipPresenter.TO_TAXON_KEY); |
|
156 |
Assert.assertEquals(20, toTaxonIun.getId()); |
|
157 |
} |
|
158 |
|
|
144 | 159 |
public TaxonRelationship getFromRelwithUuid(Taxon taxon, UUID taxonRelUuid) { |
145 | 160 |
for(TaxonRelationship tr : taxon.getRelationsFromThisTaxon()) { |
146 | 161 |
if(tr.getUuid().equals(taxonRelUuid)) { |
Also available in: Unified diff
ConceptRelationshipComposite: added enabling / disabling of edit / delete buttons and firing event when edit concept relationship dialog is opened
EditConceptRelationshipComposite : fixed problems with async calls , adapted to updated operation class, added show in dialog method
NewTaxonBaseComposite : adapted to updated operation class
StatusComposite : added methods to update taxa table ui
D3ConceptRelationshipTree : added possibility to display one to one relationships
EditConceptRelationshipPresenter, EditConceptRelationshipPresenterTest : added method to get data to setup composite
CdmBaseUI, CdmVaadinSessionUtilities : using new basic events
CdmSpringContextHelper : fixed connection bug by closing connection after getting database metadata
CdmVaadinOperation : fixed problems with async calls
ConceptRelationshipView : setup ui changes for status composite depending on whether it is a primary of secondary composite
d3.conceptrelationshiptree_connector.js : added selected node capability