Code example for Intent

Methods: getExtras, getStringArrayListExtra, putStringArrayListExtra

0
        assertThat(intent.toURI()).isEqualTo("http://foo");
    } 
 
    @Test 
    public void putStringArrayListExtra_addsListToExtras() { 
        Intent intent = new Intent();
        final ArrayList<String> strings = new ArrayList<String>(Arrays.asList("hi", "there"));
 
        intent.putStringArrayListExtra("KEY", strings);
        assertThat(intent.getStringArrayListExtra("KEY")).isEqualTo(strings);
        assertThat(Robolectric.shadowOf(intent.getExtras()).getStringArrayList("KEY")).isEqualTo(strings);
    } 
     
    @Test 
    public void putIntegerArrayListExtra_addsListToExtras() { 
        Intent intent = new Intent();
        final ArrayList<Integer> integers = new ArrayList<Integer>(Arrays.asList(100, 200, 300));
 
        intent.putIntegerArrayListExtra("KEY", integers);
        assertThat(intent.getIntegerArrayListExtra("KEY")).isEqualTo(integers);
        assertThat(Robolectric.shadowOf(intent.getExtras()).getIntegerArrayList("KEY")).isEqualTo(integers);