@Test
public void shouldStartDeviceAdminWhenRequested(){

    when(devicePolicyManager.isAdminActive((ComponentName) anyObject())).thenReturn(false);
    ShadowActivity shadowActivity = shadowOf_(deviceAdminActivity);
    deviceAdminActivity.requestDeviceAdminPermissions();
    ShadowIntent shadowIntent = shadowOf_(shadowActivity.getNextStartedActivity());
    verify(deviceAdminActivity).startActivityForResult(Matchers.any(Intent.class), Matchers.anyInt());
    assertThat(shadowIntent.getAction(), equalTo(ACTION_ADD_DEVICE_ADMIN));
    ComponentName componentName = (ComponentName)shadowIntent.getExtras().get(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
    assertThat(componentName.getClass().toString(), equalTo(ComponentName.class.toString()));
    assertThat(shadowIntent.getExtras().get(DevicePolicyManager.EXTRA_ADD_EXPLANATION).toString(),
            equalTo("Process will remove device data in case of robbery."));
}