Add RAG client
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Test set: com.example.service.GeminiClientServiceTest
|
||||
-------------------------------------------------------------------------------
|
||||
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.988 s <<< FAILURE! -- in com.example.service.GeminiClientServiceTest
|
||||
com.example.service.GeminiClientServiceTest.generateContent_whenUnexpectedExceptionOccurs_throwsGeminiClientException -- Time elapsed: 0.201 s <<< ERROR!
|
||||
java.lang.NullPointerException: Cannot invoke "com.google.genai.Models.generateContent(String, com.google.genai.types.Content, com.google.genai.types.GenerateContentConfig)" because "this.geminiClient.models" is null
|
||||
at com.example.service.GeminiClientServiceTest.generateContent_whenUnexpectedExceptionOccurs_throwsGeminiClientException(GeminiClientServiceTest .java:112)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
|
||||
com.example.service.GeminiClientServiceTest.generateContent_whenGenAiIOExceptionOccurs_throwsGeminiClientException -- Time elapsed: 0.024 s <<< ERROR!
|
||||
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
|
||||
|
||||
Misplaced or misused argument matcher detected here:
|
||||
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenUnexpectedExceptionOccurs_throwsGeminiClientException(GeminiClientServiceTest .java:112)
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenUnexpectedExceptionOccurs_throwsGeminiClientException(GeminiClientServiceTest .java:112)
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenUnexpectedExceptionOccurs_throwsGeminiClientException(GeminiClientServiceTest .java:112)
|
||||
|
||||
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(any());
|
||||
verify(mock).someMethod(contains("foo"))
|
||||
|
||||
This message may appear after an NullPointerException if the last matcher is returning an object
|
||||
like any() but the stubbed method signature expect a primitive argument, in this case,
|
||||
use primitive alternatives.
|
||||
when(mock.get(any())); // bad use, will raise NPE
|
||||
when(mock.get(anyInt())); // correct usage use
|
||||
|
||||
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.
|
||||
|
||||
at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:160)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
Suppressed: java.lang.NullPointerException: Cannot invoke "java.util.Set.forEach(java.util.function.Consumer)" because the return value of "org.junit.jupiter.api.extension.ExtensionContext$Store.remove(Object, java.lang.Class)" is null
|
||||
at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:194)
|
||||
... 2 more
|
||||
|
||||
com.example.service.GeminiClientServiceTest.generateContent_whenResponseTextIsNull_throwsGeminiClientException -- Time elapsed: 0.710 s <<< ERROR!
|
||||
java.lang.NullPointerException: Cannot invoke "com.google.genai.Models.generateContent(String, com.google.genai.types.Content, com.google.genai.types.GenerateContentConfig)" because "this.geminiClient.models" is null
|
||||
at com.example.service.GeminiClientServiceTest.generateContent_whenResponseTextIsNull_throwsGeminiClientException(GeminiClientServiceTest .java:85)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
|
||||
com.example.service.GeminiClientServiceTest.generateContent_whenApiSucceeds_returnsGeneratedText -- Time elapsed: 0.005 s <<< ERROR!
|
||||
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
|
||||
|
||||
Misplaced or misused argument matcher detected here:
|
||||
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenResponseTextIsNull_throwsGeminiClientException(GeminiClientServiceTest .java:85)
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenResponseTextIsNull_throwsGeminiClientException(GeminiClientServiceTest .java:85)
|
||||
-> at com.example.service.GeminiClientServiceTest.generateContent_whenResponseTextIsNull_throwsGeminiClientException(GeminiClientServiceTest .java:85)
|
||||
|
||||
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(any());
|
||||
verify(mock).someMethod(contains("foo"))
|
||||
|
||||
This message may appear after an NullPointerException if the last matcher is returning an object
|
||||
like any() but the stubbed method signature expect a primitive argument, in this case,
|
||||
use primitive alternatives.
|
||||
when(mock.get(any())); // bad use, will raise NPE
|
||||
when(mock.get(anyInt())); // correct usage use
|
||||
|
||||
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.
|
||||
|
||||
at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:160)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
Suppressed: java.lang.NullPointerException: Cannot invoke "java.util.Set.forEach(java.util.function.Consumer)" because the return value of "org.junit.jupiter.api.extension.ExtensionContext$Store.remove(Object, java.lang.Class)" is null
|
||||
at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:194)
|
||||
... 2 more
|
||||
|
||||
com.example.service.GeminiClientServiceTest.generateContent_whenApiResponseIsNull_throwsGeminiClientException -- Time elapsed: 0.017 s <<< ERROR!
|
||||
java.lang.NullPointerException: Cannot invoke "com.google.genai.Models.generateContent(String, com.google.genai.types.Content, com.google.genai.types.GenerateContentConfig)" because "this.geminiClient.models" is null
|
||||
at com.example.service.GeminiClientServiceTest.generateContent_whenApiResponseIsNull_throwsGeminiClientException(GeminiClientServiceTest .java:71)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
||||
|
||||
Reference in New Issue
Block a user