-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
joefong-nhs
commented
Jun 13, 2023
•
edited
Loading
edited
- 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
…ot exist on queue
…and the other for unknown NHS number
… sec, unify the way to generate trigger message in two tests
…obvious that it is for testing
…h unknown conversation id
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/test/java/uk/nhs/prm/deduction/e2e/models/ContinueRequestMessageBuilder.java
Show resolved
Hide resolved
@@ -161,4 +162,8 @@ public static LargeEhrTestFiles prepareTestFilesForLargeEhr( | |||
|
|||
return new LargeEhrTestFiles(largeEhrCore, largeEhrFragment1, largeEhrFragment2, ehrRequest, continueRequest); | |||
} | |||
|
|||
public static String getUuidAsUpperCaseString(UUID uuid) { |
There was a problem hiding this comment.
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.
public static String getUuidAsUpperCaseString(UUID uuid) { | |
public static String getUUIDAsUpperCaseString(UUID uuid) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
?
} catch (Exception e) { | |
} catch (Exception exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Addressed this comment
There was a problem hiding this comment.
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! 😄
There was a problem hiding this comment.
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)