org.unitils.mock.annotation
Annotation Type ArgumentMatcher


@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface ArgumentMatcher

An annotation for indicating that a method is an argument matcher method. The annotated method should register the argument matcher instance in the ArgumentMatcherRepository. Following example creates an argument matcher implemented by the SameArgumentMatcher class and registers it in the repository:

 @ArgumentMatcher
 public static <T> T same(T sameAs) {
      ArgumentMatcherRepository.registerArgumentMatcher(new SameArgumentMatcher(sameAs));
      return null;
 }
 

By annotating the method with this annotation, it can now be used inline in a mock invocation to register the argument matcher. For example:

myMock.aMethod(1, "test", same(myObject));



Copyright © 2011. All Rights Reserved.