-
Notifications
You must be signed in to change notification settings - Fork 14
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
PM- added testing case for sorting data from storage #1458
base: master
Are you sure you want to change the base?
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request adds a new method, Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Suite
participant Interface as IStorageUtilityIndexed
participant Dummy as DummyIndexedStorageUtility
participant Reflect as Reflection (getFieldValue)
Test->>Interface: call getSortedRecordsForValues(metaFieldNames, values, orderby)
Interface->>Dummy: delegate call to getSortedRecordsForValues
Dummy->>Reflect: retrieve field values for each record
Reflect-->>Dummy: return field value
Dummy-->>Test: return sorted record list
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 6
🧹 Nitpick comments (1)
src/test/java/org/javarosa/core/storage/IndexedStorageUtilityTests.java (1)
132-133
: Add assertion message for better test failure diagnostics.The assertion message incorrectly references "vans" instead of "adidas".
- Assert.assertArrayEquals("Failed index match [brand,style][vans,mens]", fiveSortedSizesOfMensAddidas,matchedSortedRecords.toArray()); + Assert.assertArrayEquals("Failed index match [brand,style][adidas,mens]", fiveSortedSizesOfMensAdidas,matchedSortedRecords.toArray());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/java/org/javarosa/core/services/storage/IStorageUtilityIndexed.java
(1 hunks)src/main/java/org/javarosa/core/services/storage/util/DummyIndexedStorageUtility.java
(2 hunks)src/test/java/org/javarosa/core/storage/IndexedStorageUtilityTests.java
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
src/test/java/org/javarosa/core/storage/IndexedStorageUtilityTests.java
Outdated
Show resolved
Hide resolved
src/main/java/org/javarosa/core/services/storage/IStorageUtilityIndexed.java
Outdated
Show resolved
Hide resolved
src/main/java/org/javarosa/core/services/storage/util/DummyIndexedStorageUtility.java
Show resolved
Hide resolved
src/main/java/org/javarosa/core/services/storage/util/DummyIndexedStorageUtility.java
Outdated
Show resolved
Hide resolved
src/main/java/org/javarosa/core/services/storage/util/DummyIndexedStorageUtility.java
Outdated
Show resolved
Hide resolved
src/main/java/org/javarosa/core/services/storage/util/DummyIndexedStorageUtility.java
Outdated
Show resolved
Hide resolved
@coderabbitai I pushed a fix in commit f2a04ae, please review it |
@pm-dimagi The changes look good! You've made several improvements:
(`∇´ゞ) 🔗 Analysis chain🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 8288 ✅ Actions performedComments resolved. |
@@ -251,6 +251,32 @@ public interface IStorageUtilityIndexed<E extends Externalizable> { | |||
* they may need to clean up if the bulk read doesn't complete | |||
*/ | |||
|
|||
Vector<E> getSortedRecordsForValues(String[] metaFieldNames, Object[] values,String orderby); |
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.
Java docs are out of order
} catch (Exception e) { | ||
// Log error and continue with no ordering | ||
System.err.println("Failed to compare records: " + e.getMessage()); |
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.
we should not be catching generic exceptions
@@ -126,6 +128,15 @@ public void testBulkMetaMatching() { | |||
|
|||
Vector<Shoe> matchedRecords = storage.getRecordsForValues(new String[]{Shoe.META_BRAND, Shoe.META_STYLE}, new String[]{"nike", "mens"}); | |||
Assert.assertEquals("Failed index match [brand,style][nike,mens]", getIdsFromModels(tenSizesOfMensNikes), getIdsFromModels(matchedRecords.toArray(new Shoe[]{}))); | |||
|
|||
Vector<Shoe> matchedSortedRecords = storage.getSortedRecordsForValues(new String[]{Shoe.META_BRAND, Shoe.META_STYLE}, new String[]{"adidas", "mens"},Shoe.META_SIZE+" DESC"); |
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.
what is the expected outcome for function calls without select params - storage.getSortedRecordsForValues(new String[]{}, new String[]{},Shoe.META_SIZE+" DESC");
?
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.
revert the array as it is
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.
can you add a test case for it.
Vector<Shoe> matchedAscSortedRecords = storage.getSortedRecordsForValues(new String[]{Shoe.META_BRAND, Shoe.META_STYLE}, new String[]{"vans", "mens"},Shoe.META_SIZE+" ASC"); | ||
Assert.assertArrayEquals("Failed index match [brand,style][adidas,mens]", matchedAscSortedRecords.toArray(),fiveSizesOfMensVans); | ||
|
||
Vector<Shoe> matchedAscSortedRecordsTest = storage.getSortedRecordsForValues(new String[]{Shoe.META_BRAND, Shoe.META_STYLE}, new String[]{"vans", "mens"},Shoe.META_SIZE+" ASSC"); |
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.
this call should fail right given ASSC
is not the right keyword ?
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.
revert the array is asc order as default value is ascending
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.
I don't think we should be allowing for incorrrect keywords in this method and should do a strict match and else throw an error.
Product Description
Test cases to test the sorting of an table from the storage through SQL query
Technical Summary
Sort function take the field through which sorting need to be done and take value ASC or DESC to describe the order of the sorting
Safety Assurance
Safety story
there is the test case written so it is all passed so there is no safety threat in this
Automated test coverage
Local test cases written
QA Plan
Special deploy instructions
Rollback instructions
Review
Duplicate PR
Automatically duplicate this PR as defined in contributing.md.
Summary by CodeRabbit
New Features
Tests