Project

General

Profile

Revision cc95089b

IDcc95089bbf829679ce7e4c80c0a611b622bd6081
Parent 1b6c7edf
Child 177a283a

Added by Andreas Kohlbecker over 3 years ago

ref #6296 more tests for findByTaxaAndName

View differences:

cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceSearchTaxaAndNamesTest.java
126 126
     * {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator)}
127 127
     * .
128 128
     */
129
    /**
130
     * This test permutes through all search mode combinations.
131
     *
132
     * 7 Accepted Taxa
133
     * 1 Synonym
134
     * 1 misapplied which is also in the set of accepted
135
     * 2 Names without taxa
136
     *
137
     */
129 138
    @Test
130 139
    @DataSet
131 140
    public final void testFindTaxaAndNames() {
132 141

  
133 142
        IFindTaxaAndNamesConfigurator<?> conf = new FindTaxaAndNamesConfiguratorImpl();
134 143
        conf.setTitleSearchString("Abies*");
135
        //conf.setClassification(classificationService.load(UUID.fromString(CLASSIFICATION_UUID)));
136 144
        conf.setMatchMode(MatchMode.BEGINNING);
137 145

  
146
        // ---------------------------------------------------------
147

  
138 148
        setTaxaAndNamesModes(conf, true, true, true, true, true);
139 149
        Pager<IdentifiableEntity> pager = taxonService.findTaxaAndNames(conf);
140 150
        logSearchResults(pager, Level.DEBUG);
......
150 160

  
151 161
        setTaxaAndNamesModes(conf, false, false, true, true, true);
152 162
        pager = taxonService.findTaxaAndNames(conf);
153
        logSearchResults(pager, Level.DEBUG);
163
        //logSearchResults(pager, Level.DEBUG);
154 164
        assertEquals(3, pager.getRecords().size());
155 165

  
166
        // ---------------------------------------------------------
167

  
156 168
        setTaxaAndNamesModes(conf, true, true, false, true, true);
157 169
        pager = taxonService.findTaxaAndNames(conf);
158 170
        assertEquals(10, pager.getRecords().size());
159 171

  
172

  
160 173
     // FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
161 174
     //   setTaxaAndNamesModes(conf, false, true, false, true, true);
162 175
     //   pager = taxonService.findTaxaAndNames(conf);
163 176
     //   assertEquals(3, pager.getRecords().size());
164 177

  
178
        setTaxaAndNamesModes(conf, true, false, false, true, true);
179
        pager = taxonService.findTaxaAndNames(conf);
180
        assertEquals(9, pager.getRecords().size());
181

  
165 182
        setTaxaAndNamesModes(conf, false, false, false, true, true);
166 183
        pager = taxonService.findTaxaAndNames(conf);
167 184
        assertEquals(3, pager.getRecords().size());
168 185

  
186
        // =========================================================
187

  
188
        setTaxaAndNamesModes(conf, true, true, true, false, true);
189
        pager = taxonService.findTaxaAndNames(conf);
190
        // logSearchResults(pager, Level.DEBUG);
191
        assertEquals(10, pager.getRecords().size());
192

  
193
        // FIXME the Synonym Abies subalpina missing in result set
194
//        setTaxaAndNamesModes(conf, false, true, true, false, true);
195
//        pager = taxonService.findTaxaAndNames(conf);
196
//        logSearchResults(pager, Level.DEBUG);
197
//        assertEquals(3, pager.getRecords().size());
198

  
199
        setTaxaAndNamesModes(conf, true, false, true, false, true);
200
        pager = taxonService.findTaxaAndNames(conf);
201
        logSearchResults(pager, Level.DEBUG);
202
        assertEquals(9, pager.getRecords().size());
203

  
204
        setTaxaAndNamesModes(conf, false, false, true, false, true);
205
        pager = taxonService.findTaxaAndNames(conf);
206
        logSearchResults(pager, Level.DEBUG);
207
        assertEquals(2, pager.getRecords().size());
208

  
209
        // ---------------------------------------------------------
210

  
211
        setTaxaAndNamesModes(conf, true, true, false, false, true);
212
        pager = taxonService.findTaxaAndNames(conf);
213
        logSearchResults(pager, Level.DEBUG);
214
        assertEquals(10, pager.getRecords().size());
215

  
216
        setTaxaAndNamesModes(conf, false, true, false, false, true);
217
        pager = taxonService.findTaxaAndNames(conf);
218
        logSearchResults(pager, Level.DEBUG);
219
        assertEquals(3, pager.getRecords().size());
220

  
221
        setTaxaAndNamesModes(conf, true, false, false, false, true);
222
        pager = taxonService.findTaxaAndNames(conf);
223
        logSearchResults(pager, Level.DEBUG);
224
        assertEquals(9, pager.getRecords().size());
225

  
226
        // only names without taxa
227
        // - Abies borisii-regis
228
        // - Abies lasio
229
        setTaxaAndNamesModes(conf, false, false, false, false, true);
230
        pager = taxonService.findTaxaAndNames(conf);
231
        logSearchResults(pager, Level.DEBUG);
232
        assertEquals(2, pager.getRecords().size());
233

  
234
        // =========================================================
235

  
236
        setTaxaAndNamesModes(conf, true, true, true, true, false);
237
        pager = taxonService.findTaxaAndNames(conf);
238
        logSearchResults(pager, Level.DEBUG);
239
        assertEquals(8, pager.getRecords().size());
240

  
241
        setTaxaAndNamesModes(conf, false, true, true, true, false);
242
        pager = taxonService.findTaxaAndNames(conf);
243
        logSearchResults(pager, Level.DEBUG);
244
        assertEquals(1, pager.getRecords().size());
245

  
246
        setTaxaAndNamesModes(conf, true, false, true, true, false);
247
        pager = taxonService.findTaxaAndNames(conf);
248
        logSearchResults(pager, Level.DEBUG);
249
        assertEquals(7, pager.getRecords().size());
250

  
251
        setTaxaAndNamesModes(conf, false, false, true, true, false);
252
        pager = taxonService.findTaxaAndNames(conf);
253
        logSearchResults(pager, Level.DEBUG);
254
        assertEquals(1, pager.getRecords().size());
255

  
256
        // ---------------------------------------------------------
257

  
258
        setTaxaAndNamesModes(conf, true, true, false, true, false);
259
        pager = taxonService.findTaxaAndNames(conf);
260
        logSearchResults(pager, Level.DEBUG);
261
        assertEquals(8, pager.getRecords().size());
262

  
263
        // FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
264
//        setTaxaAndNamesModes(conf, false, true, false, true, false);
265
//        pager = taxonService.findTaxaAndNames(conf);
266
//        logSearchResults(pager, Level.DEBUG);
267
//        assertEquals(2, pager.getRecords().size());
268

  
269
        setTaxaAndNamesModes(conf, true, false, false, true, false);
270
        pager = taxonService.findTaxaAndNames(conf);
271
        logSearchResults(pager, Level.DEBUG);
272
        assertEquals(7, pager.getRecords().size());
273

  
169 274
        // only misapplied names
170 275
        // - Abies kawakamii sec. Komarov, V. L., Flora SSSR 29
171 276
        setTaxaAndNamesModes(conf, false, false, false, true, false);
......
173 278
        logSearchResults(pager, Level.DEBUG);
174 279
        assertEquals(1, pager.getRecords().size());
175 280

  
281
        // =========================================================
282

  
283
        setTaxaAndNamesModes(conf, true, true, true, false, false);
284
        pager = taxonService.findTaxaAndNames(conf);
285
        logSearchResults(pager, Level.DEBUG);
286
        assertEquals(8, pager.getRecords().size());
287

  
288
        // FIXME the Synonym Abies subalpina missing in result set
289
//        setTaxaAndNamesModes(conf, false, true, true, false, false);
290
//        pager = taxonService.findTaxaAndNames(conf);
291
//        logSearchResults(pager, Level.DEBUG);
292
//        assertEquals(1, pager.getRecords().size());
293

  
294
        setTaxaAndNamesModes(conf, true, false, true, false, false);
295
        pager = taxonService.findTaxaAndNames(conf);
296
        logSearchResults(pager, Level.DEBUG);
297
        assertEquals(7, pager.getRecords().size());
298

  
299
        setTaxaAndNamesModes(conf, false, false, true, false, false);
300
        pager = taxonService.findTaxaAndNames(conf);
301
        logSearchResults(pager, Level.DEBUG);
302
        assertEquals(0, pager.getRecords().size());
303

  
304
        // ---------------------------------------------------------
305

  
306
        setTaxaAndNamesModes(conf, true, true, false, false, false);
307
        pager = taxonService.findTaxaAndNames(conf);
308
        logSearchResults(pager, Level.DEBUG);
309
        assertEquals(8, pager.getRecords().size());
310

  
311
        setTaxaAndNamesModes(conf, false, true, false, false, false);
312
        pager = taxonService.findTaxaAndNames(conf);
313
        logSearchResults(pager, Level.DEBUG);
314
        assertEquals(1, pager.getRecords().size());
315

  
316
        setTaxaAndNamesModes(conf, true, false, false, false, false);
317
        pager = taxonService.findTaxaAndNames(conf);
318
        logSearchResults(pager, Level.DEBUG);
319
        assertEquals(7, pager.getRecords().size());
320

  
321
        setTaxaAndNamesModes(conf, false, false, false, false, false);
322
        pager = taxonService.findTaxaAndNames(conf);
323
        logSearchResults(pager, Level.DEBUG);
324
        assertEquals(0, pager.getRecords().size());
325
    }
