diff --git a/datamodel/odata-v4/odata-v4-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/sample/SdkGroceryStoreServiceTest.java b/datamodel/odata-v4/odata-v4-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/sample/SdkGroceryStoreServiceTest.java index 4198794c7..b084845b6 100644 --- a/datamodel/odata-v4/odata-v4-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/sample/SdkGroceryStoreServiceTest.java +++ b/datamodel/odata-v4/odata-v4-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/sample/SdkGroceryStoreServiceTest.java @@ -7,7 +7,6 @@ import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -116,15 +115,17 @@ void testFilterPurchaseHistory() .build(); final Customer customer = Customer.builder().id(1337).build(); + customer.setVersionIdentifier("123"); + final ActionResponseCollection historyItems = service .forEntity(customer) .applyAction( Customer .filterPurchaseHistory( - Collections.singleton(Receipt.builder().customerId(1337).id(4242).build()), - Arrays.asList("milk", "eggs"), - Arrays.asList(ProductCategory.DAIRY, ProductCategory.MEAT), + List.of(Receipt.builder().customerId(1337).id(4242).build()), + List.of("milk", "eggs"), + List.of(ProductCategory.DAIRY, ProductCategory.MEAT), dateRange)) .execute(destination); diff --git a/datamodel/odata-v4/odata-v4-api-sample/src/test/resources/SdkGroceryStoreServiceTest/mappings/SdkGroceryStoreServiceTest.json b/datamodel/odata-v4/odata-v4-api-sample/src/test/resources/SdkGroceryStoreServiceTest/mappings/SdkGroceryStoreServiceTest.json index 28584daad..0145f3bc0 100644 --- a/datamodel/odata-v4/odata-v4-api-sample/src/test/resources/SdkGroceryStoreServiceTest/mappings/SdkGroceryStoreServiceTest.json +++ b/datamodel/odata-v4/odata-v4-api-sample/src/test/resources/SdkGroceryStoreServiceTest/mappings/SdkGroceryStoreServiceTest.json @@ -208,6 +208,9 @@ "Content-Type": { "equalTo": "application/json" }, + "If-Match": { + "equalTo": "123" + }, "Accept": { "equalTo": "application/json" }, diff --git a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/ServiceWithNavigableEntitiesImpl.java b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/ServiceWithNavigableEntitiesImpl.java index 3e356d324..7437a82d6 100644 --- a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/ServiceWithNavigableEntitiesImpl.java +++ b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/ServiceWithNavigableEntitiesImpl.java @@ -2,6 +2,8 @@ import javax.annotation.Nonnull; +import org.apache.http.HttpHeaders; + import com.sap.cloud.sdk.datamodel.odata.client.expression.ODataResourcePath; import io.vavr.control.Option; @@ -124,10 +126,10 @@ public SingleValueActionRequestBuilder applyAction( action.getReturnType()); maybeEntity .filter(e -> e.getVersionIdentifier().isDefined()) - .map(VdmEntity::getVersionIdentifier) + .map(VdmEntity::getVersionIdentifier) .filter(Option::isDefined) .map(Option::get) - .forEach(eTag -> requestBuilder.withHeader("ETag", eTag)); + .forEach(eTag -> requestBuilder.withHeader(HttpHeaders.IF_MATCH, eTag)); return requestBuilder; } @@ -145,10 +147,10 @@ public CollectionValueActionRequestBuilder applyAction( action.getReturnType()); maybeEntity .filter(e -> e.getVersionIdentifier().isDefined()) - .map(VdmEntity::getVersionIdentifier) + .map(VdmEntity::getVersionIdentifier) .filter(Option::isDefined) .map(Option::get) - .forEach(eTag -> requestBuilder.withHeader("ETag", eTag)); + .forEach(eTag -> requestBuilder.withHeader(HttpHeaders.IF_MATCH, eTag)); return requestBuilder; } } diff --git a/datamodel/odata-v4/odata-v4-core/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/core/BoundActionTest.java b/datamodel/odata-v4/odata-v4-core/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/core/BoundActionTest.java index 0a4394e2b..9b1131288 100644 --- a/datamodel/odata-v4/odata-v4-core/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/core/BoundActionTest.java +++ b/datamodel/odata-v4/odata-v4-core/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/core/BoundActionTest.java @@ -4,6 +4,7 @@ import java.util.Collections; +import org.apache.http.HttpHeaders; import org.junit.jupiter.api.Test; import com.sap.cloud.sdk.datamodel.odatav4.referenceservice.namespaces.trippin.Location; @@ -25,7 +26,8 @@ void testActionOnEntityWithEtag() assertThat(action.toRequest().getRelativeUri()).hasToString(targetUrl); assertThat(action.toRequest().getActionParameters()).hasToString("{}"); - assertThat(action.toRequest().getHeaders()).containsEntry("ETag", Collections.singletonList("some-etag")); + assertThat(action.toRequest().getHeaders()) + .containsEntry(HttpHeaders.IF_MATCH, Collections.singletonList("some-etag")); } @Test @@ -38,7 +40,7 @@ void testActionOnEntityNoEtag() assertThat(action.toRequest().getRelativeUri()).hasToString(targetUrl); assertThat(action.toRequest().getActionParameters()).hasToString("{}"); - assertThat(action.toRequest().getHeaders()).doesNotContainEntry("ETag", Collections.singletonList("some-etag")); + assertThat(action.toRequest().getHeaders()).doesNotContainKey(HttpHeaders.IF_MATCH); } @Test diff --git a/release_notes.md b/release_notes.md index 6bd0c8098..6d660e735 100644 --- a/release_notes.md +++ b/release_notes.md @@ -23,6 +23,7 @@ ### 🐛 Fixed Issues - [OpenAPI] Fix code generator for transitive dependency version inconsistencies for Jackson. -- [ODatav4] Fixed an issue when generating clients. +- [ODatav4] Fix incorrect HTTP header name when sending entity version identifier in bound-action requests. +- [ODatav4] Fix an issue when generating clients. - Property names: `value`, `item` and `properties` are now allowed.