Skip to content

Commit

Permalink
Added new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
qaziabubakar committed Feb 3, 2021
1 parent 5a7c34e commit b5cc3b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.vijay.jsonwizard.domain.ExpansionPanelItemModel;
import com.vijay.jsonwizard.domain.ExpansionPanelValuesModel;
import com.vijay.jsonwizard.interfaces.OnFormFetchedCallback;
import com.vijay.jsonwizard.model.DynamicLabelInfo;

import org.apache.commons.lang3.StringUtils;
import org.jeasy.rules.api.Facts;
Expand All @@ -25,6 +26,7 @@
import org.smartregister.client.utils.contract.ClientFormContract;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -657,4 +659,15 @@ public void testGetCheckBoxResultsWithNoIsRuleCheck() throws JSONException {
Assert.assertNotNull(facts);
Assert.assertEquals(4, facts.asMap().size());
}

@Test
public void testGetDynamicLabelInfoList() throws JSONException {
JSONArray jsonArray = new JSONArray("[{\"dynamic_label_title\": \"sample title\",\"dynamic_label_text\": \"sample text\",\"dynamic_label_image_src\": \"img/img.png\"}]");
ArrayList<DynamicLabelInfo> expectedList = new ArrayList<>();
expectedList.add(new DynamicLabelInfo("sample title", "sample text", "img/img.png"));
ArrayList<DynamicLabelInfo> actualList = FormUtils.getDynamicLabelInfoList(jsonArray);
Assert.assertEquals(expectedList.get(0).getDynamicLabelText(), actualList.get(0).getDynamicLabelText());
Assert.assertEquals(expectedList.get(0).getDynamicLabelTitle(), actualList.get(0).getDynamicLabelTitle());
Assert.assertEquals(expectedList.get(0).getDynamicLabelImageSrc(), actualList.get(0).getDynamicLabelImageSrc());
}
}
7 changes: 1 addition & 6 deletions sample/src/main/assets/json.form/single_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,8 @@
"dynamic_label_image_src": ""
},
{
"dynamic_label_title": "",
"dynamic_label_title": "3rd Title",
"dynamic_label_text": "Third description text",
"dynamic_label_image_src": ""
},
{
"dynamic_label_title": "",
"dynamic_label_text": "",
"dynamic_label_image_src": "img/first_img.png"
},
{
Expand Down

0 comments on commit b5cc3b6

Please sign in to comment.