Skip to content
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- '*'
# tags:
# - '!v*'
pull_request:
branches:
- '*'
types: [opened, synchronize, reopened]

jobs:
build:
Expand Down
13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ apollo {
]
}

tasks.withType(Test).configureEach {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams = false
}
}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
Expand All @@ -244,5 +252,10 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})

// unit tests
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.5.0'
testImplementation 'org.robolectric:robolectric:4.11.1'
}

Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public class ClientAndroidInterface {
@NonNull
private final Activity activity;
@NonNull
private final SQLHandler sqlHandler;
protected final SQLHandler sqlHandler;
@NonNull
private final HashMap<String, String> controls = new HashMap<>();
@NonNull
private final ArrayList<String> myList = new ArrayList<>();
@NonNull
private final ArrayList<String> enrolMessages = new ArrayList<>();
@NonNull
private final Global global;
protected final Global global;
@NonNull
private final StorageManager storageManager;
@NonNull
Expand All @@ -167,6 +167,14 @@ public class ClientAndroidInterface {
.build();
}

public ClientAndroidInterface(Activity activity, SQLHandler sqlHandler, Global global, Picasso picasso, StorageManager storageManager) {
this.activity = activity;
this.sqlHandler = sqlHandler;
this.global = global;
this.storageManager = storageManager;
this.picassoInstance = picasso;
}

@JavascriptInterface
@SuppressWarnings("unused")
public void SetUrl(String Url) {
Expand Down Expand Up @@ -666,7 +674,7 @@ public String getHF(int DistrictId, String HFLevel) {
return HFs.toString();
}

private HashMap<String, String> jsonToTable(String jsonString) {
protected HashMap<String, String> jsonToTable(String jsonString) {
HashMap<String, String> data = new HashMap<>();
try {
JSONArray array = new JSONArray(jsonString);
Expand Down Expand Up @@ -849,7 +857,7 @@ public void addOrUpdateFamilySms(int familyId, Boolean approve, String language)
}
}

private int isValidInsureeData(HashMap<String, String> data) {
protected int isValidInsureeData(HashMap<String, String> data) {
int Result;

String InsuranceNumber = data.get("txtInsuranceNumber");
Expand Down Expand Up @@ -1044,7 +1052,7 @@ else if (ExceedThreshold == 0)
return rtInsureeId;
}

private String copyImageFromGalleryToApplication(String selectedPath, String InsuranceNumber) {
protected String copyImageFromGalleryToApplication(String selectedPath, String InsuranceNumber) {
String result = "";

try {
Expand Down Expand Up @@ -2538,10 +2546,14 @@ public int UpdatePolicy(int PolicyId, String PayDate, int policystatus) throws P
return 1;//Update Success
}

protected ProgressDialog createProgressDialog(String title, String message) {
return ProgressDialog.show(activity, title, message);
}

@JavascriptInterface
@SuppressWarnings("unused")
public void uploadEnrolment() throws Exception {
final ProgressDialog finalPd = ProgressDialog.show(activity, activity.getResources().getString(R.string.Sync), activity.getResources().getString(R.string.SyncProcessing));
final ProgressDialog finalPd = createProgressDialog(activity.getResources().getString(R.string.Sync), activity.getResources().getString(R.string.SyncProcessing));
activity.runOnUiThread(() -> {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
});
Expand Down Expand Up @@ -2790,7 +2802,7 @@ public boolean VerifyPhoto(JSONArray insurees) throws JSONException {
return result;
}

private int Enrol(int CallerId) throws UserException, JSONException, IOException {
protected int Enrol(int CallerId) throws UserException, JSONException, IOException {
ArrayList<String> verifiedId = new ArrayList<>();
myList.clear();
int rtEnrolledId = 0;
Expand Down Expand Up @@ -3121,7 +3133,7 @@ private int Enrol(int CallerId) throws UserException, JSONException, IOException
return EnrolResult;
}

private int uploadEnrols(
protected int uploadEnrols(
@NonNull JSONArray familyArray,
@NonNull JSONArray insureesArray,
@NonNull JSONArray policiesArray,
Expand Down Expand Up @@ -3570,7 +3582,7 @@ protected void onPostExecute(Boolean aBoolean) {
}
}

private void DeleteUploadedData(final int FamilyId, ArrayList<String> FamilyIDs, int CallerId) {
protected void DeleteUploadedData(final int FamilyId, ArrayList<String> FamilyIDs, int CallerId) {
if (FamilyIDs.size() == 0) {
FamilyIDs = new ArrayList<>() {{
add(String.valueOf(FamilyId));
Expand Down Expand Up @@ -4713,6 +4725,10 @@ public void BackToDefaultRarPassword() {
}
}

protected Family newFetchFamilyExecute(String insuranceNumber) throws Exception {
return new FetchFamily().execute(insuranceNumber);
}

@JavascriptInterface
@SuppressWarnings("unused")
public int ModifyFamily(final String insuranceNumber) {
Expand All @@ -4724,7 +4740,7 @@ public int ModifyFamily(final String insuranceNumber) {
return 0;
} else {
try {
Family family = new FetchFamily().execute(insuranceNumber);
Family family = newFetchFamilyExecute(insuranceNumber);
InsertFamilyDataFromOnline(family);
InsertInsureeDataFromOnline(family.getMembers());
InsertPolicyDataFromOnline(family.getPolicies());
Expand Down Expand Up @@ -4752,13 +4768,15 @@ private void InsertFamilyDataFromOnline(@NonNull Family family) throws JSONExcep

if (family.getSms() != null) {
try {
System.out.println("Family SMS: " + family.getSms().isApproval() + ", " + family.getSms().getLanguage());
addOrUpdateFamilySms(family.getId(),
family.getSms().isApproval(),
family.getSms().getLanguage()
);
} catch (Exception e) {
e.printStackTrace();
Log.w("ModifyFamily", "No familySMS data in family payload");
System.out.println("problem in try block, handling in catch block");
}
}
}
Expand Down Expand Up @@ -5021,7 +5039,7 @@ public int getFamilyStat(int FamilyId) {
return status;
}

private int getFamilyStatus(int FamilyId) throws JSONException {
protected int getFamilyStatus(int FamilyId) throws JSONException {
if (FamilyId < 0) return 0;
@Language("SQL")
String Query = "SELECT isOffline FROM tblFamilies WHERE FamilyId = " + FamilyId;
Expand All @@ -5034,7 +5052,7 @@ private int getFamilyStatus(int FamilyId) throws JSONException {
else return 0;
}

private int getInsureeStatus(int InsureeId) throws JSONException {//herman
protected int getInsureeStatus(int InsureeId) throws JSONException {//herman
if (InsureeId == 0) return 1;
@Language("SQL")
String Query = "SELECT isOffline FROM tblInsuree WHERE InsureeId = " + InsureeId;
Expand Down Expand Up @@ -5252,7 +5270,7 @@ private int getNextAvailablePolicyId() {
return getMaxIdFromTable("PolicyId", "tblPolicy");
}

private int getNextAvailableInsureeId() {
protected int getNextAvailableInsureeId() {
return getMaxIdFromTable("InsureeId", "tblInsuree");
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/openimis/imispolicies/Enquire.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
public class Enquire extends ImisActivity {
private static final String LOG_TAG = "ENQUIRE";
private static final int REQUEST_SCAN_QR_CODE = 1;
private Global global;
private Escape escape;
private Picasso picasso;
private ClientAndroidInterface ca;
protected Global global;
protected Escape escape;
protected Picasso picasso;
protected ClientAndroidInterface ca;
private EditText etCHFID;
private TextView tvCHFID;
private TextView tvName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public Login(

@WorkerThread
public void execute(@NonNull String username, @NonNull String password) throws Exception {
if (Global.getGlobal().getOfficerCode() == null) {
Global.getGlobal().setOfficerCode(username);
}
String officerCode = Global.getGlobal().getOfficerCode();
if (officerCode == null) {
throw new IllegalStateException("OfficerCode should not be null on login");
Expand Down
Loading