Migrate to new group id - rebase#1214
Conversation
Fix typo
Add ID column to tmpDbGroups
Move to group.name in DatabaseTest.java
Migrate to group.name in DatabaseTest.java
…unit test..." This reverts commit ed724b8.
|
I must have done something wrong, but now the tests are failing :( ping @TheLastProject |
app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Outdated
Show resolved
Hide resolved
…java Co-authored-by: Sylvia van Os <sylvia@hackerchick.me>
|
I found the reason behind a few of the failing tests. Not all yet, there's some database constraint that are failing. Need to look at that still. |
Thanks a lot for the help! Now it only fails at ImportExport at 2 places... |
| List<Group> cardGroups = DBHelper.getLoyaltyCardGroups(database, cardId); | ||
|
|
||
| Integer groupId = CSVHelpers.extractInt(DBHelper.LoyaltyCardDbIdsGroups.groupID, record, false); | ||
| cardGroups.add(DBHelper.getGroup(database, groupId)); |
There was a problem hiding this comment.
Finally figuring out why one of the tests is failing.
For one of the unit tests, this adds an entry to cardGroups with value null, causing a NullPointerException in setLoyaltyCardGroups.
This is because DBHelper.getGroup() has 0 results for groupId 1.
I'm not quite sure yet why.
There was a problem hiding this comment.
Thanks a lot for figuring this out! Hmm I don't know why either... 🤔
There was a problem hiding this comment.
Is maybe importCardGroupMappingV2 used instead of importCardGroupMappingV3, which defaults to null if no string found?
There was a problem hiding this comment.
Doesn't look like it, the failure happens in importCardGroupMappingV3. It's the multipleCardsExportImportWithGroups test failing.
E/Catima: Failed to import data
java.lang.NullPointerException
at protect.card_locker.DBHelper.setLoyaltyCardGroups(DBHelper.java:641)
at protect.card_locker.importexport.CatimaImporter.importCardGroupMappingV3(CatimaImporter.java:540)
at protect.card_locker.importexport.CatimaImporter.parseV3CardGroups(CatimaImporter.java:361)
at protect.card_locker.importexport.CatimaImporter.parseV3(CatimaImporter.java:211)
at protect.card_locker.importexport.CatimaImporter.importCSV(CatimaImporter.java:88)
at protect.card_locker.importexport.CatimaImporter.importData(CatimaImporter.java:59)
at protect.card_locker.importexport.MultiFormatImporter.importData(MultiFormatImporter.java:47)
at protect.card_locker.ImportExportTest.multipleCardsExportImportWithGroups(ImportExportTest.java:468)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:580)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:287)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
| bundle.putString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP, groupsTabLayout.getTabAt(selectedTab).getText().toString()); | ||
| TabLayout.Tab tab = groupsTabLayout.getTabAt(selectedTab); | ||
| if (tab != null) { | ||
| Group group = (Group) groupsTabLayout.getTabAt(selectedTab).getTag(); |
There was a problem hiding this comment.
Am I missing something here or was this unnecessary duplication?
| Group group = (Group) groupsTabLayout.getTabAt(selectedTab).getTag(); | |
| Group group = (Group) tab.getTag(); |
|
|
||
| DBHelper.insertGroup(database, id); | ||
| /** | ||
| * Import a single group from the V3 scheme (database v16) into the database using the given |
| List<Group> cardGroups = DBHelper.getLoyaltyCardGroups(database, cardId); | ||
|
|
||
| Integer groupId = CSVHelpers.extractInt(DBHelper.LoyaltyCardDbIdsGroups.groupID, record, false); | ||
| cardGroups.add(DBHelper.getGroup(database, groupId)); |
There was a problem hiding this comment.
Not 100% sure this is correct, but it makes the tests pass.
| cardGroups.add(DBHelper.getGroup(database, groupId)); | |
| cardGroups.add(DBHelper.getGroupByName(database, groupsTable.get(groupId))); |
There was a problem hiding this comment.
Also not sure how importing works. Does it keep existing cards and groups? If so does this handle conflicting IDs between existing data and the exported data?
There was a problem hiding this comment.
Might be better to have a DBHelper.insertGroup(database, id, name) to be used in importGroupV3() to insert a group with a specific ID.
|
@Altonss @TheLastProject I opened #1333 based on this PR. |
This PR solves #1045