merge trunk and bugfix linkbackuri jaxb
[cdmlib.git] / cdmlib-services / src / test / java / eu / etaxonomy / cdm / api / service / TaxonNodeServiceImplTest.java
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.dbunit.annotation.DataSet;
19 import org.unitils.spring.annotation.SpringApplicationContext;
20 import org.unitils.spring.annotation.SpringBeanByType;
21
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;
30
31 /**
32 * @author n.hoffmann
33 * @created Dec 16, 2010
34 * @version 1.0
35 */
36 @SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")
37 public class TaxonNodeServiceImplTest extends CdmIntegrationTest{
38
39 @SpringBeanByType
40 private ITaxonNodeService taxonNodeService;
41
42 @SpringBeanByType
43 private IClassificationService classificationService;
44
45 @SpringBeanByType
46 private IReferenceService referenceService;
47
48 @SpringBeanByType
49 private ITermService termService;
50
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");
57
58 private Taxon t1;
59 private Taxon t2;
60 private Synonym s1;
61 private SynonymRelationshipType synonymRelationshipType;
62 private Reference<?> reference;
63 private String referenceDetail;
64 private Classification classification;
65 private TaxonNode node2;
66 private TaxonNode node1;
67
68 /**
69 * @throws java.lang.Exception
70 */
71 @Before
72 public void setUp() throws Exception {
73 }
74
75 /**
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)}.
77 */
78 @Test
79 @DataSet
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";
88
89 //
90 //TODO
91
92 // printDataSet(System.err, new String [] {"TaxonNode"});
93
94 // descriptions
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);
100
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());
105
106 }
107
108 }