Skip to content

Commit 4de3f64

Browse files
Checkstyle fixes (#302)
* Update HAPI FHIR R4 to version `8.0.0` * Update gradle resources to version `8.0.0` * Breaking model changes now means that the `Parameter.getParameter(name)` now returns a `Type` which cannot now be cast to a `StringType`. We can work around this by finding the `ParametersParameterComponent` manually and then casting it to retrieve the value. * Update HAPI FHIR R4 to version `8.0.0` * Due to Parameter changes in the latest version, there is now a slightly different error phrasing in the error returned when a parameter is missing or empty. Integration tests have been updated to reflect this. * Update DeductionIntegrationTest.java adjust modifiers to private * * Address checkstyle [FinalClass] issue (Class <ClassName> should be declared as final). * * Address checkstyle [MethodName] issue (Name `<TestName>` must match pattern `<Pattern>`.) * * Address checkstyle [ModifierOrder] issue (`<Modifier>` modifier out of order with JLS suggestions.) * * Address missed [MethodName] issue. * * Address missed [ModifierOrder] issue. * * Address Line is longer than 140 character issues. * * Address [WhitespaceAfter / WhitespaceAround] checkstyle issue (`if` is not followed by whitespace.) * * Address missed Line Length checkstyle issue. * * Address [WhitespaceAround] checkstyle issue (`<character>` is not <preceded with / followed by> whitespace.) * Address [IndentationLevel] checkstyle issues * * Address [UnusedImports] checkstyle issues. * * Address [RedundantModifier] CheckStyle issues (Redundant `<Modifier>` modifier.) * * Address [LocalVariableName] Checkstyle issues (Name `<LocalVariableName>` must match pattern '^([a-z][a-zA-Z0-9]*|_)$'.) * Address [MemberName] Checkstyle issues (Name `<LocalVariableName>` must match pattern '^([a-z][a-zA-Z0-9]*|_)$'.)
1 parent b999030 commit 4de3f64

File tree

131 files changed

+564
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+564
-362
lines changed

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/container/ActiveMqContainer.java

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

66
import java.nio.file.Path;
77

8-
public class ActiveMqContainer extends GenericContainer<ActiveMqContainer> {
8+
public final class ActiveMqContainer extends GenericContainer<ActiveMqContainer> {
99

1010
public static final int ACTIVEMQ_PORT = 5672;
1111
private static ActiveMqContainer container;

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/container/FakeMeshContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.nio.file.Path;
88

99
@Slf4j
10-
public class FakeMeshContainer extends GenericContainer<FakeMeshContainer> {
10+
public final class FakeMeshContainer extends GenericContainer<FakeMeshContainer> {
1111

1212
public static final int FAKE_MESH_PORT = 8829;
1313
private static FakeMeshContainer container;

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/container/MongoDbContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.testcontainers.containers.GenericContainer;
55

66
@Slf4j
7-
public class MongoDbContainer extends GenericContainer<MongoDbContainer> {
7+
public final class MongoDbContainer extends GenericContainer<MongoDbContainer> {
88

99
public static final int MONGODB_PORT = 27017;
1010
public static final String DEFAULT_IMAGE_AND_TAG = "mongo:8.0";

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/db/TimeToLiveTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public class TimeToLiveTest {
4848
private NhaisMongoClientConfiguration mongoConfig;
4949

5050
@Test
51-
void when_ApplicationStarts_then_TtlIndexExistsForInboundStateWithValueFromConfiguration() {
51+
void When_ApplicationStarts_Expect_TtlIndexExistsForInboundStateWithValueFromConfiguration() {
5252
var indexOperations = mongoTemplate.indexOps(InboundState.class);
5353
assertThat(timeToLiveIndexExists(indexOperations)).isTrue();
5454
}
5555

5656
@Test
57-
void when_ApplicationStarts_then_TtlIndexExistsForOutboundStateWithValueFromConfiguration() {
57+
void When_ApplicationStarts_Expect_TtlIndexExistsForOutboundStateWithValueFromConfiguration() {
5858
var indexOperations = mongoTemplate.indexOps(OutboundState.class);
5959
assertThat(timeToLiveIndexExists(indexOperations)).isTrue();
6060
}
@@ -70,7 +70,7 @@ private boolean timeToLiveIndexExists(IndexOperations indexOperations) {
7070

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

9090
@Test
9191
@Disabled("Long running test that depends on external TTL config, enable when needed")
92-
void when_TimeToLiveHasPassedInOutboundState_then_documentRemoved() {
92+
void When_TimeToLiveHasPassedInOutboundState_Expect_DocumentRemoved() {
9393
var inboundState = new OutboundState()
9494
.setWorkflowId(WorkflowId.RECEP)
9595
.setSender("some_sender")

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/DeadLetterQueueTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class DeadLetterQueueTest extends IntegrationBaseTest {
3737
private ObjectMapper objectMapper;
3838

3939
@Test
40-
public void whenSendingInvalidMessage_toMeshInboundQueue_thenMessageIsSentToDeadLetterQueue() throws JMSException {
40+
public void When_SendingInvalidMessageToMeshInboundQueue_Expect_MessageIsSentToDeadLetterQueue() throws JMSException {
4141
clearDeadLetterQueue(meshInboundQueueName);
4242
sendToMeshInboundQueue(MESSAGE_CONTENT);
4343

@@ -48,10 +48,15 @@ public void whenSendingInvalidMessage_toMeshInboundQueue_thenMessageIsSentToDead
4848
}
4949

5050
@Test
51-
public void whenMeshOutboundQueueMessageCannotBeProcessed_thenMessageIsSentToDeadLetterQueue() throws Exception {
51+
public void When_MeshOutboundQueueMessageCannotBeProcessed_Expect_MessageIsSentToDeadLetterQueue() throws Exception {
5252
String conversationId = Long.toString(System.currentTimeMillis());
5353
when(conversationIdService.getCurrentConversationId()).thenReturn(conversationId);
54-
OutboundMeshMessage meshMessage = OutboundMeshMessage.create("XX11", WorkflowId.REGISTRATION, MESSAGE_CONTENT, "2020-01-01T00:00:00Z", "asdf");
54+
OutboundMeshMessage meshMessage = OutboundMeshMessage.create(
55+
"XX11",
56+
WorkflowId.REGISTRATION, MESSAGE_CONTENT,
57+
"2020-01-01T00:00:00Z",
58+
"asdf"
59+
);
5560
doThrow(RuntimeException.class).when(meshClient).authenticate();
5661

5762
clearDeadLetterQueue(meshOutboundQueueName);
@@ -62,5 +67,4 @@ public void whenMeshOutboundQueueMessageCannotBeProcessed_thenMessageIsSentToDea
6267
assertThat(message.getStringProperty(JmsHeaders.CONVERSATION_ID)).isEqualTo(conversationId);
6368
assertThat(parseTextMessage(message)).isEqualTo(objectMapper.writeValueAsString(meshMessage));
6469
}
65-
6670
}

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/InboundMeshQueueMultiTransactionTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public class InboundMeshQueueMultiTransactionTest extends IntegrationBaseTest {
6565
private static final String TRANSACTION_5_OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN_5);
6666
private static final String TRANSACTION_6_OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN_6);
6767
private static final Instant INTERCHANGE_TRANSLATION_TIMESTAMP = ZonedDateTime
68-
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UKZone)
68+
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UK_ZONE)
6969
.toInstant();
7070

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

@@ -103,7 +103,9 @@ void setUp() {
103103
}
104104

105105
@Test
106-
void whenMeshInboundQueueRegistrationMessageIsReceived_thenMessageIsHandled(SoftAssertions softly) throws IOException, JMSException, JSONException {
106+
void When_MeshInboundQueueRegistrationMessageIsReceived_Expect_MessageIsHandled(SoftAssertions softly)
107+
throws IOException, JMSException, JSONException {
108+
107109
var meshMessage = new MeshMessage()
108110
.setWorkflowId(WorkflowId.REGISTRATION)
109111
.setContent(new String(Files.readAllBytes(interchange.getFile().toPath())));
@@ -179,7 +181,7 @@ private void assertGpSystemInboundQueueMessages(
179181

180182
// all transactions come from the same interchange and use the same conversation id
181183
String conversationId = message.getStringProperty("ConversationId");
182-
if(previousConversationId == null) {
184+
if (previousConversationId == null) {
183185
previousConversationId = conversationId;
184186
}
185187
softly.assertThat(conversationId).isEqualTo(previousConversationId);

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/InboundMeshQueueRecepTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.junit.jupiter.api.Test;
77
import org.springframework.beans.factory.annotation.Value;
88
import org.springframework.boot.test.mock.mockito.MockBean;
9-
import org.springframework.boot.test.mock.mockito.SpyBean;
109
import org.springframework.core.io.Resource;
1110
import org.springframework.test.annotation.DirtiesContext;
1211
import uk.nhs.digital.nhsconnect.nhais.IntegrationBaseTest;
@@ -41,7 +40,7 @@ public class InboundMeshQueueRecepTest extends IntegrationBaseTest {
4140
private static final String SENDER = "FHS1";
4241
private static final String RECIPIENT = "GP05";
4342
private static final Instant TRANSLATION_TIMESTAMP = ZonedDateTime
44-
.of(2020, 6, 20, 14, 0, 0, 0, TimestampService.UKZone)
43+
.of(2020, 6, 20, 14, 0, 0, 0, TimestampService.UK_ZONE)
4544
.toInstant();
4645
// Mongo only supports millis precision
4746
private static final Instant PROCESSED_TIMESTAMP = Instant.now().truncatedTo(ChronoUnit.MILLIS);
@@ -65,7 +64,7 @@ void setUp() {
6564
}
6665

6766
@Test
68-
void whenMeshInboundQueueRecepMessageIsReceived_thenRecepHandled(SoftAssertions softly) throws IOException {
67+
void When_MeshInboundQueueRecepMessageIsReceived_Expect_RecepHandled(SoftAssertions softly) throws IOException {
6968
createOutboundStateRecords();
7069

7170
sendToMeshInboundQueue(new MeshMessage()

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/InboundMeshQueueRegistrationTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public class InboundMeshQueueRegistrationTest extends IntegrationBaseTest {
4242
private static final ReferenceTransactionType.Inbound TRANSACTION_TYPE = ReferenceTransactionType.Inbound.APPROVAL;
4343
private static final String OPERATION_ID = OperationId.buildOperationId(RECIPIENT, TN);
4444
private static final Instant TRANSLATION_TIMESTAMP = ZonedDateTime
45-
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UKZone)
45+
.of(2020, 1, 25, 12, 35, 0, 0, TimestampService.UK_ZONE)
4646
.toInstant();
47-
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 00, 0, TimestampService.UKZone)
47+
private static final Instant GENERATED_TIMESTAMP = ZonedDateTime.of(2020, 6, 10, 14, 38, 00, 0, TimestampService.UK_ZONE)
4848
.toInstant();
4949
private static final String ISO_GENERATED_TIMESTAMP = new TimestampService().formatInISO(GENERATED_TIMESTAMP);
5050

@@ -66,7 +66,9 @@ void setUp() {
6666
}
6767

6868
@Test
69-
void whenMeshInboundQueueRegistrationMessageIsReceived_thenMessageIsHandled(SoftAssertions softly) throws IOException, JMSException, JSONException {
69+
void When_MeshInboundQueueRegistrationMessageIsReceived_Expect_MessageIsHandled(SoftAssertions softly)
70+
throws IOException, JMSException, JSONException {
71+
7072
var meshMessage = new MeshMessage()
7173
.setWorkflowId(WorkflowId.REGISTRATION)
7274
.setContent(new String(Files.readAllBytes(interchange.getFile().toPath())))

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/InboundStateRepositoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class InboundStateRepositoryTest {
2626
private InboundStateRepository inboundStateRepository;
2727

2828
@Test
29-
void whenDuplicateInterchangeInboundStateInserted_thenThrowsException() {
29+
void When_DuplicateInterchangeInboundStateInserted_Expect_ThrowsException() {
3030
var inboundState = new InboundState()
3131
.setWorkflowId(WorkflowId.REGISTRATION)
3232
.setSender("some_sender")
@@ -44,7 +44,7 @@ void whenDuplicateInterchangeInboundStateInserted_thenThrowsException() {
4444
}
4545

4646
@Test
47-
void whenDuplicateRecepInboundStateInserted_thenThrowsException() {
47+
void When_DuplicateRecepInboundStateInserted_Expect_ThrowsException() {
4848
var inboundState = new InboundState()
4949
.setWorkflowId(WorkflowId.RECEP)
5050
.setSender("some_sender")

src/intTest/java/uk/nhs/digital/nhsconnect/nhais/inbound/InboundUserAcceptanceTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ private void verifyThatCloseQuarterNotificationIsNotPresentOnGpSystemInboundQueu
103103
assertThat(gpSystemInboundQueueMessage).isNull();
104104
}
105105

106-
private void verifyThatNonCloseQuarterNotificationMessageIsTranslated(TestData testData, Message gpSystemInboundQueueMessage) throws JMSException, JSONException {
106+
private void verifyThatNonCloseQuarterNotificationMessageIsTranslated(TestData testData, Message gpSystemInboundQueueMessage)
107+
throws JMSException, JSONException {
108+
107109
assertThat(gpSystemInboundQueueMessage).isNotNull();
108110
// assert transaction type in JMS header is correct
109111
assertMessageHeaders(gpSystemInboundQueueMessage, "fp69_prior_notification");
@@ -130,19 +132,25 @@ private void assertOutboundRecepMessage(String recep) {
130132
List<String> messageIds = waitFor(() -> {
131133
List<String> inboxMessageIds = nhaisMeshClient.getInboxMessageIds();
132134
return inboxMessageIds.isEmpty() ? null : inboxMessageIds;
133-
} );
135+
});
134136
var meshMessage = nhaisMeshClient.getEdifactMessage(messageIds.get(0));
135137

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

139-
assertThat(meshMessage.getWorkflowId()).isEqualTo(WorkflowId.RECEP);
140-
assertThat(actualRecep.getInterchangeHeader().getRecipient()).isEqualTo(expectedRecep.getInterchangeHeader().getRecipient());
141-
assertThat(actualRecep.getInterchangeHeader().getSender()).isEqualTo(expectedRecep.getInterchangeHeader().getSender());
142-
assertThat(actualRecep.getInterchangeHeader().getSequenceNumber()).isEqualTo(expectedRecep.getInterchangeHeader().getSequenceNumber());
141+
assertThat(meshMessage.getWorkflowId())
142+
.isEqualTo(WorkflowId.RECEP);
143+
assertThat(actualRecep.getInterchangeHeader().getRecipient())
144+
.isEqualTo(expectedRecep.getInterchangeHeader().getRecipient());
145+
assertThat(actualRecep.getInterchangeHeader().getSender())
146+
.isEqualTo(expectedRecep.getInterchangeHeader().getSender());
147+
assertThat(actualRecep.getInterchangeHeader().getSequenceNumber())
148+
.isEqualTo(expectedRecep.getInterchangeHeader().getSequenceNumber());
143149
assertThat(filterTimestampedSegments(actualRecep)).containsExactlyElementsOf(filterTimestampedSegments(expectedRecep));
144-
assertThat(actualRecep.getInterchangeTrailer().getNumberOfMessages()).isEqualTo(expectedRecep.getInterchangeTrailer().getNumberOfMessages());
145-
assertThat(actualRecep.getInterchangeTrailer().getSequenceNumber()).isEqualTo(expectedRecep.getInterchangeTrailer().getSequenceNumber());
150+
assertThat(actualRecep.getInterchangeTrailer().getNumberOfMessages())
151+
.isEqualTo(expectedRecep.getInterchangeTrailer().getNumberOfMessages());
152+
assertThat(actualRecep.getInterchangeTrailer().getSequenceNumber())
153+
.isEqualTo(expectedRecep.getInterchangeTrailer().getSequenceNumber());
146154
}
147155

148156
private List<String> filterTimestampedSegments(Interchange recep) {

0 commit comments

Comments
 (0)