Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.junit.Test
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.TimeZone

class CommCareEventDataSourceTest {
companion object {
Expand All @@ -53,8 +54,13 @@ class CommCareEventDataSourceTest {

private val emptyEventQuery = RemoteEventQuery(projectId = DEFAULT_PROJECT_ID, modes = emptyList())

// Helper to format date strings as CommCare does (using US locale to match Java's Date.toString())
private val commCareDateFormat = SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)
// Helper to format date strings as CommCare does (using US locale to match Java's Date.toString()).
// The timezone is pinned to UTC so the formatted/parsed round trip is deterministic regardless of
// the machine's default timezone (e.g. "Europe/London" prints "GMT" for its short zone name even
// during BST, which reparsed as literal GMT/UTC+0 would silently shift timestamps by an hour).
private val commCareDateFormat = SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US).apply {
timeZone = TimeZone.getTimeZone("UTC")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this not needed before?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be fine in my local runs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the issue I am getting

Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification failed: call 1 of 1: ContentResolver(mockContentResolver#15).query(eq(Uri(#3)), any(), any(), any(), any())) should not be called

Calls:

  1. ContentResolver(mockContentResolver#15).query(Uri(#1), null, null, null, null)
  2. ContentResolver(mockContentResolver#15).query(Uri(#1), [case_id, last_modified], null, null, null)
  3. ContentResolver(mockContentResolver#15).query(Uri(#3), null, null, null, null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷🏻

Screenshot 2026-08-12 at 15 24 59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runs fine for me, too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runs for me as well. @meladRaouf are you sure it's not something on your local device?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then I will discard my PR and find a solution in my local setup.

}

private fun formatCommCareDate(millis: Long): String = commCareDateFormat.format(Date(millis))

Expand Down