commit 619db3066e49011fe08015b44382d4e6d02a8ee9
Author: Andreas Müller <a.mueller@bgbm.org>
Date:   Wed Jan 13 16:14:09 2021 +0100

    fix #9384, ref #9279 fixed incorrect implementation of createShortCitation and added tests

diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategy.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategy.java
index 477a0ba631..34c5ca93b6 100644
--- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategy.java
+++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategy.java
@@ -287,7 +287,8 @@ public class DefaultReferenceCacheStrategy
             }else{
                 List<Person> teamMembers = team.getTeamMembers();
                 int etAlPosition = 2;
-                for (int i = 1; i <= teamMembers.size() && i <= etAlPosition; i++){
+                for (int i = 1; i <= teamMembers.size() &&
+                        (i < etAlPosition || teamMembers.size() == etAlPosition && !team.isHasMoreMembers()) ; i++){
                     Person teamMember = teamMembers.get(i-1);
                     if(teamMember == null){
                         // this can happen in UIs in the process of adding new members
diff --git a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategyTest.java b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategyTest.java
index d52d7234d2..2d4723d64a 100644
--- a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategyTest.java
+++ b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategyTest.java
@@ -741,5 +741,47 @@ public class DefaultReferenceCacheStrategyTest {
 //      Assert.assertEquals("Unexpected title cache.", "auct.", webPage1.getTitleCache());
 //  }
 
+    @Test
+    public void testCreateShortCitation(){
+        book1.setTitle("My book");
+        book1.setAuthorship(bookTeam1);
+        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
+        Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
+
+        book1.setTitleCache(null, false);
+        book1.setEdition("ed. 3");
+
+        Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, null, false));
+        Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, "", false));
+        Assert.assertEquals("Unexpected title cache.", "Book Author 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        Assert.assertEquals("Unexpected title cache.", "Book Author (1975: 55)", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", true));
+
+        //1 person
+        Person person1 = Person.NewInstance("Pers.", "Person", "P.", "Percy");
+        Team team = Team.NewInstance(person1);
+        book1.setAuthorship(team);
+        Assert.assertEquals("Unexpected title cache.", "Person 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(true);
+        Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(false);
+
+        //2 persons
+        Person person2 = Person.NewInstance("Lers.", "Lerson", "L.", "Lercy");
+        team.addTeamMember(person2);
+        Assert.assertEquals("Unexpected title cache.", "Person & Lerson 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(true);
+        Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(false);
+
+        //3 persons
+        Person person3 = Person.NewInstance("Gers.", "Gerson", "G.", "Gercy");
+        team.addTeamMember(person3);
+        Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(true);
+        Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
+        team.setHasMoreMembers(false);  //in case we want to continue test
+
+
+    }
 
 }
