Revision 10cc0e5e
Added by Cherian Mathew almost 9 years ago
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenterTest.java | ||
---|---|---|
54 | 54 |
public void testNewTaxonBase() throws SQLException { |
55 | 55 |
RowId refId20 = new RowId(20); |
56 | 56 |
RowId refId21 = new RowId(21); |
57 |
UUID newTaxonUuid = ntbp.newTaxon("Taxon E", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid();
|
|
57 |
UUID newTaxonUuid = ntbp.newTaxon("Taxon h", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid();
|
|
58 | 58 |
List<String> ACC_TAXON_INIT_STRATEGY = Arrays.asList(new String []{ |
59 | 59 |
"sec", |
60 | 60 |
"synonymRelations" |
61 | 61 |
}); |
62 | 62 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class); |
63 | 63 |
|
64 |
UUID newSynonymUuid = ntbp.newSynonym("Synonym OfE", refId20, refId21, newTaxonUuid).getUuid();
|
|
64 |
UUID newSynonymUuid = ntbp.newSynonym("Synonym ofe", refId20, refId21, newTaxonUuid).getUuid();
|
|
65 | 65 |
taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class); |
66 | 66 |
|
67 | 67 |
Set<Synonym> synonyms = taxon.getSynonyms(); |
... | ... | |
78 | 78 |
Assert.assertEquals(taxon.getSec().getId(), 21); |
79 | 79 |
} |
80 | 80 |
|
81 |
@Test |
|
82 |
public void testNewTaxonBaseWhenNameAlreadyExists() { |
|
83 |
RowId refId20 = new RowId(20); |
|
84 |
// test taxa |
|
85 |
try { |
|
86 |
ntbp.newTaxon("Taxon e", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid(); |
|
87 |
Assert.fail("Exception should be thrown as name already exists");; |
|
88 |
} catch (IllegalArgumentException iae) { |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
try { |
|
93 |
ntbp.newTaxon("Taxon e", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid(); |
|
94 |
Assert.fail("Exception should be thrown as name already exists");; |
|
95 |
} catch (IllegalArgumentException iae) { |
|
96 |
|
|
97 |
} |
|
98 |
try{ |
|
99 |
ntbp.newTaxon("Taxon e Me.", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid(); |
|
100 |
Assert.fail("Exception should be thrown as name already exists");; |
|
101 |
} catch (IllegalArgumentException iae) { |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
// test synonym |
|
106 |
RowId refId21 = new RowId(21); |
|
107 |
UUID newTaxonUuid = ntbp.newTaxon("Taxon h", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid(); |
|
108 |
List<String> ACC_TAXON_INIT_STRATEGY = Arrays.asList(new String []{ |
|
109 |
"sec", |
|
110 |
"synonymRelations" |
|
111 |
}); |
|
112 |
Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class); |
|
113 |
try { |
|
114 |
ntbp.newSynonym("Htsynonym bofa", refId20, refId21, newTaxonUuid); |
|
115 |
Assert.fail("Exception should be thrown as name already exists");; |
|
116 |
} catch (IllegalArgumentException iae) { |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
try { |
|
121 |
ntbp.newSynonym("Htsynonym bofa", refId20, refId21, newTaxonUuid); |
|
122 |
Assert.fail("Exception should be thrown as name already exists");; |
|
123 |
} catch (IllegalArgumentException iae) { |
|
124 |
|
|
125 |
} |
|
126 |
try{ |
|
127 |
ntbp.newSynonym("Htsynonym bofa Me.", refId20, refId21, newTaxonUuid); |
|
128 |
Assert.fail("Exception should be thrown as name already exists");; |
|
129 |
} catch (IllegalArgumentException iae) { |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
} |
|
81 | 134 |
|
82 | 135 |
public static class MockNewTaxonBaseComposite implements INewTaxonBaseComposite { |
83 | 136 |
|
Also available in: Unified diff
NewTaxonBaseComposite : add exception handling when name already exists
StatusComposite : added tab sheet with main / excluded tabs
CdmQueryFactory, LeafNodeTaxonContainer : added rank filter for ranks below species aggregate
NewTaxonBasePresenter : added check if name exists
NewTaxonBasePresenterTest (.xml) : corrected data for valid names and added test for name check
CdmVaadinOperation : added method to set exception