Search in sources :

Example 6 with DriveItem

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

the class UserTests method meDriveRoot.

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

Example 7 with DriveItem

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

the class UserTests method meDriveItems.

@Test
public void meDriveItems() {
    // GET me/drive/items('<key>')
    final DriveItemCollectionPage driveItemCollectionPage = graphServiceClient.me().drive().items().buildRequest().get();
    assertNotNull(driveItemCollectionPage);
    if (driveItemCollectionPage.getCurrentPage().size() > 0) {
        DriveItem item = graphServiceClient.me().drive().items(driveItemCollectionPage.getCurrentPage().get(0).id).buildRequest().get();
        assertNotNull(item);
    }
}
Also used : DriveItem(com.microsoft.graph.models.DriveItem) DriveItemCollectionPage(com.microsoft.graph.requests.DriveItemCollectionPage) Test(org.junit.jupiter.api.Test)

Example 8 with DriveItem

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

the class OneDriveTests method downloadJsonFileFromOneDrive.

@Test
@Disabled
public void downloadJsonFileFromOneDrive() throws Exception {
    setUp();
    final DriveItemUploadableProperties item = new DriveItemUploadableProperties();
    item.name = "test.json";
    item.additionalDataManager().put("@microsoft.graph.conflictBehavior", new JsonPrimitive("replace"));
    final InputStream uploadFile = new ByteArrayInputStream("{\"hehe\":\"haha\"}".getBytes(StandardCharsets.UTF_8));
    final long fileSize = (long) uploadFile.available();
    final UploadSession session = testBase.graphClient.me().drive().root().itemWithPath(item.name).createUploadSession(DriveItemCreateUploadSessionParameterSet.newBuilder().withItem(item).build()).buildRequest().post();
    LargeFileUploadTask<DriveItem> chunkedUploadProvider = new LargeFileUploadTask<DriveItem>(session, testBase.graphClient, uploadFile, fileSize, DriveItem.class);
    final LargeFileUploadResult<DriveItem> result = chunkedUploadProvider.upload(0, null, callback);
    assertNotNull(result);
    final InputStream stream = testBase.graphClient.me().drive().root().itemWithPath(item.name).content().buildRequest().get();
    final String fileContent = CoreHttpProvider.streamToString(stream);
    assertTrue(fileContent.length() > 0);
}
Also used : DriveItem(com.microsoft.graph.models.DriveItem) DriveItemUploadableProperties(com.microsoft.graph.models.DriveItemUploadableProperties) JsonPrimitive(com.google.gson.JsonPrimitive) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) LargeFileUploadTask(com.microsoft.graph.tasks.LargeFileUploadTask) UploadSession(com.microsoft.graph.models.UploadSession) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 9 with DriveItem

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

the class CollectionPageSerializerTests method testEntityWithCollectionOnDefaultDeserializer.

@Test
public void testEntityWithCollectionOnDefaultDeserializer() throws Exception {
    final String jsonString = "{\"createdBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"cTag\":\"aYzpDMUZCQTM1Mzc4QkY5MjRDITIzNDkyNS4yNTc\",\"eTag\":\"aQzFGQkEzNTM3OEJGOTI0QyEyMzQ5MjUuMTE\",\"id\":\"C1FBA35378BF924C!234925\",\"lastModifiedBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"lastModifiedDateTime\":\"2020-09-16T17:42:17.847Z\",\"name\":\"Change Flat Tire.sco\",\"parentReference\":{\"driveId\":\"c1fba35378bf924c\",\"driveType\":\"personal\",\"id\":\"C1FBA35378BF924C!234867\",\"name\":\"UmtPlus\",\"path\":\"/drive/root:/UmtPlus\"},\"size\":59228,\"webUrl\":\"https://1drv.ms/u/s!AEySv3hTo_vBjqst\",\"items\":[],\"file\":{\"hashes\":{\"quickXorHash\":\"RjqF6zG7yzMKxLlRmXkKr0tK7oQ=\",\"sha1Hash\":\"A7A1DB7C7355A372E6097C5BD7DF6CF702AFA897\",\"sha256Hash\":\"97EF73D523368EE939D084F87DE22E28BD9236CC55D6A67EE69183FFC456CA08\"},\"mimeType\":\"application/octet-stream\"},\"fileSystemInfo\":{\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"lastModifiedDateTime\":\"2020-09-16T17:42:17.846Z\"},\"reactions\":{\"commentCount\":0},\"tags\":[],\"lenses\":[],\"thumbnails\":[{\"id\":\"0\",\"large\":{\"height\":800,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=800&height=800&cropmode=none\",\"width\":800},\"medium\":{\"height\":176,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=176&height=176&cropmode=none\",\"width\":176},\"small\":{\"height\":96,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=96&height=96&cropmode=none\",\"width\":96}}]}";
    final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
    final DriveItem driveItem = defaultSerializer.deserializeObject(jsonString, DriveItem.class);
    assertNotNull(driveItem);
    assertNotNull(driveItem.thumbnails);
    assertTrue(driveItem.thumbnails.getCurrentPage().size() > 0);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) DriveItem(com.microsoft.graph.models.DriveItem) Test(org.junit.jupiter.api.Test)

Example 10 with DriveItem

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

the class UserTests method meDriveItems.

@Test
public void meDriveItems() {
    // GET me/drive/items('<key>')
    final DriveItemCollectionPage driveItemCollectionPage = graphServiceClient.me().drive().items().buildRequest().get();
    assertNotNull(driveItemCollectionPage);
    if (driveItemCollectionPage.getCurrentPage().size() > 0) {
        DriveItem item = graphServiceClient.me().drive().items(driveItemCollectionPage.getCurrentPage().get(0).id).buildRequest().get();
        assertNotNull(item);
    }
}
Also used : DriveItem(com.microsoft.graph.models.DriveItem) DriveItemCollectionPage(com.microsoft.graph.requests.DriveItemCollectionPage) Test(org.junit.jupiter.api.Test)

Aggregations

DriveItem (com.microsoft.graph.models.DriveItem)10 Test (org.junit.jupiter.api.Test)10 DriveItemUploadableProperties (com.microsoft.graph.models.DriveItemUploadableProperties)4 UploadSession (com.microsoft.graph.models.UploadSession)4 LargeFileUploadTask (com.microsoft.graph.tasks.LargeFileUploadTask)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 Disabled (org.junit.jupiter.api.Disabled)4 JsonPrimitive (com.google.gson.JsonPrimitive)2 DriveItemCollectionPage (com.microsoft.graph.requests.DriveItemCollectionPage)2 DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)2