
org.needle4j.db.EntityTransactionProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of needle4j Show documentation
Show all versions of needle4j Show documentation
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