@Mock
  public static void validatePublicVoidNoArg(
      Invocation invocation, boolean isStatic, List<Throwable> errors) {
    FrameworkMethod it = invocation.getInvokedInstance();

    if (!isStatic && it.getMethod().getParameterTypes().length > 0) {
      it.validatePublicVoid(false, errors);
      return;
    }

    invocation.proceed();
  }
예제 #2
0
 @Mock
 public int computeX(Invocation inv, int a, int b) {
   inputValues.add(a);
   inputValues.add(b);
   int x = inv.proceed();
   outputValues.add(x);
   return x;
 }
예제 #3
0
    @Mock
    public int computeX(Invocation inv, int a, int b) {
      Integer x;

      try {
        x = inv.proceed();
        return x;
      } finally {
        // Statements to be executed on exit would be here.
        //noinspection UnusedAssignment
        x = a + b;
        values.add(x);
      }
    }
예제 #4
0
 @Mock
 public String getConfig(Invocation inv) {
   String config = inv.proceed();
   assertNull(config);
   return "test";
 }
예제 #5
0
 @Mock(minInvocations = 1, maxInvocations = 3)
 public int computeX(Invocation inv, int a, int b) {
   assertTrue(a + b >= 0);
   assertNotNull(inv.getInvokedInstance());
   return a - b;
 }
예제 #6
0
 @Mock(invocations = 1)
 public void $init(Invocation inv, String config) {
   assertNotNull(inv.getInvokedInstance());
   assertEquals("config", config);
 }
예제 #7
0
 @Mock
 public int computeX(Invocation inv, int a, int b) {
   values.add(a + b);
   return inv.proceed();
 }
예제 #8
0
 @Mock
 public void $init(Invocation inv) throws Exception {
   Field field = Random.class.getDeclaredField("seed");
   field.setAccessible(true);
   field.set(inv.getInvokedInstance(), new AtomicLong(7326906125774241L));
 }
 @Mock
 public Object invokeExplosively(Invocation invocation, Object target, Object... params)
     throws Throwable {
   FrameworkMethod it = invocation.getInvokedInstance();
   return decorator.invokeExplosively(it, target, params);
 }