326

  
327

  
328
    /**
329
     * Test method for
330
     * {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator)}
331
     * .
332
     */
333
    /**
334
     * This test permutes through all search mode combinations with classification filter
335
     *
336
     * 1 accepted taxon
337
     * 1 Synonym
338
     * 1 misapplied
339
     * 2 names without taxa
340
     *
341
     */
342
    @Test
343
    @DataSet
344
    public final void testFindTaxaAndNames_with_classification() {
345

  
346
        IFindTaxaAndNamesConfigurator<?> conf = new FindTaxaAndNamesConfiguratorImpl();
347
        conf.setTitleSearchString("Abies*");
348
        conf.setClassification(classificationService.load(UUID.fromString(CLASSIFICATION_UUID)));
349
        conf.setMatchMode(MatchMode.BEGINNING);
350

  
351
        // ---------------------------------------------------------
352

  
353
        setTaxaAndNamesModes(conf, true, true, true, true, true);
354
        Pager<IdentifiableEntity> pager = taxonService.findTaxaAndNames(conf);
355
        logSearchResults(pager, Level.DEBUG);
356
        assertEquals(5, pager.getRecords().size());
357

  
358
        // FIXME the Synonym Abies subalpina missing in result set
359
//        setTaxaAndNamesModes(conf, false, true, true, true, true);
360
//        pager = taxonService.findTaxaAndNames(conf);
361
//        logSearchResults(pager, Level.DEBUG);
362
//        assertEquals(4, pager.getRecords().size());
363

  
364
        setTaxaAndNamesModes(conf, true, false, true, true, true);
365
        pager = taxonService.findTaxaAndNames(conf);
366
        assertEquals(4, pager.getRecords().size());
367

  
368
        setTaxaAndNamesModes(conf, false, false, true, true, true);
369
        pager = taxonService.findTaxaAndNames(conf);
370
        //logSearchResults(pager, Level.DEBUG);
371
        assertEquals(3, pager.getRecords().size());
372

  
373
        // ---------------------------------------------------------
374

  
375
        setTaxaAndNamesModes(conf, true, true, false, true, true);
376
        pager = taxonService.findTaxaAndNames(conf);
377
        assertEquals(5, pager.getRecords().size());
378

  
379

  
380
     // FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
381
     //   setTaxaAndNamesModes(conf, false, true, false, true, true);
382
     //   pager = taxonService.findTaxaAndNames(conf);
383
     //   assertEquals(4, pager.getRecords().size());
384

  
385
        setTaxaAndNamesModes(conf, true, false, false, true, true);
386
        pager = taxonService.findTaxaAndNames(conf);
387
        assertEquals(4, pager.getRecords().size());
388

  
389
        setTaxaAndNamesModes(conf, false, false, false, true, true);
390
        pager = taxonService.findTaxaAndNames(conf);
391
        assertEquals(3, pager.getRecords().size());
392

  
393
        // =========================================================
394

  
395
        setTaxaAndNamesModes(conf, true, true, true, false, true);
396
        pager = taxonService.findTaxaAndNames(conf);
397
        // logSearchResults(pager, Level.DEBUG);
398
        assertEquals(4, pager.getRecords().size());
399

  
400
        // FIXME the Synonym Abies subalpina missing in result set
401
//        setTaxaAndNamesModes(conf, false, true, true, false, true);
402
//        pager = taxonService.findTaxaAndNames(conf);
403
//        logSearchResults(pager, Level.DEBUG);
404
//        assertEquals(3, pager.getRecords().size());
405

  
406
        setTaxaAndNamesModes(conf, true, false, true, false, true);
407
        pager = taxonService.findTaxaAndNames(conf);
408
        logSearchResults(pager, Level.DEBUG);
409
        assertEquals(3, pager.getRecords().size());
410

  
411
        setTaxaAndNamesModes(conf, false, false, true, false, true);
412
        pager = taxonService.findTaxaAndNames(conf);
413
        logSearchResults(pager, Level.DEBUG);
414
        assertEquals(2, pager.getRecords().size());
415

  
416
        // ---------------------------------------------------------
417

  
418
        setTaxaAndNamesModes(conf, true, true, false, false, true);
419
        pager = taxonService.findTaxaAndNames(conf);
420
        logSearchResults(pager, Level.DEBUG);
421
        assertEquals(4, pager.getRecords().size());
422

  
423
        setTaxaAndNamesModes(conf, false, true, false, false, true);
424
        pager = taxonService.findTaxaAndNames(conf);
425
        logSearchResults(pager, Level.DEBUG);
426
        assertEquals(3, pager.getRecords().size());
427

  
428
        setTaxaAndNamesModes(conf, true, false, false, false, true);
429
        pager = taxonService.findTaxaAndNames(conf);
430
        logSearchResults(pager, Level.DEBUG);
431
        assertEquals(3, pager.getRecords().size());
432

  
176 433
        // only names without taxa
177 434
        // - Abies borisii-regis
178 435
        // - Abies lasio
......
181 438
        logSearchResults(pager, Level.DEBUG);
182 439
        assertEquals(2, pager.getRecords().size());
183 440

  
184
        setTaxaAndNamesModes(conf, true, true, true, false, true);
441
        // =========================================================
442

  
443
        setTaxaAndNamesModes(conf, true, true, true, true, false);
185 444
        pager = taxonService.findTaxaAndNames(conf);
186 445
        logSearchResults(pager, Level.DEBUG);
187
        assertEquals(10, pager.getRecords().size());
446
        assertEquals(3, pager.getRecords().size());
188 447

  
448
        // FIXME the Synonym Abies subalpina missing in result set
449
//        setTaxaAndNamesModes(conf, false, true, true, true, false);
450
//        pager = taxonService.findTaxaAndNames(conf);
451
//        logSearchResults(pager, Level.DEBUG);
452
//        assertEquals(2, pager.getRecords().size());
189 453

  
190
        // FIXME permutate for all combinations, extra test each, with pager function.
191
        // if enabled:
192
        // t: taxa
193
        // s: synonym
194
        // c: common
195
        // w: NamesWithoutTaxa
196
        // m: setDoMisappliedNames
197
        // otherwise _
198
    }
454
        setTaxaAndNamesModes(conf, true, false, true, true, false);
455
        pager = taxonService.findTaxaAndNames(conf);
456
        logSearchResults(pager, Level.DEBUG);
457
        assertEquals(2, pager.getRecords().size());
458

  
459
        setTaxaAndNamesModes(conf, false, false, true, true, false);
460
        pager = taxonService.findTaxaAndNames(conf);
461
        logSearchResults(pager, Level.DEBUG);
462
        assertEquals(1, pager.getRecords().size());
463

  
464
        // ---------------------------------------------------------
465

  
466
        setTaxaAndNamesModes(conf, true, true, false, true, false);
467
        pager = taxonService.findTaxaAndNames(conf);
468
        logSearchResults(pager, Level.DEBUG);
469
        assertEquals(3, pager.getRecords().size());
470

  
471
        // FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
472
//        setTaxaAndNamesModes(conf, false, true, false, true, false);
473
//        pager = taxonService.findTaxaAndNames(conf);
474
//        logSearchResults(pager, Level.DEBUG);
475
//        assertEquals(2, pager.getRecords().size());
476

  
477
        setTaxaAndNamesModes(conf, true, false, false, true, false);
478
        pager = taxonService.findTaxaAndNames(conf);
479
        logSearchResults(pager, Level.DEBUG);
480
        assertEquals(2, pager.getRecords().size());
481

  
482
        // only misapplied names
483
        // - Abies kawakamii sec. Komarov, V. L., Flora SSSR 29
484
        setTaxaAndNamesModes(conf, false, false, false, true, false);
485
        pager = taxonService.findTaxaAndNames(conf);
486
        logSearchResults(pager, Level.DEBUG);
487
        assertEquals(1, pager.getRecords().size());
488

  
489
        // =========================================================
490

  
491
        setTaxaAndNamesModes(conf, true, true, true, false, false);
492
        pager = taxonService.findTaxaAndNames(conf);
493
        logSearchResults(pager, Level.DEBUG);
494
        assertEquals(2, pager.getRecords().size());
495

  
496
        // FIXME the Synonym Abies subalpina missing in result set
497
//        setTaxaAndNamesModes(conf, false, true, true, false, false);
498
//        pager = taxonService.findTaxaAndNames(conf);
499
//        logSearchResults(pager, Level.DEBUG);
500
//        assertEquals(1, pager.getRecords().size());
501

  
502
        setTaxaAndNamesModes(conf, true, false, true, false, false);
503
        pager = taxonService.findTaxaAndNames(conf);
504
        logSearchResults(pager, Level.DEBUG);
505
        assertEquals(1, pager.getRecords().size());
