diff --git a/src/main/java/org/commcare/formplayer/sqlitedb/SQLiteDB.java b/src/main/java/org/commcare/formplayer/sqlitedb/SQLiteDB.java index 8b8ce7851..6211aebf6 100644 --- a/src/main/java/org/commcare/formplayer/sqlitedb/SQLiteDB.java +++ b/src/main/java/org/commcare/formplayer/sqlitedb/SQLiteDB.java @@ -42,7 +42,7 @@ private Connection getNewConnection() throws SQLException { } private Boolean matchesConnection(SQLiteConnection sqLiteConnection) { - return sqLiteConnection.getUrl().contains(dbPath.getDatabasePath()); + return sqLiteConnection.getUrl().contains(dbPath.getDatabasePath().replace("/","\\")); } @Override diff --git a/src/test/java/org/commcare/formplayer/tests/CaseClaimNavigationTests.java b/src/test/java/org/commcare/formplayer/tests/CaseClaimNavigationTests.java index 50fa8e3ac..f8b3c37e5 100644 --- a/src/test/java/org/commcare/formplayer/tests/CaseClaimNavigationTests.java +++ b/src/test/java/org/commcare/formplayer/tests/CaseClaimNavigationTests.java @@ -12,6 +12,7 @@ import org.commcare.data.xml.VirtualInstances; import org.commcare.formplayer.beans.NewFormResponse; import org.commcare.formplayer.beans.QuestionBean; +import org.commcare.formplayer.beans.SubmitResponseBean; import org.commcare.formplayer.beans.menus.CommandListResponseBean; import org.commcare.formplayer.beans.menus.EntityListResponse; import org.commcare.formplayer.objects.QueryData; @@ -212,6 +213,7 @@ public void testPostInEntryWithQuery_RelevantTrue() throws Exception { ); } + /** * This tests that the session volatiles are cleared after the sync. The 'post' * and the 'assertion' share the same XPath case lookup expression so without clearing volatiles @@ -238,6 +240,57 @@ public void testPostInEntryWithQuery_clearVolatiles() throws Exception { }); selections.add("0156fa3e-093e-4136-b95c-01b13dae66c6"); + NewFormResponse formResponse; + try ( + MockRequestUtils.VerifiedMock ignoredPostMock = mockRequest.mockPost(true); + MockRequestUtils.VerifiedMock ignoredRestoreMock = mockRequest.mockRestore("restores/caseclaim3.xml"); + ) { + formResponse = sessionNavigateWithQuery(selections, + APP_PATH, + queryData, + NewFormResponse.class); + } + + SubmitResponseBean submitResponse = submitForm(new HashMap<>(), formResponse.getSessionId()); + + CommandListResponseBean commandResponse = getNextScreenForEofNavigation(submitResponse, + CommandListResponseBean.class); + assert commandResponse.getCommands().length == 4; + + if (formResponse.getNotification() != null && formResponse.getNotification().isError()) { + fail(formResponse.getNotification().getMessage()); + } + } + + /** + * Test that volatiles are cleared when a query session is completed + */ + @Test + public void testPostSearch_clearVolatiles() throws Exception { + ArrayList selections = new ArrayList<>(); + selections.add("3"); // m3 + selections.add("1"); // form + + + QueryData queryData = new QueryData(); + + EntityListResponse entityListResponse; + try (MockRequestUtils.VerifiedMock ignored = mockRequest.mockQuery("query_responses/case_claim_before_form.xml")) { + entityListResponse = sessionNavigateWithQuery(selections, + APP_PATH, + queryData, + EntityListResponse.class); + } + + + assertThat(entityListResponse.getEntities()).anyMatch(e -> { + return e.getId().equals("0156fa3e-093e-4136-b95c-01b13dae66c6"); + }); + + selections.add("0156fa3e-093e-4136-b95c-01b13dae66c6"); + + + NewFormResponse formResponse; try ( MockRequestUtils.VerifiedMock ignoredPostMock = mockRequest.mockPost(true); @@ -253,6 +306,7 @@ public void testPostInEntryWithQuery_clearVolatiles() throws Exception { } } + @Test public void testClearCachesAfterFormSubmission() throws Exception { ArrayList selections = new ArrayList<>(); diff --git a/src/test/resources/archives/case_claim_post_in_entry/modules-1/forms-2.xml b/src/test/resources/archives/case_claim_post_in_entry/modules-1/forms-2.xml index 3c0945ad4..ac8f839fe 100644 --- a/src/test/resources/archives/case_claim_post_in_entry/modules-1/forms-2.xml +++ b/src/test/resources/archives/case_claim_post_in_entry/modules-1/forms-2.xml @@ -31,8 +31,8 @@ - + diff --git a/src/test/resources/archives/case_claim_post_in_entry/suite.xml b/src/test/resources/archives/case_claim_post_in_entry/suite.xml index 9cefcf7ec..ce40bb800 100644 --- a/src/test/resources/archives/case_claim_post_in_entry/suite.xml +++ b/src/test/resources/archives/case_claim_post_in_entry/suite.xml @@ -193,6 +193,130 @@ + + + + <text> + <locale id="m3.case_short.title"/> + </text> + + +
+ + Name + +
+ + + + + + +
+ + + + Autofetch + + + + + + + + + +
+ + + + <text>Title + </text> + + +
Name +
+ + + + + + +
+
+ + +
http://openrosa.org/formdesigner/11FAC65A-F2CD-427F-A870-CF126336AAB5
+ + + + + post-claim form + + + + + + + + + + + +
+ + + + + + + + + search cases + + + + + + + + + <text> + searches + </text> + + + search cases + + + + + + + Name + + + + + + + + + + + + + + +
http://openrosa.org/formdesigner/11FAC65A-F2CD-427F-A870-CF126336AAB5
@@ -262,7 +386,7 @@
http://openrosa.org/formdesigner/5CCB1614-68B3-44C0-A166-D63AA7C1D4FB
- + m2f1 @@ -278,10 +402,10 @@
-
http://openrosa.org/formdesigner/5CCB1614-68B3-44C0-A166-D63AA7C1D4FB
+
http://openrosa.org/formdesigner/m2-f3
- + m2f2 @@ -302,12 +426,17 @@ + + + + +
http://openrosa.org/formdesigner/m2-f3
- + m2f3 @@ -351,6 +480,13 @@ + + + + Remote Module + + + @@ -409,7 +545,7 @@ - + diff --git a/src/test/resources/query_responses/case_claim_after_form.xml b/src/test/resources/query_responses/case_claim_after_form.xml new file mode 100644 index 000000000..62016f847 --- /dev/null +++ b/src/test/resources/query_responses/case_claim_after_form.xml @@ -0,0 +1,13 @@ + + + Kurt Maclin + 2017-04-21T14:25:39.125000Z + 2017-04-21 + None + None + choice1 + 123 + dupe_case_id + + diff --git a/src/test/resources/query_responses/case_claim_before_form.xml b/src/test/resources/query_responses/case_claim_before_form.xml new file mode 100644 index 000000000..263d37bf7 --- /dev/null +++ b/src/test/resources/query_responses/case_claim_before_form.xml @@ -0,0 +1,27 @@ + + + Burt Maclin + 2017-04-21T14:25:39.125000Z + 2017-04-21 + None + None + choice1 + 123 + dupe_case_id + yes + + + + Kurt Maclin + 2017-04-21T14:25:39.125000Z + 2017-04-21 + None + None + choice1 + 123 + dupe_case_id + yes + +