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

org.needle4j.db.EntityTransactionProvider Maven / Gradle / Ivy

Go to download

Needle is a lightweight framework for testing Java EE components outside of the container in isolation. It reduces the test setup code by analysing dependencies and automatic injection of mock objects. It will thus maximize the speed of development as well as the execution of unit tests.

The newest version!
package org.needle4j.db;

import org.needle4j.injection.InjectionProvider;
import org.needle4j.injection.InjectionTargetInformation;

import javax.persistence.EntityTransaction;

class EntityTransactionProvider implements InjectionProvider {
  private final DatabaseTestcase databaseTestcase;

  public EntityTransactionProvider(DatabaseTestcase databaseTestcase) {
    this.databaseTestcase = databaseTestcase;
  }

  @Override
  public boolean verify(InjectionTargetInformation information) {
    return information.getType() == EntityTransaction.class;
  }

  @Override
  public EntityTransaction getInjectedObject(Class injectionPointType) {
    return databaseTestcase.getEntityManager().getTransaction();
  }

  @Override
  public Object getKey(InjectionTargetInformation information) {
    return EntityTransaction.class;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy