Source:
public void setUp ( ) throws java.lang.Exception { super . setUp ( ) ; mContext = mComponentContextFixture.getTestDouble ( ) . getApplicationContext ( ) ; mCallLogManager = new com.android.server.telecom.CallLogManager ( mContext , mMockPhoneAccountRegistrar , mMissedCallNotifier ) ; mContentProvider = mContext.getContentResolver ( ) . acquireProvider ( "0@call_log" ) ; mDefaultAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID ) ) ; mOtherUserAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID ) ) ; mManagedProfileAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID ) ) ; android.os.UserManager userManager = ( ( android.os.UserManager ) ( mContext.getSystemService ( Context.USER_SERVICE ) ) ) ; android.content.pm.UserInfo userInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID , "test" , 0 ) ; android.content.pm.UserInfo otherUserInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID , "test2" , 0 ) ; android.content.pm.UserInfo managedProfileUserInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID , "test3" , android.content.pm.UserInfo.FLAG_MANAGED_PROFILE ) ; org.mockito.Mockito.doAnswer ( new org.mockito.stubbing.Answer < android.net.Uri > ( ) { @ java.lang.Override public android.net.Uri answer ( org.mockito.invocation.InvocationOnMock invocation ) throws java.lang.Throwable { return ( ( android.net.Uri ) ( invocation.getArguments ( ) [ 1 ] ) ) ; } } ) . when ( mContentProvider ) . insert ( org.mockito.Matchers.anyString ( ) , org.mockito.Matchers.any ( android.net.Uri.class ) , org.mockito.Matchers.any ( android.content.ContentValues.class ) ) ; org.mockito.Mockito.when ( userManager.isUserRunning ( org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( true ) ; org.mockito.Mockito.when ( userManager.isUserUnlocked ( org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( true ) ; org.mockito.Mockito.when ( userManager.hasUserRestriction ( org.mockito.Matchers.any ( java.lang.String.class ) , org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( false ) ; org.mockito.Mockito.when ( userManager.getUsers ( org.mockito.Matchers.any ( java.lang.Boolean.class ) ) ) . thenReturn ( java.util.Arrays.asList ( userInfo , otherUserInfo , managedProfileUserInfo ) ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID ) ) ) . thenReturn ( userInfo ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID ) ) ) . thenReturn ( otherUserInfo ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID ) ) ) . thenReturn ( managedProfileUserInfo ) ; }

Target:
public void setUp ( ) throws java.lang.Exception { super . setUp ( ) ; mContext = mComponentContextFixture.getTestDouble ( ) . getApplicationContext ( ) ; mCallLogManager = new com.android.server.telecom.CallLogManager ( mContext , mMockPhoneAccountRegistrar , mMissedCallNotifier ) ; mContentProvider = mContext.getContentResolver ( ) . acquireProvider ( "0@call_log" ) ; mDefaultAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID ) ) ; mOtherUserAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID ) ) ; mManagedProfileAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID ) ) ; mSelfManagedAccountHandle = new android.telecom.PhoneAccountHandle ( new android.content.ComponentName ( "com.android.server.telecom.tests" , "CallLogManagerSelfMgdTest" ) , com.android.server.telecom.tests.CallLogManagerTest.TEST_SELF_MGD_PHONE_ACCOUNT_ID , android.os.UserHandle.of ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID ) ) ; android.os.UserManager userManager = ( ( android.os.UserManager ) ( mContext.getSystemService ( Context.USER_SERVICE ) ) ) ; android.content.pm.UserInfo userInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID , "test" , 0 ) ; android.content.pm.UserInfo otherUserInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID , "test2" , 0 ) ; android.content.pm.UserInfo managedProfileUserInfo = new android.content.pm.UserInfo ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID , "test3" , android.content.pm.UserInfo.FLAG_MANAGED_PROFILE ) ; org.mockito.Mockito.doAnswer ( new org.mockito.stubbing.Answer < android.net.Uri > ( ) { @ java.lang.Override public android.net.Uri answer ( org.mockito.invocation.InvocationOnMock invocation ) throws java.lang.Throwable { return ( ( android.net.Uri ) ( invocation.getArguments ( ) [ 1 ] ) ) ; } } ) . when ( mContentProvider ) . insert ( org.mockito.Matchers.anyString ( ) , org.mockito.Matchers.any ( android.net.Uri.class ) , org.mockito.Matchers.any ( android.content.ContentValues.class ) ) ; org.mockito.Mockito.when ( userManager.isUserRunning ( org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( true ) ; org.mockito.Mockito.when ( userManager.isUserUnlocked ( org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( true ) ; org.mockito.Mockito.when ( userManager.hasUserRestriction ( org.mockito.Matchers.any ( java.lang.String.class ) , org.mockito.Matchers.any ( android.os.UserHandle.class ) ) ) . thenReturn ( false ) ; org.mockito.Mockito.when ( userManager.getUsers ( org.mockito.Matchers.any ( java.lang.Boolean.class ) ) ) . thenReturn ( java.util.Arrays.asList ( userInfo , otherUserInfo , managedProfileUserInfo ) ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.CURRENT_USER_ID ) ) ) . thenReturn ( userInfo ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.OTHER_USER_ID ) ) ) . thenReturn ( otherUserInfo ) ; org.mockito.Mockito.when ( userManager.getUserInfo ( org.mockito.Matchers.eq ( com.android.server.telecom.tests.CallLogManagerTest.MANAGED_USER_ID ) ) ) . thenReturn ( managedProfileUserInfo ) ; }