use of com.microsoft.graph.models.extensions.DriveItem 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());
}
use of com.microsoft.graph.models.extensions.DriveItem in project msgraph-sdk-java by microsoftgraph.
the class DefaultHttpProviderTests method testPostItem.
@Test
public void testPostItem() 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 DriveItem item = mProvider.send(new MockHttpRequest(), DriveItem.class, new DriveItem());
assertEquals(itemId, item.id);
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
use of com.microsoft.graph.models.extensions.DriveItem in project msgraph-sdk-java by microsoftgraph.
the class DefaultHttpProviderTests method testBodyLessResponse.
@Test
public void testBodyLessResponse() throws Exception {
final int[] codes = new int[] { 204, 304 };
final AtomicInteger currentCode = new AtomicInteger(0);
setDefaultHttpProvider(null);
final ITestConnectionData data = new ITestConnectionData() {
@Override
public int getRequestCode() {
return codes[currentCode.get()];
}
@Override
public String getJsonResponse() {
return null;
}
@Override
public Map<String, String> getHeaders() {
return new HashMap<>();
}
};
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
for (final int ignored : codes) {
DriveItem result = mProvider.send(new MockHttpRequest(), DriveItem.class, null);
currentCode.incrementAndGet();
assertNull(result);
}
assertEquals(codes.length, mAuthenticationProvider.getInterceptionCount());
}
Aggregations