I'm trying to get familiar with Mockito Captor but I get both NullPointerException and InvalidUseOfMatchersException. I have a feeling, that I am doing something wrong and/or understanding the captor technique incorrectly.
Here is my testing class:
@Test
public void testFindByClientIdAndBatchDateBetween() {
DateTime todayDateTime = new DateTime().withTimeAtStartOfDay();
mockedTransactRepViewModel.capture().setClientId("123456");
mockedTransactRepViewModel.capture().setBatchDate(todayDateTime.toDate());
mockTransactRepViewRepository.save(mockedTransactRepViewModel.capture());
verify(mockTransactRepViewRepository).findByClientIdAndClDateBetween("123456", todayDateTime.toDate(),
todayDateTime.plusDays(1).toDate()).get(0);
String mockClientId = mockedTransactRepViewModel.getValue().getClientId();
assertThat(mockClientId.equals("123456"));
verify(mockTransactRepViewRepository, times(1)).save(mockedTransactRepViewModel.capture());
}
Aucun commentaire:
Enregistrer un commentaire