3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.strategy
.cache
.agent
;
14 import static org
.junit
.Assert
.assertNotNull
;
15 import junit
.framework
.Assert
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.junit
.After
;
19 import org
.junit
.AfterClass
;
20 import org
.junit
.Before
;
21 import org
.junit
.BeforeClass
;
22 import org
.junit
.Test
;
24 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
25 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
26 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
33 public class TeamDefaultCacheStrategyTest
{
34 @SuppressWarnings("unused")
35 private static final Logger logger
= Logger
.getLogger(TeamDefaultCacheStrategyTest
.class);
37 private static Team team1
;
38 private static Team team2
;
39 private static Team team3
;
41 private static Person person1
;
42 private static Person person2
;
43 private static Person person3
;
44 private static Person person4
;
47 * @throws java.lang.Exception
50 public static void setUpBeforeClass() throws Exception
{
54 * @throws java.lang.Exception
57 public static void tearDownAfterClass() throws Exception
{
63 * @throws java.lang.Exception
66 public void setUp() throws Exception
{
67 team1
= Team
.NewInstance();
68 team2
= Team
.NewInstance();
69 team3
= Team
.NewInstance(); //empty team
71 person1
= Person
.NewInstance();
73 person1
.setFirstname("P1FN");
74 person1
.setLastname("P1LN");
75 person1
.setPrefix("Dr1.");
76 person1
.setSuffix("Suff1");
78 person2
= Person
.NewInstance();
79 person2
.setNomenclaturalTitle("P2NomT");
80 person2
.setLastname("P2LN");
81 person2
.setFirstname("P2FN");
82 person2
.setSuffix("P2Suff");
84 person3
= Person
.NewInstance();
85 person3
.setNomenclaturalTitle("P3NomT");
88 person4
= Person
.NewInstance(); //empty person
90 team1
.addTeamMember(person1
);
91 team2
.addTeamMember(person2
);
92 team2
.addTeamMember(person1
);
93 team2
.addTeamMember(person3
);
100 * @throws java.lang.Exception
103 public void tearDown() throws Exception
{
106 //**************************************** TESTS **************************************
109 * Test method for {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy#NewInstance()}.
112 public final void testNewInstance() {
113 TeamDefaultCacheStrategy cacheStrategy
= TeamDefaultCacheStrategy
.NewInstance();
114 assertNotNull(cacheStrategy
);
118 public final void testGetNomenclaturalTitleCache(){
119 Assert
.assertNotNull("team1 nomenclatural title must not to be null", team1
.getNomenclaturalTitle());
120 Assert
.assertEquals("team1 nomenclatural title should be created by elements", "Dr1. P1FN P1LN Suff1", team1
.getNomenclaturalTitle());
121 person1
.setSuffix(null);
122 Assert
.assertEquals("team1 nomenclatural title should be Dr1. P1FN P1LN", "Dr1. P1FN P1LN", team1
.getNomenclaturalTitle());
124 Assert
.assertEquals("team2 nomenclatural title should be 'P2NomT & Dr1. P1FN P1LN & P3NomT'", "P2NomT & Dr1. P1FN P1LN & P3NomT", team2
.getNomenclaturalTitle());
126 Assert
.assertNotNull("team3 nomenclatural title must not to be null", team3
.getNomenclaturalTitle());
127 Assert
.assertTrue("team3 nomenclatural title must not be empty", CdmUtils
.isNotEmpty(team3
.getNomenclaturalTitle()));
128 //don't take to serious, may be also something different, but not empty
129 Assert
.assertEquals("team3 nomenclatural title should be empty team replacement string", TeamDefaultCacheStrategy
.EMPTY_TEAM
, team3
.getNomenclaturalTitle());
134 public final void testGetTitleCache(){
135 Assert
.assertNotNull("team1 title cache must not to be null", team1
.getTitleCache());
136 Assert
.assertEquals("team1 title cache should be created by elements", "Dr1. P1FN P1LN Suff1", team1
.getTitleCache());
137 person1
.setSuffix(null);
138 Assert
.assertEquals("team1 title cache should be Dr1. P1FN P1LN", "Dr1. P1FN P1LN", team1
.getTitleCache());
140 Assert
.assertEquals("team2 title cache should be 'P2FN P2LN P2Suff & Dr1. P1FN P1LN & P3NomT'", "P2FN P2LN P2Suff & Dr1. P1FN P1LN & P3NomT", team2
.getTitleCache());
142 Assert
.assertNotNull("team3 title cache must not to be null", team3
.getTitleCache());
143 Assert
.assertTrue("team3 title cache must not be empty", CdmUtils
.isNotEmpty(team3
.getTitleCache()));
144 //don't take to serious, may be also something different, but not empty
145 Assert
.assertEquals("team3 title cache should should be empty team replacement string", TeamDefaultCacheStrategy
.EMPTY_TEAM
, team3
.getTitleCache());