Revision a735bbbf
Added by Andreas Kohlbecker about 7 years ago
- ID a735bbbfccc284e24f355551d2496cd15e790243
- Parent a1dac6b2
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/EditConceptRelationshipPresenterTest.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
import org.junit.Assert; |
19 |
import org.junit.BeforeClass; |
|
20 | 19 |
import org.junit.Test; |
21 | 20 |
import org.unitils.dbunit.annotation.DataSet; |
21 |
import org.unitils.spring.annotation.SpringBeanByType; |
|
22 | 22 |
|
23 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
|
23 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
24 | 25 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
25 | 26 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
26 | 27 |
import eu.etaxonomy.cdm.vaadin.CdmVaadinBaseTest; |
27 | 28 |
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer; |
28 | 29 |
import eu.etaxonomy.cdm.vaadin.container.IdUuidName; |
29 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* @author cmathew |
... | ... | |
36 | 36 |
@DataSet |
37 | 37 |
public class EditConceptRelationshipPresenterTest extends CdmVaadinBaseTest { |
38 | 38 |
|
39 |
@SpringBeanByType |
|
40 |
private CdmRepository cdmRepo = null; |
|
41 |
|
|
42 |
@SpringBeanByType |
|
43 |
private EditConceptRelationshipPresenter ecrp = null; |
|
44 |
|
|
39 | 45 |
private static final Logger logger = Logger.getLogger(EditConceptRelationshipPresenterTest.class); |
40 |
public static EditConceptRelationshipPresenter ecrp; |
|
46 |
|
|
41 | 47 |
|
42 | 48 |
private static List<String> FROM_TAXON_INIT_STRATEGY = Arrays.asList(new String []{ |
43 | 49 |
"relationsFromThisTaxon" |
44 | 50 |
}); |
45 | 51 |
|
46 |
@BeforeClass |
|
47 |
public static void init() { |
|
48 |
ecrp = new EditConceptRelationshipPresenter(); |
|
49 |
} |
|
50 |
|
|
51 | 52 |
@Test |
52 | 53 |
public void testLoadTaxonRelationshipTypeContainer() throws SQLException { |
53 | 54 |
CdmSQLContainer container = ecrp.loadTaxonRelationshipTypeContainer(); |
... | ... | |
63 | 64 |
|
64 | 65 |
IdUuidName trId =ecrp.createRelationship(fromTaxonUuid, relTypeUuid, toTaxonUuid); |
65 | 66 |
|
66 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
67 |
Taxon taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
67 | 68 |
Assert.assertEquals(1, taxon.getRelationsFromThisTaxon().size()); |
68 | 69 |
|
69 | 70 |
Assert.assertEquals(trId.getUuid(),taxon.getRelationsFromThisTaxon().iterator().next().getUuid()); |
... | ... | |
76 | 77 |
UUID newToTaxonUuid = UUID.fromString("5004a8e7-b907-4744-b67e-44ccb057ab3b"); |
77 | 78 |
UUID newRelTypeUuid = UUID.fromString("a8f03491-2ad6-4fae-a04c-2a4c117a2e9b"); |
78 | 79 |
|
79 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
80 |
Taxon taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
80 | 81 |
TaxonRelationship tr = getFromRelwithUuid(taxon, taxonRelUuid); |
81 | 82 |
|
82 | 83 |
UUID oldToTaxonUuid = tr.getToTaxon().getUuid(); |
... | ... | |
88 | 89 |
|
89 | 90 |
// change both to taxon and relationship type |
90 | 91 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, newToTaxonUuid); |
91 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
92 |
taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
92 | 93 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
93 | 94 |
|
94 | 95 |
Assert.assertNotNull(tr); |
... | ... | |
100 | 101 |
|
101 | 102 |
// change only relationship type |
102 | 103 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, newRelTypeUuid, null); |
103 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
104 |
taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
104 | 105 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
105 | 106 |
|
106 | 107 |
Assert.assertNotNull(tr); |
... | ... | |
112 | 113 |
|
113 | 114 |
// change only to taxon |
114 | 115 |
ecrp.updateRelationship(fromTaxonUuid, taxonRelUuid, null, newToTaxonUuid); |
115 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
116 |
taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
116 | 117 |
tr = getFromRelwithUuid(taxon, taxonRelUuid); |
117 | 118 |
|
118 | 119 |
Assert.assertNotNull(tr); |
... | ... | |
127 | 128 |
UUID taxonRelUuid = UUID.fromString("cac9fa65-9b15-445f-80e4-56f77952f7ec"); |
128 | 129 |
|
129 | 130 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid); |
130 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
131 |
Taxon taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
131 | 132 |
Assert.assertEquals(4, taxon.getRelationsFromThisTaxon().size()); |
132 | 133 |
|
133 | 134 |
TaxonRelationship tr = getFromRelwithUuid(taxon, taxonRelUuid); |
... | ... | |
137 | 138 |
taxonRelUuid = UUID.fromString("9634d870-bab1-4fdc-8845-c7e71aa8dc6b"); |
138 | 139 |
|
139 | 140 |
ecrp.deleteRelationship(fromTaxonUuid, taxonRelUuid); |
140 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
141 |
taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(fromTaxonUuid,FROM_TAXON_INIT_STRATEGY),Taxon.class);
|
|
141 | 142 |
Assert.assertEquals(0, taxon.getRelationsFromThisTaxon().size()); |
142 | 143 |
} |
143 | 144 |
|
Also available in: Unified diff
ref #5285 attempt to avoid using the CdmSpringContextHelper
using DI to get rid of CdmSpringContextHelper, but got stuck due to the complexity and variety of the 'design patterns' that have been used.