Skip to content

Commit

Permalink
Merge pull request #60 from OpenSRP/code-refactor
Browse files Browse the repository at this point in the history
code refacor and update core version
  • Loading branch information
Ephraim (Keyman) Muhia committed Jan 31, 2019
2 parents e53bc29 + 665dce7 commit 861b220
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ subprojects {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "http://nexus.motechproject.org/content/repositories/drishti" }
maven { url "http://nexus.motechproject.org/content/repositories/snapshots" }
maven { url "http://acra.googlecode.com/svn/repository/releases" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" }
Expand Down
2 changes: 1 addition & 1 deletion opensrp-immunization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ tasks.withType(Test) {
}

dependencies {
implementation('org.smartregister:opensrp-client-core:1.3.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:1.5.16-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import static org.smartregister.util.Utils.addToList;
import static org.smartregister.util.Utils.addToRow;
import static org.smartregister.util.Utils.convertDateFormat;
import static org.smartregister.util.Utils.getPreference;
import static org.smartregister.util.Utils.getValue;

/**
Expand All @@ -91,7 +90,7 @@ public static HashMap<String, String> providerDetails() {
org.smartregister.Context context = ImmunizationLibrary.getInstance().context();
org.smartregister.util.Log.logDebug("ANM DETAILS" + context.anmController().get());
org.smartregister.util.Log.logDebug("USER DETAILS" + context.allSettings().fetchUserInformation());
org.smartregister.util.Log.logDebug("TEAM DETAILS" + getPreference(context.applicationContext(), "team", "{}"));
org.smartregister.util.Log.logDebug("TEAM DETAILS" + context.allSharedPreferences().getPreference("team"));

String locationJson = context.anmLocationController().get();
LocationTree locationTree = AssetHandler.jsonStringToJava(locationJson, LocationTree.class);
Expand All @@ -118,7 +117,7 @@ public static HashMap<String, String> providerDetails() {
}

try {
JSONObject tm = new JSONObject(getPreference(context.applicationContext(), "team", "{}"));
JSONObject tm = new JSONObject(context.allSharedPreferences().getPreference("team"));
map.put("provider_name", tm.getJSONObject("person").getString("display"));
map.put("provider_identifier", tm.getString("identifier"));
map.put("provider_team", tm.getJSONObject("team").getString("teamName"));
Expand All @@ -131,7 +130,7 @@ public static HashMap<String, String> providerDetails() {

public static ArrayList<HashMap<String, String>> getWasted(String startDate, String endDate, String type) {
String sqlWasted = "select sum (total_wasted)as total_wasted from stock where `report` ='" + type + "' and `date` between '" + startDate + "' and '" + endDate + "'";
return ImmunizationLibrary.getInstance().context().commonrepository("stock").rawQuery(sqlWasted);
return ImmunizationLibrary.getInstance().context().commonrepository("stock").rawQuery(sqlWasted, new String[]{});
}

public static int getWasted(String startDate, String endDate, String type, String... variables) {
Expand All @@ -155,7 +154,7 @@ public static ArrayList<HashMap<String, String>> getUsed(String startDate, Strin
q += " ) e ";

Log.i("DD", q);
return ImmunizationLibrary.getInstance().context().commonrepository(table).rawQuery(q);
return ImmunizationLibrary.getInstance().context().commonrepository(table).rawQuery(q, new String[]{});
}

public static int getTotalUsed(String startDate, String endDate, String table, String... vaccines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.Date;
import java.util.List;

import static org.mockito.ArgumentMatchers.eq;

/**
* Created by onaio on 29/08/2017.
*/
Expand Down Expand Up @@ -80,7 +82,7 @@ public void verifygetwastedcallssqlmethodonce() {
PowerMockito.when(ImmunizationLibrary.getInstance().context().commonrepository(org.mockito.ArgumentMatchers.anyString())).thenReturn(commonRepository);
VaccinatorUtils.getWasted("", "", "");
VaccinatorUtils.getWasted("", "", "", "");
Mockito.verify(commonRepository, Mockito.times(1)).rawQuery(org.mockito.ArgumentMatchers.anyString());
Mockito.verify(commonRepository, Mockito.times(1)).rawQuery(org.mockito.ArgumentMatchers.anyString(), eq(new String[]{}));
}

@Test
Expand All @@ -90,7 +92,7 @@ public void verifyGetUsedcallssqlmethodonce() {
PowerMockito.when(ImmunizationLibrary.getInstance().context()).thenReturn(context);
PowerMockito.when(ImmunizationLibrary.getInstance().context().commonrepository(org.mockito.ArgumentMatchers.anyString())).thenReturn(commonRepository);
VaccinatorUtils.getUsed("", "", "", new String[]{"", ""});
Mockito.verify(commonRepository, Mockito.times(1)).rawQuery(org.mockito.ArgumentMatchers.anyString());
Mockito.verify(commonRepository, Mockito.times(1)).rawQuery(org.mockito.ArgumentMatchers.anyString(), eq(new String[]{}));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ android {
dependencies {

testImplementation 'junit:junit:4.12'
implementation('org.smartregister:opensrp-client-core:1.3.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:1.5.16-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public SampleRepository(Context context, org.smartregister.Context openSRPContex
public void onCreate(SQLiteDatabase database) {
super.onCreate(database);
EventClientRepository.createTable(database, EventClientRepository.Table.client, EventClientRepository.client_column.values());
EventClientRepository.createTable(database, EventClientRepository.Table.address, EventClientRepository.address_column.values());
//EventClientRepository.createTable(database, EventClientRepository.Table.address, EventClientRepository.address_column.values());
EventClientRepository.createTable(database, EventClientRepository.Table.event, EventClientRepository.event_column.values());
EventClientRepository.createTable(database, EventClientRepository.Table.obs, EventClientRepository.obs_column.values());
//EventClientRepository.createTable(database, EventClientRepository.Table.obs, EventClientRepository.obs_column.values());

VaccineRepository.createTable(database);
VaccineNameRepository.createTable(database);
Expand Down Expand Up @@ -151,7 +151,7 @@ private void upgradeToVersion2(SQLiteDatabase db) {
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL);
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_OUT_OF_AREA_COL_INDEX);

EventClientRepository.createTable(db, EventClientRepository.Table.path_reports, EventClientRepository.report_column.values());
//EventClientRepository.createTable(db, EventClientRepository.Table.path_reports, EventClientRepository.report_column.values());
db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_HIA2_STATUS_COL);

IMDatabaseUtils.accessAssetsAndFillDataBaseForVaccineTypes(context, db);
Expand Down

0 comments on commit 861b220

Please sign in to comment.