All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.camunda.bpm.extension.mockito.answer.AbstractAnswer Maven / Gradle / Ivy

package org.camunda.bpm.extension.mockito.answer;

import org.camunda.bpm.engine.delegate.VariableScope;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

/**
 * Specialized {@link org.mockito.stubbing.Answer} that takes the single
 * argument of an execute() or notify() method and delegates to type safe call.
 *
 * @param 
 *          can be {@link org.camunda.bpm.engine.delegate.DelegateExecution} or
 *          {@link org.camunda.bpm.engine.delegate.DelegateTask}
 */
abstract class AbstractAnswer implements Answer {

  @Override
  @SuppressWarnings("unchecked")
  public final Void answer(final InvocationOnMock invocation) throws Throwable {
    answer((T) invocation.getArguments()[0]);
    return null;
  }

  /**
   * Every implementing class must define what "answer" should actually do.
   *
   * @param parameter
   *          either DelegateTask or DelegateExecution.
   * @throws Exception
   *           when anything fails
   */
  protected abstract void answer(T parameter) throws Exception;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy