From 858fbf1f022194095918ac17e4425786f81728f3 Mon Sep 17 00:00:00 2001 From: Philip Gichuhi Date: Thu, 22 Aug 2024 17:00:49 +0300 Subject: [PATCH 1/5] Use Java 17 for release workflows --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5c51d118..18edd71a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ permissions: env: PREVIEW_TASK: publishToSonatype PUBLISH_TASK: publishToSonatype closeAndReleaseSonatypeStagingRepository - JAVA_VERSION: 21 + JAVA_VERSION: 17 JAVA_DIST: 'temurin' jobs: From b1a3785246facc7e9aa408e8c6b71d957f6f3e55 Mon Sep 17 00:00:00 2001 From: Philip Gichuhi Date: Thu, 22 Aug 2024 18:49:52 +0300 Subject: [PATCH 2/5] Switch to mockito-core from mockito-inline which is deprecated --- components/abstractions/gradle/dependencies.gradle | 2 +- components/authentication/azure/gradle/dependencies.gradle | 2 +- components/bundle/gradle/dependencies.gradle | 2 +- components/http/okHttp/gradle/dependencies.gradle | 2 +- components/serialization/multipart/gradle/dependencies.gradle | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/abstractions/gradle/dependencies.gradle b/components/abstractions/gradle/dependencies.gradle index 2658657f7..db3f618ba 100644 --- a/components/abstractions/gradle/dependencies.gradle +++ b/components/abstractions/gradle/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { // Use JUnit Jupiter API for testing. testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0' - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation 'org.mockito:mockito-core:5.12.0' // Use JUnit Jupiter Engine for testing. testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' diff --git a/components/authentication/azure/gradle/dependencies.gradle b/components/authentication/azure/gradle/dependencies.gradle index 4f36ad38e..e4acc45a6 100644 --- a/components/authentication/azure/gradle/dependencies.gradle +++ b/components/authentication/azure/gradle/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { // Use JUnit Jupiter API for testing. testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0' - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation 'org.mockito:mockito-core:5.12.0' // Use JUnit Jupiter Engine for testing. diff --git a/components/bundle/gradle/dependencies.gradle b/components/bundle/gradle/dependencies.gradle index 3ab8e026f..dd9ea7503 100644 --- a/components/bundle/gradle/dependencies.gradle +++ b/components/bundle/gradle/dependencies.gradle @@ -5,7 +5,7 @@ dependencies { // Use JUnit Jupiter Engine for testing. testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation 'org.mockito:mockito-core:5.12.0' implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1' diff --git a/components/http/okHttp/gradle/dependencies.gradle b/components/http/okHttp/gradle/dependencies.gradle index 11e93b50c..a934dee81 100644 --- a/components/http/okHttp/gradle/dependencies.gradle +++ b/components/http/okHttp/gradle/dependencies.gradle @@ -5,7 +5,7 @@ dependencies { // Use JUnit Jupiter Engine for testing. testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation 'org.mockito:mockito-core:5.12.0' testImplementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' diff --git a/components/serialization/multipart/gradle/dependencies.gradle b/components/serialization/multipart/gradle/dependencies.gradle index 4dee68e94..f8576f3b9 100644 --- a/components/serialization/multipart/gradle/dependencies.gradle +++ b/components/serialization/multipart/gradle/dependencies.gradle @@ -1,7 +1,7 @@ dependencies { // Use JUnit Jupiter API for testing. testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0' - testImplementation 'org.mockito:mockito-inline:5.2.0' + testImplementation 'org.mockito:mockito-core:5.12.0' // Use JUnit Jupiter Engine for testing. testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' From 23c64a193e5dce4ced5ead02e719b7c14ce9f6d4 Mon Sep 17 00:00:00 2001 From: Philip Gichuhi Date: Thu, 22 Aug 2024 18:57:36 +0300 Subject: [PATCH 3/5] Bump workflows to use java 21 --- .github/workflows/api-level-lint.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/sonarcloud.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/api-level-lint.yml b/.github/workflows/api-level-lint.yml index ed53555f8..292d92788 100644 --- a/.github/workflows/api-level-lint.yml +++ b/.github/workflows/api-level-lint.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 17 + java-version: 21 cache: gradle - name: Setup Android SDK uses: android-actions/setup-android@v3.2.1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2dbe3705e..31e5a8dc3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: - name: Setup JDK uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: gradle - name: Detect secrets diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18edd71a5..d5c51d118 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ permissions: env: PREVIEW_TASK: publishToSonatype PUBLISH_TASK: publishToSonatype closeAndReleaseSonatypeStagingRepository - JAVA_VERSION: 17 + JAVA_VERSION: 21 JAVA_DIST: 'temurin' jobs: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 42ddfec43..d266ae9b1 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -23,9 +23,9 @@ jobs: - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: 17 + java-version: 21 distribution: 'temurin' - cache: gradle + cache: gradle - name: Cache SonarCloud packages uses: actions/cache@v4 with: From 6d68180ab346485abd18870feb9d26c37514fe95 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 22 Aug 2024 13:26:48 -0400 Subject: [PATCH 4/5] fix: failing unit test caused by ordering --- .../kiota/serialization/JsonSerializationWriterTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java index 357c45b14..d2ab4e7f8 100644 --- a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java +++ b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java @@ -190,10 +190,10 @@ void writesSampleObjectValueWithUntypedProperties() throws IOException { // Assert var expectedString = "{\"id\":\"1\"," - + "\"location\":{\"hasReception\":true,\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE" + + "\"location\":{\"hasReception\":true,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222}," + + "\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE" + " 36th St\",\"postalCode\":\"98052\"},\"displayName\":\"Microsoft Building" - + " 92\",\"floorCount\":50,\"contact\":null,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222}}," - + "\"keywords\":[" + + " 92\",\"floorCount\":50,\"contact\":null},\"keywords\":[" + "{\"wssId\":345345345,\"label\":\"Keyword1\",\"termGuid\":\"10e9cc83-b5a4-4c8d-8dab-4ada1252dd70\",\"created\":\"2023-07-26T10:41:26Z\"}," + "{\"wssId\":345345345,\"label\":\"Keyword2\",\"termGuid\":\"2cae6c6a-9bb8-4a78-afff-81b88e735fef\",\"created\":\"2023-07-26T10:51:26Z\"}]," + "\"extra\":{\"createdDateTime\":\"2024-01-15T00:00:00+00:00\"}}"; From 843db9c76fcd4f3973f834f8fc44b3e4036a777f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 22 Aug 2024 13:28:25 -0400 Subject: [PATCH 5/5] chore: linting missing closure --- .../JsonSerializationWriterTests.java | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java index d2ab4e7f8..f9a5f5038 100644 --- a/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java +++ b/components/serialization/json/src/test/java/com/microsoft/kiota/serialization/JsonSerializationWriterTests.java @@ -53,15 +53,17 @@ void writesSampleObjectValueWithPrimitivesInAdditionalData() throws IOException .getAdditionalData() .put("aliases", aliases); // place a collection in the additional data - var jsonSerializer = new JsonSerializationWriter(); - jsonSerializer.writeObjectValue("", testEntity); - var contentStream = jsonSerializer.getSerializedContent(); - var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8"); - // Assert - var expectedString = - "{\"aliases\":[\"alias1\",\"alias2\"],\"nickName\":\"Peter" - + " Pan\",\"hasDependents\":true,\"accountBalance\":330.7,\"reportsCount\":4,\"averageScore\":78.142}"; - assertEquals(expectedString, serializedJsonString); + try (final var jsonSerializer = new JsonSerializationWriter()) { + jsonSerializer.writeObjectValue("", testEntity); + var contentStream = jsonSerializer.getSerializedContent(); + var serializedJsonString = + new String(Compatibility.readAllBytes(contentStream), "UTF-8"); + // Assert + var expectedString = + "{\"aliases\":[\"alias1\",\"alias2\"],\"nickName\":\"Peter" + + " Pan\",\"hasDependents\":true,\"accountBalance\":330.7,\"reportsCount\":4,\"averageScore\":78.142}"; + assertEquals(expectedString, serializedJsonString); + } } @Test @@ -79,14 +81,16 @@ void writesSampleObjectValueWithParsableInAdditionalData() throws IOException { .getAdditionalData() .put("manager", managerAdditionalData); // place a parsable in the addtionaldata - var jsonSerializer = new JsonSerializationWriter(); - jsonSerializer.writeObjectValue("", testEntity); - var contentStream = jsonSerializer.getSerializedContent(); - var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8"); - // Assert - var expectedString = - "{\"id\":\"test_id\",\"phones\":[\"123456789\"],\"manager\":{\"id\":\"manager_id\",\"myEnum\":\"VALUE1\"}}"; - assertEquals(expectedString, serializedJsonString); + try (final var jsonSerializer = new JsonSerializationWriter()) { + jsonSerializer.writeObjectValue("", testEntity); + var contentStream = jsonSerializer.getSerializedContent(); + var serializedJsonString = + new String(Compatibility.readAllBytes(contentStream), "UTF-8"); + // Assert + var expectedString = + "{\"id\":\"test_id\",\"phones\":[\"123456789\"],\"manager\":{\"id\":\"manager_id\",\"myEnum\":\"VALUE1\"}}"; + assertEquals(expectedString, serializedJsonString); + } } @Test @@ -182,21 +186,23 @@ void writesSampleObjectValueWithUntypedProperties() throws IOException { } })); - var jsonSerializer = new JsonSerializationWriter(); - jsonSerializer.writeObjectValue("", untypedTestEntity); - var contentStream = jsonSerializer.getSerializedContent(); - var serializedJsonString = new String(Compatibility.readAllBytes(contentStream), "UTF-8"); - - // Assert - var expectedString = - "{\"id\":\"1\"," - + "\"location\":{\"hasReception\":true,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222}," - + "\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE" - + " 36th St\",\"postalCode\":\"98052\"},\"displayName\":\"Microsoft Building" - + " 92\",\"floorCount\":50,\"contact\":null},\"keywords\":[" - + "{\"wssId\":345345345,\"label\":\"Keyword1\",\"termGuid\":\"10e9cc83-b5a4-4c8d-8dab-4ada1252dd70\",\"created\":\"2023-07-26T10:41:26Z\"}," - + "{\"wssId\":345345345,\"label\":\"Keyword2\",\"termGuid\":\"2cae6c6a-9bb8-4a78-afff-81b88e735fef\",\"created\":\"2023-07-26T10:51:26Z\"}]," - + "\"extra\":{\"createdDateTime\":\"2024-01-15T00:00:00+00:00\"}}"; - assertEquals(expectedString, serializedJsonString); + try (final var jsonSerializer = new JsonSerializationWriter()) { + jsonSerializer.writeObjectValue("", untypedTestEntity); + var contentStream = jsonSerializer.getSerializedContent(); + var serializedJsonString = + new String(Compatibility.readAllBytes(contentStream), "UTF-8"); + + // Assert + var expectedString = + "{\"id\":\"1\"," + + "\"location\":{\"hasReception\":true,\"coordinates\":{\"latitude\":47.641942,\"longitude\":-122.127222}," + + "\"address\":{\"state\":\"Washington\",\"city\":\"Redmond\",\"street\":\"NE" + + " 36th St\",\"postalCode\":\"98052\"},\"displayName\":\"Microsoft" + + " Building 92\",\"floorCount\":50,\"contact\":null},\"keywords\":[" + + "{\"wssId\":345345345,\"label\":\"Keyword1\",\"termGuid\":\"10e9cc83-b5a4-4c8d-8dab-4ada1252dd70\",\"created\":\"2023-07-26T10:41:26Z\"}," + + "{\"wssId\":345345345,\"label\":\"Keyword2\",\"termGuid\":\"2cae6c6a-9bb8-4a78-afff-81b88e735fef\",\"created\":\"2023-07-26T10:51:26Z\"}]," + + "\"extra\":{\"createdDateTime\":\"2024-01-15T00:00:00+00:00\"}}"; + assertEquals(expectedString, serializedJsonString); + } } }