Project

General

Profile

« Previous | Next » 

Revision 90046bc4

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-model #5830

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/GenericDefaultCacheStrategyTest.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
31 31
public class GenericDefaultCacheStrategyTest {
32 32
	@SuppressWarnings("unused")
33 33
	private static final Logger logger = Logger.getLogger(GenericDefaultCacheStrategyTest.class);
34
	
34

  
35 35
	private static IGeneric generic1;
36 36
	private static Team team1;
37 37
	private static GenericDefaultCacheStrategy defaultStrategy;
38 38
	private static final String detail1 = "55";
39
	
39

  
40 40
	/**
41 41
	 * @throws java.lang.Exception
42 42
	 */
......
54 54
		generic1.setCacheStrategy(defaultStrategy);
55 55
		team1 = Team.NewTitledInstance("Authorteam", "AT.");
56 56
	}
57
	
57

  
58 58
//**************************** TESTS ***********************************
59 59

  
60
	
60

  
61 61
	@Test
62 62
	public void testGetTitleCache(){
63 63
		generic1.setTitle("auct.");
64 64
		Assert.assertEquals("Unexpected title cache.", "auct.", generic1.getTitleCache());
65 65
	}
66
	
67
	
66

  
67

  
68 68
	@Test
69 69
	public void testGetInRef(){
70 70
		generic1.setTitle("auct.");
71 71
		IBook book1 = ReferenceFactory.newBook();
72 72
		book1.setTitle("My book title");
73 73
		book1.setAuthorship(team1);
74
		Reference<?> inRef = (Reference<?>)book1;
74
		Reference inRef = (Reference)book1;
75 75
		generic1.setInReference(inRef);
76 76
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
77 77
		//TODO author still unclear
......
86 86
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
87 87
		Assert.assertEquals("Unexpected title cache.", "My generic title: 2", generic1.getNomenclaturalCitation("2"));
88 88
	}
89
	
89

  
90 90
	@Test
91 91
	public void testGetTitleCache2(){
92 92
		generic1.setTitle("Part Title");
93 93
		IBook book1 = ReferenceFactory.newBook();
94 94
		book1.setTitle("My book title");
95 95
		book1.setAuthorship(team1);
96
		Reference<?> inRef = (Reference<?>)book1;
96
		Reference inRef = (Reference)book1;
97 97
		generic1.setInReference(inRef);
98 98
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
99 99
		Assert.assertEquals("Unexpected title cache.", "Part Title in Authorteam, My book title", generic1.getTitleCache());
100 100
	}
101 101

  
102
	
102

  
103 103
	@Test
104 104
	public void testGetAbbrevTitleCache(){
105 105
		generic1.setTitle("Part Title");
......
109 109
		book1.setTitle("My book title");
110 110
		book1.setAbbrevTitle("My bk. tit.");
111 111
		book1.setAuthorship(team1);  //TODO handling not yet defined
112
		Reference<?> inRef = (Reference<?>)book1;
112
		Reference inRef = (Reference)book1;
113 113
		generic1.setInReference(inRef);
114 114
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
115 115
		generic1.setAbbrevTitleCache(null, false);  //reset cache in case aspectJ is not enabled
......
124 124
		//TODO
125 125
//		Assert.assertEquals("Unexpected nom. ref.", "in AT., My bk. tit., ser. 11, 23: pp. 44. 1987", generic1.getNomenclaturalCitation("pp. 44"));
126 126

  
127
		
127

  
128 128
		//protected
129 129
		generic1.setAbbrevTitleCache("My prot. abb. tit. in a bk.", true);
130 130
		Assert.assertEquals("Unexpected abbrev title cache.", "My prot. abb. tit. in a bk.", generic1.getAbbrevTitleCache());
131 131
		Assert.assertEquals("Unexpected title cache.", "Part Title in Authorteam, My book title. 1987", generic1.getTitleCache());
132
		
132

  
133 133
		generic1.setDatePublished(null);
134 134
		Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.", generic1.getNomenclaturalCitation(null));
135 135
		Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.", generic1.getNomenclaturalCitation(""));
136 136
		Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.: pp. 44", generic1.getNomenclaturalCitation("pp. 44"));
137
		
137

  
138 138
		generic1.setDatePublished(TimePeriodParser.parseString("1893"));
139 139
		Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.: pp. 44. 1893", generic1.getNomenclaturalCitation("pp. 44"));
140
		
140

  
141 141
	}
142 142

  
143 143
	@Test
......
147 147
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
148 148
		Assert.assertEquals("Unexpected title cache.", "Authorteam, My generic title", generic1.getTitleCache());
149 149
	}
150
	
150

  
151 151
	@Test
152 152
	public void testAuthorOnly(){
153 153
		generic1.setAuthorship(team1);
......
155 155
		Assert.assertEquals("Unexpected title cache.", "Authorteam", generic1.getTitleCache());
156 156
		Assert.assertEquals("", generic1.getNomenclaturalCitation(null));
157 157
	}
158
	
158

  
159 159
	@Test
160 160
	public void testYearAndAuthorOnly(){
161 161
		generic1.setAuthorship(team1);
162 162
		generic1.setDatePublished(TimePeriodParser.parseString("1792"));
163 163
		generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
164
		Assert.assertEquals("Unexpected title cache.", "Authorteam, 1792", generic1.getTitleCache());	
164
		Assert.assertEquals("Unexpected title cache.", "Authorteam, 1792", generic1.getTitleCache());
165 165
		Assert.assertEquals("1792", generic1.getNomenclaturalCitation(null));
166 166
	}
167
	
167

  
168 168
	@Test
169 169
	public void testDoubleDotBeforeYear(){
170 170
		generic1.setAuthorship(team1);
......
176 176
	}
177 177

  
178 178

  
179
	
179

  
180 180
}

Also available in: Unified diff