use of com.microsoft.graph.concurrency.IProgressCallback in project msgraph-sdk-java by microsoftgraph.
the class GraphServiceClientTest method testOverrideOfDefaultExecutors.
@Test
public void testOverrideOfDefaultExecutors() {
IExecutors ex = new IExecutors() {
@Override
public void performOnBackground(Runnable runnable) {
// do nothing
}
@Override
public <Result> void performOnForeground(Result result, ICallback<Result> callback) {
// do nothing
}
@Override
public <Result> void performOnForeground(int progress, int progressMax, IProgressCallback<Result> callback) {
// do nothing
}
@Override
public <Result> void performOnForeground(ClientException exception, ICallback<Result> callback) {
// do nothing
}
};
IGraphServiceClient client = //
GraphServiceClient.builder().authenticationProvider(//
auth).executors(//
ex).buildClient();
assertEquals(ex, client.getExecutors());
assertEquals(auth, client.getAuthenticationProvider());
assertNotNull(client.getHttpProvider());
assertNotNull(client.getLogger());
assertNotNull(client.getSerializer());
assertEquals(ex, ((DefaultHttpProvider) client.getHttpProvider()).getExecutors());
}
use of com.microsoft.graph.concurrency.IProgressCallback in project msgraph-sdk-java by microsoftgraph.
the class DefaultHttpProviderTests method testPostByte.
@Test
public void testPostByte() throws Exception {
final String itemId = "itemId";
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return 200;
}
@Override
public String getJsonResponse() {
return "{ \"id\": \"zzz\" }";
}
@Override
public Map<String, String> getHeaders() {
final HashMap<String, String> map = new HashMap<>();
map.put("Content-Type", "application/json");
return map;
}
};
final DriveItem expectedItem = new DriveItem();
expectedItem.id = itemId;
setDefaultHttpProvider(expectedItem);
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
final AtomicBoolean progress = new AtomicBoolean(false);
final AtomicBoolean success = new AtomicBoolean(false);
final AtomicBoolean failure = new AtomicBoolean(false);
final IProgressCallback<DriveItem> progressCallback = new IProgressCallback<DriveItem>() {
@Override
public void progress(final long current, final long max) {
progress.set(true);
}
@Override
public void success(final DriveItem item) {
success.set(true);
}
@Override
public void failure(final ClientException ex) {
failure.set(true);
}
};
mProvider.send(new MockHttpRequest(), progressCallback, DriveItem.class, new byte[] { 1, 2, 3, 4 });
assertTrue(progress.get());
assertTrue(success.get());
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
Aggregations