Skip to content

Commit 1cd0389

Browse files
committed
logs formatting improvement
1 parent ba8a5f7 commit 1cd0389

File tree

6 files changed

+32
-34
lines changed

6 files changed

+32
-34
lines changed

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/EhrExtractStatusService.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void saveEhrExtractMessageId(String conversationId, String messageId) {
161161
ehrExtractStatusRepository.save(ehrExtractStatus);
162162
},
163163
() -> {
164-
throw new EhrExtractException("Unable to find EHR Extract status with conversation id " + conversationId);
164+
throw new EhrExtractException("Unable to find EHR Extract status with conversationId " + conversationId);
165165
});
166166
}
167167

@@ -314,8 +314,8 @@ public Optional<EhrExtractStatus> updateEhrExtractStatusContinue(String conversa
314314
EhrExtractStatus.class);
315315

316316
if (ehrExtractStatus == null) {
317-
throw new EhrExtractException("Received a Continue message with a conversation_id '" + conversationId
318-
+ "' that is not recognised");
317+
throw new EhrExtractException(format("Received a Continue message with a conversationId %s that is not recognised",
318+
conversationId));
319319
}
320320

321321
LOGGER.info("Database successfully updated with EHRContinue");
@@ -342,34 +342,34 @@ public void updateEhrExtractStatusWithEhrReceivedAckError(String conversationId,
342342

343343
if (ehrExtractStatus == null) {
344344
throw new EhrExtractException(format(
345-
"Couldn't update EHR received acknowledgement with error information because EHR status doesn't exist, conversation_id: %s",
345+
"Couldn't update EHR received acknowledgement with error information because EHR status doesn't exist, conversationId: %s",
346346
conversationId));
347347
}
348348

349349
logger().info("EHR status (EHR received acknowledgement) record successfully "
350-
+ "updated in the database with error information conversation_id: {}", conversationId);
350+
+ "updated in the database with error information conversationId: {}", conversationId);
351351

352352
}
353353

354354
public void updateEhrExtractStatusAck(String conversationId, EhrReceivedAcknowledgement ack) {
355355

356356
if (ack.getErrors() == null && !isEhrStatusWaitingForFinalAck(conversationId)) {
357-
logger().warn("Received unexpected acknowledgement of EHR Extract with conversation id=" + conversationId);
357+
logger().warn("Received unexpected acknowledgement of EHR Extract with conversationId: {}", conversationId);
358358
return;
359359
}
360360

361361
if (hasAcknowledgementExceededAckTimeoutLimit(conversationId, ack.getReceived())
362362
&& hasEhrStatusReceivedAckWithErrors(conversationId)) {
363363

364-
logger().warn("Received an ACK message with conversation_id: {}, "
364+
logger().warn("Received an ACK message with conversationId: {}, "
365365
+ "but it is being ignored because the EhrExtract has already been marked as failed "
366366
+ "from not receiving an acknowledgement from the requester in time.",
367367
conversationId);
368368
return;
369369
}
370370

371371
if (hasFinalAckBeenReceived(conversationId)) {
372-
logger().warn("Received an ACK message with a conversation_id: {} that is a duplicate", conversationId);
372+
logger().warn("Received an ACK message with a conversationId: {} that is a duplicate", conversationId);
373373
return;
374374
}
375375

@@ -396,11 +396,11 @@ && hasEhrStatusReceivedAckWithErrors(conversationId)) {
396396
EhrExtractStatus.class);
397397

398398
if (ehrExtractStatus == null) {
399-
throw new EhrExtractException("Received an ACK message with a conversation_id '" + conversationId
400-
+ "' that is not recognised");
399+
throw new EhrExtractException(format("Received an ACK message with a conversationId %s that is not recognised",
400+
conversationId));
401401
}
402402

403-
logger().info("Database successfully updated with EHRAcknowledgement, conversation_id: {}", conversationId);
403+
logger().info("Database successfully updated with EHRAcknowledgement, conversationId: {}", conversationId);
404404
}
405405

406406
public void saveAckForConversation(String conversationId, EhrReceivedAcknowledgement ack) {
@@ -502,10 +502,10 @@ public EhrExtractStatus updateEhrExtractStatusError(
502502

503503
if (ehrExtractStatus == null) {
504504
throw new EhrExtractException(format(
505-
"Couldn't update EHR status with error information because it doesn't exist conversation_id: %s", conversationId));
505+
"Couldn't update EHR status with error information because it doesn't exist conversationId: %s", conversationId));
506506
}
507507

