Revision e549f3ff
Added by Andreas Müller over 12 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/BotanicNameCacheStrategyTest.java | ||
---|---|---|
16 | 16 |
import java.lang.reflect.InvocationTargetException; |
17 | 17 |
import java.lang.reflect.Method; |
18 | 18 |
import java.util.GregorianCalendar; |
19 |
import java.util.List; |
|
19 | 20 |
|
20 | 21 |
import org.apache.log4j.Logger; |
21 | 22 |
import org.junit.Before; |
... | ... | |
33 | 34 |
import eu.etaxonomy.cdm.model.name.Rank; |
34 | 35 |
import eu.etaxonomy.cdm.model.reference.Reference; |
35 | 36 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
37 |
import eu.etaxonomy.cdm.strategy.TaggedText; |
|
36 | 38 |
|
37 | 39 |
/** |
38 | 40 |
* @author a.mueller |
... | ... | |
224 | 226 |
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy#getInfraGenusNameCache(eu.etaxonomy.cdm.model.name.BotanicalName)}. |
225 | 227 |
*/ |
226 | 228 |
@Test |
227 |
public final void testGetInfraGenusNameCache() { |
|
228 |
String methodName = "getInfraGenusNameCache"; |
|
229 |
public final void testGetInfraGenusTaggedNameCache() {
|
|
230 |
String methodName = "getInfraGenusTaggedNameCache";
|
|
229 | 231 |
Method method = getMethod(NonViralNameDefaultCacheStrategy.class, methodName, NonViralName.class); |
230 |
this.getValue(method, strategy, subGenusName); |
|
232 |
this.getStringValue(method, strategy, subGenusName);
|
|
231 | 233 |
assertEquals("Genus subg. InfraGenericPart", strategy.getNameCache(subGenusName)); |
232 | 234 |
} |
233 | 235 |
|
... | ... | |
264 | 266 |
protected Method getMethod(Class clazz, String methodName, Class paramClazzes){ |
265 | 267 |
Method method; |
266 | 268 |
try { |
267 |
method = clazz.getDeclaredMethod("getInfraGenusNameCache", paramClazzes);
|
|
269 |
method = clazz.getDeclaredMethod(methodName, paramClazzes);
|
|
268 | 270 |
} catch (SecurityException e) { |
269 | 271 |
logger.error("SecurityException " + e.getMessage()); |
270 | 272 |
return null; |
... | ... | |
275 | 277 |
return method; |
276 | 278 |
} |
277 | 279 |
|
278 |
protected String getValue(Method method, Object object,Object parameter){ |
|
280 |
protected String getStringValue(Method method, Object object,Object parameter){
|
|
279 | 281 |
try { |
280 |
return (String)method.invoke(object, parameter); |
|
282 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
283 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
281 | 284 |
} catch (IllegalArgumentException e) { |
282 | 285 |
logger.error("IllegalArgumentException " + e.getMessage()); |
283 | 286 |
return null; |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZoologicalNameCacheStrategyTest.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import java.lang.reflect.InvocationTargetException; |
17 | 17 |
import java.lang.reflect.Method; |
18 |
import java.util.List; |
|
18 | 19 |
|
19 | 20 |
import org.apache.log4j.Logger; |
20 | 21 |
import org.junit.Before; |
... | ... | |
27 | 28 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
28 | 29 |
import eu.etaxonomy.cdm.model.name.Rank; |
29 | 30 |
import eu.etaxonomy.cdm.model.name.ZoologicalName; |
31 |
import eu.etaxonomy.cdm.strategy.TaggedText; |
|
30 | 32 |
|
31 | 33 |
/** |
32 | 34 |
* @author a.mueller |
... | ... | |
35 | 37 |
public class ZoologicalNameCacheStrategyTest { |
36 | 38 |
private static final Logger logger = Logger.getLogger(ZoologicalNameCacheStrategyTest.class); |
37 | 39 |
|
38 |
private ZooNameDefaultCacheStrategy strategy; |
|
40 |
private ZooNameDefaultCacheStrategy<ZoologicalName> strategy;
|
|
39 | 41 |
private ZoologicalName familyName; |
40 | 42 |
private ZoologicalName genusName; |
41 | 43 |
private ZoologicalName subGenusName; |
... | ... | |
193 | 195 |
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy#getInfraGenusNameCache(eu.etaxonomy.cdm.model.name.BotanicalName)}. |
194 | 196 |
*/ |
195 | 197 |
@Test |
196 |
public final void testGetInfraGenusNameCache() { |
|
197 |
String methodName = "getInfraGenusNameCache"; |
|
198 |
public final void testGetInfraGenusTaggedNameCache() {
|
|
199 |
String methodName = "getInfraGenusTaggedNameCache";
|
|
198 | 200 |
Method method = getMethod(NonViralNameDefaultCacheStrategy.class, methodName, NonViralName.class); |
199 | 201 |
|
200 | 202 |
this.getValue(method, strategy, subGenusName); |
... | ... | |
242 | 244 |
protected Method getMethod(Class clazz, String methodName, Class paramClazzes){ |
243 | 245 |
Method method; |
244 | 246 |
try { |
245 |
method = clazz.getDeclaredMethod("getInfraGenusNameCache", paramClazzes);
|
|
247 |
method = clazz.getDeclaredMethod(methodName, paramClazzes);
|
|
246 | 248 |
} catch (SecurityException e) { |
247 | 249 |
logger.error("SecurityException " + e.getMessage()); |
248 | 250 |
return null; |
... | ... | |
255 | 257 |
|
256 | 258 |
protected String getValue(Method method, Object object,Object parameter){ |
257 | 259 |
try { |
258 |
return (String)method.invoke(object, parameter); |
|
260 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
261 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
259 | 262 |
} catch (IllegalArgumentException e) { |
260 | 263 |
logger.error("IllegalArgumentException " + e.getMessage()); |
261 | 264 |
return null; |
Also available in: Unified diff
fixing bugs in test for botanicalNameCacheStrategy and zoologicalNameCacheStrategy