Search in sources :

Example 1 with Drive

use of com.microsoft.graph.models.Drive in project msgraph-sdk-java by microsoftgraph.

the class UserTests method meDrive.

@Test
public void meDrive() {
    // GET me/drive
    final Drive drive = graphServiceClient.me().drive().buildRequest().get();
    assertNotNull(drive);
}
Also used : Drive(com.microsoft.graph.models.Drive) Test(org.junit.jupiter.api.Test)

Example 2 with Drive

use of com.microsoft.graph.models.Drive in project msgraph-sdk-java by microsoftgraph.

the class AdditionalDataTests method testChildAdditionalDataDeserialization.

@Test
public void testChildAdditionalDataDeserialization() {
    String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#drives/$entity\",\"id\":\"8bf6ae90006c4a4c\",\"driveType\":\"personal\",\"owner\":{\"user\":{\"displayName\":\"Peter\",\"id\":\"8bf6ae90006c4a4c\",\"email\":\"petertest@onmicrosoft.com\"}},\"quota\":{\"deleted\":1485718314,\"remaining\":983887466461,\"state\":\"normal\",\"total\":1142461300736,\"used\":158573834275}}";
    Drive result = serializer.deserializeObject(source, Drive.class);
    JsonElement email = result.owner.user.additionalDataManager().get("email");
    assertEquals("\"petertest@onmicrosoft.com\"", email.toString());
}
Also used : JsonElement(com.google.gson.JsonElement) Drive(com.microsoft.graph.models.Drive) Test(org.junit.jupiter.api.Test)

Example 3 with Drive

use of com.microsoft.graph.models.Drive in project msgraph-beta-sdk-java by microsoftgraph.

the class AdditionalDataTests method testChildAdditionalDataDeserialization.

@Test
public void testChildAdditionalDataDeserialization() {
    String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#drives/$entity\",\"id\":\"8bf6ae90006c4a4c\",\"driveType\":\"personal\",\"owner\":{\"user\":{\"displayName\":\"Peter\",\"id\":\"8bf6ae90006c4a4c\",\"email\":\"petertest@onmicrosoft.com\"}},\"quota\":{\"deleted\":1485718314,\"remaining\":983887466461,\"state\":\"normal\",\"total\":1142461300736,\"used\":158573834275}}";
    Drive result = serializer.deserializeObject(source, Drive.class);
    JsonElement email = result.owner.user.additionalDataManager().get("email");
    assertEquals("\"petertest@onmicrosoft.com\"", email.toString());
}
Also used : JsonElement(com.google.gson.JsonElement) Drive(com.microsoft.graph.models.Drive) Test(org.junit.jupiter.api.Test)

Example 4 with Drive

use of com.microsoft.graph.models.Drive in project msgraph-sdk-java by microsoftgraph.

the class DefaultSerializerTests 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);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) Drive(com.microsoft.graph.models.Drive) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 5 with Drive

use of com.microsoft.graph.models.Drive in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests 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);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) Drive(com.microsoft.graph.models.Drive) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Aggregations

Drive (com.microsoft.graph.models.Drive)6 Test (org.junit.jupiter.api.Test)6 JsonElement (com.google.gson.JsonElement)2 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)2 DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)2