508-
logger().info("EHR status record successfully updated in the database with error information conversation_id: {}", conversationId);
508+
logger().info("EHR status record successfully updated in the database with error information conversationId: {}", conversationId);
509509

510510
return ehrExtractStatus;
511511
}
@@ -631,8 +631,7 @@ private boolean checkForContinueOutOfOrderAndDuplicate(String conversationId) {
631631
}
632632

633633
if (ehrExtractStatus.getEhrContinue() != null) {
634-
LOGGER.warn("Received a Continue message with a conversation_id '" + conversationId
635-
+ "' that is duplicate");
634+
LOGGER.warn("Received a Continue message with a conversationId {} that is duplicate", conversationId);
636635
return true;
637636
}
638637

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/scheduling/EhrExtractTimeoutScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void processEhrExtractAckTimeouts() {
4545

4646
} catch (EhrExtractException exception) {
4747

48-
logger().error("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversation_id: {}",
48+
logger().error("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversationId: {}",
4949
ehrExtractStatus.getConversationId(), exception);
5050
throw exception;
5151
} catch (Exception exception) {

service/src/main/java/uk/nhs/adaptors/gp2gp/mhs/exception/UnrecognisedInteractionIdException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class UnrecognisedInteractionIdException extends RuntimeException {
44

5-
private static final String EXCEPTION_MESSAGE = "Received an unrecognized %s message with conversation_id: %s";
5+
private static final String EXCEPTION_MESSAGE = "Received an unrecognized %s message with conversationId: %s";
66

77
public UnrecognisedInteractionIdException(String messageType, String conversationId) {
88
super(EXCEPTION_MESSAGE.formatted(messageType, conversationId));

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/EhrExtractStatusServiceTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void shouldLogWarningWhenLateAcknowledgementReceivedAfter8DaysAndEhrReceivedAckH
112112
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack);
113113

114114
verify(logger, times(1))
115-
.warn("Received an ACK message with conversation_id: {}, "
115+
.warn("Received an ACK message with conversationId: {}, "
116116
+ "but it is being ignored because the EhrExtract has already been marked as failed "
117117
+ "from not receiving an acknowledgement from the requester in time.",
118118
conversationId);
@@ -144,9 +144,9 @@ void shouldNotLogWarningThatAckIsIgnoredWhenAcknowledgementReceivedAfter8Days()
144144
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack);
145145

146146
verify(logger, never())
147-
.warn("Received an ACK message with a conversation_id: {}, but it will be ignored", conversationId);
147+
.warn("Received an ACK message with a conversationId: {}, but it will be ignored", conversationId);
148148
verify(logger, times(1))
149-
.warn("Received an ACK message with a conversation_id: {} that is a duplicate", conversationId);
149+
.warn("Received an ACK message with a conversationId: {} that is a duplicate", conversationId);
150150
}
151151

152152
@Test
@@ -166,7 +166,7 @@ void shouldUpdateStatusWithErrorAndSpecificErrorCodeAndMessage() {
166166
ERROR_MESSAGE);
167167

168168
verify(logger).info("EHR status (EHR received acknowledgement) record successfully "
169-
+ "updated in the database with error information conversation_id: {}", inProgressConversationId);
169+
+ "updated in the database with error information conversationId: {}", inProgressConversationId);
170170
verify(mongoTemplate, times(1)).findAndModify(queryCaptor.capture(),
171171
updateCaptor.capture(),
172172
any(FindAndModifyOptions.class),
@@ -219,9 +219,9 @@ void shouldNotLogWarningThatAckIsIgnoredWhenAcknowledgementReceivedAfterWithinAn
219219
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack);
220220

221221
verify(logger, never())
222-
.warn("Received an ACK message with a conversation_id: {}, but it will be ignored", conversationId);
222+
.warn("Received an ACK message with a conversationId: {}, but it will be ignored", conversationId);
223223
verify(logger, times(1))
224-
.warn("Received an ACK message with a conversation_id: {} that is a duplicate", conversationId);
224+
.warn("Received an ACK message with a conversationId: {} that is a duplicate", conversationId);
225225
}
226226

