From 85aab812375409419e515066111407a7c80e38f0 Mon Sep 17 00:00:00 2001 From: craig mcclendon Date: Thu, 31 Oct 2024 12:27:33 -0500 Subject: [PATCH] add comments to explain non-intuitive logic in test --- .../java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java b/src/test/java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java index 2c34263..6571487 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java @@ -88,6 +88,13 @@ class CdsHooksServletIT implements IServerSupport { private Boolean hasCdsServices() throws IOException { var response = callCdsServicesDiscovery(); + + // NOTE: this is looking for a repsonse that indicates there are CDS services availalble. + // And empty response looks like: {"services": []} + // Looking at the actual response string consumes the InputStream which has side-effects, making it tricky to compare the actual contents. + // Hence the test just looks at the length to make this determination. + // The actual response has newlines in it which vary in size on some systems, but a value of 25 seems to work across linux/mac/windows + // to ensure the repsonse actually contains CDS services in it return response.getEntity().getContentLength() > 25 || response.getEntity().isChunked(); }