1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.cdm.api.service;
|
12
|
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.junit.Assert;
|
16
|
import org.junit.Before;
|
17
|
import org.junit.Test;
|
18
|
import org.unitils.spring.annotation.SpringBeanByType;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
21
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
25
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
26
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
27
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
28
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
29
|
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
|
30
|
|
31
|
/**
|
32
|
* @author n.hoffmann
|
33
|
* @created Dec 16, 2010
|
34
|
* @version 1.0
|
35
|
*/
|
36
|
public class TaxonNodeServiceImplTest extends CdmIntegrationTest{
|
37
|
|
38
|
@SpringBeanByType
|
39
|
private ITaxonNodeService taxonNodeService;
|
40
|
|
41
|
@SpringBeanByType
|
42
|
private IClassificationService classificationService;
|
43
|
|
44
|
@SpringBeanByType
|
45
|
private IReferenceService referenceService;
|
46
|
|
47
|
private static final UUID t1Uuid = UUID.fromString("55c3e41a-c629-40e6-aa6a-ff274ac6ddb1");
|
48
|
private static final UUID t2Uuid = UUID.fromString("2659a7e0-ff35-4ee4-8493-b453756ab955");
|
49
|
private static final UUID classificationUuid = UUID.fromString("6c2bc8d9-ee62-4222-be89-4a8e31770878");
|
50
|
private static final UUID referenceUuid = UUID.fromString("de7d1205-291f-45d9-9059-ca83fc7ade14");
|
51
|
private static final UUID node1Uuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
|
52
|
private static final UUID node2Uuid = UUID.fromString("2d41f0c2-b785-4f73-a436-cc2d5e93cc5b");
|
53
|
|
54
|
private Taxon t1;
|
55
|
private Taxon t2;
|
56
|
private Synonym s1;
|
57
|
private SynonymRelationshipType synonymRelationshipType;
|
58
|
private Reference reference;
|
59
|
private String referenceDetail;
|
60
|
private Classification classification;
|
61
|
private TaxonNode node2;
|
62
|
private TaxonNode node1;
|
63
|
|
64
|
/**
|
65
|
* @throws java.lang.Exception
|
66
|
*/
|
67
|
@Before
|
68
|
public void setUp() throws Exception {
|
69
|
|
70
|
classification = classificationService.load(classificationUuid);
|
71
|
|
72
|
node1 = taxonNodeService.load(node1Uuid);
|
73
|
|
74
|
node2 = taxonNodeService.load(node2Uuid);
|
75
|
|
76
|
reference = referenceService.load(referenceUuid);
|
77
|
|
78
|
// referencing
|
79
|
synonymRelationshipType = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF();
|
80
|
referenceDetail = "test";
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Test method for {@link eu.etaxonomy.cdm.api.service.TaxonNodeServiceImpl#makeTaxonNodeASynonymOfAnotherTaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode, eu.etaxonomy.cdm.model.taxon.TaxonNode, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
85
|
*/
|
86
|
@Test
|
87
|
public final void testMakeTaxonNodeASynonymOfAnotherTaxonNode() {
|
88
|
// descriptions
|
89
|
|
90
|
taxonNodeService.makeTaxonNodeASynonymOfAnotherTaxonNode(node1, node2, synonymRelationshipType, reference, referenceDetail);
|
91
|
|
92
|
Assert.assertFalse(t2.getSynonyms().isEmpty());
|
93
|
Assert.assertTrue(t2.getDescriptions().size() == 2);
|
94
|
|
95
|
}
|
96
|
|
97
|
}
|