227227
@Test
@@ -243,9 +243,9 @@ void updateEhrExtractStatusWhenEhrExtractCorePendingIsNull() {
243243

244244
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack);
245245

246-
verify(logger, never()).warn("Received an ACK message with a conversation_id={} exceeded 8 days", conversationId);
246+
verify(logger, never()).warn("Received an ACK message with a conversationId={} exceeded 8 days", conversationId);
247247
verify(logger, times(1))
248-
.info("Database successfully updated with EHRAcknowledgement, conversation_id: {}", conversationId);
248+
.info("Database successfully updated with EHRAcknowledgement, conversationId: {}", conversationId);
249249
}
250250

251251
@Test
@@ -262,7 +262,7 @@ void ehrExtractStatusThrowsExceptionWhenConversationIdNotFound() {
262262
Exception exception = assertThrows(UnrecognisedInteractionIdException.class, () ->
263263
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack));
264264

265-
assertEquals("Received an unrecognized ACK message with conversation_id: " + conversationId,
265+
assertEquals("Received an unrecognized ACK message with conversationId: " + conversationId,
266266
exception.getMessage());
267267

268268
verify(ehrExtractStatusServiceSpy, never()).updateEhrExtractStatusError(conversationId,
@@ -404,7 +404,7 @@ void shouldUpdateStatusWithErrorWhenEhrExtractAckTimeoutOccurs() {
404404
ERROR_MESSAGE);
405405

406406
verify(logger).info("EHR status (EHR received acknowledgement) record successfully "
407-
+ "updated in the database with error information conversation_id: {}", inProgressConversationId);
407+
+ "updated in the database with error information conversationId: {}", inProgressConversationId);
408408
}
409409

410410

@@ -521,7 +521,7 @@ void shouldLogWarningWithMsgIgnoredWhenLateAcknowledgementReceivedAfter8DaysAndE
521521
ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack);
522522

523523
verify(logger, times(1))
524-
.warn("Received an ACK message with conversation_id: {}, "
524+
.warn("Received an ACK message with conversationId: {}, "
525525
+ "but it is being ignored because the EhrExtract has already been marked as failed "
526526
+ "from not receiving an acknowledgement from the requester in time.",
527527
conversationId);

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/AgentPersonMapperTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public void setUp() {
5757

5858
@ParameterizedTest
5959
@MethodSource("readPractitionerRoleTests")
60-
public void When_MappingPractitionerToAgent_Expect_RepresentedAgentXml(String practitionerRoleJson, String outputXml)
61-
throws IOException {
60+
public void When_MappingPractitionerToAgent_Expect_RepresentedAgentXml(String practitionerRoleJson, String outputXml) {
6261

6362
var jsonInputPractitionerRole = ResourceTestFileUtils.getFileContent(practitionerRoleJson);
6463
var expectedOutput = ResourceTestFileUtils.getFileContent(outputXml);

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/scheduling/EhrExtractTimeoutSchedulerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ void updateEhrExtractStatusListWithEhrReceivedAcknowledgementError() {
297297

298298
() -> assertEquals(
299299
"Couldn't update EHR received acknowledgement with error information because EHR status doesn't exist, "
300-
+ "conversation_id: " + inProgressConversationId, exception.getMessage()),
300+
+ "conversationId: " + inProgressConversationId, exception.getMessage()),
301301
() -> verify(logger)
302-
.error(eq("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversation_id: {}"),
302+
.error(eq("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversationId: {}"),
303303
eq(inProgressConversationId),
304304
any(EhrExtractException.class))
305305
);
@@ -342,8 +342,8 @@ void whenEhrExtractStatusIsNullInterceptExceptionAndLogErrorMsg() {
342342
var exception = assertThrows(EhrExtractException.class, ehrExtractTimeoutSchedulerSpy::processEhrExtractAckTimeouts);
343343

344344
assertEquals("Couldn't update EHR received acknowledgement with error information because EHR status doesn't exist, "
345-
+ "conversation_id: " + inProgressConversationId, exception.getMessage());
346-
verify(logger).error(eq("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversation_id: {}"),
345+
+ "conversationId: " + inProgressConversationId, exception.getMessage());
346+
verify(logger).error(eq("An error occurred when updating EHR Extract with Ack erorrs, EHR Extract Status conversationId: {}"),
347347
eq(inProgressConversationId),
348348
any(EhrExtractException.class));
349349
}

0 commit comments

Comments
 (0)