Детали ошибки:
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.
мой код:
@InjectMocks
protected ItemArrangeManager arrangeManagerSpy = spy(new ItemArrangeManagerImpl());
@Mock
protected JuItemWriteService juItemWriteService;
when(arrangeManagerSpy
.updateItemAttributes(mapCaptor.capture(), eq(juId), eq(itemTO.getSellerId())))
.thenReturn(false);
Как вы можете видеть, я звоню whenна updateItemAttributes(что делает возвращающие boolean) не на updateItemAttributesByJuId.
- Почему Mockito пытается вернуть
booleanизupdateItemAttributesByJuId? - Как это исправить?
@Repositoryметода Spring DAO с @Aspect . если даwhen(someDao.someMethod()).thenReturn(List<xxx>), то получу исключение WrongTypeOfReturnValue. Благодаря отладке я вижу, чтоsomeMethodметод действительно был вызван в приведенном выше заявлении и запускает Around Advice и возвращает,nullно Mockito ожидаетList<xxx>.