Skip to content

Commit

Permalink
Merge pull request #538 from commercetools/head-deserialize-fix
Browse files Browse the repository at this point in the history
fix deserialization of head API requests
  • Loading branch information
jenschude authored Jan 5, 2024
2 parents ee51cb9 + fdd1722 commit 8c4da5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public void queryById() {
});
}

@Test
public void exists() {
CartsFixtures.withCart(cart -> {
int statusCode = CommercetoolsTestUtils.getProjectApiRoot()
.carts()
.withKey(cart.getKey())
.head()
.executeBlocking()
.getStatusCode();
Assertions.assertThat(statusCode).isEqualTo(200);
});
}

@Test
public void queryByKey() {
CartsFixtures.withCart(cart -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ResponseSerializerImpl(final ObjectMapper mapper) {

public <O> ApiHttpResponse<O> convertResponse(final ApiHttpResponse<byte[]> response, final Class<O> outputType) {
try {
if (response.getBody() == null) {
if (response.getBody() == null || response.getBody().length == 0) {
return (ApiHttpResponse<O>) response;
}
O newBody = mapper.readValue(response.getBody(), outputType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static String bytesToUTF8String(final byte[] input) {

public static <I, O> ApiHttpResponse<O> convertResponse(final ApiHttpResponse<byte[]> response,
final Class<O> outputType) {
if (response.getBody() == null) {
if (response.getBody() == null || response.getBody().length == 0) {
return (ApiHttpResponse<O>) response;
}
O newBody = JsonUtils.fromJsonByteArray(response.getBody(), outputType);
Expand Down

0 comments on commit 8c4da5d

Please sign in to comment.