mardi 25 août 2020

How to implements unit tests for SQLQueryFactory query?

It is my repository class implementation, Im using querydsl-sql for the DB persistence, It works very good when run the spring-boot project, but i need to strcuture unit test for this fragment of code, I try to use Mocks but i dont now how use this for SQLQueryFactory class or use other types of tools for unit test

@Repository
@Transactional
public class ContactRepository implements IContactRepository  {
    @Inject
    SQLQueryFactory queryFactory;

    
    @Transactional(readOnly = true)
    @Override
    public Tuple getContactInformationQuery(String memberCode) {
        return queryFactory
                .select(
                        sspcotdatconper.direccionprin,
                        sspcotdatconper.numtelcelu)
                .from(sspcotdatconper)
                .innerJoin(sspcotperson)
                .on(sspcotperson.codigoper.eq(sspcotdatconper.codigoper)
                        .and(sspcotdatconper.codigotipocontac.eq("GTH"))
                        .and(sspcotdatconper.est.eq("ACT")))
                .innerJoin(sspcotfun)
                .on(sspcotfun.codigoper.eq(sspcotper.codigoper))
                .where(sspcotfun.codigofun.eq(memberCode))
                .fetchOne();
    }
}

Aucun commentaire:

Enregistrer un commentaire