Project

General

Profile

Revision 07a6e50e

ID07a6e50ee2aab8dbc97179e4646fc8556bf27666
Parent a8609cad
Child 77c1c705

Added by Andreas Müller over 2 years ago

rel #5957 improve tests for groupTaxaByHigherTaxon

View differences:

cdmlib-db/pom.xml
25 25
   <dependency>
26 26
      <groupId>com.mchange</groupId>
27 27
      <artifactId>c3p0</artifactId>
28
      <version>0.9.5.2</version>
28
<!--       <version>0.9.5.2</version> -->
29 29
    </dependency>
30 30

  
31 31
    <dependency>
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImplTest.java
18 18
import java.util.List;
19 19
import java.util.UUID;
20 20

  
21
import org.apache.commons.lang.StringUtils;
21 22
import org.apache.log4j.Logger;
22 23
import org.junit.Assert;
23 24
import org.junit.Test;
......
75 76
     */
76 77
//    @Test
77 78
    public final void testSetTaxonNodeComparator() {
78

  
79

  
80 79
//		fail("Not yet implemented");
81 80
    }
82 81

  
......
351 350
        taxonUuids.add(acacia_sect_botrycephalae_uuid);
352 351

  
353 352
        List<GroupedTaxonDTO> result = this.service.groupTaxaByHigherTaxon(taxonUuids, CLASSIFICATION_UUID, minRank, maxRank);
354
        Assert.assertFalse("", result.isEmpty());
353
        System.out.println(result);
354
        Assert.assertEquals(3, result.size());
355
        //acacia_acicularis_uuid  //is a root taxon with no parents
356
        Assert.assertEquals(acacia_acicularis_uuid, result.get(0).getTaxonUuid());
357
        Assert.assertNull(result.get(0).getGroupTaxonUuid());
358
        Assert.assertTrue(StringUtils.isBlank(result.get(0).getGroupTaxonName()));
359
        //acacia_cuspidifolia_uuid
360
        Assert.assertEquals(acacia_cuspidifolia_uuid, result.get(1).getTaxonUuid());
361
        Assert.assertNotNull(result.get(1).getGroupTaxonUuid());
362
        Assert.assertFalse(StringUtils.isBlank(result.get(1).getGroupTaxonName()));
363
        //acacia_sect_botrycephalae_uuid
364
        Assert.assertEquals(acacia_sect_botrycephalae_uuid, result.get(2).getTaxonUuid());
365
        Assert.assertNotNull(result.get(2).getGroupTaxonUuid());
366
        Assert.assertFalse(StringUtils.isBlank(result.get(2).getGroupTaxonName()));
355 367
    }
356 368

  
357 369

  
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java
13 13
import java.sql.ResultSet;
14 14
import java.sql.SQLException;
15 15
import java.util.ArrayList;
16
import java.util.Arrays;
16 17
import java.util.List;
17 18
import java.util.UUID;
18 19

  
......
27 28
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
28 29
import eu.etaxonomy.cdm.api.service.ITaxonService;
29 30
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
31
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
30 32
import eu.etaxonomy.cdm.common.AccountStore;
31 33
import eu.etaxonomy.cdm.database.CdmDataSource;
32 34
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
......
35 37
import eu.etaxonomy.cdm.database.DbSchemaValidation;
36 38
import eu.etaxonomy.cdm.database.ICdmDataSource;
37 39
import eu.etaxonomy.cdm.model.agent.Person;
40
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
38 41
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;
39 42
import eu.etaxonomy.cdm.model.description.Distribution;
40 43
import eu.etaxonomy.cdm.model.description.FeatureNode;
......
45 48
import eu.etaxonomy.cdm.model.name.BotanicalName;
46 49
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
47 50
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
48
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
49 51
import eu.etaxonomy.cdm.model.name.Rank;
50 52
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
51 53
import eu.etaxonomy.cdm.model.reference.Reference;
......
68 70
		dataSource = lsDataSources.get(1);
69 71
//		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
70 72

  
71
		String server = "localhost";
72
		String database = (schema == DbSchemaValidation.VALIDATE  ? "cdm35" : "cdm36");
73
		database = "cdm36";
74
//		database = "350_editor_test";
75
		String username = "edit";
76
		dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
77

  
78
//		String server = "160.45.63.171";
79
//		String database = "cdm_production_algaterra";
73
//		String server = "localhost";
74
//		String database = (schema == DbSchemaValidation.VALIDATE  ? "cdm35" : "cdm36");
75
//		database = "cdm36";
76
////		database = "cdm_production_edaphobase";
80 77
//		String username = "edit";
81 78
//		dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
82 79

  
80
		String server = "160.45.63.171";
81
		String database = "cdm_production_edaphobase";
82
		String username = "edit";
83
		dataSource = CdmDataSource.NewMySqlInstance(server, database, username, AccountStore.readOrStorePassword(server, database, username, null));
84

  
83 85

  
84 86
//		String server = "test.e-taxonomy.eu";
85 87
////		String database = "cdm_test";
......
99 101
//		username = "pesiexport";
100 102
////		dataSource = CdmDataSource.NewSqlServer2005Instance(server, database, port, username, AccountStore.readOrStorePassword(server, database, username, null));
101 103
//
102
		//H2
103
        String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2";
104
//		String path = "C:\\Users\\pesiimport\\.cdmLibrary\\writableResources\\h2\\LocalH2";
105
//      String path = "C:\\Users\\a.mueller\\eclipse\\svn\\cdmlib-trunk\\cdmlib-remote-webapp\\src\\test\\resources\\h2";
106
		username = "sa";
107
    	dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path,   NomenclaturalCode.ICNAFP);
104
//		//H2
105
//        String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2";
106
////		String path = "C:\\Users\\pesiimport\\.cdmLibrary\\writableResources\\h2\\LocalH2";
107
////      String path = "C:\\Users\\a.mueller\\eclipse\\svn\\cdmlib-trunk\\cdmlib-remote-webapp\\src\\test\\resources\\h2";
108
//		username = "sa";
109
//    	dataSource = CdmDataSource.NewH2EmbeddedInstance("cdm", username, "", path,   NomenclaturalCode.ICNAFP);
108 110

  
109 111
//    	dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, "sa", NomenclaturalCode.ICNAFP);
110 112

  
......
127 129
		//CdmPersistentDataSource.save(dataSource.getName(), dataSource);
128 130
		CdmApplicationController appCtr;
129 131
		appCtr = CdmApplicationController.NewInstance(dataSource, schema);
130
		Classification classification = appCtr.getClassificationService().list(null, null, null, null, null).get(0);
132
//		Classification classification = appCtr.getClassificationService().list(null, null, null, null, null).get(0);
131 133
//		logger.warn(classification.getMicroReference());
132 134
//        logger.warn(classification.getName());
133 135

  
134 136
//		TransactionStatus tx = appCtr.startTransaction();
135
		appCtr.getCommonService().getReferencingObjects(classification);
137

  
138
		testGroupedTaxa(appCtr);
139

  
136 140

  
137 141
//		int n = appCtr.getAgentService().count(null);
138 142
//		logger.warn("End adding " + n + " persons");
......
162 166
	}
163 167

  
164 168

  
169
    /**
170
     * @param appCtr
171
     */
172
    private void testGroupedTaxa(CdmApplicationController appCtr) {
173
        UUID classificationUuid = UUID.fromString("91231ebf-1c7a-47b9-a56c-b45b33137244");
174
		UUID taxonUuid1 = UUID.fromString("3bae1c86-1235-4e2e-be63-c7f8c4410527");
175
		UUID taxonUuid2 = UUID.fromString("235d3872-defe-4b92-bf2f-75a7c91510de");
176
		List<UUID> taxonUuids = Arrays.asList(new UUID[]{taxonUuid1, taxonUuid2});
177
		Rank maxRank = DefinedTermBase.getTermByClassAndUUID(Rank.class, UUID.fromString("af5f2481-3192-403f-ae65-7c957a0f02b6"));
178
		Rank minRank = DefinedTermBase.getTermByClassAndUUID(Rank.class, UUID.fromString("78786e16-2a70-48af-a608-494023b91904"));
179
        List<GroupedTaxonDTO> groupedTaxa = appCtr.getClassificationService().groupTaxaByHigherTaxon(taxonUuids, classificationUuid, minRank, maxRank);
180
        System.out.println(groupedTaxa);
181
    }
182

  
183

  
165 184
    private void addPerson(CdmApplicationController appCtr) {
166 185
        TransactionStatus tx = appCtr.startTransaction();
167 186
		appCtr.getAgentService().save(Person.NewInstance());

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)