Project

General

Profile

Download (2.96 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.lazyloading;
10

    
11
import java.util.Arrays;
12
import java.util.List;
13
import java.util.Set;
14
import java.util.UUID;
15

    
16
import org.junit.Ignore;
17
import org.junit.Test;
18

    
19
import eu.etaxonomy.cdm.api.service.ITaxonService;
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.cdm.model.name.TaxonName;
22
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
25
import eu.etaxonomy.taxeditor.httpinvoker.BaseRemotingTest;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27

    
28
/**
29
 * This test class is primarily for performance testing.
30
 * It should be used to make read-only calls to the target cdm-server.
31
 *
32
 * @author cmathew
33
 * @date 26 Aug 2015
34
 *
35
 */
36
//FIXME:Remoting ignoring until we can target integration servers
37
@Ignore
38
public class PropertyPathsTest extends BaseRemotingTest {
39

    
40
    @Test
41
    public void taxonLoadTest() {
42
        // load taxon Crepis from cichorieae
43
        UUID taxonBaseUuid = UUID.fromString("d0ae2121-1c32-4737-8c49-f871d429fd90");
44
        List<String> taxonBasePropertyPaths = Arrays.asList(new String[] {
45
                "synonym.synonym.name.status.type",
46
                "name.homotypicalGroup.typifiedNames.taxonBases.synonyms.relatedFrom.name.status"
47
        });
48
        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths);
49
        Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
50
        Set<TaxonRelationship> taxonRelations = taxon.getTaxonRelations();
51
        for(TaxonRelationship rel : taxonRelations) {
52
            rel.getFromTaxon().getName().getStatus().size();
53
        }
54
        Set<TaxonName> typifiedNames = taxon.getName().getHomotypicalGroup().getTypifiedNames();
55
        for(TaxonName name : typifiedNames) {
56
            Set<TaxonBase> taxonBases = name.getTaxonBases();
57
            for(TaxonBase tb : taxonBases) {
58
            	//TODO needs to be adapted after synonym relationship removal
59
//                if(tb instanceof Synonym) {
60
//                    Synonym syn = CdmBase.deproxy(tb, Synonym.class);
61
//                    Set<TaxonRelationship> rels = syn.getTaxonRelations();
62
//                    for(TaxonRelationship rel : rels) {
63
//                        rel.getSynonym().getName().getStatus().size();
64
//                    }
65
//                }
66
                if(tb instanceof Taxon) {
67
                    Taxon tax = CdmBase.deproxy(tb, Taxon.class);
68
                    Set<TaxonRelationship> rels = tax.getTaxonRelations();
69
                    for(TaxonRelationship rel : rels) {
70
                        rel.getFromTaxon().getName().getStatus().size();
71
                    }
72
                }
73
            }
74
        }
75
    }
76

    
77
}
(3-3/5)