I faced with problem while testing data rest repositories. I call rest resource and check if it gets me proper json. But for pre-population data I don't want to use in memory db, so I mocked repository method invocation.
@MockBean
  private CommentRepository commentRepository;
and did this
given(commentRepository.findOne(1L)).willReturn(comment);
And now, while calling "/comments/1" I get 404 error, so data rest didn't expose my repository. The main question is "How can we mock repository method for getting data from database?"
My test class:
    @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CommentTest
{
  @Autowired
  private TestRestTemplate restTemplate;
  @MockBean
  private CommentRepository commentRepository;
  @Before
  public void setup()
  {
    Comment comment = new Comment();
    comment.setText("description");
    comment.setCommentId(1L);
    given(commentRepository.findOne(1L)).willReturn(comment);
  }
  @Test
  public void shouldCheckCommentGetResource()
  {
    ParameterizedTypeReference<Resource<Comment>> responseType = new ParameterizedTypeReference<Resource<Comment>>() {};
    ResponseEntity<Resource<Comment>> responseEntity =
        restTemplate.exchange("/comments/1", HttpMethod.GET, null, responseType, Collections
            .emptyMap());
    Comment actualResult = responseEntity.getBody().getContent();
    assertEquals("description", actualResult.getText());
    // more assertions
  }
}
As I understand, using MockBean annotation I replace current repository bean and it will not be exposed by data rest, Do we have any way to pre-populate data into db or mock invocation of repository method?