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

mockit.internal.util.TestMethod Maven / Gradle / Ivy

Go to download

JMockit is a Java toolkit for automated developer testing. It contains APIs for the creation of the objects to be tested, for mocking dependencies, and for faking external APIs; JUnit (4 & 5) and TestNG test runners are supported. It also contains an advanced code coverage tool.

There is a newer version: 1.49
Show newest version
/*
 * Copyright (c) 2006 Rogério Liesenfeld
 * This file is subject to the terms of the MIT license (see LICENSE.txt).
 */
package mockit.internal.util;

import java.lang.annotation.*;
import java.lang.reflect.*;
import javax.annotation.*;

public final class TestMethod
{
   @Nonnull public final String testClassDesc;
   @Nonnull public final String testMethodDesc;
   @Nonnull private final Type[] parameterTypes;
   @Nonnull private final Class[] parameterClasses;
   @Nonnull private final Annotation[][] parameterAnnotations;
   @Nonnull private final Object[] parameterValues;

   public TestMethod(@Nonnull Method testMethod, @Nonnull Object[] parameterValues)
   {
      testClassDesc = mockit.external.asm.Type.getInternalName(testMethod.getDeclaringClass());
      testMethodDesc = testMethod.getName() + mockit.external.asm.Type.getMethodDescriptor(testMethod);
      parameterTypes = testMethod.getGenericParameterTypes();
      parameterClasses = testMethod.getParameterTypes();
      parameterAnnotations = testMethod.getParameterAnnotations();
      this.parameterValues = parameterValues;
   }

   @Nonnegative public int getParameterCount() { return parameterTypes.length; }
   @Nonnull public Type getParameterType(@Nonnegative int index) { return parameterTypes[index]; }
   @Nonnull public Class getParameterClass(@Nonnegative int index) { return parameterClasses[index]; }
   @Nonnull public Annotation[] getParameterAnnotations(@Nonnegative int index) { return parameterAnnotations[index]; }
   @Nullable public Object getParameterValue(@Nonnegative int index) { return parameterValues[index]; }

   public void setParameterValue(@Nonnegative int index, @Nullable Object value)
   {
      if (value != null) {
         parameterValues[index] = value;
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy