Szczegóły błędu:
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
Boolean cannot be returned by updateItemAttributesByJuId()
updateItemAttributesByJuId() should return ResultRich
This exception might occur in wrongly written multi-threaded tests.
Please refer to Mockito FAQ on limitations of concurrency testing.
mój kod:
@InjectMocks
protected ItemArrangeManager arrangeManagerSpy = spy(new ItemArrangeManagerImpl());
@Mock
protected JuItemWriteService juItemWriteService;
when(arrangeManagerSpy
.updateItemAttributes(mapCaptor.capture(), eq(juId), eq(itemTO.getSellerId())))
.thenReturn(false);
Jak widać, wzywam whenna updateItemAttributes(co nie zwracają boolean) nie na updateItemAttributesByJuId.
- Dlaczego Mockito próbuje zwrócić
booleanodupdateItemAttributesByJuId? - Jak można to naprawić?
@Repositorymetody Spring DAO z @Aspect . jeśli to zrobięwhen(someDao.someMethod()).thenReturn(List<xxx>), mam ten wyjątek WrongTypeOfReturnValue. Poprzez debugowanie widzę, żesomeMethodmetoda została faktycznie wywołana w powyższej instrukcji i wyzwala pomoc w zakresienullokrążenia i zwraca, ale Mockito oczekujeList<xxx>.