commit cd37bc26592e1a204cd72fc92366b7ea11c6fc1e
Author: Andreas Müller <a.mueller@bgbm.org>
Date:   Thu May 20 12:49:24 2021 +0200

    ref #9326, ref  #3764 fix secion in book-section handling and some cleanup in ReferenceDefaultCacheStrategy (cont.)

diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
index c45f38600d..a3c9ad85c3 100644
--- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
+++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
@@ -115,8 +115,12 @@ public class Team extends TeamOrPersonBase<Team> {
 	 */
 	static public Team NewTitledInstance(String title, String nomTitle){
 		Team result = new Team();
-		result.setTitleCache(title, true);
-		result.setNomenclaturalTitle(nomTitle, true);
+		if (isNotBlank(title)){
+		    result.setTitleCache(title, true);
+		}
+		if (isNotBlank(nomTitle)){
+		    result.setNomenclaturalTitle(nomTitle, true);
+		}
 		return result;
 	}
 
diff --git a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java
index 1ef0ea8e14..776a23fd2a 100644
--- a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java
+++ b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java
@@ -12,6 +12,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import eu.etaxonomy.cdm.common.DOI;
 import eu.etaxonomy.cdm.common.URI;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
@@ -381,5 +382,66 @@ public class NomenclaturalSourceFormatterTest {
         //only inref has volume
         generic1.setVolume(null);
         Assert.assertEquals("in InRefAuthor, My InRef 9: 55. 1883"+SEP+"1884", formatter.format(generic1, detail1));
-   }
+    }
+
+    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
+    public void testSectionInArticle(){
+        //#9326, #3764
+        Reference journal = ReferenceFactory.newJournal();
+        journal.setTitle("Phytotaxa");
+        Reference article = ReferenceFactory.newArticle();
+        String articleTitle = "New diatom species Navicula davidovichii from Vietnam (Southeast Asia)";
+        article.setTitle(articleTitle);
+        Team articleTeam = Team.NewTitledInstance("Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P.", null);
+        article.setAuthorship(articleTeam);
+        article.setInJournal(journal);
+        article.setVolume("452(1)");
+        article.setPages("83-91");
+        article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
+        article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P.", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(article);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "in Phytotaxa 452(1): 55. 8 Jul 2020",
+                formatter.format(section, detail1));
+    }
+
+    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
+    public void testSectionInBookSection(){
+        //#9326, #3764
+        Reference book = ReferenceFactory.newBook();
+        book.setTitle("Species Plantarum");
+        Person person = Person.NewInstance("L.", "Linne", "C.G.", "Carl-Gustav");
+        Team bookAuthor = Team.NewInstance(person); // Team.NewTitledInstance("Linne", null);
+
+        book.setAuthorship(bookAuthor);
+        book.setVolume("3");
+        Reference bookSection = ReferenceFactory.newBookSection();
+        String bookSectionTitle = "Trees";
+        bookSection.setTitle(bookSectionTitle);
+        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", "Chap. Aut.");
+        bookSection.setAuthorship(bookSectionTeam);
+        bookSection.setInBook(book);
+        bookSection.setPages("83-91");
+        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
+        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Section author", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(bookSection);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "in Linne, Species Plantarum 3: 55. 1752",
+                formatter.format(section, detail1));
+        bookAuthor = Team.NewTitledInstance("Linneus", null);
+        book.setAuthorship(bookAuthor);
+        Assert.assertEquals("Unexpected title cache.",
+                "in Linneus, Species Plantarum 3: 55. 1752",
+                formatter.format(section, detail1));
+
+
+    }
 }
\ No newline at end of file
diff --git a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java
index 05d7d9e31b..3769ec8aca 100644
--- a/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java
+++ b/cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java
@@ -132,10 +132,11 @@ public class ReferenceDefaultCacheStrategyTest {
 	public void testArticleGetTitleCache(){
 		journal1.setTitle("My journal");
 		((Reference)journal1).setAuthorship(articleTeam2);  //incorrect use anyway
-		article1.setTitle("My article");
 		article1.setInJournal(journal1);
 		article1.setAuthorship(articleTeam1);
 		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
+	    Assert.assertEquals("Team1 1975: "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
+	    article1.setTitle("My article");
 		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
 
 		article1.setInJournal(null);
@@ -375,7 +376,7 @@ public class ReferenceDefaultCacheStrategyTest {
         article.setAuthorship(articleTeam);
         article.setInJournal(journal);
         article.setVolume("452(1)");
-        article.setVolume("83-91");
+        article.setPages("83-91");
         article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
         article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
         Reference section = ReferenceFactory.newSection();
@@ -384,8 +385,37 @@ public class ReferenceDefaultCacheStrategyTest {
         section.setInReference(article);
 
         Assert.assertEquals("Unexpected title cache.",
-                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 – In: "
-                + "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., New diatom species Navicula davidovichii from Vietnam (Southeast Asia). – Phytotaxa 83-91.", section.getTitleCache());
+                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 "+UTF8.EN_DASH+" In: "
+                + "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., "
+                + "New diatom species Navicula davidovichii from Vietnam (Southeast Asia). "+UTF8.EN_DASH+" Phytotaxa 452(1).",
+                section.getTitleCache());
+    }
+
+    @Test
+    public void testSectionInBookSection(){
+        //#9326, #3764
+        Reference book = ReferenceFactory.newBook();
+        book.setTitle("Species Plantarum");
+        Team bookAuthor = Team.NewTitledInstance("Linne", null);
+        book.setAuthorship(bookAuthor);
+        book.setVolume("3");
+        Reference bookSection = ReferenceFactory.newBookSection();
+        String bookSectionTitle = "Trees";
+        bookSection.setTitle(bookSectionTitle);
+        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", null);
+        bookSection.setAuthorship(bookSectionTeam);
+        bookSection.setInBook(book);
+        bookSection.setPages("83-91");
+        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
+        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Section author", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(bookSection);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "Section author 1752 "+UTF8.EN_DASH+" In: Chapter author, Trees, pp. 83-91. "+UTF8.EN_DASH+" In: Linne, Species Plantarum 3.",
+                section.getTitleCache());
     }
 
     @Test
