Project

General

Profile

Revision 7f1eb40e

ID7f1eb40e31e48880af2c6b89006f4bad22aa8915
Parent 78234aa8
Child afc431d5

Added by Andreas Müller about 1 year ago

ref #6794 fix termType settings in deleteTerms test and clean it up

View differences:

cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TermServiceImplTest.java
33 33
import eu.etaxonomy.cdm.model.common.Representation;
34 34
import eu.etaxonomy.cdm.model.common.TermType;
35 35
import eu.etaxonomy.cdm.model.common.TermVocabulary;
36
import eu.etaxonomy.cdm.model.description.State;
36 37
import eu.etaxonomy.cdm.model.location.NamedArea;
37 38
import eu.etaxonomy.cdm.model.name.IBotanicalName;
38 39
import eu.etaxonomy.cdm.model.name.Rank;
......
45 46
/**
46 47
 * @author a.mueller
47 48
 * @since 27.05.2008
48
 * @version 1.0
49 49
 */
50 50
public class TermServiceImplTest extends CdmTransactionalIntegrationTest{
51 51
    @SuppressWarnings("unused")
......
207 207
                "DefinedTermBase","Representation"};
208 208

  
209 209
    	commitAndStartNewTransaction(tableNames);
210
    	TermVocabulary<DefinedTerm> vocs = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);
211
    	vocs.addTerm(DefinedTerm.NewInstance(TermType.State, "green", "green", "gn"));
212
    	vocs= vocabularyService.save(vocs);
210
    	TermVocabulary<State> vocStates = TermVocabulary.NewInstance(TermType.State, "Test States", null, null, null);
211
    	vocStates.addTerm(State.NewInstance("green", "green", "gn"));
212
    	vocabularyService.save(vocStates);
213 213
    	Pager<DefinedTermBase> term = termService.findByRepresentationText("green", DefinedTermBase.class, null, null);
214 214
    	if (term.getCount() != 0){
215

  
216 215
    		DeleteResult result = termService.delete(term.getRecords().get(0));
217 216
    		assertTrue(result.isOk());
218 217
    		commitAndStartNewTransaction(tableNames);
219 218
       	}
220
    	TermVocabulary<DefinedTerm> voc = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);
221
    	voc.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));
222
    	UUID vocUUID = vocabularyService.save(voc).getUuid();
223

  
224
    	voc = vocabularyService.find(vocUUID);
225
    	Set<DefinedTerm> terms = voc.getTerms();
226
    	DefinedTermBase termBase =terms.iterator().next();
227
    	UUID termUUID = termBase.getUuid();
219
    	TermVocabulary<DefinedTerm> vocDna = TermVocabulary.NewInstance(TermType.DnaMarker, "Test DNA marker", null, null, null);
220
    	vocDna.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));
221
    	vocabularyService.save(vocDna);
222

  
223
    	vocDna = vocabularyService.find(vocDna.getUuid());
224
    	Set<DefinedTerm> terms = vocDna.getTerms();
225
    	DefinedTerm termBase =terms.iterator().next();
228 226
    	termService.delete(termBase, null);
229 227
    	//commitAndStartNewTransaction(tableNames);
230
    	termBase =  termService.load(termUUID);
228
    	termBase =  (DefinedTerm)termService.load(termBase.getUuid());
231 229
    	assertNull(termBase);
232 230

  
233 231

  
234 232
    	//TermVocabulary<DefinedTerm> voc = TermVocabulary.NewInstance(TermType.Feature, "TestFeatures", null, null, null);
235
        voc.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));
236
        vocUUID = vocabularyService.save(voc).getUuid();
233
        vocDna.addTerm(DefinedTerm.NewDnaMarkerInstance("test", "marker", "t"));
234
        vocabularyService.save(vocDna);
237 235

  
238
        voc = vocabularyService.find(vocUUID);
239
        terms = voc.getTerms();
236
        vocDna = vocabularyService.find(vocDna.getUuid());
237
        terms = vocDna.getTerms();
240 238
        termBase =terms.iterator().next();
241
        termUUID = termBase.getUuid();
242
        termBase = termService.load(termUUID);
239
        termBase = (DefinedTerm)termService.load(termBase.getUuid());
243 240
        IBotanicalName testName = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
244 241
        Taxon testTaxon = Taxon.NewInstance(testName,null);
245
        testTaxon.addIdentifier("Test", (DefinedTerm) termBase);
242
        testTaxon.addIdentifier("Test", termBase);
246 243
        taxonService.save(testTaxon);
247 244
        termService.delete(termBase, null);
248 245
        //commitAndStartNewTransaction(tableNames);
249
        termBase =  termService.load(termUUID);
246
        termBase =  (DefinedTerm)termService.load(termBase.getUuid());
250 247
        assertNotNull(termBase);
251 248
    }
252 249

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)