Project

General

Profile

« Previous | Next » 

Revision 1b756c5f

Added by Andreas Kohlbecker almost 5 years ago

fix #6392 test for uses and use records and refactoring of the uses feature block

  • fixing wrong assumptions for cyprus
  • bibliography as pseudo feature block better testable

View differences:

modules/cdm_dataportal/cdm_dataportal.css
262 262
    font-style: italic;
263 263
}
264 264

  
265
.use-records th {
266
    font-weight: normal;
267
}
268

  
269

  
265 270
/*
266 271
 * ======= synonymy =======
267 272
 */
......
706 711
    font-size: 100%; /* reset fontsize */
707 712
}
708 713

  
709
#useRecords th {
710
  font-weight: normal;
711
}
712 714

  
713 715
/* for compatibility with d5 themes */
714 716
.block-cdm-dataportal-feature ul {
modules/cdm_dataportal/cdm_dataportal.module
2431 2431
 *   source reference is considered to be not empty.
2432 2432
 *
2433 2433
 * @TODO this function may have become obsolete by the new method of detecting empty blocks,
2434
 *       see $block_content_is_not_empty in compose_feature_blocks() and
2434
 *       see $block_content_is_not_empty in make_feature_block_list() and
2435 2435
 *       $feature_block_has_content in compose_feature_block_items_generic
2436 2436
 */
2437 2437
function has_feature_node_description_elements($featureNode) {
modules/cdm_dataportal/includes/descriptions.inc
679 679
   *
680 680
   * @ingroup compose
681 681
   */
682
  function compose_feature_blocks($mergedFeatureNodes, $taxon) {
682
  function make_feature_block_list($mergedFeatureNodes, $taxon) {
683 683

  
684 684
    $block_list = array();
685 685

  
......
707 707

  
708 708
        if(array_search($node->feature->uuid, $use_description_features) !== false) {
709 709
          // do not show features which belong to the UseDescriptions, these are
710
          // handled by theme_cdm_block_Uses where the according descriptions are
710
          // handled by compose_feature_block_items_use_records() where the according descriptions are
711 711
          // fetched again separately.
712
          // UseDescriptions are a feature special to palmweb
712
          // UseDescriptions are a special feature introduced for palmweb
713 713
          continue;
714 714
        }
715 715

  
......
731 731
        }
732 732

  
733 733
        /*
734
         * Contend/Use Description (Use + UseRecord)
734
         * Content/Use Description (Use + UseRecord)
735 735
         */
736 736
        else if ($node->feature->uuid == UUID_USE_RECORD) {
737
          $block->content[] = cdm_block_use_description_content($taxon->uuid);
737
          $block->content[] = cdm_block_use_description_content($taxon->uuid, $node->feature);
738 738
          $block_content_is_empty = FALSE;
739 739
        }
740 740

  
......
787 787

  
788 788
    drupal_alter('cdm_feature_node_blocks', $block_list, $taxon);
789 789

  
790
    return _block_get_renderable_array($block_list);
790
    return  $block_list;
791 791
  }
792 792

  
793 793
/**
......
1516 1516
            $elements_out_array[] = compose_description_element_common_taxon_name($description_element, $feature_block_settings);
1517 1517
            break;
1518 1518
          case 'Uses':
1519
            /* IGNORE Uses classes, these are handled completely in theme_cdm_UseDescription */
1519
            /* IGNORE Uses classes, these are handled completely in compose_feature_block_items_use_records()  */
1520 1520
            break;
1521 1521
          default:
1522 1522
            $feature_block_has_content = true;
......
2004 2004
 * @return array
2005 2005
 *   A drupal render array
2006 2006
 */
2007
function cdm_block_use_description_content($taxon_uuid) {
2007
function cdm_block_use_description_content($taxon_uuid, $feature) {
2008 2008

  
2009
  $use_description_content = '';
2009
  $use_description_content = array();
2010 2010

  
2011 2011
  if (is_uuid($taxon_uuid )) {
2012 2012
    $markerTypes = array();
2013 2013
    $markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
2014 2014
    $useDescriptions = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXON . '/' . $taxon_uuid . '/descriptions', $markerTypes);
2015 2015
    if (!empty($useDescriptions)) {
2016
      $use_description_content = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxon_uuid));
2016
      $use_description_content = compose_feature_block_items_use_records($useDescriptions, $taxon_uuid, $feature);
2017 2017
    }
2018 2018
  }
2019 2019

  
2020
  return markup_to_render_array($use_description_content);
2020
  return $use_description_content;
2021
}
2022

  
2023
/**
2024
 * Creates a trunk of a feature object which can be used to build pseudo feature blocks like the Bibliography.
2025
 *
2026
 * @param $representation_L10n
2027
 * @param String $pseudo_feature_key
2028
 *    Will be set as uuid but should be one of 'BIBLIOGRAPHY', ... more to come. See also get_feature_block_settings()
2029
 *
2030
 * @return object
2031
 *  The feature object
2032
 */
2033
function make_pseudo_feature($representation_L10n, $pseudo_feature_key = null){
2034
  $feature = new stdClass;
2035
  $feature->representation_L10n = $representation_L10n;
2036
  $feature->uuid = $pseudo_feature_key;
2037

  
2038
  return $feature;
2039

  
2021 2040
}
2022 2041

  
2023 2042

  
modules/cdm_dataportal/includes/occurrences.inc
406 406
//                 continue;
407 407
//               }
408 408
              $elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
409
              $description_render_elements = compose_feature_blocks($elements_by_feature, null);
409
              $description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
410 410
              $dd_elements[] = $description_render_elements;
411 411
            }
412 412

  
modules/cdm_dataportal/includes/pages.inc
713 713
    }
714 714
  }
715 715

  
716
  $pseudo_feature_blocks = array();
717
  $pseudo_feature_block_toc_items = array();
716 718

  
717
  // Render the sections for each feature
718
  $render_array['taxon_description_features'] = compose_feature_blocks($merged_tree->root->childNodes, $taxon);
719 719

  
720
  // Render the sections for each real feature
721
  $feature_block_list = make_feature_block_list($merged_tree->root->childNodes, $taxon);
722

  
723
  // Bibliography
720 724
  $bibliography_settings = get_bibliography_settings();
721 725
  if($bibliography_settings['enabled'] == 1){
722
    $bibliography_block = feature_block(t('Bibliography'));
723
    $bibliography_block->content = FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', '');
726
    $feature_bibliography = make_pseudo_feature('Bibliography', 'BIBLIOGRAPHY');
727
    $bibliography_block = feature_block(t('Bibliography'), $feature_bibliography);
728
    $bibliography_item = markup_to_render_array(FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', ''));
729
    $bibliography_block->content[] = compose_feature_block_wrap_elements(array($bibliography_item), $feature_bibliography);
724 730

  
725 731
    if(!empty($bibliography_block->content)){
726
      $render_array['taxon_description_bibliography'] =  markup_to_render_array(
727
        theme('block',
728
          array(
729
            'elements' => array(
730
              '#block' => $bibliography_block,
731
              '#children' => $bibliography_block->content,
732
            )
733
          )
734
        ),
735
        100 // weight
736
      );
737
      cdm_toc_list_add_item('Bibliography', 'bibliography');
732
      $pseudo_feature_block_toc_items['Bibliography']= 'bibliography';
733
      $pseudo_feature_blocks[] = $bibliography_block;
738 734
    }
735
  }
736

  
737
  $render_array['taxon_description_features'] = _block_get_renderable_array(
738
    array_merge($feature_block_list, $pseudo_feature_blocks)
739
  );
739 740

  
741
  if($pseudo_feature_block_toc_items){
742
    foreach ($pseudo_feature_block_toc_items as $label=>$fragment){
743
      cdm_toc_list_add_item($label, $fragment);
744
    }
740 745
  }
741 746

  
742 747
  // create the table of content
modules/cdm_dataportal/settings.php
685 685
        'sort_elements' => NO_SORT,
686 686
        'glue' => '',
687 687
        'element_tag' => NULL
688
      ),
