Project

General

Profile

Revision 0c3b20de

ID0c3b20de0bb0d878024a3ae3af2863d28909d9aa
Parent 6826dbcd
Child 014b9fa9

Added by Katja Luther about 3 years ago

adapt tests to return type updateResult and missing exception for update-services methods

View differences:

cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplBusinessTest.java
115 115
		boolean deleteSynonym = false;
116 116
		boolean copyCitationInfo = true;
117 117
		Taxon taxon = null;
118
		try {
119
			taxon = (Taxon)service.changeSynonymToAcceptedTaxon(s1, t1, deleteSynonym).getCdmEntity();
120
			Assert.fail("Change must fail for synonym and taxon in same homotypical group");
121
		} catch (HomotypicalGroupChangeException e) {
122
			//OK
123
		}
118

  
119
		UpdateResult result;
120
        try {
121
            result = service.changeSynonymToAcceptedTaxon(s1, t1, deleteSynonym);
122
            Assert.assertTrue("Change must fail for synonym and taxon in same homotypical group",result.isAbort());
123
        } catch (HomotypicalGroupChangeException e1) {
124
            // TODO Auto-generated catch block
125
            e1.printStackTrace();
126
        }
127

  
128

  
124 129
		t1.addSynonym(s2, heteroTypicSynonymType);
125 130
		Assert.assertEquals("Homotypical group of old accepted taxon should still contain exactly 2 names", 2, oldGroup.getTypifiedNames().size());
126 131
		Assert.assertTrue("Old accepted taxon should now have 2 synonyms", t1.getSynonyms().size() == 2);
......
189 194
		Assert.assertTrue("Relationship to s2 must have been concidered in 'for'-loop", iWasHere);
190 195

  
191 196
		try {
192
			service.changeSynonymToAcceptedTaxon(homotypicSynonym, t1, false);
193
			Assert.fail("The method should throw an exception when invoked on taxa in the same homotypical group");
197
			UpdateResult result = service.changeSynonymToAcceptedTaxon(homotypicSynonym, t1, false);
198

  
199
			Assert.assertTrue("The method should throw an exception when invoked on taxa in the same homotypical group", !result.getExceptions().isEmpty());
194 200
		} catch (HomotypicalGroupChangeException e) {
195 201
			//OK
196 202
		}
......
215 221
		TaxonNameBase<?,?> synonymName = s1.getName();
216 222
		UUID synNameUUID = synonymName.getUuid();
217 223

  
218
		Taxon newTaxon = service.changeSynonymToRelatedTaxon(s1, t2, TaxonRelationshipType.CONGRUENT_OR_EXCLUDES(), reference, referenceDetail);
224
		Taxon newTaxon = (Taxon) service.changeSynonymToRelatedTaxon(s1, t2, TaxonRelationshipType.CONGRUENT_OR_EXCLUDES(), reference, referenceDetail).getCdmEntity();
219 225
		//check removeTaxonBase()
220 226
		//UUID s1UUID = service.update(s1);
221 227
		UUID newTaxonUUID = service.save(newTaxon).getUuid();
......
229 235
		assertTrue(synonymName.getTaxonBases().contains(newTaxon));
230 236

  
231 237
		synonymName = s2.getName();
232
        newTaxon = service.changeSynonymToRelatedTaxon(s2, t1, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), reference, referenceDetail);
238
        newTaxon = (Taxon)service.changeSynonymToRelatedTaxon(s2, t1, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), reference, referenceDetail).getCdmEntity();
233 239
        //check removeTaxonBase()
234 240
        //UUID s1UUID = service.update(s1);
235 241
        newTaxonUUID = service.save(newTaxon).getUuid();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)