Closed pvpkiran closed 6 years ago
As I understand, the only way to mock methods annotated with @Query is to provide custom implementation, like:
PersonRepository personRepository = new RepositoryMockBuilder().usingImplementation(RepoMock.class).mock(PersonRepository.class);
Where RepoMock is following:
public class RepoMock implements DataStoreAware {
private DataStore dataStore;
//this method is annotated with @Query in PersonRepository
public List<Person> findSome() {
return new ArrayList<>(dataStore.retrieveAll());
}
@Override
public void setDataStore(DataStore dataStore) {
this.dataStore = dataStore;
}
}
@iceberk thanks for the comment.
RE @pvpkiran: That is exactly what you would have to do. There is no way that this framework would be able to parse and process all vendor-specific SQL/NoSQL queries and provide the implementation for you. You'll have to replace the behavior of native queries with your own Java-based implementation.
Hi, I want to know how I can mock the repository methods which has @Query defined.
Thanks