689
      // settings for pseudo feature bibliography
690
      // only hard coded here
691
      'BIBLIOGRAPHY' => array(
692
        'as_list' => 'div',
693
        'link_to_reference' => 0,
694
        'link_to_name_used_in_source' => 1,
695
        'sources_as_content' => 0,
696
        'sources_as_content_to_bibliography' => 0,
697
        'sort_elements' => NO_SORT,
698
        'glue' => '',
699
        'element_tag' => NULL
688 700
      )
689 701
    );
690 702

  
......
833 845
      'sources_as_content' => 0,
834 846
      'sources_as_content_to_bibliography' => 0,
835 847
      'sort_elements' => NO_SORT, // will cause ...
836
      'glue' => '',
848
      'glue' => ' ',
837 849
      'element_tag' => 'div',
838 850
      'special' => array()
839 851
    );
......
861 873
      default:
862 874
        $settings_for_theme = $other_themes_default;
863 875
    }
876
    // add pseudo feature settings
877
    $settings_for_theme['BIBLIOGRAPHY'] = $default['BIBLIOGRAPHY'];
878

  
864 879
    // ---- END of DEFAULTS
865 880

  
866 881
    $saved_settings = variable_get(FEATURE_BLOCK_SETTINGS, NULL);
......
889 904

  
890 905
    return $feature_block_setting;
891 906
}
892
  /**
907

  
908
/**
893 909
 * returns the current setting for the original source bibliography
894 910
 *
895 911
 * Caches internally
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
357 357
}
358 358

  
359 359
/**
360
 * This theming function formats the use description and use record list for
361
 * these descriptions.
360
 * Composes block of USE_RECORD and USES feature elements for the given TaxonDescriptions.
362 361
 *
363
 * @see http://drupal.org/node/1354
364
 */
