Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting fixes #489

Merged
merged 6 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion opensrp-giz-malawi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ android {
dataBinding {
enabled = true
}
configurations.all {
exclude group: 'com.github.lecho', module: 'hellocharts-library'
}
}

tasks.withType(Test) {
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion opensrp-giz-malawi/src/main/assets/ec_client_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "hiv_status_current"
"concept": "159427AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
"Rota",
"Measles",
"MR",
"Yellow Fever"
"Yellow Fever",
"IPV",
"MV"
],
"openmrs_choice_ids": {
"BCG": "149310AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
Expand All @@ -77,7 +79,9 @@
"Rota": "162272AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Measles": "149286AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"MR": "149286AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Yellow Fever": "149253AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"Yellow Fever": "149253AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"IPV": "ipv",
"MV": "mv"
},
"v_required": {
"value": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ChildDetailTabbedActivity> controller;
@Captor
private ArgumentCaptor<Intent> intentArgumentCaptor;
@Captor
private ArgumentCaptor<Integer> 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();
}
}

}