简体   繁体   中英

How do I unit test the querydsl query inside the given method?

public UserEntity findUserByUsername( String username ) {

    QUserEntity tableUser = QUserEntity.userEntity;

    JPAQuery query = new JPAQuery( entityManager )
        .from( tableUser )
        .where( tableUser.ds_username.eq( username ) );

    return ( UserEntity ) query.singleResult( tableUser );
}

Using the last version of junit.

您可以模拟EntityManager并验证Querydsl以您预期的方式使用EntityManager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM