com.atlassian.jira.easymock
Class EasyMockMatcherUtils

java.lang.Object
  extended by com.atlassian.jira.easymock.EasyMockMatcherUtils

public final class EasyMockMatcherUtils
extends Object

Static utilities for easier creation of EasyMock matchers.

Since:
v4.2

Method Summary
static
<T> T
any(Class<T> argumentType)
          

Typed 'any' matcher.

static
<E> Collection<E>
anyCollection(Class<E> elementType)
          

Typed 'any collection' matcher.

static
<E> List<E>
anyList(Class<E> elementType)
          

Typed 'any list' matcher.

static
<K,V> Map<K,V>
anyMap(Class<K> keyType, Class<V> valueType)
          

Typed 'any map' matcher.

static String anyString()
          Shortcut for any(Class) called with String class.
static
<K,V> Map<K,V>
mapContaining(K key, V value)
          Matcher for a map containing given key and value.
static
<K,V> Map<K,V>
mapContaining(K key1, V value1, K key2, V value2)
          Matcher for a map containing at least two entries specified by given keys and values
static
<T> T
nullArg(Class<T> argumentType)
          Typed 'is null' matcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nullArg

public static <T> T nullArg(Class<T> argumentType)
Typed 'is null' matcher.

Type Parameters:
T - type of the matched argument
Parameters:
argumentType - class representing argument's type
Returns:
typed 'is null' EasyMock matcher

any

public static <T> T any(Class<T> argumentType)

Typed 'any' matcher.

WARNING this is just syntactic sugar, it is different than EasyMock.isA(Class) in that it does not check type of the actual argument.

Type Parameters:
T - type of the matched argument
Parameters:
argumentType - class representing argument's type
Returns:
typed 'any' EasyMock matcher

anyString

public static String anyString()
Shortcut for any(Class) called with String class.

Returns:
typed 'any string' EasyMock matcher
See Also:
any(Class)

anyMap

public static <K,V> Map<K,V> anyMap(Class<K> keyType,
                                    Class<V> valueType)

Typed 'any map' matcher.

This is equivalent to EasyMock.isA(Class)} with a Map parameter, but avoids type-safety warnings in the calling methods.

Type Parameters:
K - type of the map key
V - type of the map value
Parameters:
keyType - class representing the type of map keys
valueType - class representing the type of map values
Returns:
typed 'is any map' EasyMock matcher

anyList

public static <E> List<E> anyList(Class<E> elementType)

Typed 'any list' matcher.

This is equivalent to EasyMock.isA(Class) with a List parameter, but avoids type-safety warnings in the calling methods.

Type Parameters:
E - type of the list element
Parameters:
elementType - class representing the type of list elements
Returns:
typed 'is any list' EasyMock matcher

anyCollection

public static <E> Collection<E> anyCollection(Class<E> elementType)

Typed 'any collection' matcher.

This is equivalent to EasyMock.isA(Class), with a Collection parameter, but avoids type-safety warnings in the calling methods.

Type Parameters:
E - type of the collection element
Parameters:
elementType - class representing the type of list elements
Returns:
typed 'is any collection' EasyMock matcher

mapContaining

public static <K,V> Map<K,V> mapContaining(K key,
                                           V value)
Matcher for a map containing given key and value.

Type Parameters:
K - type of key
V - type of value
Parameters:
key - key
value - value
Returns:
map containing matcher

mapContaining

public static <K,V> Map<K,V> mapContaining(K key1,
                                           V value1,
                                           K key2,
                                           V value2)
Matcher for a map containing at least two entries specified by given keys and values

Type Parameters:
K - type of key
V - type of value
Parameters:
key1 - first key
value1 - first value
key2 - second key
value2 - second value
Returns:
map containing matcher


Copyright © 2002-2014 Atlassian. All Rights Reserved.