use of com.microsoft.graph.models.extensions.Drive in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testDriveDeserialization.
/**
* Make sure that deserializing a Drive also returns members from BaseDrive
*
* @throws Exception If there is an exception during the test
*/
@Test
public void testDriveDeserialization() throws Exception {
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#drives/$entity\",\"id\":\"8bf6ae90006c4a4c\",\"driveType\":\"personal\",\"owner\":{\"user\":{\"displayName\":\"Peter\",\"id\":\"8bf6ae90006c4a4c\"}},\"quota\":{\"deleted\":1485718314,\"remaining\":983887466461,\"state\":\"normal\",\"total\":1142461300736,\"used\":158573834275}}";
Drive result = serializer.deserializeObject(source, Drive.class);
assertNotNull(result);
assertEquals("personal", result.driveType);
assertEquals(Long.valueOf(983887466461L), result.quota.remaining);
assertEquals("8bf6ae90006c4a4c", result.id);
}
use of com.microsoft.graph.models.extensions.Drive in project msgraph-sdk-java by microsoftgraph.
the class DefaultHttpProviderTests method testDriveResponse.
@Test
public void testDriveResponse() throws Exception {
final String driveId = "driveId";
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 Drive expectedDrive = new Drive();
expectedDrive.id = driveId;
setDefaultHttpProvider(expectedDrive);
mProvider.setConnectionFactory(new MockConnectionFactory(new MockConnection(data)));
final Drive drive = mProvider.send(new MockHttpRequest(), Drive.class, null);
assertEquals(driveId, drive.id);
assertEquals(1, mAuthenticationProvider.getInterceptionCount());
}
Aggregations