From ff60eccc67998c59eba5602d76c9c6cfff691c31 Mon Sep 17 00:00:00 2001 From: thiagotognoli Date: Wed, 6 Aug 2025 14:39:05 -0300 Subject: [PATCH 1/3] Improves test reliability and adds Maven Invoker plugin Ensures tests validate successful responses by checking status codes and reading from input streams instead of error streams. Removes extraneous semicolons for code style consistency. Adds Maven Invoker plugin to support integration testing scenarios. --- .../fit/tecsvc/http/ODataVersionConformanceITCase.java | 8 +++++--- .../apache/olingo/server/core/ODataHandlerImplTest.java | 2 +- pom.xml | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/ODataVersionConformanceITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/ODataVersionConformanceITCase.java index b86b5be09..550c49ace 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/ODataVersionConformanceITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/http/ODataVersionConformanceITCase.java @@ -96,9 +96,10 @@ public void validODataMaxVersionHeader() throws Exception { connection.setRequestProperty(HttpHeader.ODATA_MAX_VERSION, "5.0"); connection.connect(); + assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode()); assertEquals("4.0", connection.getHeaderField(HttpHeader.ODATA_VERSION)); - final String content = IOUtils.toString(connection.getErrorStream(), Charset.defaultCharset()); + final String content = IOUtils.toString(connection.getInputStream(), Charset.defaultCharset()); assertNotNull(content); } @@ -112,10 +113,11 @@ public void validODataVersionAndMaxVersionHeader() throws Exception { connection.setRequestProperty(HttpHeader.ODATA_MAX_VERSION, "5.0"); connection.connect(); + assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode()); assertEquals("4.0", connection.getHeaderField(HttpHeader.ODATA_VERSION)); - final String content = IOUtils.toString(connection.getErrorStream(), Charset.defaultCharset()); - assertNotNull(content);; + final String content = IOUtils.toString(connection.getInputStream(), Charset.defaultCharset()); + assertNotNull(content); } @Test diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerImplTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerImplTest.java index a4d8a6074..b17e8acf6 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerImplTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerImplTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions;; +import static org.mockito.Mockito.verifyNoInteractions; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/pom.xml b/pom.xml index 955af2720..ae98f9048 100644 --- a/pom.xml +++ b/pom.xml @@ -335,6 +335,11 @@ cobertura-maven-plugin 2.7 + + org.apache.maven.plugins + maven-invoker-plugin + 3.8.0 + From f9a6942aa28487443c4ff5dfba67f4dc092fe301 Mon Sep 17 00:00:00 2001 From: thiagotognoli Date: Wed, 6 Aug 2025 14:40:40 -0300 Subject: [PATCH 2/3] Updates parent version to 5.0.2-SNAPSHOT across modules Aligns all module parent references to the latest snapshot version to ensure consistency and enable development on the 5.0.2 release line. Facilitates dependency management and prepares for upcoming changes. --- dist/android-lib/pom.xml | 2 +- dist/client-lib/pom.xml | 2 +- dist/javadoc/pom.xml | 2 +- dist/pom.xml | 2 +- dist/server-lib-ext/pom.xml | 2 +- dist/server-lib/pom.xml | 2 +- ext/client-android/pom.xml | 2 +- ext/client-proxy/pom.xml | 2 +- ext/karaf/karaf-features/pom.xml | 2 +- ext/karaf/karaf-fit/pom.xml | 2 +- .../org/apache/olingo/osgi/itests/server/CarServiceTest.java | 2 +- ext/karaf/pom.xml | 2 +- ext/pojogen-maven-plugin/pom.xml | 2 +- ext/pom.xml | 2 +- fit/pom.xml | 2 +- lib/client-api/pom.xml | 2 +- lib/client-core/pom.xml | 2 +- lib/commons-api/pom.xml | 2 +- lib/commons-core/pom.xml | 2 +- lib/pom.xml | 2 +- lib/server-api/pom.xml | 2 +- lib/server-core-ext/pom.xml | 2 +- lib/server-core/pom.xml | 2 +- lib/server-tecsvc/pom.xml | 2 +- lib/server-test/pom.xml | 2 +- pom.xml | 2 +- samples/client/pom.xml | 2 +- samples/osgi/server/pom.xml | 2 +- samples/pom.xml | 2 +- samples/server/pom.xml | 2 +- samples/tutorials/p0_all/pom.xml | 4 ++-- samples/tutorials/p10_media/pom.xml | 4 ++-- samples/tutorials/p11_batch/pom.xml | 4 ++-- samples/tutorials/p12_deep_insert/pom.xml | 4 ++-- samples/tutorials/p12_deep_insert_preparation/pom.xml | 4 ++-- samples/tutorials/p1_read/pom.xml | 4 ++-- samples/tutorials/p2_readep/pom.xml | 4 ++-- samples/tutorials/p3_write/pom.xml | 4 ++-- samples/tutorials/p4_navigation/pom.xml | 4 ++-- samples/tutorials/p5_queryoptions-tcs/pom.xml | 4 ++-- samples/tutorials/p6_queryoptions-es/pom.xml | 4 ++-- samples/tutorials/p7_queryoptions-o/pom.xml | 4 ++-- samples/tutorials/p8_queryoptions-f/pom.xml | 4 ++-- samples/tutorials/p9_action/pom.xml | 4 ++-- samples/tutorials/p9_action_preparation/pom.xml | 4 ++-- samples/tutorials/pe_streaming/pom.xml | 4 ++-- samples/tutorials/pom.xml | 2 +- 47 files changed, 63 insertions(+), 63 deletions(-) diff --git a/dist/android-lib/pom.xml b/dist/android-lib/pom.xml index 94654562f..0d9060c50 100644 --- a/dist/android-lib/pom.xml +++ b/dist/android-lib/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-dist - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/dist/client-lib/pom.xml b/dist/client-lib/pom.xml index bfabd152a..3acbe7f6b 100644 --- a/dist/client-lib/pom.xml +++ b/dist/client-lib/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-dist - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/dist/javadoc/pom.xml b/dist/javadoc/pom.xml index 5fcce52e3..6354b6b53 100644 --- a/dist/javadoc/pom.xml +++ b/dist/javadoc/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-dist - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/dist/pom.xml b/dist/pom.xml index c98a51afb..b56c27dd3 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/dist/server-lib-ext/pom.xml b/dist/server-lib-ext/pom.xml index 3fd0d73ac..22e6af5c3 100644 --- a/dist/server-lib-ext/pom.xml +++ b/dist/server-lib-ext/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-dist - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/dist/server-lib/pom.xml b/dist/server-lib/pom.xml index 36e14f049..6583e5403 100644 --- a/dist/server-lib/pom.xml +++ b/dist/server-lib/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-dist - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/client-android/pom.xml b/ext/client-android/pom.xml index 25935e311..ca94d45da 100644 --- a/ext/client-android/pom.xml +++ b/ext/client-android/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-ext - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/client-proxy/pom.xml b/ext/client-proxy/pom.xml index 48ecef780..ec6064324 100644 --- a/ext/client-proxy/pom.xml +++ b/ext/client-proxy/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-ext - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/karaf/karaf-features/pom.xml b/ext/karaf/karaf-features/pom.xml index 91a6a7420..8cfa0a9cc 100644 --- a/ext/karaf/karaf-features/pom.xml +++ b/ext/karaf/karaf-features/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-karaf - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/karaf/karaf-fit/pom.xml b/ext/karaf/karaf-fit/pom.xml index a4e81179a..610810e8a 100644 --- a/ext/karaf/karaf-fit/pom.xml +++ b/ext/karaf/karaf-fit/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-karaf - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java index 72ea909d3..800d022e8 100644 --- a/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java +++ b/ext/karaf/karaf-fit/src/test/java/org/apache/olingo/osgi/itests/server/CarServiceTest.java @@ -96,7 +96,7 @@ public Option[] config() { return new Option[] { olingoBaseConfig(), features(olingoUrl, "olingo-server", "olingo-client"), - mavenBundle("org.apache.olingo", "odata-server-osgi-sample", "5.0.1-SNAPSHOT"), + mavenBundle("org.apache.olingo", "odata-server-osgi-sample", "5.0.2-SNAPSHOT"), logLevel(LogLevel.INFO) }; } diff --git a/ext/karaf/pom.xml b/ext/karaf/pom.xml index 42c32fceb..e7c5d0ebc 100644 --- a/ext/karaf/pom.xml +++ b/ext/karaf/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-ext - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/pojogen-maven-plugin/pom.xml b/ext/pojogen-maven-plugin/pom.xml index 3622f5f8d..26c473b90 100644 --- a/ext/pojogen-maven-plugin/pom.xml +++ b/ext/pojogen-maven-plugin/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-ext - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/ext/pom.xml b/ext/pom.xml index e0239dd6f..5ecc4d93a 100644 --- a/ext/pom.xml +++ b/ext/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/fit/pom.xml b/fit/pom.xml index f0c137771..541acaef0 100644 --- a/fit/pom.xml +++ b/fit/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT diff --git a/lib/client-api/pom.xml b/lib/client-api/pom.xml index da9f52ee1..5fdbc3828 100644 --- a/lib/client-api/pom.xml +++ b/lib/client-api/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/client-core/pom.xml b/lib/client-core/pom.xml index a5c2b7ac3..86327f4df 100644 --- a/lib/client-core/pom.xml +++ b/lib/client-core/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/commons-api/pom.xml b/lib/commons-api/pom.xml index 53cfc2b53..7c507f139 100644 --- a/lib/commons-api/pom.xml +++ b/lib/commons-api/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/commons-core/pom.xml b/lib/commons-core/pom.xml index 10cdc758d..e14f4bc64 100644 --- a/lib/commons-core/pom.xml +++ b/lib/commons-core/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/pom.xml b/lib/pom.xml index d1b447216..7de4abe94 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml index 924c94364..b364d8472 100644 --- a/lib/server-api/pom.xml +++ b/lib/server-api/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/server-core-ext/pom.xml b/lib/server-core-ext/pom.xml index e5205ad09..1dcdb1a9a 100644 --- a/lib/server-core-ext/pom.xml +++ b/lib/server-core-ext/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml index 46cec3880..34ca068d7 100644 --- a/lib/server-core/pom.xml +++ b/lib/server-core/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml index 44423cee7..13312019b 100644 --- a/lib/server-tecsvc/pom.xml +++ b/lib/server-tecsvc/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/lib/server-test/pom.xml b/lib/server-test/pom.xml index a1588e615..38dd60de1 100644 --- a/lib/server-test/pom.xml +++ b/lib/server-test/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-lib - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/pom.xml b/pom.xml index ae98f9048..1807635bf 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT pom Olingo-OData diff --git a/samples/client/pom.xml b/samples/client/pom.xml index f67944f57..dec4048b4 100644 --- a/samples/client/pom.xml +++ b/samples/client/pom.xml @@ -31,7 +31,7 @@ org.apache.olingo odata-samples - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/samples/osgi/server/pom.xml b/samples/osgi/server/pom.xml index 521ee2210..db1e1de86 100644 --- a/samples/osgi/server/pom.xml +++ b/samples/osgi/server/pom.xml @@ -30,7 +30,7 @@ under the License. org.apache.olingo odata-samples - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ../.. diff --git a/samples/pom.xml b/samples/pom.xml index 37f922b44..5317b328c 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-parent - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/samples/server/pom.xml b/samples/server/pom.xml index e2829c5a2..9049ab7fe 100644 --- a/samples/server/pom.xml +++ b/samples/server/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-samples - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. diff --git a/samples/tutorials/p0_all/pom.xml b/samples/tutorials/p0_all/pom.xml index 4690641f2..4c8da8e11 100644 --- a/samples/tutorials/p0_all/pom.xml +++ b/samples/tutorials/p0_all/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId} Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p10_media/pom.xml b/samples/tutorials/p10_media/pom.xml index 15f778488..11951aaca 100644 --- a/samples/tutorials/p10_media/pom.xml +++ b/samples/tutorials/p10_media/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-Media war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p11_batch/pom.xml b/samples/tutorials/p11_batch/pom.xml index 5561f4ef4..a6197aa55 100644 --- a/samples/tutorials/p11_batch/pom.xml +++ b/samples/tutorials/p11_batch/pom.xml @@ -25,13 +25,13 @@ my.group.id DemoService-Batch war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 17 3.11.0 diff --git a/samples/tutorials/p12_deep_insert/pom.xml b/samples/tutorials/p12_deep_insert/pom.xml index b5ac082ef..e4897c86a 100644 --- a/samples/tutorials/p12_deep_insert/pom.xml +++ b/samples/tutorials/p12_deep_insert/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-DeepInsert war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p12_deep_insert_preparation/pom.xml b/samples/tutorials/p12_deep_insert_preparation/pom.xml index b95e6b989..8fcdce1eb 100644 --- a/samples/tutorials/p12_deep_insert_preparation/pom.xml +++ b/samples/tutorials/p12_deep_insert_preparation/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-DeepInsertPreparation war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p1_read/pom.xml b/samples/tutorials/p1_read/pom.xml index baf1bc5c7..3c57021df 100755 --- a/samples/tutorials/p1_read/pom.xml +++ b/samples/tutorials/p1_read/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-Read war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p2_readep/pom.xml b/samples/tutorials/p2_readep/pom.xml index a0801233e..cf7a64c24 100755 --- a/samples/tutorials/p2_readep/pom.xml +++ b/samples/tutorials/p2_readep/pom.xml @@ -9,7 +9,7 @@ my.group.id DemoService-ReadEp war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -19,7 +19,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p3_write/pom.xml b/samples/tutorials/p3_write/pom.xml index 8bf3f9de0..bfd58c6ae 100755 --- a/samples/tutorials/p3_write/pom.xml +++ b/samples/tutorials/p3_write/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-Write war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p4_navigation/pom.xml b/samples/tutorials/p4_navigation/pom.xml index c6e23da1e..399575af4 100755 --- a/samples/tutorials/p4_navigation/pom.xml +++ b/samples/tutorials/p4_navigation/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-Navigation war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p5_queryoptions-tcs/pom.xml b/samples/tutorials/p5_queryoptions-tcs/pom.xml index 6ce71d091..eb9eb1b27 100755 --- a/samples/tutorials/p5_queryoptions-tcs/pom.xml +++ b/samples/tutorials/p5_queryoptions-tcs/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-QueryOptions-TCS war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p6_queryoptions-es/pom.xml b/samples/tutorials/p6_queryoptions-es/pom.xml index 463e7f1b5..0b2722d49 100755 --- a/samples/tutorials/p6_queryoptions-es/pom.xml +++ b/samples/tutorials/p6_queryoptions-es/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-QueryOptions-ES war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p7_queryoptions-o/pom.xml b/samples/tutorials/p7_queryoptions-o/pom.xml index 228f64d29..a75be3eaf 100644 --- a/samples/tutorials/p7_queryoptions-o/pom.xml +++ b/samples/tutorials/p7_queryoptions-o/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-QueryOptions-O war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p8_queryoptions-f/pom.xml b/samples/tutorials/p8_queryoptions-f/pom.xml index bf788f556..64328eb84 100644 --- a/samples/tutorials/p8_queryoptions-f/pom.xml +++ b/samples/tutorials/p8_queryoptions-f/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-QueryOptions-F war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId} Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p9_action/pom.xml b/samples/tutorials/p9_action/pom.xml index 926abf9f4..986d28f7f 100644 --- a/samples/tutorials/p9_action/pom.xml +++ b/samples/tutorials/p9_action/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-Action war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/p9_action_preparation/pom.xml b/samples/tutorials/p9_action_preparation/pom.xml index 1a51df707..a0a4ac3b4 100644 --- a/samples/tutorials/p9_action_preparation/pom.xml +++ b/samples/tutorials/p9_action_preparation/pom.xml @@ -25,7 +25,7 @@ my.group.id DemoService-ActionPreparation war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -35,7 +35,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/pe_streaming/pom.xml b/samples/tutorials/pe_streaming/pom.xml index 8e9f1d65a..a76e53a71 100755 --- a/samples/tutorials/pe_streaming/pom.xml +++ b/samples/tutorials/pe_streaming/pom.xml @@ -9,7 +9,7 @@ my.group.id DemoService-Streaming war - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT ${project.artifactId}-Webapp @@ -19,7 +19,7 @@ 2.5 - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT 1.7.7 diff --git a/samples/tutorials/pom.xml b/samples/tutorials/pom.xml index 2e43744c6..eb55f0ed4 100644 --- a/samples/tutorials/pom.xml +++ b/samples/tutorials/pom.xml @@ -30,7 +30,7 @@ org.apache.olingo odata-samples - 5.0.1-SNAPSHOT + 5.0.2-SNAPSHOT .. From 8b25568f87447d2db0c9de843bdc621cd5961f05 Mon Sep 17 00:00:00 2001 From: thiagotognoli Date: Wed, 6 Aug 2025 17:04:41 -0300 Subject: [PATCH 3/3] Adds support for dynamic property options in aggregate expressions Introduces a mechanism to associate options, such as scale, with dynamic properties in aggregation expressions. Enhances flexibility for aggregate calculations, especially for methods requiring specific decimal precision. Improves property handling during parsing and type construction to better align with aggregation semantics. This implementation was necessary to fix an issue where aggregations using sum on decimal values caused errors in the JSON serializer due to missing scale information. --- .../apply/AggregateExpression.java | 18 ++++++++ ...egateExpressionDynamicPropertyOptions.java | 26 +++++++++++ .../server/core/uri/parser/ApplyParser.java | 45 ++++++++++++++----- .../apply/AggregateExpressionImpl.java | 20 +++++++-- 4 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpressionDynamicPropertyOptions.java diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpression.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpression.java index 44c3b8d3b..565c6628a 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpression.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpression.java @@ -19,6 +19,7 @@ package org.apache.olingo.server.api.uri.queryoption.apply; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -85,9 +86,26 @@ public enum StandardMethod { SUM, MIN, MAX, AVERAGE, COUNT_DISTINCT } */ Set getDynamicProperties(); + + /** + * Gets the dynamic properties for aggregation expression. + * @return the set of properties + */ + Map getDynamicPropertiesWithOptions(); + + /** * Adds the dynamic property for aggregation expression. * @param name an identifier */ void addDynamicProperty(String name); + + /** + * Adds the dynamic property for aggregation expression. + * @param name an identifier + * @param options the options for the dynamic property + */ + void addDynamicProperty(String name, AggregateExpressionDynamicPropertyOptions options); + } + diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpressionDynamicPropertyOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpressionDynamicPropertyOptions.java new file mode 100644 index 000000000..018d19c5a --- /dev/null +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/apply/AggregateExpressionDynamicPropertyOptions.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.server.api.uri.queryoption.apply; + +/** + * Represents the options for dynamic properties in aggregate expressions. + */ +public class AggregateExpressionDynamicPropertyOptions { + public Integer scale; +} \ No newline at end of file diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java index 71404d206..582154597 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ApplyParser.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumMap; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -54,6 +54,7 @@ import org.apache.olingo.server.api.uri.queryoption.apply.Aggregate; import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression; import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression.StandardMethod; +import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpressionDynamicPropertyOptions; import org.apache.olingo.server.api.uri.queryoption.apply.BottomTop; import org.apache.olingo.server.api.uri.queryoption.apply.Compute; import org.apache.olingo.server.api.uri.queryoption.apply.Concat; @@ -223,22 +224,37 @@ private ApplyItem parseTrafo(EdmStructuredType referencedType) throws UriParserE private Aggregate parseAggregateTrafo(EdmStructuredType referencedType) throws UriParserException, UriValidationException { AggregateImpl aggregate = new AggregateImpl(); - Set dynamicProps = new HashSet<>(); + Map dynamicProps = new HashMap<>(); do { - AggregateExpression aggregateExpr = parseAggregateExpr(referencedType, dynamicProps, Requirement.REQUIRED); - aggregate.addExpression(aggregateExpr); - dynamicProps.addAll(aggregateExpr.getDynamicProperties()); + AggregateExpression aggregateExpr = parseAggregateExpr( + referencedType, + dynamicProps.keySet(), + Requirement.REQUIRED + ); + aggregate.addExpression(aggregateExpr); + dynamicProps.putAll(aggregateExpr.getDynamicPropertiesWithOptions()); } while (tokenizer.next(TokenKind.COMMA)); - dynamicProps.forEach(dp -> addPropertyToRefType(referencedType, dp)); + dynamicProps.keySet().forEach(dp -> + addPropertyToRefType(referencedType, dp, dynamicProps.get(dp)) + ); ParserHelper.requireNext(tokenizer, TokenKind.CLOSE); return aggregate; } - private void addPropertyToRefType(EdmStructuredType referencedType, String alias) { - ((DynamicStructuredType) referencedType).addProperty( - createDynamicProperty(alias, - // The OData standard mandates Edm.Decimal (with no decimals), although counts are always integer. - odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal))); + private void addPropertyToRefType( + EdmStructuredType referencedType, + String alias, + AggregateExpressionDynamicPropertyOptions options + ) { + DynamicProperty dynamicProperty = createDynamicProperty( + alias, + odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal) + ); + if (options != null && options.scale != null) { + dynamicProperty.setScale(options.scale); + } + + ((DynamicStructuredType) referencedType).addProperty(dynamicProperty); } public AggregateExpression parseAggregateMethodCallExpr(UriTokenizer tokenizer, EdmStructuredType referringType) @@ -300,7 +316,12 @@ private AggregateExpression parseAggregateExpr(EdmStructuredType referencedType, final String alias = parseAsAlias(referencedType, dynamicProps, aliasRequired); if(alias != null) { aggregateExpression.setAlias(alias); - aggregateExpression.addDynamicProperty(alias); + AggregateExpressionDynamicPropertyOptions options = new AggregateExpressionDynamicPropertyOptions(); + if (aggregateExpression.getStandardMethod() == StandardMethod.SUM + || aggregateExpression.getStandardMethod() == StandardMethod.AVERAGE) { + options.scale = Integer.MAX_VALUE; + } + aggregateExpression.addDynamicProperty(alias, options); } parseAggregateFrom(aggregateExpression, referencedType); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/AggregateExpressionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/AggregateExpressionImpl.java index 63baa1cda..8b9508a5f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/AggregateExpressionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/apply/AggregateExpressionImpl.java @@ -20,8 +20,9 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -29,6 +30,7 @@ import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression; +import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpressionDynamicPropertyOptions; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; @@ -45,7 +47,7 @@ public class AggregateExpressionImpl implements AggregateExpression { private String alias; private AggregateExpression inlineAggregateExpression; private List from = new ArrayList<>(); - private Set dynamicProperties = new HashSet<>(); + private Map dynamicProperties = new HashMap<>(); @Override public List getPath() { @@ -125,11 +127,21 @@ public T accept(ExpressionVisitor visitor) throws ExpressionVisitExceptio @Override public Set getDynamicProperties() { - return Collections.unmodifiableSet(dynamicProperties); + return Collections.unmodifiableSet(dynamicProperties.keySet()); } @Override public void addDynamicProperty(String name) { - dynamicProperties.add(name); + dynamicProperties.put(name, null); + } + + @Override + public void addDynamicProperty(String name, AggregateExpressionDynamicPropertyOptions options) { + dynamicProperties.put(name, options); + } + + @Override + public Map getDynamicPropertiesWithOptions() { + return Collections.unmodifiableMap(dynamicProperties); } }