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

io.ebean.WithStaticFinders Maven / Gradle / Ivy

There is a newer version: 13.7.0
Show newest version
package io.ebean;

import java.util.ArrayList;
import java.util.List;

/**
 * Manages the set of WithStaticFinder.
 *
 */
public class WithStaticFinders {

  protected List> staticFinderReplacement = new ArrayList>();

  /**
   * Create and return a WithStaticFinder. Expects a static 'finder' field on the beanType class.
   */
  public  WithStaticFinder withFinder(Class beanType) {
    WithStaticFinder withFinder = new WithStaticFinder(beanType);
    staticFinderReplacement.add(withFinder);
    return withFinder;
  }

  /**
   * Use test doubles replacing original implementations.
   */
  public void useTestDoubles() {

    for (WithStaticFinder withStaticFinder : staticFinderReplacement) {
      withStaticFinder.useTestDouble();
    }
  }

  /**
   * Restore the original implementations.
   */
  public void restoreOriginal() {

    for (WithStaticFinder withStaticFinder : staticFinderReplacement) {
      withStaticFinder.restoreOriginal();
    }
  }

  /**
   * Before the start of a MockiEbean run calls useTestDoubles().
   */
  public void beforeRun() {
    useTestDoubles();
  }

  /**
   * After the end of a MockiEbean run calls restoreOriginal().
   */
  public void afterRun() {
    restoreOriginal();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy