jeudi 24 août 2017

SpringBoot repository: don't have access to methods in tests

I'm learning Springboot and Java (8 years developing with C#), and I have a problem accessing springboot repository methods outside of the classpath. I have the following repository:

package com.rfd.infrastructure.repositories;

import com.rfd.infrastructure.models.BetStatus;
import org.springframework.data.repository.CrudRepository;

@org.springframework.stereotype.Repository
public interface BetStatusRepository extends CrudRepository<BetStatus, String>{
    BetStatus findByValue(int value);
}

This method is inside src/main/java/com/rfd... and I can access to methods in CrudRepository like save, findAll, etc. from another service class in src/main/java/com/rfd/domain/services

On the other hand, I want to make some integration tests and I need to pre-populate the database, so I have a method inside src/test/java/com/rfd... (notice the test path) in which I have declared a BetStatusRepository object. However, here I cannot access to save, findAll, etc. methods, only the one defined in my interface findByValue.

Question: Why can't I access to methods declared in CrudRepository inside the tests classpath?

Aucun commentaire:

Enregistrer un commentaire