3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.UUID
;
15 import org
.junit
.Assert
;
16 import org
.junit
.Before
;
17 import org
.junit
.Test
;
18 import org
.unitils
.dbunit
.annotation
.DataSet
;
19 import org
.unitils
.spring
.annotation
.SpringApplicationContext
;
20 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
22 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
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
;
33 * @created Dec 16, 2010
36 @SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")
37 public class TaxonNodeServiceImplTest
extends CdmIntegrationTest
{
40 private ITaxonNodeService taxonNodeService
;
43 private IClassificationService classificationService
;
46 private IReferenceService referenceService
;
49 private ITermService termService
;
51 private static final UUID t1Uuid
= UUID
.fromString("55c3e41a-c629-40e6-aa6a-ff274ac6ddb1");
52 private static final UUID t2Uuid
= UUID
.fromString("2659a7e0-ff35-4ee4-8493-b453756ab955");
53 private static final UUID classificationUuid
= UUID
.fromString("6c2bc8d9-ee62-4222-be89-4a8e31770878");
54 private static final UUID referenceUuid
= UUID
.fromString("de7d1205-291f-45d9-9059-ca83fc7ade14");
55 private static final UUID node1Uuid
= UUID
.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
56 private static final UUID node2Uuid
= UUID
.fromString("2d41f0c2-b785-4f73-a436-cc2d5e93cc5b");
61 private SynonymRelationshipType synonymRelationshipType
;
62 private Reference
<?
> reference
;
63 private String referenceDetail
;
64 private Classification classification
;
65 private TaxonNode node2
;
66 private TaxonNode node1
;
69 * @throws java.lang.Exception
72 public void setUp() throws Exception
{
76 * 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)}.
80 public final void testMakeTaxonNodeASynonymOfAnotherTaxonNode() {
81 classification
= classificationService
.load(classificationUuid
);
82 node1
= taxonNodeService
.load(node1Uuid
);
83 node2
= taxonNodeService
.load(node2Uuid
);
84 reference
= referenceService
.load(referenceUuid
);
85 // synonymRelationshipType = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF();
86 synonymRelationshipType
= CdmBase
.deproxy(termService
.load(SynonymRelationshipType
.uuidHomotypicSynonymOf
), SynonymRelationshipType
.class) ;
87 referenceDetail
= "test";
92 // printDataSet(System.err, new String [] {"TaxonNode"});
95 t1
= node1
.getTaxon();
96 t2
= node2
.getTaxon();
97 Assert
.assertEquals(2, t1
.getDescriptions().size());
98 Assert
.assertTrue(t2
.getSynonyms().isEmpty());
99 Assert
.assertTrue(t2
.getDescriptions().size() == 0);
101 taxonNodeService
.makeTaxonNodeASynonymOfAnotherTaxonNode(node1
, node2
, synonymRelationshipType
, reference
, referenceDetail
);
102 termService
.saveOrUpdate(synonymRelationshipType
);
103 Assert
.assertFalse(t2
.getSynonyms().isEmpty());
104 Assert
.assertEquals(2, t2
.getDescriptions().size());