365
function theme_cdm_UseDescription($variables) {
362
 * @param $descriptions
363
 *   The set of TaxonDescriptions
364
 * @param $taxonUuid
365
 *   UUID of the taxon to which the descriptions belong
366
* @return array
367
 *    A Drupal render array
368
 *
369
 * @see cdm_block_use_description_content()
370
 *
371
 * @ingroup compose
372
*/
373
  function compose_feature_block_items_use_records($descriptions, $taxonUuid, $feature) {
366 374

  
367 375

  
368 376
  RenderHints::pushToRenderStack('block_Uses');
369 377

  
370
  $descriptions = $variables['description'];
371
  $taxonUuid = $variables['taxonUuid'];
372
  $out = '<ul id="Description" class ="description">';
373 378
  if ($descriptions == NULL) {
374
    return '';
379
    return null;
375 380
  }
376 381

  
377 382
  $feature_block_settings = get_feature_block_settings(UUID_USE_RECORD);
378 383

  
379
  $descriptionSynonyms = '';
380
  $descriptionOut = '';
381
  $synonymOut = '';
384
  $on_current_taxon = array();
385
  $on_other_taxa = array();
386

  
382 387
  $currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
383 388

  
384 389
  foreach ($descriptions as $description) {
......
390 395
      }
391 396
    }
392 397
    // uses will be ordered by source
393
    foreach ($description->sources as $source) {
398
    foreach ($description->sources as $description_source) {
394 399
      $originalTaxonUsedInSource = NULL;
395 400
      $originalTaxonPager = NULL;
396
      if ($source->originalNameString) {
401
      if ($description_source->originalNameString) {
397 402
        $request_params = array();
398
        $request_params['query'] = $source->originalNameString;
403
        $request_params['query'] = $description_source->originalNameString;
399 404
        $request_params['matchMode'] = "EXACT";
400 405
        $originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
401 406
        if ($originalTaxonPager->count > 0) {
......
409 414
        $originalTaxonUsedInSource = $currentTaxon->name;
410 415
      }
411 416

  
412
      $is_about_current_taxon = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
413

  
414
      if (!$is_about_current_taxon) {
415
        $descriptionOut .= '<li class="descriptionText DescriptionElement">';
416
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
417
          'absolute' => TRUE,
418
          'html' => TRUE,
419
        ));
420
        $descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
421
        $descriptionOut .= $useSummary;
422
        foreach ($description->sources as $source) {
423
          $descriptionOut .= " (" . theme('cdm_OriginalSource', array(
424
              'source' => $source,
425
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
426
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1)) . ")";
427
        }
428
        $hasUseRecords = FALSE;
429
        $descriptionUseRecordOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
430
        foreach ($description->elements as $descriptionElement) {
431
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
432
            $hasUseRecords = TRUE;
433
            // FIXME localization hardcoded to English
434
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
435
            $descriptionUseRecordOut .= '<tr>';
436
            $descriptionUseRecordOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
437
            $descriptionUseRecordOut .= '</tr>';
438
          }
439
        }
440
        $descriptionUseRecordOut .= '</table></div>';
441
        if ($hasUseRecords) {
442
          $descriptionOut .= $descriptionUseRecordOut . '</li>';
443
        }
417
      $markup = '<li class="descriptionText DescriptionElement">';
418
      $name_used_in_source_link_to_show_use = l($description_source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
419
        'absolute' => TRUE,
420
        'html' => TRUE,
421
      ));
422
      $markup .= $name_used_in_source_link_to_show_use . ': ';
423
      $markup .= $useSummary;
424
      foreach ($description->sources as $element_source) {
425
        $markup .= " (" . theme('cdm_OriginalSource', array(
426
            'source' => $element_source,
427
            'doLink' => $feature_block_settings['link_to_reference'] == 1,
428
            'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1)) . ")";
444 429
      }
445
      else {
446
        // TODO +/- duplicate of above, unify this code
447
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
448
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
449
          'absolute' => TRUE,
450
          'html' => TRUE,
451
        ));
452

  
453
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
454
        $synonymOut .= $useSummary;
455
        foreach ($description->sources as $source) {
456
          $synonymOut .= " (" . theme('cdm_OriginalSource', array(
457
              'source' => $source,
458
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
459
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1
460
            )) . ")";
430
      $hasUseRecords = FALSE;
431
      $descriptionUseRecordOut = '<div class="use-records"><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
432
      foreach ($description->elements as $descriptionElement) {
433
        if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
434
          $hasUseRecords = TRUE;
435
          $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
436
          $descriptionUseRecordOut .= '<tr>';
437
          $descriptionUseRecordOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
438
          $descriptionUseRecordOut .= '</tr>';
461 439
        }
440
      }
441
      $descriptionUseRecordOut .= '</table></div>';
442
      if ($hasUseRecords) {
443
        $markup .= $descriptionUseRecordOut . '</li>';
444
      }
462 445

  
463
        $hasUseRecords = FALSE;
464
        $useRecordTableOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
465
        foreach ($description->elements as $descriptionElement) {
466
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
467
            $hasUseRecords = TRUE;
468
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
469
            $useRecordTableOut .= '<tr>';
470
            $useRecordTableOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
471
            $useRecordTableOut .= '</tr>';
472
          }
473
        }
474
        $useRecordTableOut .= '</table></div>';
475
        if ($hasUseRecords) {
476
          $synonymOut .= $useRecordTableOut . '</li>';
477
        }
446
      $is_about_current_taxon_name = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
447
      if ($is_about_current_taxon_name) {
448
        $on_current_taxon[] = markup_to_render_array($markup);
449
      } else {
450
        $on_other_taxa[] = markup_to_render_array($markup);
478 451
      }
479 452

  
480
      // }
481 453
    }
482 454
  }
