Невозможно издеваться над ответом JSON в Spring ResttemplateJAVA

Программисты JAVA общаются здесь
Anonymous
Невозможно издеваться над ответом JSON в Spring Resttemplate

Сообщение Anonymous »

Я пытаюсь издеваться над строкой в ответе Resttemplate, но я получаю ошибку в коде. Пожалуйста, предоставьте входы. < /P>

ошибка: < /h1>

org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Misplaced argument matcher detected here:

You cannot use argument matchers outside of verification or stubbing.
Examples of correct usage of argument matchers:
when(mock.get(anyInt())).thenReturn(null);
doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject());
verify(mock).someMethod(contains("foo"))

Also, this error might show up because you use argument matchers with methods that cannot be mocked.
Following methods *cannot* be stubbed/verified: final/private/equals()/hashCode().
Mocking methods declared on non-public parent classes is not supported.
< /code>

Приведенная выше ошибка произошла в этой строке: < /p>

Ошибка в коде строки ниже: < /h1>

when(this.userProfileClientRestTemplateProvider.currentUserProfileWithPermissionsRestTemplate()
.exchange(
any(RequestEntity.class),eq(String.class))) .thenReturn(mockResponseEntityFromFile("com/cnanational/dealerplanadmin/service/applyRuleSetsToDealer/user-permissions.json",
String.class, ResponseEntity.ok()));


Подробнее здесь: https://stackoverflow.com/questions/565 ... sttemplate

Вернуться в «JAVA»