I have the following code, and I was wondering how to mock the component used in the value annotation. It is not instantiated in the model class, so I can't really use the annotation @InjectMocks, how do I perform a mock in this context?
public interface Vehicule {
@Value('#{target.VEHICULE_ID}')
BigInteger getId();
@Value('#{@mapperUtility.clobToString(target.CERTIFICATE)}') // How to mock this call?
String getCertificate();
}
@Component
public class MapperUtility {
public String clobToString(Clob clob) {
return (clob == null) ? null : ClobType.INSTANCE.toString(clob); // from org.hibernate.type
}
}
public interface VehiculeRepository extends JpaRepository<Vehicule, String> {
@Query(value = SQL_QUERY_FIND_VEHICULE_BY_IDS)
List<Vehicule> findVehiculeByIds(@Param("Ids") List<BigInteger> ids);
}
What would a test that mocks the component inside the value annotation would look like?