483
  $out .= $descriptionOut . $synonymOut;
484
  $out .= "</ul></div>";
455

  
456
  $render_array = compose_feature_block_wrap_elements(array_merge($on_current_taxon, $on_other_taxa), $feature);
485 457

  
486 458
  RenderHints::popFromRenderStack();
487 459

  
488
  return $out;
460
  return $render_array;
489 461
}
modules/cdm_dataportal/theme/theme_registry.inc
80 80
    'cdm_poytomousKeyNode_modifyingText' => array('variables' => array('modifyingText' => NULL)),
81 81
    'cdm_list_IdentificationKeys' => array('variables' => array('type' => NULL, 'taxonUuid' => NULL)),
82 82
    'cdm_block_IdentificationKeys' => array('variables' => array('taxonUuid' => NULL)),
83
    'cdm_UseDescription' => array('variables' => array('description' => NULL, 'taxonUuid' => NULL)),
84 83

  
85 84
    // Themes in cdm_dataportal.media.theme.
86 85
    'cdm_media_mime_application' => array('variables' => array('mediaRepresentation' => NULL, 'feature' => NULL)),
src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Bassia_indica_TaxonProfileTest.java
8 8
 */
9 9
package eu.etaxonomy.dataportal.selenium.tests.cyprus;
10 10

  
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNotNull;
13
import static org.junit.Assert.assertNull;
14

  
15 11
import java.net.MalformedURLException;
16 12
import java.util.List;
17 13
import java.util.UUID;
......
80 76

  
81 77
        featureBlock = p.getFeatureBlockAt(2, "distribution", "div", "span");
82 78

  
83
        assertEquals("Distribution\nDivision 4A Division 5B Division 6C\nThe record for division 5 may refer to division 6.\nA. J. Chrtek & B. Slavík, Contribution to the flora of Cyprus. 4. in Fl. Medit. 10. 2001, B. A. Della & G. Iatrou, New plant records from Cyprus in Kew Bull. 50. 1995, C. R. Hand, Supplementary notes to the flora of Cyprus III. in Willdenowia 33. 2003", featureBlock.getText());
79
        assertEquals("Distribution\n"
80
                + "Division 4A\n"
81
                + "Division 5B\n"
82
                + "Division 6C\n"
83
                + "The record for division 5 may refer to division 6.\nA. J. Chrtek & B. Slavík, Contribution to the flora of Cyprus. 4. in Fl. Medit. 10. 2001, B. A. Della & G. Iatrou, New plant records from Cyprus in Kew Bull. 50. 1995, C. R. Hand, Supplementary notes to the flora of Cyprus III. in Willdenowia 33. 2003", featureBlock.getText());
84 84
        assertEquals("Distribution", featureBlock.getHeader());
85 85
        assertEquals("expecting two footnote keys", 3, featureBlock.countFootNoteKeys());
86 86

  
src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Calamus_acanthospathus_TaxonProfileTest.java
58 58
    @Test
59 59
    public void testTitleAndTabs() {
60 60

  
61
        assertEquals(getContext().prepareTitle("Calamus acanthospathus Griff., Calcutta J. Nat. Hist. 5: 39. 1845"), p.getTitle());
61
        assertEquals(getContext().prepareTitle("Calamus acanthospathus Griff., Calcutta J. Nat. Hist. 5: 39. 1845"), driver.getTitle());
62 62
        assertNull("Authorship information should be hidden", p.getAuthorInformationText());
63 63

  
64 64
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
......
75 75
    public void testProfileImage() {
76 76
        ImgElement profileImage = p.getProfileImage();
77 77
        assertNotNull("Expecting profile images to be switched on", profileImage);
78
        assertTrue("Expoecting image palm_tc_29336_1.jpg", profileImage.getSrcUrl().toString().endsWith("/palm_tc_29336_1.jpg"));
78
        assertTrue("Expecting image palm_tc_29336_1.jpg", profileImage.getSrcUrl().toString().endsWith("/palm_tc_29336_1.jpg"));
79 79
    }
80 80

  
81 81

  
src/test/java/eu/etaxonomy/dataportal/selenium/tests/palmae/Iriartea_deltoidea_UsesTest.java
1
/**
2
 * Copyright (C) 2009 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.dataportal.selenium.tests.palmae;
10

  
11
import java.net.MalformedURLException;
12
import java.util.List;
13
import java.util.UUID;
14

  
15
import org.junit.Before;
16
import org.junit.Test;
17
import org.openqa.selenium.By;
18
import org.openqa.selenium.WebElement;
19

  
20
import eu.etaxonomy.dataportal.DataPortalContext;
21
import eu.etaxonomy.dataportal.elements.FeatureBlock;
22
import eu.etaxonomy.dataportal.elements.LinkElement;
23
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
24
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
25
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
26

  
27
/**
28
 * @author a.kohlbecker
29
 *
30
 */
31

  
32
@DataPortalContexts( { DataPortalContext.palmae })
33
public class Iriartea_deltoidea_UsesTest extends CdmDataPortalTestBase{
34

  
35
    static UUID taxonUuid = UUID.fromString("ce870eca-0422-4a3c-b849-0f5ca0370b1f");
36

  
37
    static TaxonProfilePage p = null;
38

  
39
    @Before
40
    public void setUp() throws MalformedURLException {
41

  
42
        if(p == null){
43
            p = new TaxonProfilePage(driver, getContext(), taxonUuid);
44
        }
45

  
46
    }
47

  
48

  
49
    @Test
50
    public void testTitleAndTabs() {
51

  
52
        assertEquals(getContext().prepareTitle("Iriartea deltoidea Ruiz & Pav., Syst. Veg. Fl. Peruv. Chil. : 298 (1798)"), driver.getTitle());
53
        assertNull("Authorship information should be hidden", p.getAuthorInformationText());
54

  
55
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
56
        int tabId = 0;
57
        assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
58
        assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
59
        assertEquals("Images", primaryTabs.get(tabId++).getText());
60
        assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
61

  
62
    }
63

  
64

  
65
    @Test
66
    public void testFeatureToc() {
67

  
68
        assertEquals("Content", p.getTableOfContentHeader());
69
        List<LinkElement> links = p.getTableOfContentLinks();
70
        assertEquals("Expecting 7 entries in the TOC of the profile page.", 7, links.size());
71
    }
72

  
73
    @Test
74
    public void testFeatureDistribution() {
75

  
76
        int featureId = 0;
77

  
78
        int descriptionElementFontSize = 11;
79
        String expectedListStyleType = "none";
80
        String expectedCssDisplay = "inline";
81
        String expectedListStylePosition = "outside";
82
        String expectedListStyleImage = "none";
83
        int indent = 23;
84

  
85
        /* distribution */
86
        String featureClass = "distribution";
87
        String featureLabel = "Distribution";
88
        String blockTextFull = featureLabel + "\n\n\n\n\nMap uses TDWG level 3 distributions (http://www.nhm.ac.uk/hosted_sites/tdwg/geogrphy.html)\n"
89
                + "Bolivia (World Checklist of Arecaceae), Brazil North (World Checklist of Arecaceae), Colombia (World Checklist of Arecaceae), Costa Rica (World Checklist of Arecaceae), Ecuador (World Checklist of Arecaceae), Nicaragua (World Checklist of Arecaceae), Panamá (World Checklist of Arecaceae), Peru (World Checklist of Arecaceae), Venezuela (World Checklist of Arecaceae)\n"
90
                + "Central America to Ecuador W of the Andes, and in the W part of the Amazon region from Venezuela to Bolivia. Perhaps the most common native tree species in Ecuador, occurring in all provinces that include moist lowland areas. (Borchsenius F., Borgtoft-Pedersen H. and Baslev H. 1998. Manual to the Palms of Ecuador. AAU Reports 37. Department of Systematic Botany, University of Aarhus, Denmark in collaboration with Pontificia Universidad Catalica del Ecuador)";
91

  
92
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
93
        FeatureBlock featureBlockDistribution = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
94

  
95
        assertEquals(blockTextFull, featureBlockDistribution.getText());
96
        featureBlockDistribution.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
97

  
98
        assertNotNull("Expecting an OpenLayers map", featureBlockDistribution.getElement().findElement(By.id("openlayers-map-distribution")));
99
        assertEquals("Map uses TDWG level 3 distributions (http://www.nhm.ac.uk/hosted_sites/tdwg/geogrphy.html)", featureBlockDistribution.getElement().findElement(By.className("distribution_map_caption")).getText());
100

  
101
    }
102

  
103
    @Test
104
    public void testUses() {
105

  
106
        int featureId = 2;
107
        int descriptionElementFontSize = 11;
108
        String expectedCssDisplay = "inline";
109
        String expectedListStyleType = "none";
110
        String expectedListStylePosition = "outside";
111
        String expectedListStyleImage = "none";
112
        int indent = 23;
113

  
114
        /* Biology And Ecology */
115
        String featureClass = "uses";
116
        String featureLabel = "Uses";
117
        String blockTextFull = featureLabel + "\nThe outer part of the stems are used throughout its range for building purposes, e.g., floors, posts, poles; also for blowguns, bows, harpoons and arrow points; and also for firewood. The leaves are used for thatching and basketry. The heart and seeds are occasionally eaten. The inside layer of the leaf sheath is used to give women strength in labor (Shemluck & Ness 163, Ecuador). Hollowed-out stems are used as coffins by Embera Indians in Colombia (R. Bernal, pers. comm.). Steven King (pers. comm.) reports that in northern Peru Angotere-Secoya and Quechua people use the stems of I. deltoidea as canoes. Large specimens are selected and carefully felled. The soft central ground tissue is removed from the center of the stem, and base and apex fashioned into bow and stern. The canoes are widely used for shortening trips, especially long overland trips where short-cuts can be made by river. Canoes last about two or three months. Such is the demand for these temporary canoes that many of the larger specimens of Iriartea have been felled in this area. Rodrigo Bernal (pers. comm.) reports that in Colombia the Embera Indians of the Choco tie the stems together and use them as rafts. Since these are so heavy they are only used for downstream travel. (Henderson, A. 1990. Introduction and the Iriarteinae. Flora Neotropica Monograph 53.)";
118
        expectedCssDisplay = "list-item";
119
        expectedListStyleType = "none";
120

  
121
        p.testTableOfContentEntry(featureId,featureLabel, featureClass);
122
        FeatureBlock featureBlockBibliography = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
123

  
124
        assertEquals(blockTextFull, featureBlockBibliography.getText());
125
        featureBlockBibliography.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
126

  
127
    }
128

  
129
    @Test
130
    public void testFeatureUseRecord() {
131

  
132
        int featureId = 5;
133

  
134
        String featureClass = "use-record";
135
        String featureLabel = "Use Record";
136

  
137
        p.testTableOfContentEntry(featureId,featureLabel, featureClass);
138
        FeatureBlock featureBlockBioEco = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
139

  
140
        List<WebElement> listItems = featureBlockBioEco.getElement().findElements(By.tagName("li"));
141
        assertEquals(95, listItems.size());
142

  
143
        String item14UseRecordText =
144
                "Use Category Use Sub Category Plant Part Human Group Ethnic Group Country\n"
145
                + "Construction Thatch Entire leaf Indigenous Tsimane/Mosetene Bolivia\n"
146
                + "Utensils and Tools Domestic Stem Indigenous Tsimane/Mosetene Bolivia\n"
147
                + "Utensils and Tools Domestic Leaf sheath Indigenous Tsimane/Mosetene Bolivia\n"
148
                + "Human Food Food Palm heart Indigenous Tsimane/Mosetene Bolivia\n"
149
                + "Cultural Personal adornment Seeds Indigenous Tsimane/Mosetene Bolivia\n"
150
                + "Construction Houses Stem Indigenous Tsimane/Mosetene Bolivia";
151

  
152

  
153
        assertEquals("Iriartea deltoidea Ruiz & Pav.: Alimentación humana. Palmito. Cuando es tierno, se corta y pela para consumir crudo en ensalada. Comercial. Semilla. Es utilizada en la elaboración de collares. Construcción. Estípite. Construcción de viviendas, en postes y vigas transversales. La parte externa es cortada el segmentos longitudinales, secada, y empleada en las paredes, suelo, y como cuerda natural. Construcción. Hoja. Techado de campamentos temporales. Utensilios y herr. de uso doméstico. Estípite. Elaboración de \"guarachas\" (estantes para depositar objetos). Utensilios y herr. de uso doméstico. Hoja (vaina). La vaina seca de la hoja se utiliza para hacer recipientes. (Armesilla, P.J., Usos de las palmeras (Arecaceae),en la Reserva de la Biosfera-Tierra Comunitaria de Orígen Pilón Lajas, (Bolivia). 2006)\n"
154
                + item14UseRecordText,
155
                listItems.get(0).getText());
156
        // tabular
157
        assertEquals(item14UseRecordText,
158
                listItems.get(0).findElement(By.className("use-records")).getText());
159
        // synonym
160
        assertEquals("Iriartea ventricosa Mart.: De las líneas de la hoja de esta palmera que crece en forma silvestre, los tacana elaboran recipientes de diferentes tamaños. (…). Para la elaboración de cercos , (…), los tacana utilizan los troncos de las palmeras chonta, motacú, copa, assai, majillo, pachiuva, tola y tuana. (…). Para la elaboración de cercos , (…), los tacana utilizan los troncos de las palmeras chonta, motacú, copa, assai, majillo, pachiuva, tola y tuana. (Hissink, K., and A. Hahn, Los Tacana- datos sobre la historia de su civilización. 2000 (as Iriartea ventricosa Mart.))",
161
            listItems.get(81).getText());
162

  
163
    }
164

  
165
    @Test
166
    public void testBibliography() {
167

  
168
        int featureId = 6;
169
        int descriptionElementFontSize = 11;
170
        String expectedCssDisplay = "block";
171
        String expectedListStyleType = "none";
172
        String expectedListStylePosition = "outside";
173
        String expectedListStyleImage = "none";
174
        int indent = 0;
175

  
176
        String featureClass = "bibliography";
177
        String featureLabel = "Bibliography";
178
        String blockTextFull = featureLabel + "\n"
179
                + " Borchsenius F., Borgtoft-Pedersen H. and Baslev H. 1998. Manual to the Palms of Ecuador. AAU Reports 37. Department of Systematic Botany, University of Aarhus, Denmark in collaboration with Pontificia Universidad Catalica del Ecuador\n"
180
                + " World Checklist of Arecaceae\n"
181
                + " Henderson, A. 1990. Introduction and the Iriarteinae. Flora Neotropica Monograph 53.";
182

  
183
        p.testTableOfContentEntry(featureId,featureLabel, featureClass);
184
        FeatureBlock featureBlockBibliography = p.getFeatureBlockAt(featureId, featureClass, "div", "div");
185

  
186
        assertEquals(blockTextFull, featureBlockBibliography.getText());
187
        featureBlockBibliography.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
188

  
189
    }
190

  
191
}

Also available in: Unified diff