Skip to content

Commit

Permalink
Merge branch 'master' of github.com:opensrp/opensrp-client-chw into u…
Browse files Browse the repository at this point in the history
…pdate-wcaro-liberia
  • Loading branch information
allan-on committed Sep 30, 2021
2 parents 4629cbd + c56a4df commit d678ced
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 12 deletions.
12 changes: 6 additions & 6 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ android {
chad {
dimension = 'baseDimension'
applicationIdSuffix ".chad"
versionCode 1
versionName "1.0.1"
versionCode 2
versionName "1.0.2"
buildConfigField "String", 'opensrp_url', '"https://wcaro-td.smartregister.org/opensrp/"'
buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/chad/"'
buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-stage.smartregister.org/opensrp/"'
Expand All @@ -248,6 +248,8 @@ android {
buildConfigField "String", 'DEFAULT_LOCATION', '"Village"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"'
buildConfigField "int", "DATABASE_VERSION", '14'
buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5'
buildConfigField "int", "MAX_READ_TIMEOUT", '5'
}
drc {
resConfigs "en", "fr"
Expand Down Expand Up @@ -311,7 +313,7 @@ android {
versionName "0.2.0"
buildConfigField "String", 'opensrp_url', '"https://wcaro-lr.smartregister.org/opensrp/"'
buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/liberia/"'
buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-lr-preview.smartregister.org/opensrp/"'
buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-stage.smartregister.org/opensrp/"'
buildConfigField "String[]", "LOCATION_HIERACHY", '{"Clinic" , "CHSS" , "CHA"}'
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village"}'
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}'
Expand Down Expand Up @@ -344,7 +346,7 @@ android {
}

dependencies {
implementation('org.smartregister:opensrp-client-chw-core:2.1.2-alpha-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-chw-core:2.1.3-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'androidx.legacy', module: 'legacy-support-v4'
Expand Down Expand Up @@ -375,8 +377,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'org.mockito:mockito-android:3.0.0'

implementation 'com.github.lecho:hellocharts-android:v1.5.8'

//For viewing PDFs in the app
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public class ChwApplicationFlv extends DefaultChwApplicationFlv {
@Override
public boolean useThinkMd() {
return true;
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void markEventsForReUpload() {
* @return
*/
public static Long getMinimumVerifiedServerVersion() {
String sql = "select max(serverVersion) serverVersion from event where dateCreated <= (select min(dateCreated) minDate from event where ifnull(eventId,'') = '' and syncStatus = 'Synced') ";
String sql = "select max(serverVersion) serverVersion from event where dateCreated <= (select min(dateCreated) minDate from event where ifnull(eventId,'') = '' and syncStatus = 'Synced') ";
DataMap<Long> dataMap = c -> {
return getCursorLongValue(c, "serverVersion");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public boolean saveWashCheckEvent(String jsonString) {
}
}
}
/*NCUtils.addEvent(allSharedPreferences, baseEvent);
NCUtils.startClientProcessing();*/
NCUtils.addEvent(allSharedPreferences, baseEvent);
NCUtils.startClientProcessing();
return true;
} catch (Exception e) {
Timber.e(e);
Expand Down
3 changes: 3 additions & 0 deletions opensrp-chw/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<string name="login_title">Appli CFC</string>
<string name="logo">logo</string>

<string name="login_text">Connexion</string>
<string name="home">Accueil</string>
<string name="searching_for_device_to_connect_to">En recherche l\'appareil (destinataire) à envoyer les données...</string>
<string name="title_family_detail">Détails sur le ménage</string>
<string name="not_done">N\'a pas été fait</string>
<string name="not_provided">N\'a pas été donné</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.robolectric.RobolectricTestRunner;
import org.smartregister.clientandeventmodel.Event;
import org.smartregister.dao.AbstractDao;
import org.smartregister.repository.BaseRepository;
import org.smartregister.repository.Repository;

import java.util.Arrays;
Expand All @@ -37,7 +38,7 @@ public void setUp() {
}

@Test
public void getEvents() {
public void getEventsReturnsCorrectEvents() {
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"json"});
matrixCursor.addRow(new Object[]{eventJson});
Mockito.doReturn(matrixCursor).when(database).rawQuery(Mockito.any(), Mockito.any());
Expand All @@ -48,13 +49,31 @@ public void getEvents() {
}

@Test
public void getLatestEvent() {
public void getLatestEventReturnsCorrectEvent() {
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"json"});
matrixCursor.addRow(new Object[]{eventJson});
Mockito.doReturn(matrixCursor).when(database).rawQuery(Mockito.any(), Mockito.any());
Event event = EventDao.getLatestEvent("some-base-entity-id", Arrays.asList("some-event-type", "another-event-type"));
Assert.assertNotNull(event);
}

@Test
public void markEventsForReUploadExecutesCorrectUpdateQueries() {
Mockito.doReturn(database).when(repository).getWritableDatabase();
EventDao.markEventsForReUpload();
Mockito.verify(database).rawExecSQL("update client set syncStatus = '" + BaseRepository.TYPE_Unsynced + "' where baseEntityId in (select baseEntityId from event where ifnull(eventId,'') = '') ");
Mockito.verify(database).rawExecSQL("update ImageList set syncStatus = '" + BaseRepository.TYPE_Unsynced + "' where entityId in (select baseEntityId from event where ifnull(eventId,'') = '') ");
Mockito.verify(database).rawExecSQL("update event set syncStatus = '" + BaseRepository.TYPE_Unsynced + "' where ifnull(eventId,'') = '' ");
}

@Test
public void getMinimumVerifiedServerVersionReturnsCorrectVersion() {
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"serverVersion"});
matrixCursor.addRow(new Object[]{12324567L});
Mockito.doReturn(matrixCursor).when(database).rawQuery(Mockito.any(), Mockito.any());
Long serverVersion = EventDao.getMinimumVerifiedServerVersion();
Assert.assertNotNull(serverVersion);
Assert.assertTrue(serverVersion.equals(12324567L));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.smartregister.immunization.domain.Vaccine;
import org.smartregister.repository.Repository;

import java.util.List;
import java.util.Map;

public class ReportDaoTest extends ReportDao {
Expand Down Expand Up @@ -39,4 +41,18 @@ public void testExtractRecordedLocations() {
Mockito.verify(database).rawQuery(Mockito.anyString(), Mockito.any());
Assert.assertEquals(locations.size(), 0);
}

@Test
public void testFetchAllVaccines() {
Mockito.doReturn(database).when(repository).getReadableDatabase();

MatrixCursor matrixCursor = new MatrixCursor(new String[]{"location_id", "provider_id"});

Mockito.doReturn(matrixCursor).when(database).rawQuery(Mockito.any(), Mockito.any());

Map<String, List<Vaccine>> vaccines = ReportDao.fetchAllVaccines();

Mockito.verify(database).rawQuery(Mockito.anyString(), Mockito.any());
Assert.assertEquals(vaccines.size(), 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import org.smartregister.Context;
import org.smartregister.CoreLibrary;
import org.smartregister.chw.activity.FamilyProfileActivity;
import org.smartregister.chw.anc.domain.MemberObject;
import org.smartregister.chw.application.ChwApplication;

import java.util.LinkedHashMap;
Expand Down Expand Up @@ -83,4 +85,17 @@ public void tearDown() {
Context.getInstance().session().expire();
System.gc();
}

@Test
public void testGetContactSchedule() {
LocalDate lastContact = LocalDate.parse("19/06/2019", DateTimeFormat.forPattern("dd/MM/yyyy"));

MemberObject memberObject = new MemberObject();
ReflectionHelpers.setField(memberObject, "lastMenstrualPeriod", "01-01-2019");
ReflectionHelpers.setField(memberObject, "baseEntityId", "12345");

Map<Integer, LocalDate> contacts = ContactUtil.getContactSchedule(memberObject, lastContact);

TestCase.assertNotNull(contacts);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package org.smartregister.chw.application;

public class ChwApplicationFlv extends DefaultChwApplicationFlv {
@Override
public boolean showChildrenUnderFiveAndGirlsAgeNineToEleven() {
return true;
}
}

0 comments on commit d678ced

Please sign in to comment.