Skip to content

Commit 87006e6

Browse files
authored
Merge pull request #98 from microsoftgraph/feature/v1-sync
feature/v1 sync
2 parents 70fca8e + 8bc088d commit 87006e6

File tree

5 files changed

+46
-10
lines changed

5 files changed

+46
-10
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ updates:
55
schedule:
66
interval: daily
77
open-pull-requests-limit: 10
8+
- package-ecosystem: maven
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
open-pull-requests-limit: 10
813
- package-ecosystem: github-actions
914
directory: "/"
1015
schedule:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ repositories {
2020
dependencies {
2121
// Include the sdk as a dependency
2222
implementation 'com.microsoft.graph:microsoft-graph-beta:0.14.0-SNAPSHOT'
23+
// Uncomment the line below if you are building an android application
24+
//implementation 'com.google.guava:guava:30.1.1-android'
2325
}
2426
```
2527

devx.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
languages:
2+
- java
3+
extensions:
4+
services:
5+
- Microsoft Graph
6+
dependencyFile: /gradle/dependencies.gradle

src/test/java/com/microsoft/graph/functional/OneDriveTests.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.microsoft.graph.functional;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
34
import static org.junit.jupiter.api.Assertions.assertFalse;
45
import static org.junit.jupiter.api.Assertions.assertNotNull;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
67

78
import java.io.ByteArrayInputStream;
89
import java.io.IOException;
910
import java.io.InputStream;
11+
import java.net.URL;
1012
import java.nio.charset.StandardCharsets;
1113

1214
import org.junit.jupiter.api.BeforeEach;
@@ -24,13 +26,13 @@
2426
import com.microsoft.graph.models.UploadSession;
2527
import com.microsoft.graph.models.DriveItemCreateUploadSessionParameterSet;
2628

27-
@Disabled
2829
public class OneDriveTests {
2930
private TestBase testBase;
3031

31-
@BeforeEach
3232
public void setUp() {
33-
testBase = new TestBase();
33+
if(testBase == null) {
34+
testBase = new TestBase();
35+
}
3436
}
3537

3638
final IProgressCallback callback = new IProgressCallback () {
@@ -39,6 +41,17 @@ public void progress(final long current, final long max) {
3941
//Check progress
4042
}
4143
};
44+
/**
45+
* Tests that paths are properly encoded acording to ODSP's expectations
46+
* - everything is encoded to the application/x-www-form-urlencoded MIME format
47+
* - spaces are encoded with %20
48+
*/
49+
@Test
50+
public void itemWithPathEncodesSpecialCharacters() {
51+
final URL requestURL = new TestBase(false).graphClient.me().drive().root().itemWithPath("some folder/some name with a + and a #777.docx").buildRequest().getRequestUrl();
52+
assertEquals("/me/drive/root:/some%20folder%2Fsome%20name%20with%20a%20%2B%20and%20a%20%23777.docx:", requestURL.getPath().replace("/v1.0", "").replace("/beta", ""));
53+
// version replacement so the test is version agnostic
54+
}
4255
/**
4356
* Test large file upload.
4457
* https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/chunked-uploads.md
@@ -47,8 +60,10 @@ public void progress(final long current, final long max) {
4760
* @throws InterruptedException if the chunked upload fails
4861
*/
4962
@Test
63+
@Disabled
5064
public void testLargeFileUpload() throws IOException, InterruptedException {
51-
//Get resource file from file system
65+
setUp();
66+
//Get resource file from file system
5267
InputStream uploadFile = OneDriveTests.class.getClassLoader().getResourceAsStream("largefile10M.blob");
5368
long fileSize = (long) uploadFile.available();
5469

@@ -72,14 +87,18 @@ public void testLargeFileUpload() throws IOException, InterruptedException {
7287
assertNotNull(result);
7388
}
7489
@Test
90+
@Disabled
7591
public void testDownloadWithCustomRequest() throws IOException {
92+
setUp();
7693
final String testDownloadFileId = "01RWFXFJG3UYRHE75RZVFYWKNUEBB53H7A";
7794
try (final InputStream stream = testBase.graphClient.customRequest("/me/drive/items/"+testDownloadFileId+"/content", InputStream.class).buildRequest().get()) {
7895
assertFalse(stream.read() == -1, "stream should not be empty");
7996
}
8097
}
8198
@Test
99+
@Disabled
82100
public void downloadJsonFileFromOneDrive() throws Exception {
101+
setUp();
83102
final DriveItemUploadableProperties item = new DriveItemUploadableProperties();
84103
item.name = "test.json";
85104
item.additionalDataManager().put("@microsoft.graph.conflictBehavior", new JsonPrimitive("replace"));

src/test/java/com/microsoft/graph/functional/TestBase.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.microsoft.graph.http.CoreHttpProvider;
1414
import com.microsoft.graph.http.IHttpRequest;
1515
import com.microsoft.graph.httpcore.HttpClients;
16-
import com.microsoft.graph.authentication.IAuthenticationProvider;
16+
import com.microsoft.graph.authentication.BaseAuthenticationProvider;
1717
import com.microsoft.graph.requests.GraphServiceClient;
1818

1919
import okhttp3.OkHttpClient;
@@ -58,20 +58,24 @@ private void GetClient(boolean authenticate)
5858
}
5959
}
6060
}
61-
public IAuthenticationProvider getUnauthenticationProvider() {
62-
return new IAuthenticationProvider() {
61+
public BaseAuthenticationProvider getUnauthenticationProvider() {
62+
return new BaseAuthenticationProvider() {
6363
@Override
6464
public CompletableFuture<String> getAuthorizationTokenAsync(final URL requestUrl) {
6565
return CompletableFuture.completedFuture((String)null);
6666
}
6767
};
6868
}
69-
public IAuthenticationProvider getAuthenticationProvider() {
69+
public BaseAuthenticationProvider getAuthenticationProvider() {
7070
final String accessToken = GetAccessToken().replace("\"", "");
71-
return new IAuthenticationProvider() {
71+
return new BaseAuthenticationProvider() {
7272
@Override
7373
public CompletableFuture<String> getAuthorizationTokenAsync(final URL requestUrl) {
74-
return CompletableFuture.completedFuture(accessToken);
74+
if(this.shouldAuthenticateRequestWithUrl(requestUrl)) {
75+
return CompletableFuture.completedFuture(accessToken);
76+
} else {
77+
return CompletableFuture.completedFuture(null);
78+
}
7579
}
7680
};
7781
}

0 commit comments

Comments
 (0)