diff --git a/opensrp-giz-malawi/build.gradle b/opensrp-giz-malawi/build.gradle index 635efce3..63909a57 100644 --- a/opensrp-giz-malawi/build.gradle +++ b/opensrp-giz-malawi/build.gradle @@ -226,6 +226,9 @@ android { dataBinding { enabled = true } + configurations.all { + exclude group: 'com.github.lecho', module: 'hellocharts-library' + } } tasks.withType(Test) { @@ -251,7 +254,8 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' // exclude group: 'com.github.lecho', module: 'hellocharts-library' } - implementation('org.smartregister:opensrp-client-child:0.6.9-SNAPSHOT@aar') { + + implementation('org.smartregister:opensrp-client-child:0.7.3-ALPHA3-SNAPSHOT@aar') { transitive = true exclude group: 'id.zelory', module: 'compressor' exclude group: 'org.smartregister', module: 'opensrp-client-core' diff --git a/opensrp-giz-malawi/src/main/assets/ec_client_fields.json b/opensrp-giz-malawi/src/main/assets/ec_client_fields.json index 838ea4d1..2fcda8ca 100644 --- a/opensrp-giz-malawi/src/main/assets/ec_client_fields.json +++ b/opensrp-giz-malawi/src/main/assets/ec_client_fields.json @@ -837,7 +837,7 @@ "type": "Event", "json_mapping": { "field": "obs.fieldCode", - "concept": "hiv_status_current" + "concept": "159427AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" } }, { diff --git a/opensrp-giz-malawi/src/main/assets/json.form/adverse_event.json b/opensrp-giz-malawi/src/main/assets/json.form/adverse_event.json index a63f4efc..f9da35a5 100644 --- a/opensrp-giz-malawi/src/main/assets/json.form/adverse_event.json +++ b/opensrp-giz-malawi/src/main/assets/json.form/adverse_event.json @@ -66,7 +66,9 @@ "Rota", "Measles", "MR", - "Yellow Fever" + "Yellow Fever", + "IPV", + "MV" ], "openmrs_choice_ids": { "BCG": "149310AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", @@ -77,7 +79,9 @@ "Rota": "162272AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "Measles": "149286AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "MR": "149286AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "Yellow Fever": "149253AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "Yellow Fever": "149253AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "IPV": "ipv", + "MV": "mv" }, "v_required": { "value": true, diff --git a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/activity/ChildDetailTabbedActivity.java b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/activity/ChildDetailTabbedActivity.java index a3ccf383..76b0465b 100644 --- a/opensrp-giz-malawi/src/main/java/org/smartregister/giz/activity/ChildDetailTabbedActivity.java +++ b/opensrp-giz-malawi/src/main/java/org/smartregister/giz/activity/ChildDetailTabbedActivity.java @@ -155,6 +155,8 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); + if (data == null) + return; try { String jsonString = data.getStringExtra(JsonFormConstants.JSON_FORM_KEY.JSON); Timber.d(jsonString); diff --git a/opensrp-giz-malawi/src/test/java/org/smartregister/giz/activity/ChildDetailTabbedActivityTest.java b/opensrp-giz-malawi/src/test/java/org/smartregister/giz/activity/ChildDetailTabbedActivityTest.java new file mode 100644 index 00000000..3092749b --- /dev/null +++ b/opensrp-giz-malawi/src/test/java/org/smartregister/giz/activity/ChildDetailTabbedActivityTest.java @@ -0,0 +1,83 @@ +package org.smartregister.giz.activity; + +import android.content.Intent; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.robolectric.Robolectric; +import org.robolectric.android.controller.ActivityController; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.Context; +import org.smartregister.CoreLibrary; +import org.smartregister.child.activity.BaseChildDetailTabbedActivity; +import org.smartregister.giz.BaseUnitTest; + + +public class ChildDetailTabbedActivityTest extends BaseUnitTest { + @Rule + public MockitoRule rule = MockitoJUnit.rule(); + private ChildDetailTabbedActivity activity; + private ActivityController controller; + @Captor + private ArgumentCaptor intentArgumentCaptor; + @Captor + private ArgumentCaptor integerArgumentCaptor; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + + Context context = Context.getInstance(); + CoreLibrary.init(context); + + //Auto login by default + context.session().start(context.session().lengthInMilliseconds()); + + controller = Robolectric.buildActivity(ChildDetailTabbedActivity.class).create().start().resume().restart(); + activity = controller.get(); + } + + @Test + public void testStartFormActivityInvokesChildForm() { + activity = Mockito.spy(activity); + + Mockito.doNothing().when(activity).startActivityForResult(ArgumentMatchers.any(Intent.class), ArgumentMatchers.anyInt()); + + activity.startFormActivity("{}"); + + Mockito.verify(activity).startActivityForResult(intentArgumentCaptor.capture(), integerArgumentCaptor.capture()); + + Intent capturedIntent = intentArgumentCaptor.getValue(); + Assert.assertNotNull(capturedIntent); + Assert.assertEquals("org.smartregister.giz.activity.ChildFormActivity", capturedIntent.getComponent().getClassName()); + + Integer capturedInteger = integerArgumentCaptor.getValue(); + + Assert.assertNotNull(capturedInteger); + int requestCode = ReflectionHelpers.getStaticField(BaseChildDetailTabbedActivity.class, "REQUEST_CODE_GET_JSON"); + Assert.assertEquals(requestCode, capturedInteger.intValue()); + + } + + + @After + public void tearDown() { + try { + activity.finish(); + controller.pause().stop().destroy(); //destroy controller if we can + } catch (Exception e) { + e.printStackTrace(); + } + } + +}