jeudi 19 juillet 2018

Mockito, mocking two methods in different clases

I am testing REST with Mockito, I have controller, service classes. In controller service class there are two methods where I get information from database, I want to mock these methods to return response I have created. However, it ignores my mocks. Could you check it please? my mocks

 when(oppProcExecutor.runProcSync(new GetCardsOpp("testas", "vienasdutrys"))).thenReturn("test");
    when(requestRepository.findById("test")).thenReturn(mockRequest);

  private MockMvc mockMvc;

@Autowired
@Mock
OppProcExecutor oppProcExecutor;

@Autowired
@Mock
RequestRepository requestRepository;


@Autowired
@Spy CardService cardService;
@Autowired
protected WebApplicationContext wac;

@Autowired
@InjectMocks
CardController cardController;

Aucun commentaire:

Enregistrer un commentaire