@@ -54,7 +54,7 @@ public void run() {
5454 public void testPerformOnForegroundWithResult () {
5555 final String expectedResult = "result value" ;
5656 final String expectedLogMessage = "Starting foreground task, current active count:0, with result result value" ;
57- final MockCallback <String > callback = new MockCallback <>();
57+ final ExecutorTestCallback <String > callback = new ExecutorTestCallback <>();
5858
5959 defaultExecutors .performOnForeground (expectedResult ,callback );
6060
@@ -89,7 +89,7 @@ public void testPerformOnForegroundWithProgress() throws Exception {
8989 public void testPerformOnForegroundWithClientException () {
9090 final String expectedExceptionMessage = "client exception message" ;
9191 final String expectedLogMessage = "Starting foreground task, current active count:0, with exception com.microsoft.graph.core.ClientException: client exception message" ;
92- final MockCallback <String > callback = new MockCallback <>();
92+ final ExecutorTestCallback <String > callback = new ExecutorTestCallback <>();
9393
9494 defaultExecutors .performOnForeground (new ClientException (expectedExceptionMessage ,null , GraphErrorCodes .InvalidAcceptType ),
9595 callback );
@@ -104,38 +104,6 @@ public void testPerformOnForegroundWithClientException() {
104104 assertTrue (mLogger .hasMessage (expectedLogMessage ));
105105 }
106106
107- private class MockCallback <T > implements ICallback <T > {
108-
109- SimpleWaiter _completionWaiter = new SimpleWaiter ();
110- AtomicReference <CallingState > _callingState = new AtomicReference <>(CallingState .Unknown );
111-
112- AtomicBoolean _successCalled = new AtomicBoolean (false );
113- AtomicReference <T > _successResult = new AtomicReference <>();
114-
115- AtomicBoolean _failureCalled = new AtomicBoolean (false );
116- AtomicReference <ClientException > _exceptionResult = new AtomicReference <>();
117-
118- @ Override
119- public void success (T result ) {
120- _successCalled .set (true );
121- _successResult .set (result );
122- _callingState .set (getCallingState ());
123- _completionWaiter .signal ();
124- }
125-
126- @ Override
127- public void failure (ClientException ex ) {
128- _failureCalled .set (true );
129- _exceptionResult .set (ex );
130- _callingState .set (getCallingState ());
131- _completionWaiter .signal ();
132- }
133-
134- private CallingState getCallingState (){
135- return Looper .getMainLooper ().isCurrentThread () ? CallingState .Foreground : CallingState .Background ;
136- }
137- }
138-
139107 private class ExecutorTestCallback <T > implements IProgressCallback <T > {
140108 SimpleWaiter _completionWaiter = new SimpleWaiter ();
141109 AtomicReference <CallingState > _callingState = new AtomicReference <>(CallingState .Unknown );
0 commit comments