BaseChildActivity extends CollectionActivity { public void view() throws JSONException { Intent intent = new Intent(this, ViewChildActivity.class); intent.putExtra("id", child.getUniqueId()); child.put("saved", true); finish(); startActivity(intent); }  Child load(); Child save(); void view(); @Override void onCreate(Bundle savedInstanceState); void showAlertDialog(); static final int CLOSE_ACTIVITY; }
@Test public void testViewChild() throws Exception { ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); doNothing().when(activity).startActivity(captor.capture()); activity.child = new Child("id1", "user1", null); activity.view(); Intent intent = captor.getValue(); assertThat(intent.getComponent(), equalTo(new ComponentName(activity.getContext(), ViewChildActivity.class))); assertThat(intent.getStringExtra("id"), equalTo("id1")); }