Skip to content

Commit 640b0d4

Browse files
committed
adressing pitest
1 parent 7099f0b commit 640b0d4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,29 @@ void shouldNotLogWarningThatAckIsIgnoredWhenAcknowledgementReceivedAfterWithinAn
226226
.warn("Received an ACK message with a conversationId: {} that is a duplicate", conversationId);
227227
}
228228

229+
@Test
230+
void receiveExceptionWhenEhrExtractStatusIsNull() {
231+
232+
EhrExtractStatusService ehrExtractStatusServiceSpy = spy(ehrExtractStatusService);
233+
String conversationId = generateRandomUppercaseUUID();
234+
Instant currentInstant = Instant.now();
235+
Optional<EhrExtractStatus> ehrExtractStatus = Optional.of(EhrExtractStatus.builder().ehrExtractCorePending(null).build());
236+
237+
doReturn(true).when(ehrExtractStatusServiceSpy).isEhrStatusWaitingForFinalAck(conversationId);
238+
doReturn(false).when(ehrExtractStatusServiceSpy).hasFinalAckBeenReceived(conversationId);
239+
doReturn(ehrExtractStatus).when(ehrExtractStatusRepository).findByConversationId(conversationId);
240+
when(ack.getErrors()).thenReturn(null);
241+
when(ack.getReceived()).thenReturn(currentInstant);
242+
doReturn(null)
243+
.when(mongoTemplate).findAndModify(any(Query.class), any(Update.class), any(FindAndModifyOptions.class), any(Class.class));
244+
245+
Exception ehrExtractException = assertThrows(EhrExtractException.class,
246+
() -> ehrExtractStatusServiceSpy.updateEhrExtractStatusAck(conversationId, ack));
247+
248+
assertTrue(ehrExtractException.getMessage()
249+
.contains(format("Received an ACK message with a conversationId %s that is not recognised", conversationId)));
250+
}
251+
229252
@Test
230253
void updateEhrExtractStatusWhenEhrExtractCorePendingIsNull() {
231254

0 commit comments

Comments
 (0)