Skip to content

Conversation

@Kota-Jagadeesh
Copy link
Collaborator

Description (required)

Fixes #2819

What changes did you make and why?

This PR implements the requested unit tests for the OkHttpJsonApiClient:getCampaigns method to ensure the API layer is working correctly.

The changes include:

  1. Model Fixes: Updated CampaignConfig and CampaignResponseDTO by changing their fields from immutable (val) to mutable (var). This is essential to allow the Gson library to correctly deserialize the JSON data into these Kotlin data classes during the test run and at application runtime.
  2. Test Resources: Added two new JSON files (campaigns_response_with_data.json and campaigns_response_empty.json) to the test resources directory to provide mock responses for the API calls.
  3. Unit Tests: Implemented the two required test cases in OkHttpJsonApiClientTests.kt to cover both scenarios: a successful response with campaign data and a successful response with an empty campaign list.

Tests performed (required)

Tested ProdDebug on Redmi note 13 pro 5g with API level 35.

@github-actions
Copy link

✅ Generated APK variants!

@nicolas-raoul nicolas-raoul merged commit def3355 into commons-app:main Oct 19, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test for fetching campaigns

2 participants