Project

General

Profile

« Previous | Next » 

Revision 30c47554

Added by Katja Luther almost 8 years ago

fix test

View differences:

eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java
10 10
package eu.etaxonomy.taxeditor.session;
11 11

  
12 12
import java.util.ArrayList;
13
import java.util.HashSet;
13 14
import java.util.Iterator;
14 15
import java.util.List;
15 16
import java.util.Map;
......
24 25
import org.unitils.dbunit.annotation.DataSet;
25 26

  
26 27
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
28
import eu.etaxonomy.cdm.api.service.DeleteResult;
27 29
import eu.etaxonomy.cdm.api.service.ICommonService;
28 30
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
29 31
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
......
31 33
import eu.etaxonomy.cdm.api.service.ITermService;
32 34
import eu.etaxonomy.cdm.api.service.IUserService;
33 35
import eu.etaxonomy.cdm.api.service.IVocabularyService;
36
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
34 37
import eu.etaxonomy.cdm.model.agent.AgentBase;
35 38
import eu.etaxonomy.cdm.model.agent.Person;
36 39
import eu.etaxonomy.cdm.model.common.CdmBase;
......
341 344

  
342 345

  
343 346
        PolytomousKeyNode rootNode = pKey.getRoot();
344
        PolytomousKeyNode child = rootNode.getChildAt(0);
345
        PolytomousKey subKey = child.getSubkey();
347
        PolytomousKeyNode childNode = rootNode.getChildAt(0);
348
        PolytomousKey subKey = HibernateProxyHelper.deproxy( childNode.getSubkey(), PolytomousKey.class);;
349

  
350

  
351
        DeleteResult result = polytomousKeyService.delete(subKey.getUuid());
352
        //A used subKey can't be deleted
353
        if (result.isOk()){
354
            Assert.fail();
355
        }
346 356

  
347
        polytomousKeyService.delete(subKey.getUuid());
348 357

  
358
        Set<Integer> ids = new HashSet<Integer>();
359
        ids.add(2753);
360
        ids.add(2754);
361
        ids.add(2751);
362
        List<PolytomousKeyNode> nodes = polytomousKeyNodeService.findById(ids);
363
        for (PolytomousKeyNode child:nodes){
364
            child.setSubkey(null);
365
           // polytomousKeyNodeService.merge(child);
366
        }
367
        polytomousKeyNodeService.merge(nodes, true);
368
        result = polytomousKeyService.delete(subKey.getUuid());
369
        if (!result.isOk()){
370
            Assert.fail();
371
        }
349 372
        // retrieving subkey shows its null
350 373
        subKey = CdmBase.deproxy(polytomousKeyService.find(subKeyUuid),PolytomousKey.class);
351 374
        Assert.assertNull(subKey);
......
353 376
        pKey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
354 377

  
355 378

  
356
        rootNode = pKey.getRoot();
357
        child = rootNode.getChildAt(0);
358
        subKey = child.getSubkey();
359
        // subkey will not be null, because the delete functionality of the subkey
360
        // does not currently delete it from a polytomous key node
361

  
362
        // FIXME: With the new delete functionality this should be null, shouldn't it ?
363
        Assert.assertNotNull(subKey);
364 379
    }
365 380

  
366 381

  

Also available in: Unified diff