-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:OpenSRP/opensrp-client-native-for…
…m into optimize-native-forms
- Loading branch information
Showing
4 changed files
with
134 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 5 additions & 148 deletions
153
android-json-form-wizard/src/main/java/com/vijay/jsonwizard/domain/Form.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,152 +1,9 @@ | ||
package com.vijay.jsonwizard.domain; | ||
|
||
import java.io.Serializable; | ||
import java.util.Set; | ||
/** | ||
* This has been deprecated in favour of {@link org.smartregister.client.utils.domain.Form} | ||
*/ | ||
@Deprecated | ||
public class Form extends org.smartregister.client.utils.domain.Form { | ||
|
||
public class Form implements Serializable { | ||
|
||
private String name; | ||
|
||
private int homeAsUpIndicator; | ||
|
||
private int actionBarBackground; | ||
private int navigationBackground; | ||
|
||
private int backIcon; | ||
|
||
private String nextLabel; | ||
private String previousLabel; | ||
private String saveLabel; | ||
|
||
private boolean wizard = true; | ||
private boolean hideSaveLabel = false; | ||
|
||
private boolean hideNextButton = false; | ||
private boolean hidePreviousButton = false; | ||
|
||
private Set<String> hiddenFields; | ||
|
||
private Set<String> disabledFields; | ||
|
||
private static String datePickerDisplayFormat; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getHomeAsUpIndicator() { | ||
return homeAsUpIndicator; | ||
} | ||
|
||
public void setHomeAsUpIndicator(int homeAsUpIndicator) { | ||
this.homeAsUpIndicator = homeAsUpIndicator; | ||
} | ||
|
||
public int getActionBarBackground() { | ||
return actionBarBackground; | ||
} | ||
|
||
public void setActionBarBackground(int actionBarBackground) { | ||
this.actionBarBackground = actionBarBackground; | ||
} | ||
|
||
public int getNavigationBackground() { | ||
return navigationBackground; | ||
} | ||
|
||
public void setNavigationBackground(int navigationBackground) { | ||
this.navigationBackground = navigationBackground; | ||
} | ||
|
||
public boolean isWizard() { | ||
return wizard; | ||
} | ||
|
||
public void setWizard(boolean wizard) { | ||
this.wizard = wizard; | ||
} | ||
|
||
public String getNextLabel() { | ||
return nextLabel; | ||
} | ||
|
||
public void setNextLabel(String nextLabel) { | ||
this.nextLabel = nextLabel; | ||
} | ||
|
||
public String getPreviousLabel() { | ||
return previousLabel; | ||
} | ||
|
||
public void setPreviousLabel(String previousLabel) { | ||
this.previousLabel = previousLabel; | ||
} | ||
|
||
public String getSaveLabel() { | ||
return saveLabel; | ||
} | ||
|
||
public void setSaveLabel(String saveLabel) { | ||
this.saveLabel = saveLabel; | ||
} | ||
|
||
public boolean isHideSaveLabel() { | ||
return hideSaveLabel; | ||
} | ||
|
||
public void setHideSaveLabel(boolean hideSaveLabel) { | ||
this.hideSaveLabel = hideSaveLabel; | ||
} | ||
|
||
public int getBackIcon() { | ||
return backIcon; | ||
} | ||
|
||
public void setBackIcon(int backIcon) { | ||
this.backIcon = backIcon; | ||
} | ||
|
||
public void setHideNextButton(Boolean b){ | ||
hideNextButton = b; | ||
} | ||
|
||
public void setHidePreviousButton(Boolean b){ | ||
hidePreviousButton = b; | ||
} | ||
|
||
public boolean isHideNextButton(){ | ||
return hideNextButton; | ||
} | ||
|
||
public boolean isHidePreviousButton() { | ||
return hidePreviousButton; | ||
} | ||
|
||
public Set<String> getHiddenFields() { | ||
return hiddenFields; | ||
} | ||
|
||
public void setHiddenFields(Set<String> hiddenFields) { | ||
this.hiddenFields = hiddenFields; | ||
} | ||
|
||
public Set<String> getDisabledFields() { | ||
return disabledFields; | ||
} | ||
|
||
public void setDisabledFields(Set<String> disabledFields) { | ||
this.disabledFields = disabledFields; | ||
} | ||
|
||
public static String getDatePickerDisplayFormat() { | ||
return datePickerDisplayFormat; | ||
} | ||
|
||
public void setDatePickerDisplayFormat(String datePickerDisplayFormat) { | ||
Form.datePickerDisplayFormat = datePickerDisplayFormat; | ||
} | ||
} |
127 changes: 127 additions & 0 deletions
127
...n-form-wizard/src/test/java/com/vijay/jsonwizard/domain/MultiSelectListAccessoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.vijay.jsonwizard.domain; | ||
|
||
import android.support.v7.app.AlertDialog; | ||
|
||
import com.vijay.jsonwizard.adapter.MultiSelectListAdapter; | ||
import com.vijay.jsonwizard.adapter.MultiSelectListSelectedAdapter; | ||
|
||
import org.json.JSONObject; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
import org.robolectric.util.ReflectionHelpers; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Created by Ephraim Kigamba - nek.eam@gmail.com on 01-10-2020. | ||
*/ | ||
public class MultiSelectListAccessoryTest { | ||
|
||
@Rule | ||
public MockitoRule mockitoRule = MockitoJUnit.rule(); | ||
|
||
private MultiSelectListAccessory multiSelectListAccessory; | ||
|
||
@Mock | ||
private MultiSelectListAdapter adapter; | ||
|
||
@Mock | ||
private MultiSelectListSelectedAdapter multiSelectListSelectedAdapter; | ||
|
||
@Mock | ||
private AlertDialog alertDialog; | ||
|
||
private List<MultiSelectItem> itemList; | ||
private List<MultiSelectItem> selectedItemList; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
multiSelectListAccessory = new MultiSelectListAccessory(multiSelectListSelectedAdapter, adapter, alertDialog, selectedItemList, itemList); | ||
} | ||
|
||
@Test | ||
public void getSelectedAdapter() { | ||
Assert.assertEquals(multiSelectListSelectedAdapter, multiSelectListAccessory.getSelectedAdapter()); | ||
} | ||
|
||
@Test | ||
public void setSelectedAdapter() { | ||
Assert.assertEquals(this.multiSelectListSelectedAdapter, multiSelectListAccessory.getSelectedAdapter()); | ||
MultiSelectListSelectedAdapter multiSelectListSelectedAdapter = Mockito.mock(MultiSelectListSelectedAdapter.class); | ||
|
||
multiSelectListAccessory.setSelectedAdapter(multiSelectListSelectedAdapter); | ||
|
||
Assert.assertEquals(multiSelectListSelectedAdapter, multiSelectListAccessory.getSelectedAdapter()); | ||
} | ||
|
||
@Test | ||
public void getListAdapter() { | ||
Assert.assertEquals(adapter, multiSelectListAccessory.getListAdapter()); | ||
} | ||
|
||
@Test | ||
public void setListAdapter() { | ||
MultiSelectListAdapter adapter = Mockito.mock(MultiSelectListAdapter.class); | ||
|
||
multiSelectListAccessory.setListAdapter(adapter); | ||
|
||
Assert.assertEquals(adapter, ReflectionHelpers.getField(multiSelectListAccessory, "listAdapter")); | ||
|
||
} | ||
|
||
@Test | ||
public void getAlertDialog() { | ||
Assert.assertEquals(alertDialog, multiSelectListAccessory.getAlertDialog()); | ||
} | ||
|
||
@Test | ||
public void setAlertDialog() { | ||
AlertDialog alertDialog = Mockito.mock(AlertDialog.class); | ||
|
||
multiSelectListAccessory.setAlertDialog(alertDialog); | ||
Assert.assertEquals(alertDialog, ReflectionHelpers.getField(multiSelectListAccessory, "alertDialog")); | ||
} | ||
|
||
@Test | ||
public void getItemList() { | ||
Assert.assertEquals(itemList, multiSelectListAccessory.getItemList()); | ||
} | ||
|
||
@Test | ||
public void getFormAttributes() { | ||
JSONObject formAttributes = new JSONObject(); | ||
ReflectionHelpers.setField(multiSelectListAccessory, "formAttributes", formAttributes); | ||
|
||
Assert.assertEquals(formAttributes, multiSelectListAccessory.getFormAttributes()); | ||
} | ||
|
||
@Test | ||
public void setFormAttributes() { | ||
JSONObject formAttributes = new JSONObject(); | ||
multiSelectListAccessory.setFormAttributes(formAttributes); | ||
|
||
Assert.assertEquals(formAttributes, ReflectionHelpers.getField(multiSelectListAccessory, "formAttributes")); | ||
} | ||
|
||
@Test | ||
public void setItemList() { | ||
List<MultiSelectItem> itemList = new ArrayList<>(); | ||
|
||
multiSelectListAccessory.setItemList(itemList); | ||
|
||
Assert.assertTrue(itemList == ReflectionHelpers.getField(multiSelectListAccessory, "itemList")); | ||
} | ||
|
||
@Test | ||
public void getSelectedItemList() { | ||
Assert.assertEquals(selectedItemList, multiSelectListAccessory.getSelectedItemList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters