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

name.falgout.jeffrey.testing.junit5.CaptorParameterFactory Maven / Gradle / Ivy

package name.falgout.jeffrey.testing.junit5;

import com.google.common.reflect.TypeToken;
import java.lang.reflect.Parameter;
import org.mockito.ArgumentCaptor;

/**
 * Processes parameters of type {@link ArgumentCaptor}.
 */
final class CaptorParameterFactory implements ParameterFactory {
  @Override
  public boolean supports(Parameter parameter) {
    return parameter.getType() == ArgumentCaptor.class;
  }

  @Override
  public Object getParameterValue(Parameter parameter) {
    TypeToken parameterType = TypeToken.of(parameter.getParameterizedType());
    TypeToken captorParameter =
        parameterType.resolveType(ArgumentCaptor.class.getTypeParameters()[0]);
    return ArgumentCaptor.forClass(captorParameter.getRawType());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy