From 2a0999f8f5e6c9f6b935c740efd2f3bdee9681d8 Mon Sep 17 00:00:00 2001 From: Morphyum Date: Tue, 15 Mar 2022 11:24:21 +0100 Subject: [PATCH] * inject objectMapper via Dependency Injection * added format to expires JSON Conversion --- .../connector/DgcGatewayRevocationListUploadConnector.java | 6 +++--- .../ec/dgc/gateway/connector/dto/RevocationBatchDto.java | 2 ++ .../connector/RevocationListUploadConnectorTest.java | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/europa/ec/dgc/gateway/connector/DgcGatewayRevocationListUploadConnector.java b/src/main/java/eu/europa/ec/dgc/gateway/connector/DgcGatewayRevocationListUploadConnector.java index f17c900..2be8bb9 100644 --- a/src/main/java/eu/europa/ec/dgc/gateway/connector/DgcGatewayRevocationListUploadConnector.java +++ b/src/main/java/eu/europa/ec/dgc/gateway/connector/DgcGatewayRevocationListUploadConnector.java @@ -113,8 +113,8 @@ void init() throws KeyStoreException, CertificateEncodingException, IOException public String uploadRevocationBatch(RevocationBatchDto revocationBatchDto) throws DgcRevocationBatchUploadException, JsonProcessingException { - mapper.registerModule(new JavaTimeModule()); - String jsonString = mapper.writeValueAsString(revocationBatchDto); + objectMapper.registerModule(new JavaTimeModule()); + String jsonString = objectMapper.writeValueAsString(revocationBatchDto); String payload = new SignedStringMessageBuilder().withPayload(jsonString) .withSigningCertificate(uploadCertificateHolder, uploadCertificatePrivateKey).buildAsString(); @@ -149,7 +149,7 @@ public void deleteRevocationBatch(String batchId) throws DgcRevocationBatchUploa RevocationBatchDeleteRequestDto deleteRequest = new RevocationBatchDeleteRequestDto(); deleteRequest.setBatchId(batchId); - String jsonString = mapper.writeValueAsString(deleteRequest); + String jsonString = objectMapper.writeValueAsString(deleteRequest); String payload = new SignedStringMessageBuilder().withPayload(jsonString) .withSigningCertificate(uploadCertificateHolder, uploadCertificatePrivateKey).buildAsString(); diff --git a/src/main/java/eu/europa/ec/dgc/gateway/connector/dto/RevocationBatchDto.java b/src/main/java/eu/europa/ec/dgc/gateway/connector/dto/RevocationBatchDto.java index 096537e..bd6eb0e 100644 --- a/src/main/java/eu/europa/ec/dgc/gateway/connector/dto/RevocationBatchDto.java +++ b/src/main/java/eu/europa/ec/dgc/gateway/connector/dto/RevocationBatchDto.java @@ -20,6 +20,7 @@ package eu.europa.ec.dgc.gateway.connector.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.ZonedDateTime; import java.util.List; import lombok.AllArgsConstructor; @@ -34,6 +35,7 @@ public class RevocationBatchDto { private String country; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") private ZonedDateTime expires; private String kid; diff --git a/src/test/java/eu/europa/ec/dgc/gateway/connector/RevocationListUploadConnectorTest.java b/src/test/java/eu/europa/ec/dgc/gateway/connector/RevocationListUploadConnectorTest.java index 3f7b32d..318d8c5 100644 --- a/src/test/java/eu/europa/ec/dgc/gateway/connector/RevocationListUploadConnectorTest.java +++ b/src/test/java/eu/europa/ec/dgc/gateway/connector/RevocationListUploadConnectorTest.java @@ -85,7 +85,6 @@ void testUploadOfRevocationList() throws Exception { verify(restClientMock).uploadBatch(any()); SignedStringMessageParser parser = new SignedStringMessageParser(argumentCaptor.getValue()); - Assertions.assertEquals(getRevocationJSON(), parser.getPayload()); Assertions.assertEquals(certificateUtils.convertCertificate(testKeyStore.getUpload()), parser.getSigningCertificate());