Skip to content

Commit 93ea88a

Browse files
authored
Merge pull request #1518 from kekolab/dev
Fix for issue 1517 and correction of two tests not respecting the REST reference (impacted by the fix)
2 parents dde3ec2 + 9d368ce commit 93ea88a

File tree

10 files changed

+83
-20
lines changed

10 files changed

+83
-20
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
## [3.1.4] - 2024-02-21
15+
16+
- Bumps Kiota-Java abstractions, authentication, http, and serialization components
17+
- Fixes a test in the test suite which did not respect the REST reference [#1517](https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/1517)
18+
- Fixes a bug with LargeFileUploadTask [#1517](https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/1517)
19+
20+
### Changed
21+
1422
## [3.1.3] - 2024-02-14
1523

1624
### Changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mavenGroupId = com.microsoft.graph
2525
mavenArtifactId = microsoft-graph-core
2626
mavenMajorVersion = 3
2727
mavenMinorVersion = 1
28-
mavenPatchVersion = 3
28+
mavenPatchVersion = 4
2929
mavenArtifactSuffix =
3030

3131
#These values are used to run functional tests

gradle/dependencies.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ dependencies {
1616
api 'com.squareup.okhttp3:okhttp:4.12.0'
1717
api 'com.azure:azure-core:1.46.0'
1818

19-
api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.0.2'
20-
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.0.2'
21-
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.0.2'
22-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.0.2'
23-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.0.2'
24-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.0.2'
25-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.0.2'
19+
api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.0.3'
20+
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.0.3'
21+
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.0.3'
22+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.0.3'
23+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.0.3'
24+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.0.3'
25+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.0.3'
2626
}

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repositories {
2222
2323
dependencies {
2424
// Include the sdk as a dependency
25-
implementation 'com.microsoft.graph:microsoft-graph-core:3.1.3'
25+
implementation 'com.microsoft.graph:microsoft-graph-core:3.1.4'
2626
// This dependency is only needed if you are using the TokenCredentialAuthProvider
2727
implementation 'com.azure:azure-identity:1.11.0'
2828
}
@@ -37,7 +37,7 @@ Add the dependency in `dependencies` in pom.xml
3737
<!-- Include the sdk as a dependency -->
3838
<groupId>com.microsoft.graph</groupId>
3939
<artifactId>microsoft-graph-core</artifactId>
40-
<version>3.1.3</version>
40+
<version>3.1.4</version>
4141
<!-- This dependency is only needed if you are using the TokenCredentialAuthProvider -->
4242
<groupId>com.azure</groupId>
4343
<artifactId>azure-identity</artifactId>

src/main/java/com/microsoft/graph/core/models/IUploadSession.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ public interface IUploadSession extends Parsable, AdditionalDataHolder {
2323
* Sets the Upload Url
2424
* @param url the upload Url for the session
2525
*/
26-
void setUploadUrl(@Nonnull String url);
26+
void setUploadUrl(@Nonnull final String url);
2727
/**
2828
* Gets the Next Expected Ranges.
2929
* A collection of byte ranges that the server is missing for the file. These ranges are zero indexed and of the format 'start-end' (e.g. '0-26' to indicate the first 27 bytes of the file). When uploading files as Outlook attachments, instead of a collection of ranges, this property always indicates a single value '{start}', the location in the file where the next upload should begin.
3030
* @return the Next Expected Ranges.
3131
*/
32-
@Nonnull
32+
@Nullable
3333
List<String> getNextExpectedRanges();
3434
/**
3535
* Sets the ranges that are yet to be uploaded.
3636
* @param nextExpectedRanges the byte ranges yet to be uploaded.
3737
*/
38-
void setNextExpectedRanges(@Nonnull List<String> nextExpectedRanges);
38+
void setNextExpectedRanges(@Nonnull final List<String> nextExpectedRanges);
3939
/**
4040
* Expiration date of the upload session
4141
* @return the expiration date.
@@ -46,5 +46,5 @@ public interface IUploadSession extends Parsable, AdditionalDataHolder {
4646
* Set the expiration date of the UploadSession
4747
* @param dateTime the expiration date of the UploadSession.
4848
*/
49-
void setExpirationDateTime(@Nonnull OffsetDateTime dateTime);
49+
void setExpirationDateTime(@Nonnull final OffsetDateTime dateTime);
5050
}

src/main/java/com/microsoft/graph/core/models/UploadSession.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ public void setUploadUrl(@Nonnull final String uploadUrl) {
5555
* Get the next upload byte ranges to be uploaded.
5656
* @return The byte ranges to be uploaded.
5757
*/
58-
@Nonnull
58+
@Nullable
5959
@Override
6060
public List<String> getNextExpectedRanges() {
61+
if (nextExpectedRanges == null) {
62+
return null;
63+
}
6164
return new ArrayList<>(nextExpectedRanges);
6265
}
6366
/**

src/main/java/com/microsoft/graph/core/requests/upload/UploadResponseHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.net.HttpURLConnection;
1919
import java.net.URI;
2020
import java.net.URISyntaxException;
21+
import java.util.List;
2122
import java.util.Objects;
2223

2324
/**
@@ -76,7 +77,8 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
7677
} else {
7778
final ParseNode parseNode = parseNodeFactory.getParseNode(contentType, in);
7879
final UploadSession uploadSession = parseNode.getObjectValue(UploadSession::createFromDiscriminatorValue);
79-
if (!uploadSession.getNextExpectedRanges().isEmpty()) {
80+
final List<String> nextExpectedRanges = uploadSession.getNextExpectedRanges();
81+
if (!(nextExpectedRanges == null || nextExpectedRanges.isEmpty())) {
8082
uploadResult.uploadSession = uploadSession;
8183
} else {
8284
uploadResult.itemResponse = parseNode.getObjectValue(factory);

src/test/java/com/microsoft/graph/core/requests/upload/UploadResponseHandlerTest.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,36 @@ void GetUploadItemOnCompletedUpload() {
5151
assertEquals("largeFile.vhd", item.name);
5252
assertEquals(33, item.size);
5353
}
54+
55+
@Test
56+
void GetUploadItemOnCompletedUpdate() {
57+
registry.contentTypeAssociatedFactories.put(CoreConstants.MimeTypeNames.APPLICATION_JSON, new JsonParseNodeFactory());
58+
59+
UploadResponseHandler responseHandler = new UploadResponseHandler(null);
60+
ResponseBody body = ResponseBody.create("{\n" +
61+
" \"id\": \"912310013A123\",\n" +
62+
" \"name\": \"largeFile.vhd\",\n" +
63+
" \"size\": 33\n" +
64+
"}"
65+
, MediaType.parse(CoreConstants.MimeTypeNames.APPLICATION_JSON));
66+
Response response = new Response.Builder()
67+
.request(mock(Request.class))
68+
.protocol(mock(Protocol.class))
69+
.body(body)
70+
.code(HttpURLConnection.HTTP_OK)
71+
.message("OK")
72+
.build();
73+
UploadResult<TestDriveItem> result = responseHandler
74+
.handleResponse(response, TestDriveItem::createFromDiscriminatorValue);
75+
responseHandler.handleResponse(response, parseNode -> {return new TestDriveItem();});
76+
TestDriveItem item = result.itemResponse;
77+
assertTrue(result.isUploadSuccessful());
78+
assertNotNull(item);
79+
assertEquals("912310013A123", item.id);
80+
assertEquals("largeFile.vhd", item.name);
81+
assertEquals(33, item.size);
82+
}
83+
5484
@Test
5585
void getFileAttachmentLocationOnCompletedUpload() {
5686
registry.contentTypeAssociatedFactories.put(CoreConstants.MimeTypeNames.APPLICATION_JSON, new JsonParseNodeFactory());
@@ -89,9 +119,9 @@ void getUploadSessionOnProgressingUpload() {
89119
Response response = new Response.Builder()
90120
.request(mock(Request.class))
91121
.protocol(mock(Protocol.class))
92-
.message("OK")
122+
.message("Accepted")
93123
.body(body)
94-
.code(HttpURLConnection.HTTP_OK)
124+
.code(HttpURLConnection.HTTP_ACCEPTED)
95125
.build();
96126
UploadResult<TestDriveItem> result = responseHandler
97127
.handleResponse(response, TestDriveItem::createFromDiscriminatorValue);
@@ -105,6 +135,7 @@ void getUploadSessionOnProgressingUpload() {
105135
assertEquals("77829-99375", session.getNextExpectedRanges().get(1));
106136
assertEquals(2, session.getNextExpectedRanges().size());
107137
}
138+
108139
@Test
109140
void throwsServiceExceptionOnErrorResponse() {
110141
UploadResponseHandler responseHandler = new UploadResponseHandler(null);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.microsoft.graph.core.requests.upload;
2+
3+
import static org.junit.jupiter.api.Assertions.assertNull;
4+
5+
import java.util.List;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import com.microsoft.graph.core.models.UploadSession;
10+
11+
class UploadSessionTest {
12+
@Test
13+
void getNextExpectedRangesDoesNotFailOnDefault()
14+
{
15+
final UploadSession uploadSession = new UploadSession();
16+
final List<String> result = uploadSession.getNextExpectedRanges();
17+
assertNull(result);
18+
}
19+
}

src/test/java/com/microsoft/graph/core/requests/upload/UploadSliceRequestTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ void putReturnsExpectedUploadSession() throws IOException {
4040
Response response = new Response.Builder()
4141
.request(new Request.Builder().post(mock(RequestBody.class)).url("https://a.b.c/").build())
4242
.protocol(Protocol.HTTP_1_1)
43-
.message("OK")
43+
.message("Accepted")
4444
.body(body)
45-
.code(HttpURLConnection.HTTP_OK)
45+
.code(HttpURLConnection.HTTP_ACCEPTED)
4646
.build();
4747

4848
OkHttpClient mockClient = getMockClient(response);

0 commit comments

Comments
 (0)