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

org.camunda.bpm.extension.mockito.function.CreateInstance Maven / Gradle / Ivy

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

import static com.google.common.base.Throwables.propagate;

import org.mockito.Mockito;

/**
 * Helper to create either mock() or new() instances for given type.
 */
public final class CreateInstance {

  public static  T mockInstance(final Class type) {
    return Mockito.mock(type);
  }

  @SuppressWarnings("unchecked")
  public static  T newInstanceByDefaultConstructor(final Class type) {
    try {
      return (T) type.getConstructors()[0].newInstance();
    } catch (final Exception e) {
      throw propagate(e);
    }

  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy