Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRMT-3413 E2E testing - Unexpected Interaction ID and NHS number #21

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

joefong-nhs
Copy link
Contributor

@joefong-nhs joefong-nhs commented Jun 13, 2023

  • Added a test for unrecognised Interaction ID from mhs inbound queue
  • Added a test for UK05 with unrecognised NHS number from mhs inbound queue
  • Added a test for COPC continue request with unrecognised conversation Id from mhs inbound queue
  • Added model class and builder for test messages
  • Added HealthCheck class which calls the health check endpoints of each service e.g. ehr-repo

Copy link
Contributor

@AndyFlintNHS AndyFlintNHS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only small bits to change - the main logic with the parameterised test looks very elegant!


import java.util.UUID;

public final class ContinueRequestMessage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just have this as public class. Usually you'd only use final in a case where you want to be certain nobody will extend this class in future


import java.util.UUID;

public final class ContinueRequestMessageBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just have this as public class. Usually you'd only use final in a case where you want to be certain nobody will extend this class in future


import java.util.UUID;

public final class EhrRequestMessageBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just have this as public class. Usually you'd only use final in a case where you want to be certain nobody will extend this class in future

private String sourceGpAsid;
private String destinationGpAsid;

public UUID getConversationId() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please move these getters below the constructor?

.replaceAll("200000000149", destinationGpAsid);
}

public String conversationId() {
Copy link
Contributor

@AndyFlintNHS AndyFlintNHS Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's worth us breaking the conversationId and messageId methods out into a static method on a utility class. This UUID as upper case string format is useful across more than just the continueRequestMessage class and rather than us duplicating a lot of code, having something like this might help:

    public static String getUuidAsUpperCaseString(UUID uuid) {
        return uuid.toString().toUpperCase();
    }

Which could be called in the code like this (using line 34 as an example):

.replaceAll("DBC31D30-F984-11ED-A4C4-956AA80C6B4E", getUuidAsUpperCaseString(conversationId))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I have added the static method getUuidAsUpperCaseString to TestUtils class and call it for conversation ids and message ids.
Later could you have a look and see if I did it right?
Because conversation id is a private field so I keep the getter methods, but now all those getter would call to our getUuidAsUpperCaseString :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest you don't even need the 'conversationId()' method at all. conversationId IS a private field as you say, but you don't need to use getters to reference private variables in the scope of the class where they're defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I overlooked this comment...
For conversationId(), in the e2e test that is a part that we need the conversation id from the message (the test use the conversation id to find an expected message in outbound queue), so I have kept the getter method for this purpose.

@@ -161,4 +162,8 @@ public static LargeEhrTestFiles prepareTestFilesForLargeEhr(

return new LargeEhrTestFiles(largeEhrCore, largeEhrFragment1, largeEhrFragment2, ehrRequest, continueRequest);
}

public static String getUuidAsUpperCaseString(UUID uuid) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably capitalise 'UUID' in the method name.

Suggested change
public static String getUuidAsUpperCaseString(UUID uuid) {
public static String getUUIDAsUpperCaseString(UUID uuid) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! addressed this comment

.with()
.pollInterval(200, TimeUnit.MILLISECONDS)
.until(() -> getRequest(healthCheckUrl).getStatusCode().is2xxSuccessful(), is(true));
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please change this to exception?

Suggested change
} catch (Exception e) {
} catch (Exception exception) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Addressed this comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @joefong-nhs - I was meaning to add here, can we be specific to what exception we can expect to be caught here? A tip from me is if you hold your cursor over any logic, usually it'll display a definition where it will give you a lovely breakdown of the exceptions!

For example,

try {} catch(IllegalArgumentException exception) {}

In Java, we try to be as explicit as possible! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have changed it like this:
catch (HttpClientErrorException | ConditionTimeoutException exception)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants