Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit c6551b3

Browse files
committed
Updates to code to address Peter's feedback for DefaultExecutorsTests, BaseCollectionPageTests, and BaseCollectionRequestTests.
1 parent 822c977 commit c6551b3

3 files changed

Lines changed: 3 additions & 35 deletions

File tree

graphsdk/src/androidTest/java/com/microsoft/graph/concurrency/DefaultExecutorsTests.java

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

graphsdk/src/androidTest/java/com/microsoft/graph/http/BaseCollectionPageTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public void testCurrentPage() {
5050

5151
public void testNextPage() {
5252
assertEquals(mRequestBuilder, baseCollectionPage.getNextPage());
53-
assertEquals(requestUrl, baseCollectionPage.getNextPage().getRequestUrl());
5453
}
5554

5655
public void testRawObject() {

graphsdk/src/androidTest/java/com/microsoft/graph/http/BaseCollectionRequestTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Test cases for {@see BaseCollectionRequest}
2121
*/
2222
public class BaseCollectionRequestTests extends AndroidTestCase {
23+
2324
private MockAuthenticationProvider mAuthenticationProvider;
2425
private MockBaseClient mBaseClient;
2526
private BaseCollectionRequest request;

0 commit comments

Comments
 (0)