私のプロジェクトでは、私はメモリ内テストクラスを書く必要があるためにリポジトリクラスを作成しました。私のリポジトリコードは以下の通りです。Springデータjpaリポジトリインメモリテストケース
package org.jaap.reference.repository;
import java.util.List;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.stereotype.Repository;
import org.jaap.entity.AccountType;
/**
* Repository for type
*
*/
@Repository
public interface AccountTypeRepository
extends JpaRepository<AccountType, Integer>, QueryDslPredicateExecutor<Type> {
/**
* @param AccountTypeCode
* @return List<Type>
*/
@Query("select T from AccountType T where T.AccountTypeCode not in ?# {@environment.getProperty('commit.types').split(',')}")
List<AccountType> findByAccountTypeCodeNotIn();
}
これは私がjunitを使ってユニットテストケースを書く必要があります、誰かが私を助けることができますか?
こんにちは下回っ見つけます、助けてくれなかった... 'addressService'はnull ... Autowiredは私にとってはうまくいかなかった..何が間違っていますか? – Sergey
@georges van私はIn-Memoryテストについて質問し、In-Memoryで使用されるデータベースにデータを挿入し、テストケースでそれを使用しました。 – AdamIJK
@SergeyはAutowired for Serviceクラスを使用せず、サービスクラスを宣言してテストケースを実行するだけで、うまくいくと思います。 – AdamIJK