Hier ist der Beispielcode, den ich stören möchte: < /p>
Code: Select all
SampleResponse sampleResp = response.asJson(SampleResponse.class);
< /code>
Ich habe versucht, ChatGPT nach Lösungen zu fragen, die gelieferte Lösung jedoch immer noch fehlschlägt. Hier ist eine Beispiellösung: < /p>
@Mock
SimpleHttp.Response response;
< /code>
SampleResponse sampleResponse = new SampleResponse();
when(response.asJson(SampleResponse.class)).thenReturn(sampleResponse);
< /code>
It returns this error:
org.mockito.exceptions.misusing.NotAMockException: Argument passed to Mockito.mockingDetails() should be a mock, but is an instance of class java.lang.Class!
< /code>
I have also tried this solution:
when(response.asJson(any(SampleResponse.class))).thenReturn(sampleResponse);
< /code>
It still fails and returns this error:
no suitable method found for asJson(sampleResponse)
method org.keycloak.broker.provider.util.SimpleHttp.Response.asJson(java.lang.Class) is not applicable
(inference variable T has incompatible bounds
equality constraints: sampleResponse
lower bounds: java.lang.Object,java.lang.Class)
method org.keycloak.broker.provider.util.SimpleHttp.Response.asJson(com.fasterxml.jackson.core.type.TypeReference) is not applicable
(inference variable T has incompatible bounds
equality constraints: sampleResponse
lower bounds: java.lang.Object,com.fasterxml.jackson.core.type.TypeReference