Pass implements Parcelable { public void requestToSavePass(@NonNull Context context) { Intent intent = new Intent(Intent.ACTION_VIEW) .setData(publicUri) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } Pass(@NonNull Uri uri, @Nullable String id); protected  Pass(@NonNull Parcel in); @Override void writeToParcel(@NonNull Parcel dest, int flags); @Override int describeContents(); void requestToSavePass(@NonNull Context context); @NonNull Uri getPublicUri(); @Nullable String getId(); @NonNull
    static final Creator<Pass> CREATOR; }
@Test public void testRequestToSavePass() throws Exception { final Pass pass = new Pass(Uri.parse("https: Context context = Mockito.mock(Context.class); Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Intent intent = (Intent) invocation.getArguments()[0]; assertEquals(pass.getPublicUri(), intent.getData()); assertEquals(Intent.FLAG_ACTIVITY_NEW_TASK, intent.getFlags()); return null; } }).when(context).startActivity(Mockito.any(Intent.class)); pass.requestToSavePass(context); }