-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : adds test case for embeddingClientConversion #136
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
972bd2c
feat : adds test case for embeddingClientConversion
rajadilipkolli 60f1954
adds reasoning
rajadilipkolli 23fd193
adds more assertions
rajadilipkolli 9a176f5
adds validation and more test cases
rajadilipkolli bcb1671
modulerize the request
rajadilipkolli 6f7b1b4
adds more test cases
rajadilipkolli 2777a25
re define prompt
rajadilipkolli 01c8726
rename test case
rajadilipkolli 88dc14a
adds -ve test case
rajadilipkolli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai, please review all test cases in this class and provide if there are any suggestions or improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajadilipkolli, here are my suggestions and observations after reviewing the test cases in
ChatControllerTest
:Balance of Positive and Negative Tests
Additional Assertions
testChat
,chatWithPrompt
,chatWithSystemPrompt
, orsentimentAnalyzer
, you might add more assertions checking the structure of the JSON body. For instance, verifying each top-level field in the response to ensure your controller includes all expected properties.outputParser
, besides checking the size ofmovies
, you might verify each item meets certain criteria if relevant (such as ensuring the type is a string and non-empty).Edge / Corner Cases
embeddingClientConversion
, you test the expected size of the double array. Consider verifying whether the values are valid embeddings (e.g., checking if any non-numeric values appear, or if each value is finite), though this depends on how much your application needs to validate them.ragWithSimpleStore
, you are checking a general text snippet in the answer. If the application logic is expected to do specific manipulations, consider verifying that the entire returned structure is well-formed.Descriptive Test Names
shouldReturnSarcasticSentiment()
ortestRagWithSimpleStoreProvidesValidResponse()
. This especially helps when reading test reports or debugging.Parameterization
chatWithPrompt
andchatWithSystemPrompt
, if you plan to test multiple variations of user prompts, JUnit’s parameterized tests could reduce duplication.Maintainability
ChatController
grows more complex, consider refactoring common RestAssured setup steps into a utility function or a custom test extension. This way, you keep each test more “readable” while reducing duplicate code.Overall, the tests are straightforward and effectively use RestAssured’s fluent approach. Implementing additional negative tests and refining validations will help ensure broader coverage and correctness of the API responses. If you have any further questions or would like more suggestions, let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai, can you please help me with writing code to implement all above suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajadilipkolli, here's some example code illustrating how you could incorporate the suggestions from my earlier review into your test suite. Please feel free to adjust any details to suit your project’s requirements.
1. Negative Test Cases
Below is an example test checking how the endpoint responds to a malformed request (e.g., an empty JSON). You can add more variations of malformed or invalid data as needed:
2. Additional Assertions
For more thorough checks on JSON structure, you can use RestAssured’s fluent approach to verify multiple response fields. Here’s an example updated from the
testChat
method, checking top-level fields:3. Edge / Corner Cases
In
embeddingClientConversion
, if you want to ensure the returned values are valid embeddings (for instance, checking if they are finite numbers), you can add these checks:4. Descriptive Test Names
Renaming existing tests helps clarify their expected behavior. For example, instead of
sentimentAnalyzer
, you could rename it toshouldAnalyzeSentimentAsSarcastic()
. Below is an illustrative renaming (you can rename others too):5. Parameterization
If you plan to test multiple input prompts for
chatWithPrompt
, you can use JUnit parameterized tests. Below is a minimal example of how you might set this up:Notice how the
containsStringIgnoringCase
check ensures the response includes your provided prompt in some manner.6. Maintainability
If your test class grows in complexity, you can reduce duplication of common setup steps by extracting them into utility methods or a separate class. For example, if you find yourself constructing
AIChatRequest
with the same defaults repeatedly, you might do something like:I hope these examples help you integrate the suggestions effectively. Let me know if you have any questions, or if there are other specific adjustments you’d like!