506

  
507
        setTaxaAndNamesModes(conf, false, false, true, false, false);
508
        pager = taxonService.findTaxaAndNames(conf);
509
        logSearchResults(pager, Level.DEBUG);
510
        assertEquals(0, pager.getRecords().size());
511

  
512
        // ---------------------------------------------------------
513

  
514
        setTaxaAndNamesModes(conf, true, true, false, false, false);
515
        pager = taxonService.findTaxaAndNames(conf);
516
        logSearchResults(pager, Level.DEBUG);
517
        assertEquals(2, pager.getRecords().size());
199 518

  
519
        setTaxaAndNamesModes(conf, false, true, false, false, false);
520
        pager = taxonService.findTaxaAndNames(conf);
521
        logSearchResults(pager, Level.DEBUG);
522
        assertEquals(1, pager.getRecords().size());
523

  
524
        setTaxaAndNamesModes(conf, true, false, false, false, false);
525
        pager = taxonService.findTaxaAndNames(conf);
526
        logSearchResults(pager, Level.DEBUG);
527
        assertEquals(1, pager.getRecords().size());
528

  
529
        setTaxaAndNamesModes(conf, false, false, false, false, false);
530
        pager = taxonService.findTaxaAndNames(conf);
531
        logSearchResults(pager, Level.DEBUG);
532
        assertEquals(0, pager.getRecords().size());
533
    }
200 534

  
201 535
    /**
202 536
     * Test method for
......
391 725
        t_abies_kawakamii.getTitleCache();
392 726
        taxonService.save(t_abies_kawakamii);
393 727

  
394

  
728
        //
729
        // 1 Misapplied Name
730
        //
395 731
        // abies_kawakamii_sensu_komarov as missapplied name for t_abies_balsamea
396 732
        Taxon t_abies_kawakamii_sensu_komarov = Taxon.NewInstance(n_abies_kawakamii, sec_sensu);
397 733
        taxonService.save(t_abies_kawakamii_sensu_komarov);
......
403 739
        Taxon t_abies_lasiocarpa = Taxon.NewInstance(n_abies_lasiocarpa, sec);
404 740
        taxonService.save(t_abies_lasiocarpa);
405 741

  
406
        // add taxa to classifications
742
        // add 3 taxa to classifications
407 743
        europeanAbiesClassification.addChildTaxon(t_abies_balsamea, null, null);
408 744
        alternativeClassification.addChildTaxon(t_abies_lasiocarpa, null, null);
409 745
        classificationService.saveOrUpdate(europeanAbiesClassification);
410 746
        classificationService.saveOrUpdate(alternativeClassification);
411 747

  
412 748
        //
413
        // Names without taxa
749
        // 2 Names without taxa
414 750
        //
415 751
        BotanicalName n_abies_borisiiregis = BotanicalName.NewInstance(Rank.SPECIES());
416 752
        n_abies_borisiiregis.setNameCache("Abies borisii-regis", true);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)