### Question:
Gateway3DSecureActivity extends AppCompatActivity { String getExtraTitle() { Bundle extras = getIntent().getExtras(); if (extras != null) { return extras.getString(EXTRA_TITLE); } return null; }   static final String EXTRA_HTML; static final String EXTRA_TITLE; static final String EXTRA_ACS_RESULT; }### Answer:
@Test public void testGetExtraTitleReturnsNullIfMissing() { Intent testIntent = new Intent(); doReturn(testIntent).when(activity).getIntent(); String title = activity.getExtraTitle(); assertNull(title); }
@Test public void testGetExtraTitleReturnsValueIfExists() { String expectedTitle = "My Title"; Intent testIntent = new Intent(); testIntent.putExtra(Gateway3DSecureActivity.EXTRA_TITLE, expectedTitle); doReturn(testIntent).when(activity).getIntent(); String title = activity.getExtraTitle(); assertEquals(expectedTitle, title); }