Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ddc81bc
Update HAPI FHIR R4 to version `8.0.0`
MartinWheelerMT May 19, 2025
4e01998
Merge branch 'develop' into update-hapi-fhir-r4-to-8.0.0
MartinWheelerMT May 20, 2025
1040870
Update HAPI FHIR R4 to version `8.0.0`
MartinWheelerMT May 20, 2025
bf9d841
Update DeductionIntegrationTest.java
MartinWheelerMT May 20, 2025
368b1c0
* Address checkstyle [FinalClass] issue (Class <ClassName> should be …
MartinWheelerMT May 20, 2025
fc61412
* Address checkstyle [MethodName] issue (Name `<TestName>` must match…
MartinWheelerMT May 20, 2025
1ff8322
* Address checkstyle [ModifierOrder] issue (`<Modifier>` modifier out…
MartinWheelerMT May 20, 2025
3082386
* Address missed [MethodName] issue.
MartinWheelerMT May 20, 2025
c23c04a
* Address missed [ModifierOrder] issue.
MartinWheelerMT May 20, 2025
65479d0
* Address Line is longer than 140 character issues.
MartinWheelerMT May 20, 2025
c24e472
* Address [WhitespaceAfter / WhitespaceAround] checkstyle issue (`if`…
MartinWheelerMT May 20, 2025
9fe7fc0
* Address missed Line Length checkstyle issue.
MartinWheelerMT May 20, 2025
4ff1a55
* Address [WhitespaceAround] checkstyle issue (`<character>` is not <…
MartinWheelerMT May 20, 2025
da03ced
* Address [UnusedImports] checkstyle issues.
MartinWheelerMT May 20, 2025
47282ec
* Address [RedundantModifier] CheckStyle issues (Redundant `<Modifier…
MartinWheelerMT May 20, 2025
be73bb1
* Address [LocalVariableName] Checkstyle issues (Name `<LocalVariable…
MartinWheelerMT May 21, 2025
9fa4e44
Merge branch 'develop' into checkstyle-fixes
MartinWheelerMT May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.nio.file.Path;

public class ActiveMqContainer extends GenericContainer<ActiveMqContainer> {
public final class ActiveMqContainer extends GenericContainer<ActiveMqContainer> {

public static final int ACTIVEMQ_PORT = 5672;
private static ActiveMqContainer container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.nio.file.Path;

@Slf4j
public class FakeMeshContainer extends GenericContainer<FakeMeshContainer> {
public final class FakeMeshContainer extends GenericContainer<FakeMeshContainer> {

public static final int FAKE_MESH_PORT = 8829;
private static FakeMeshContainer container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.testcontainers.containers.GenericContainer;

@Slf4j
public class MongoDbContainer extends GenericContainer<MongoDbContainer> {
public final class MongoDbContainer extends GenericContainer<MongoDbContainer> {

public static final int MONGODB_PORT = 27017;
public static final String DEFAULT_IMAGE_AND_TAG = "mongo:8.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public class TimeToLiveTest {
private NhaisMongoClientConfiguration mongoConfig;

@Test
void when_ApplicationStarts_then_TtlIndexExistsForInboundStateWithValueFromConfiguration() {
void When_ApplicationStarts_Expect_TtlIndexExistsForInboundStateWithValueFromConfiguration() {
var indexOperations = mongoTemplate.indexOps(InboundState.class);
assertThat(timeToLiveIndexExists(indexOperations)).isTrue();
}

@Test
void when_ApplicationStarts_then_TtlIndexExistsForOutboundStateWithValueFromConfiguration() {
void When_ApplicationStarts_Expect_TtlIndexExistsForOutboundStateWithValueFromConfiguration() {
var indexOperations = mongoTemplate.indexOps(OutboundState.class);
assertThat(timeToLiveIndexExists(indexOperations)).isTrue();
}
Expand All @@ -70,7 +70,7 @@ private boolean timeToLiveIndexExists(IndexOperations indexOperations) {

@Test
@Disabled("Long running test that depends on external TTL config, enable when needed")
void when_TimeToLiveHasPassedInInboundState_then_documentRemoved() {
void When_TimeToLiveHasPassedInInboundState_Expect_DocumentRemoved() {
var inboundState = new InboundState()
.setWorkflowId(WorkflowId.RECEP)
.setSender("some_sender")
Expand All @@ -89,7 +89,7 @@ void when_TimeToLiveHasPassedInInboundState_then_documentRemoved() {

@Test
@Disabled("Long running test that depends on external TTL config, enable when needed")
void when_TimeToLiveHasPassedInOutboundState_then_documentRemoved() {
void When_TimeToLiveHasPassedInOutboundState_Expect_DocumentRemoved() {
var inboundState = new OutboundState()
.setWorkflowId(WorkflowId.RECEP)
.setSender("some_sender")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DeadLetterQueueTest extends IntegrationBaseTest {
private ObjectMapper objectMapper;

@Test
public void whenSendingInvalidMessage_toMeshInboundQueue_thenMessageIsSentToDeadLetterQueue() throws JMSException {
public void When_SendingInvalidMessageToMeshInboundQueue_Expect_MessageIsSentToDeadLetterQueue() throws JMSException {
clearDeadLetterQueue(meshInboundQueueName);
sendToMeshInboundQueue(MESSAGE_CONTENT);

Expand All @@ -48,10 +48,15 @@ public void whenSendingInvalidMessage_toMeshInboundQueue_thenMessageIsSentToDead
}

@Test
public void whenMeshOutboundQueueMessageCannotBeProcessed_thenMessageIsSentToDeadLetterQueue() throws Exception {
public void When_MeshOutboundQueueMessageCannotBeProcessed_Expect_MessageIsSentToDeadLetterQueue() throws Exception {
String conversationId = Long.toString(System.currentTimeMillis());
when(conversationIdService.getCurrentConversationId()).thenReturn(conversationId);
OutboundMeshMessage meshMessage = OutboundMeshMessage.create("XX11", WorkflowId.REGISTRATION, MESSAGE_CONTENT, "2020-01-01T00:00:00Z", "asdf");
OutboundMeshMessage meshMessage = OutboundMeshMessage.create(
"XX11",
WorkflowId.REGISTRATION, MESSAGE_CONTENT,
"2020-01-01T00:00:00Z",
"asdf"
);
doThrow(RuntimeException.class).when(meshClient).authenticate();

clearDeadLetterQueue(meshOutboundQueueName);
Expand All @@ -62,5 +67,4 @@ public void whenMeshOutboundQueueMessageCannotBeProcessed_thenMessageIsSentToDea
assertThat(message.getStringProperty(JmsHeaders.CONVERSATION_ID)).isEqualTo(conversationId);
assertThat(parseTextMessage(message)).isEqualTo(objectMapper.writeValueAsString(meshMessage));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public class InboundMeshQueueMultiTransactionTest extends IntegrationBaseTest {
private static final String TRANSACTION_5_OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN_5);
private static final String TRANSACTION_6_OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN_6);
private static final Instant INTERCHANGE_TRANSLATION_TIMESTAMP = ZonedDateTime
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UKZone)
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UK_ZONE)
.toInstant();

private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 0, 0, TimestampService.UKZone)
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 0, 0, TimestampService.UK_ZONE)
.toInstant();
private static final String ISO_GENERATED_TIMESTAMP = new TimestampService().formatInISO(GENERATED_TIMESTAMP);

Expand Down Expand Up @@ -103,7 +103,9 @@ void setUp() {
}

@Test
void whenMeshInboundQueueRegistrationMessageIsReceived_thenMessageIsHandled(SoftAssertions softly) throws IOException, JMSException, JSONException {
void When_MeshInboundQueueRegistrationMessageIsReceived_Expect_MessageIsHandled(SoftAssertions softly)
throws IOException, JMSException, JSONException {

var meshMessage = new MeshMessage()
.setWorkflowId(WorkflowId.REGISTRATION)
.setContent(new String(Files.readAllBytes(interchange.getFile().toPath())));
Expand Down Expand Up @@ -179,7 +181,7 @@ private void assertGpSystemInboundQueueMessages(

// all transactions come from the same interchange and use the same conversation id
String conversationId = message.getStringProperty("ConversationId");
if(previousConversationId == null) {
if (previousConversationId == null) {
previousConversationId = conversationId;
}
softly.assertThat(conversationId).isEqualTo(previousConversationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.core.io.Resource;
import org.springframework.test.annotation.DirtiesContext;
import uk.nhs.digital.nhsconnect.nhais.IntegrationBaseTest;
Expand Down Expand Up @@ -41,7 +40,7 @@ public class InboundMeshQueueRecepTest extends IntegrationBaseTest {
private static final String SENDER = "FHS1";
private static final String RECIPIENT = "GP05";
private static final Instant TRANSLATION_TIMESTAMP = ZonedDateTime
.of(2020, 6, 20, 14, 0, 0, 0, TimestampService.UKZone)
.of(2020, 6, 20, 14, 0, 0, 0, TimestampService.UK_ZONE)
.toInstant();
// Mongo only supports millis precision
private static final Instant PROCESSED_TIMESTAMP = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Expand All @@ -65,7 +64,7 @@ void setUp() {
}

@Test
void whenMeshInboundQueueRecepMessageIsReceived_thenRecepHandled(SoftAssertions softly) throws IOException {
void When_MeshInboundQueueRecepMessageIsReceived_Expect_RecepHandled(SoftAssertions softly) throws IOException {
createOutboundStateRecords();

sendToMeshInboundQueue(new MeshMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class InboundMeshQueueRegistrationTest extends IntegrationBaseTest {
private static final ReferenceTransactionType.Inbound TRANSACTION_TYPE = ReferenceTransactionType.Inbound.APPROVAL;
private static final String OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN);
private static final Instant TRANSLATION_TIMESTAMP = ZonedDateTime
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UKZone)
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UK_ZONE)
.toInstant();
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 00, 0, TimestampService.UKZone)
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 00, 0, TimestampService.UK_ZONE)
.toInstant();
private static final String ISO_GENERATED_TIMESTAMP = new TimestampService().formatInISO(GENERATED_TIMESTAMP);

Expand All @@ -66,7 +66,9 @@ void setUp() {
}

@Test
void whenMeshInboundQueueRegistrationMessageIsReceived_thenMessageIsHandled(SoftAssertions softly) throws IOException, JMSException, JSONException {
void When_MeshInboundQueueRegistrationMessageIsReceived_Expect_MessageIsHandled(SoftAssertions softly)
throws IOException, JMSException, JSONException {

var meshMessage = new MeshMessage()
.setWorkflowId(WorkflowId.REGISTRATION)
.setContent(new String(Files.readAllBytes(interchange.getFile().toPath())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class InboundStateRepositoryTest {
private InboundStateRepository inboundStateRepository;

@Test
void whenDuplicateInterchangeInboundStateInserted_thenThrowsException() {
void When_DuplicateInterchangeInboundStateInserted_Expect_ThrowsException() {
var inboundState = new InboundState()
.setWorkflowId(WorkflowId.REGISTRATION)
.setSender("some_sender")
Expand All @@ -44,7 +44,7 @@ void whenDuplicateInterchangeInboundStateInserted_thenThrowsException() {
}

@Test
void whenDuplicateRecepInboundStateInserted_thenThrowsException() {
void When_DuplicateRecepInboundStateInserted_Expect_ThrowsException() {
var inboundState = new InboundState()
.setWorkflowId(WorkflowId.RECEP)
.setSender("some_sender")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ private void verifyThatCloseQuarterNotificationIsNotPresentOnGpSystemInboundQueu
assertThat(gpSystemInboundQueueMessage).isNull();
}

private void verifyThatNonCloseQuarterNotificationMessageIsTranslated(TestData testData, Message gpSystemInboundQueueMessage) throws JMSException, JSONException {
private void verifyThatNonCloseQuarterNotificationMessageIsTranslated(TestData testData, Message gpSystemInboundQueueMessage)
throws JMSException, JSONException {

assertThat(gpSystemInboundQueueMessage).isNotNull();
// assert transaction type in JMS header is correct
assertMessageHeaders(gpSystemInboundQueueMessage, "fp69_prior_notification");
Expand All @@ -130,19 +132,25 @@ private void assertOutboundRecepMessage(String recep) {
List<String> messageIds = waitFor(() -> {
List<String> inboxMessageIds = nhaisMeshClient.getInboxMessageIds();
return inboxMessageIds.isEmpty() ? null : inboxMessageIds;
} );
});
var meshMessage = nhaisMeshClient.getEdifactMessage(messageIds.get(0));

Interchange expectedRecep = edifactParser.parse(recep);
Interchange actualRecep = edifactParser.parse(meshMessage.getContent());

assertThat(meshMessage.getWorkflowId()).isEqualTo(WorkflowId.RECEP);
assertThat(actualRecep.getInterchangeHeader().getRecipient()).isEqualTo(expectedRecep.getInterchangeHeader().getRecipient());
assertThat(actualRecep.getInterchangeHeader().getSender()).isEqualTo(expectedRecep.getInterchangeHeader().getSender());
assertThat(actualRecep.getInterchangeHeader().getSequenceNumber()).isEqualTo(expectedRecep.getInterchangeHeader().getSequenceNumber());
assertThat(meshMessage.getWorkflowId())
.isEqualTo(WorkflowId.RECEP);
assertThat(actualRecep.getInterchangeHeader().getRecipient())
.isEqualTo(expectedRecep.getInterchangeHeader().getRecipient());
assertThat(actualRecep.getInterchangeHeader().getSender())
.isEqualTo(expectedRecep.getInterchangeHeader().getSender());
assertThat(actualRecep.getInterchangeHeader().getSequenceNumber())
.isEqualTo(expectedRecep.getInterchangeHeader().getSequenceNumber());
assertThat(filterTimestampedSegments(actualRecep)).containsExactlyElementsOf(filterTimestampedSegments(expectedRecep));
assertThat(actualRecep.getInterchangeTrailer().getNumberOfMessages()).isEqualTo(expectedRecep.getInterchangeTrailer().getNumberOfMessages());
assertThat(actualRecep.getInterchangeTrailer().getSequenceNumber()).isEqualTo(expectedRecep.getInterchangeTrailer().getSequenceNumber());
assertThat(actualRecep.getInterchangeTrailer().getNumberOfMessages())
.isEqualTo(expectedRecep.getInterchangeTrailer().getNumberOfMessages());
assertThat(actualRecep.getInterchangeTrailer().getSequenceNumber())
.isEqualTo(expectedRecep.getInterchangeTrailer().getSequenceNumber());
}

private List<String> filterTimestampedSegments(Interchange recep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ void beforeEach() {
}

@Test
void When_CallingMeshSendMessageEndpoint_Then_MessageIdIsReturned() {
void When_CallingMeshSendMessageEndpoint_Expect_MessageIdIsReturned() {
MeshMessageId meshMessageId = meshClient.sendEdifactMessage(OUTBOUND_MESH_MESSAGE);
assertThat(meshMessageId).isNotNull();
assertThat(meshMessageId.getMessageID()).isNotEmpty();
}

@Test
void When_CallingMeshGetMessageEndpoint_Then_MessageIsReturned() {
void When_CallingMeshGetMessageEndpoint_Expect_MessageIsReturned() {
MeshMessageId testMessageId = meshClient.sendEdifactMessage(OUTBOUND_MESH_MESSAGE);

InboundMeshMessage meshMessage = nhaisMeshClient.getEdifactMessage(testMessageId.getMessageID());
Expand All @@ -76,7 +76,7 @@ void When_CallingMeshGetMessageEndpoint_Then_MessageIsReturned() {
}

@Test
void When_CallingGetMessageWithLargeContentAndWrongWorkflowId_Then_MeshWorkflowUnknownExceptionIsThrown() {
void When_CallingGetMessageWithLargeContentAndWrongWorkflowId_Expect_MeshWorkflowUnknownExceptionIsThrown() {
MeshMessageId testMessageId = sendLargeMessageWithWrongWorkflowId();

assertThatThrownBy(() -> nhaisMeshClient.getEdifactMessage(testMessageId.getMessageID()))
Expand Down Expand Up @@ -108,39 +108,39 @@ private <T> T parseInto(Class<T> clazz, CloseableHttpResponse response) throws I
}

@Test
void When_CallingMeshAcknowledgeEndpoint_Then_NoExceptionIsThrown() {
void When_CallingMeshAcknowledgeEndpoint_Expect_NoExceptionIsThrown() {
MeshMessageId testMessageId = meshClient.sendEdifactMessage(OUTBOUND_MESH_MESSAGE);

assertThatCode(() -> nhaisMeshClient.acknowledgeMessage(testMessageId.getMessageID()))
.doesNotThrowAnyException();
}

@Test
void When_PollingFromMesh_Then_EmptyListIsReturned() {
void When_PollingFromMesh_Expect_EmptyListIsReturned() {
assertThat(meshClient.getInboxMessageIds()).isEqualTo(List.of());
}

@Test
void When_PollingFromMeshAfterSendingMsg_Then_ListWithMsgIdIsReturned() {
void When_PollingFromMeshAfterSendingMsg_Expect_ListWithMsgIdIsReturned() {
MeshMessageId testMessageId = meshClient.sendEdifactMessage(OUTBOUND_MESH_MESSAGE);

assertThat(nhaisMeshClient.getInboxMessageIds()).contains(testMessageId.getMessageID());
}

@Test
void When_Authenticating_Then_NoExceptionThrown() {
void When_Authenticating_Expect_NoExceptionThrown() {
assertThatCode(() -> meshClient.authenticate()).doesNotThrowAnyException();
}

@Test
void When_downloadMessageThatDoesNotExist_then_throwException() {
void When_DownloadMessageThatDoesNotExist_Expect_ExceptionThrown() {
assertThatExceptionOfType(MeshApiConnectionException.class).isThrownBy(
() -> meshClient.getEdifactMessage("thisisaninvalidmessageid1234567890")
);
}

@Test
void When_downloadMessageThatIsGone_then_throwException() {
void When_DownloadingMessageWhichIsGone_Expect_ExceptionThrown() {
MeshMessageId testMessageId = meshClient.sendEdifactMessage(OUTBOUND_MESH_MESSAGE);
var messageId = testMessageId.getMessageID();
nhaisMeshClient.acknowledgeMessage(messageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MeshConnectivityIntegrationTest {
* @throws Exception
*/
@Test
void when_CallingMeshCountMessagesEndpoint_Then_Http200IsReturned() throws Exception {
void When_CallingMeshCountMessagesEndpoint_Expect_Http200IsReturned() throws Exception {
try (CloseableHttpClient client = meshHttpClientBuilder.build()) {
HttpGet httpGet = new HttpGet(meshConfig.getHost() + meshConfig.getMailboxId() + "/count");
httpGet.setHeaders(new MeshHeaders(meshConfig).createMinimalHeaders());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class OutboundUserAcceptanceTest extends IntegrationBaseTest {
private static final String RECIPIENT = "XX11";
private static final String SENDER = "TES5";
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime
.of(2020, 6, 10, 14, 38, 10, 0, TimestampService.UKZone)
.of(2020, 6, 10, 14, 38, 10, 0, TimestampService.UK_ZONE)
.toInstant();
@Autowired
private MockMvc mockMvc;
Expand Down
Loading